phlex_kit 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README.md +135 -0
  4. data/app/assets/stylesheets/phlex_kit/_tokens.css +91 -0
  5. data/app/assets/stylesheets/phlex_kit/phlex_kit.css +82 -0
  6. data/app/components/phlex_kit/accordion/accordion.css +14 -0
  7. data/app/components/phlex_kit/accordion/accordion.rb +10 -0
  8. data/app/components/phlex_kit/accordion/accordion_content.rb +8 -0
  9. data/app/components/phlex_kit/accordion/accordion_default_content.rb +6 -0
  10. data/app/components/phlex_kit/accordion/accordion_default_trigger.rb +12 -0
  11. data/app/components/phlex_kit/accordion/accordion_icon.rb +16 -0
  12. data/app/components/phlex_kit/accordion/accordion_item.rb +12 -0
  13. data/app/components/phlex_kit/accordion/accordion_trigger.rb +8 -0
  14. data/app/components/phlex_kit/alert/alert.css +32 -0
  15. data/app/components/phlex_kit/alert/alert.rb +37 -0
  16. data/app/components/phlex_kit/alert/alert_description.rb +12 -0
  17. data/app/components/phlex_kit/alert/alert_title.rb +12 -0
  18. data/app/components/phlex_kit/alert_dialog/alert_dialog.css +37 -0
  19. data/app/components/phlex_kit/alert_dialog/alert_dialog.rb +20 -0
  20. data/app/components/phlex_kit/alert_dialog/alert_dialog_action.rb +14 -0
  21. data/app/components/phlex_kit/alert_dialog/alert_dialog_cancel.rb +13 -0
  22. data/app/components/phlex_kit/alert_dialog/alert_dialog_content.rb +19 -0
  23. data/app/components/phlex_kit/alert_dialog/alert_dialog_description.rb +12 -0
  24. data/app/components/phlex_kit/alert_dialog/alert_dialog_footer.rb +12 -0
  25. data/app/components/phlex_kit/alert_dialog/alert_dialog_header.rb +12 -0
  26. data/app/components/phlex_kit/alert_dialog/alert_dialog_title.rb +12 -0
  27. data/app/components/phlex_kit/alert_dialog/alert_dialog_trigger.rb +12 -0
  28. data/app/components/phlex_kit/aspect_ratio/aspect_ratio.css +12 -0
  29. data/app/components/phlex_kit/aspect_ratio/aspect_ratio.rb +27 -0
  30. data/app/components/phlex_kit/attachment/attachment.css +62 -0
  31. data/app/components/phlex_kit/attachment/attachment.rb +16 -0
  32. data/app/components/phlex_kit/attachment/attachment_action.rb +24 -0
  33. data/app/components/phlex_kit/attachment/attachment_actions.rb +7 -0
  34. data/app/components/phlex_kit/attachment/attachment_content.rb +7 -0
  35. data/app/components/phlex_kit/attachment/attachment_description.rb +7 -0
  36. data/app/components/phlex_kit/attachment/attachment_media.rb +8 -0
  37. data/app/components/phlex_kit/attachment/attachment_title.rb +7 -0
  38. data/app/components/phlex_kit/avatar/avatar.css +35 -0
  39. data/app/components/phlex_kit/avatar/avatar.rb +25 -0
  40. data/app/components/phlex_kit/avatar/avatar_fallback.rb +13 -0
  41. data/app/components/phlex_kit/avatar/avatar_group.rb +7 -0
  42. data/app/components/phlex_kit/avatar/avatar_image.rb +24 -0
  43. data/app/components/phlex_kit/badge/badge.css +50 -0
  44. data/app/components/phlex_kit/badge/badge.rb +39 -0
  45. data/app/components/phlex_kit/breadcrumb/breadcrumb.css +18 -0
  46. data/app/components/phlex_kit/breadcrumb/breadcrumb.rb +8 -0
  47. data/app/components/phlex_kit/breadcrumb/breadcrumb_ellipsis.rb +15 -0
  48. data/app/components/phlex_kit/breadcrumb/breadcrumb_item.rb +6 -0
  49. data/app/components/phlex_kit/breadcrumb/breadcrumb_link.rb +9 -0
  50. data/app/components/phlex_kit/breadcrumb/breadcrumb_list.rb +6 -0
  51. data/app/components/phlex_kit/breadcrumb/breadcrumb_page.rb +8 -0
  52. data/app/components/phlex_kit/breadcrumb/breadcrumb_separator.rb +10 -0
  53. data/app/components/phlex_kit/bubble/bubble.css +32 -0
  54. data/app/components/phlex_kit/bubble/bubble.rb +17 -0
  55. data/app/components/phlex_kit/bubble/bubble_content.rb +11 -0
  56. data/app/components/phlex_kit/bubble/bubble_group.rb +6 -0
  57. data/app/components/phlex_kit/bubble/bubble_reactions.rb +12 -0
  58. data/app/components/phlex_kit/button/button.css +72 -0
  59. data/app/components/phlex_kit/button/button.rb +51 -0
  60. data/app/components/phlex_kit/button_group/button_group.css +8 -0
  61. data/app/components/phlex_kit/button_group/button_group.rb +14 -0
  62. data/app/components/phlex_kit/calendar/calendar.css +109 -0
  63. data/app/components/phlex_kit/calendar/calendar.rb +47 -0
  64. data/app/components/phlex_kit/calendar/calendar_body.rb +13 -0
  65. data/app/components/phlex_kit/calendar/calendar_days.rb +98 -0
  66. data/app/components/phlex_kit/calendar/calendar_header.rb +13 -0
  67. data/app/components/phlex_kit/calendar/calendar_next.rb +40 -0
  68. data/app/components/phlex_kit/calendar/calendar_prev.rb +40 -0
  69. data/app/components/phlex_kit/calendar/calendar_title.rb +19 -0
  70. data/app/components/phlex_kit/calendar/calendar_weekdays.rb +27 -0
  71. data/app/components/phlex_kit/card/card.css +15 -0
  72. data/app/components/phlex_kit/card/card.rb +29 -0
  73. data/app/components/phlex_kit/card/card_content.rb +12 -0
  74. data/app/components/phlex_kit/card/card_description.rb +12 -0
  75. data/app/components/phlex_kit/card/card_footer.rb +12 -0
  76. data/app/components/phlex_kit/card/card_header.rb +12 -0
  77. data/app/components/phlex_kit/card/card_title.rb +12 -0
  78. data/app/components/phlex_kit/carousel/carousel.css +41 -0
  79. data/app/components/phlex_kit/carousel/carousel.rb +37 -0
  80. data/app/components/phlex_kit/carousel/carousel_content.rb +16 -0
  81. data/app/components/phlex_kit/carousel/carousel_item.rb +17 -0
  82. data/app/components/phlex_kit/carousel/carousel_next.rb +39 -0
  83. data/app/components/phlex_kit/carousel/carousel_previous.rb +40 -0
  84. data/app/components/phlex_kit/chart/chart.css +9 -0
  85. data/app/components/phlex_kit/chart/chart.rb +31 -0
  86. data/app/components/phlex_kit/checkbox/checkbox.css +27 -0
  87. data/app/components/phlex_kit/checkbox/checkbox.rb +26 -0
  88. data/app/components/phlex_kit/clipboard/clipboard.css +8 -0
  89. data/app/components/phlex_kit/clipboard/clipboard.rb +19 -0
  90. data/app/components/phlex_kit/clipboard/clipboard_popover.rb +14 -0
  91. data/app/components/phlex_kit/clipboard/clipboard_source.rb +6 -0
  92. data/app/components/phlex_kit/clipboard/clipboard_trigger.rb +6 -0
  93. data/app/components/phlex_kit/codeblock/codeblock.css +7 -0
  94. data/app/components/phlex_kit/codeblock/codeblock.rb +23 -0
  95. data/app/components/phlex_kit/collapsible/collapsible.css +3 -0
  96. data/app/components/phlex_kit/collapsible/collapsible.rb +13 -0
  97. data/app/components/phlex_kit/collapsible/collapsible_content.rb +8 -0
  98. data/app/components/phlex_kit/collapsible/collapsible_trigger.rb +8 -0
  99. data/app/components/phlex_kit/combobox/combobox.css +310 -0
  100. data/app/components/phlex_kit/combobox/combobox.rb +33 -0
  101. data/app/components/phlex_kit/combobox/combobox_badge.rb +15 -0
  102. data/app/components/phlex_kit/combobox/combobox_badge_trigger.rb +55 -0
  103. data/app/components/phlex_kit/combobox/combobox_checkbox.rb +21 -0
  104. data/app/components/phlex_kit/combobox/combobox_clear_button.rb +39 -0
  105. data/app/components/phlex_kit/combobox/combobox_empty_state.rb +17 -0
  106. data/app/components/phlex_kit/combobox/combobox_input_trigger.rb +69 -0
  107. data/app/components/phlex_kit/combobox/combobox_item.rb +19 -0
  108. data/app/components/phlex_kit/combobox/combobox_item_indicator.rb +27 -0
  109. data/app/components/phlex_kit/combobox/combobox_list.rb +12 -0
  110. data/app/components/phlex_kit/combobox/combobox_list_group.rb +14 -0
  111. data/app/components/phlex_kit/combobox/combobox_popover.rb +27 -0
  112. data/app/components/phlex_kit/combobox/combobox_radio.rb +26 -0
  113. data/app/components/phlex_kit/combobox/combobox_search_input.rb +49 -0
  114. data/app/components/phlex_kit/combobox/combobox_toggle_all_checkbox.rb +21 -0
  115. data/app/components/phlex_kit/combobox/combobox_trigger.rb +48 -0
  116. data/app/components/phlex_kit/command/command.css +104 -0
  117. data/app/components/phlex_kit/command/command.rb +18 -0
  118. data/app/components/phlex_kit/command/command_dialog.rb +19 -0
  119. data/app/components/phlex_kit/command/command_dialog_content.rb +37 -0
  120. data/app/components/phlex_kit/command/command_dialog_trigger.rb +22 -0
  121. data/app/components/phlex_kit/command/command_empty.rb +17 -0
  122. data/app/components/phlex_kit/command/command_group.rb +32 -0
  123. data/app/components/phlex_kit/command/command_input.rb +56 -0
  124. data/app/components/phlex_kit/command/command_item.rb +22 -0
  125. data/app/components/phlex_kit/command/command_list.rb +12 -0
  126. data/app/components/phlex_kit/context_menu/context_menu.css +19 -0
  127. data/app/components/phlex_kit/context_menu/context_menu.rb +11 -0
  128. data/app/components/phlex_kit/context_menu/context_menu_content.rb +8 -0
  129. data/app/components/phlex_kit/context_menu/context_menu_item.rb +25 -0
  130. data/app/components/phlex_kit/context_menu/context_menu_label.rb +11 -0
  131. data/app/components/phlex_kit/context_menu/context_menu_separator.rb +8 -0
  132. data/app/components/phlex_kit/context_menu/context_menu_trigger.rb +8 -0
  133. data/app/components/phlex_kit/data_table/data_table.css +110 -0
  134. data/app/components/phlex_kit/data_table/data_table.rb +25 -0
  135. data/app/components/phlex_kit/data_table/data_table_bulk_actions.rb +15 -0
  136. data/app/components/phlex_kit/data_table/data_table_column_toggle.rb +61 -0
  137. data/app/components/phlex_kit/data_table/data_table_expand_toggle.rb +40 -0
  138. data/app/components/phlex_kit/data_table/data_table_form.rb +36 -0
  139. data/app/components/phlex_kit/data_table/data_table_kaminari_adapter.rb +17 -0
  140. data/app/components/phlex_kit/data_table/data_table_manual_adapter.rb +18 -0
  141. data/app/components/phlex_kit/data_table/data_table_pagination.rb +98 -0
  142. data/app/components/phlex_kit/data_table/data_table_pagination_bar.rb +13 -0
  143. data/app/components/phlex_kit/data_table/data_table_pagy_adapter.rb +17 -0
  144. data/app/components/phlex_kit/data_table/data_table_per_page_select.rb +29 -0
  145. data/app/components/phlex_kit/data_table/data_table_row_checkbox.rb +24 -0
  146. data/app/components/phlex_kit/data_table/data_table_search.rb +51 -0
  147. data/app/components/phlex_kit/data_table/data_table_select_all_checkbox.rb +19 -0
  148. data/app/components/phlex_kit/data_table/data_table_selection_summary.rb +19 -0
  149. data/app/components/phlex_kit/data_table/data_table_sort_head.rb +82 -0
  150. data/app/components/phlex_kit/data_table/data_table_toolbar.rb +13 -0
  151. data/app/components/phlex_kit/date_picker/date_picker.css +28 -0
  152. data/app/components/phlex_kit/date_picker/date_picker.rb +71 -0
  153. data/app/components/phlex_kit/dialog/dialog.css +32 -0
  154. data/app/components/phlex_kit/dialog/dialog.rb +14 -0
  155. data/app/components/phlex_kit/dialog/dialog_content.rb +21 -0
  156. data/app/components/phlex_kit/dialog/dialog_description.rb +6 -0
  157. data/app/components/phlex_kit/dialog/dialog_footer.rb +6 -0
  158. data/app/components/phlex_kit/dialog/dialog_header.rb +6 -0
  159. data/app/components/phlex_kit/dialog/dialog_middle.rb +6 -0
  160. data/app/components/phlex_kit/dialog/dialog_title.rb +6 -0
  161. data/app/components/phlex_kit/dialog/dialog_trigger.rb +8 -0
  162. data/app/components/phlex_kit/drawer/drawer.css +54 -0
  163. data/app/components/phlex_kit/drawer/drawer.rb +18 -0
  164. data/app/components/phlex_kit/drawer/drawer_close.rb +9 -0
  165. data/app/components/phlex_kit/drawer/drawer_content.rb +21 -0
  166. data/app/components/phlex_kit/drawer/drawer_description.rb +7 -0
  167. data/app/components/phlex_kit/drawer/drawer_footer.rb +7 -0
  168. data/app/components/phlex_kit/drawer/drawer_header.rb +7 -0
  169. data/app/components/phlex_kit/drawer/drawer_title.rb +7 -0
  170. data/app/components/phlex_kit/drawer/drawer_trigger.rb +9 -0
  171. data/app/components/phlex_kit/dropdown_menu/dropdown_menu.css +38 -0
  172. data/app/components/phlex_kit/dropdown_menu/dropdown_menu.rb +22 -0
  173. data/app/components/phlex_kit/dropdown_menu/dropdown_menu_content.rb +23 -0
  174. data/app/components/phlex_kit/dropdown_menu/dropdown_menu_item.rb +22 -0
  175. data/app/components/phlex_kit/dropdown_menu/dropdown_menu_label.rb +12 -0
  176. data/app/components/phlex_kit/dropdown_menu/dropdown_menu_separator.rb +12 -0
  177. data/app/components/phlex_kit/dropdown_menu/dropdown_menu_trigger.rb +15 -0
  178. data/app/components/phlex_kit/empty/empty.css +25 -0
  179. data/app/components/phlex_kit/empty/empty.rb +6 -0
  180. data/app/components/phlex_kit/empty/empty_content.rb +6 -0
  181. data/app/components/phlex_kit/empty/empty_description.rb +6 -0
  182. data/app/components/phlex_kit/empty/empty_header.rb +6 -0
  183. data/app/components/phlex_kit/empty/empty_media.rb +14 -0
  184. data/app/components/phlex_kit/empty/empty_title.rb +6 -0
  185. data/app/components/phlex_kit/form/form.css +15 -0
  186. data/app/components/phlex_kit/form/form.rb +27 -0
  187. data/app/components/phlex_kit/form_field/form_field.css +31 -0
  188. data/app/components/phlex_kit/form_field/form_field.rb +31 -0
  189. data/app/components/phlex_kit/form_field/form_field_error.rb +19 -0
  190. data/app/components/phlex_kit/form_field/form_field_hint.rb +13 -0
  191. data/app/components/phlex_kit/form_field/form_field_label.rb +13 -0
  192. data/app/components/phlex_kit/hover_card/hover_card.css +8 -0
  193. data/app/components/phlex_kit/hover_card/hover_card.rb +10 -0
  194. data/app/components/phlex_kit/hover_card/hover_card_content.rb +8 -0
  195. data/app/components/phlex_kit/hover_card/hover_card_trigger.rb +6 -0
  196. data/app/components/phlex_kit/input/input.css +29 -0
  197. data/app/components/phlex_kit/input/input.rb +34 -0
  198. data/app/components/phlex_kit/input_group/input_group.css +35 -0
  199. data/app/components/phlex_kit/input_group/input_group.rb +15 -0
  200. data/app/components/phlex_kit/input_group/input_group_addon.rb +16 -0
  201. data/app/components/phlex_kit/input_group/input_group_text.rb +7 -0
  202. data/app/components/phlex_kit/input_otp/input_otp.css +32 -0
  203. data/app/components/phlex_kit/input_otp/input_otp.rb +29 -0
  204. data/app/components/phlex_kit/input_otp/input_otp_group.rb +7 -0
  205. data/app/components/phlex_kit/input_otp/input_otp_separator.rb +7 -0
  206. data/app/components/phlex_kit/input_otp/input_otp_slot.rb +27 -0
  207. data/app/components/phlex_kit/item/item.css +32 -0
  208. data/app/components/phlex_kit/item/item.rb +18 -0
  209. data/app/components/phlex_kit/item/item_actions.rb +7 -0
  210. data/app/components/phlex_kit/item/item_content.rb +7 -0
  211. data/app/components/phlex_kit/item/item_description.rb +7 -0
  212. data/app/components/phlex_kit/item/item_group.rb +7 -0
  213. data/app/components/phlex_kit/item/item_media.rb +7 -0
  214. data/app/components/phlex_kit/item/item_title.rb +7 -0
  215. data/app/components/phlex_kit/kbd/kbd.css +17 -0
  216. data/app/components/phlex_kit/kbd/kbd.rb +14 -0
  217. data/app/components/phlex_kit/kbd/kbd_group.rb +12 -0
  218. data/app/components/phlex_kit/label/label.css +12 -0
  219. data/app/components/phlex_kit/label/label.rb +14 -0
  220. data/app/components/phlex_kit/link/link.css +6 -0
  221. data/app/components/phlex_kit/link/link.rb +47 -0
  222. data/app/components/phlex_kit/masked_input/masked_input.rb +12 -0
  223. data/app/components/phlex_kit/menubar/menubar.css +66 -0
  224. data/app/components/phlex_kit/menubar/menubar.rb +24 -0
  225. data/app/components/phlex_kit/menubar/menubar_content.rb +9 -0
  226. data/app/components/phlex_kit/menubar/menubar_item.rb +26 -0
  227. data/app/components/phlex_kit/menubar/menubar_menu.rb +9 -0
  228. data/app/components/phlex_kit/menubar/menubar_separator.rb +7 -0
  229. data/app/components/phlex_kit/menubar/menubar_trigger.rb +14 -0
  230. data/app/components/phlex_kit/message/message.css +20 -0
  231. data/app/components/phlex_kit/message/message.rb +14 -0
  232. data/app/components/phlex_kit/message/message_avatar.rb +6 -0
  233. data/app/components/phlex_kit/message/message_content.rb +6 -0
  234. data/app/components/phlex_kit/message/message_footer.rb +6 -0
  235. data/app/components/phlex_kit/message/message_group.rb +6 -0
  236. data/app/components/phlex_kit/message/message_header.rb +6 -0
  237. data/app/components/phlex_kit/message_scroller/message_scroller.css +2 -0
  238. data/app/components/phlex_kit/message_scroller/message_scroller.rb +11 -0
  239. data/app/components/phlex_kit/native_select/native_select.css +51 -0
  240. data/app/components/phlex_kit/native_select/native_select.rb +48 -0
  241. data/app/components/phlex_kit/native_select/native_select_group.rb +13 -0
  242. data/app/components/phlex_kit/native_select/native_select_icon.rb +32 -0
  243. data/app/components/phlex_kit/native_select/native_select_option.rb +14 -0
  244. data/app/components/phlex_kit/navigation_menu/navigation_menu.css +67 -0
  245. data/app/components/phlex_kit/navigation_menu/navigation_menu.rb +23 -0
  246. data/app/components/phlex_kit/navigation_menu/navigation_menu_content.rb +9 -0
  247. data/app/components/phlex_kit/navigation_menu/navigation_menu_item.rb +9 -0
  248. data/app/components/phlex_kit/navigation_menu/navigation_menu_link.rb +13 -0
  249. data/app/components/phlex_kit/navigation_menu/navigation_menu_list.rb +7 -0
  250. data/app/components/phlex_kit/navigation_menu/navigation_menu_trigger.rb +27 -0
  251. data/app/components/phlex_kit/pagination/pagination.css +5 -0
  252. data/app/components/phlex_kit/pagination/pagination.rb +10 -0
  253. data/app/components/phlex_kit/pagination/pagination_content.rb +6 -0
  254. data/app/components/phlex_kit/pagination/pagination_ellipsis.rb +17 -0
  255. data/app/components/phlex_kit/pagination/pagination_item.rb +14 -0
  256. data/app/components/phlex_kit/popover/popover.css +9 -0
  257. data/app/components/phlex_kit/popover/popover.rb +11 -0
  258. data/app/components/phlex_kit/popover/popover_content.rb +8 -0
  259. data/app/components/phlex_kit/popover/popover_trigger.rb +8 -0
  260. data/app/components/phlex_kit/progress/progress.css +17 -0
  261. data/app/components/phlex_kit/progress/progress.rb +25 -0
  262. data/app/components/phlex_kit/radio_button/radio_button.css +9 -0
  263. data/app/components/phlex_kit/radio_button/radio_button.rb +19 -0
  264. data/app/components/phlex_kit/radio_group/radio_group.css +3 -0
  265. data/app/components/phlex_kit/radio_group/radio_group.rb +14 -0
  266. data/app/components/phlex_kit/resizable/resizable.css +23 -0
  267. data/app/components/phlex_kit/resizable/resizable_handle.rb +21 -0
  268. data/app/components/phlex_kit/resizable/resizable_panel.rb +19 -0
  269. data/app/components/phlex_kit/resizable/resizable_panel_group.rb +26 -0
  270. data/app/components/phlex_kit/scroll_area/scroll_area.css +21 -0
  271. data/app/components/phlex_kit/scroll_area/scroll_area.rb +15 -0
  272. data/app/components/phlex_kit/select/select.css +80 -0
  273. data/app/components/phlex_kit/select/select.rb +43 -0
  274. data/app/components/phlex_kit/select/select_content.rb +24 -0
  275. data/app/components/phlex_kit/select/select_group.rb +13 -0
  276. data/app/components/phlex_kit/select/select_input.rb +23 -0
  277. data/app/components/phlex_kit/select/select_item.rb +52 -0
  278. data/app/components/phlex_kit/select/select_label.rb +13 -0
  279. data/app/components/phlex_kit/select/select_trigger.rb +42 -0
  280. data/app/components/phlex_kit/select/select_value.rb +21 -0
  281. data/app/components/phlex_kit/separator/separator.css +6 -0
  282. data/app/components/phlex_kit/separator/separator.rb +30 -0
  283. data/app/components/phlex_kit/sheet/sheet.css +17 -0
  284. data/app/components/phlex_kit/sheet/sheet.rb +14 -0
  285. data/app/components/phlex_kit/sheet/sheet_content.rb +25 -0
  286. data/app/components/phlex_kit/sheet/sheet_description.rb +6 -0
  287. data/app/components/phlex_kit/sheet/sheet_footer.rb +6 -0
  288. data/app/components/phlex_kit/sheet/sheet_header.rb +6 -0
  289. data/app/components/phlex_kit/sheet/sheet_middle.rb +6 -0
  290. data/app/components/phlex_kit/sheet/sheet_title.rb +6 -0
  291. data/app/components/phlex_kit/sheet/sheet_trigger.rb +6 -0
  292. data/app/components/phlex_kit/shortcut_key/shortcut_key.css +17 -0
  293. data/app/components/phlex_kit/shortcut_key/shortcut_key.rb +9 -0
  294. data/app/components/phlex_kit/sidebar/sidebar.css +42 -0
  295. data/app/components/phlex_kit/sidebar/sidebar.rb +19 -0
  296. data/app/components/phlex_kit/sidebar/sidebar_content.rb +12 -0
  297. data/app/components/phlex_kit/sidebar/sidebar_footer.rb +12 -0
  298. data/app/components/phlex_kit/sidebar/sidebar_group.rb +12 -0
  299. data/app/components/phlex_kit/sidebar/sidebar_header.rb +12 -0
  300. data/app/components/phlex_kit/sidebar/sidebar_inset.rb +14 -0
  301. data/app/components/phlex_kit/sidebar/sidebar_menu.rb +12 -0
  302. data/app/components/phlex_kit/sidebar/sidebar_menu_button.rb +17 -0
  303. data/app/components/phlex_kit/sidebar/sidebar_menu_item.rb +12 -0
  304. data/app/components/phlex_kit/sidebar/sidebar_wrapper.rb +13 -0
  305. data/app/components/phlex_kit/skeleton/skeleton.css +7 -0
  306. data/app/components/phlex_kit/skeleton/skeleton.rb +9 -0
  307. data/app/components/phlex_kit/slider/slider.css +52 -0
  308. data/app/components/phlex_kit/slider/slider.rb +39 -0
  309. data/app/components/phlex_kit/spinner/spinner.css +5 -0
  310. data/app/components/phlex_kit/spinner/spinner.rb +27 -0
  311. data/app/components/phlex_kit/stars/stars.css +4 -0
  312. data/app/components/phlex_kit/stars/stars.rb +19 -0
  313. data/app/components/phlex_kit/switch/switch.css +28 -0
  314. data/app/components/phlex_kit/switch/switch.rb +21 -0
  315. data/app/components/phlex_kit/table/table.css +24 -0
  316. data/app/components/phlex_kit/table/table.rb +35 -0
  317. data/app/components/phlex_kit/table/table_body.rb +12 -0
  318. data/app/components/phlex_kit/table/table_caption.rb +12 -0
  319. data/app/components/phlex_kit/table/table_cell.rb +12 -0
  320. data/app/components/phlex_kit/table/table_footer.rb +12 -0
  321. data/app/components/phlex_kit/table/table_head.rb +12 -0
  322. data/app/components/phlex_kit/table/table_header.rb +12 -0
  323. data/app/components/phlex_kit/table/table_row.rb +12 -0
  324. data/app/components/phlex_kit/tabs/tabs.css +13 -0
  325. data/app/components/phlex_kit/tabs/tabs.rb +13 -0
  326. data/app/components/phlex_kit/tabs/tabs_content.rb +11 -0
  327. data/app/components/phlex_kit/tabs/tabs_list.rb +6 -0
  328. data/app/components/phlex_kit/tabs/tabs_trigger.rb +17 -0
  329. data/app/components/phlex_kit/textarea/textarea.css +27 -0
  330. data/app/components/phlex_kit/textarea/textarea.rb +24 -0
  331. data/app/components/phlex_kit/theme_toggle/theme_toggle.rb +15 -0
  332. data/app/components/phlex_kit/toast/toast.css +163 -0
  333. data/app/components/phlex_kit/toast/toast.rb +21 -0
  334. data/app/components/phlex_kit/toast/toast_action.rb +19 -0
  335. data/app/components/phlex_kit/toast/toast_cancel.rb +18 -0
  336. data/app/components/phlex_kit/toast/toast_close.rb +35 -0
  337. data/app/components/phlex_kit/toast/toast_description.rb +13 -0
  338. data/app/components/phlex_kit/toast/toast_icon.rb +63 -0
  339. data/app/components/phlex_kit/toast/toast_item.rb +70 -0
  340. data/app/components/phlex_kit/toast/toast_region.rb +121 -0
  341. data/app/components/phlex_kit/toast/toast_title.rb +13 -0
  342. data/app/components/phlex_kit/toggle/toggle.css +16 -0
  343. data/app/components/phlex_kit/toggle/toggle.rb +59 -0
  344. data/app/components/phlex_kit/toggle_group/toggle_group.css +10 -0
  345. data/app/components/phlex_kit/toggle_group/toggle_group.rb +65 -0
  346. data/app/components/phlex_kit/toggle_group/toggle_group_item.rb +37 -0
  347. data/app/components/phlex_kit/tooltip/tooltip.css +28 -0
  348. data/app/components/phlex_kit/tooltip/tooltip.rb +15 -0
  349. data/app/components/phlex_kit/tooltip/tooltip_content.rb +12 -0
  350. data/app/components/phlex_kit/tooltip/tooltip_trigger.rb +13 -0
  351. data/app/components/phlex_kit/typography/blockquote.rb +12 -0
  352. data/app/components/phlex_kit/typography/heading.rb +38 -0
  353. data/app/components/phlex_kit/typography/inline_code.rb +13 -0
  354. data/app/components/phlex_kit/typography/inline_link.rb +15 -0
  355. data/app/components/phlex_kit/typography/text.rb +48 -0
  356. data/app/components/phlex_kit/typography/typography.css +50 -0
  357. data/app/javascript/phlex_kit/controllers/accordion_controller.js +59 -0
  358. data/app/javascript/phlex_kit/controllers/alert_dialog_controller.js +24 -0
  359. data/app/javascript/phlex_kit/controllers/avatar_controller.js +30 -0
  360. data/app/javascript/phlex_kit/controllers/calendar_controller.js +316 -0
  361. data/app/javascript/phlex_kit/controllers/calendar_input_controller.js +10 -0
  362. data/app/javascript/phlex_kit/controllers/carousel_controller.js +189 -0
  363. data/app/javascript/phlex_kit/controllers/chart_controller.js +135 -0
  364. data/app/javascript/phlex_kit/controllers/clipboard_controller.js +30 -0
  365. data/app/javascript/phlex_kit/controllers/collapsible_controller.js +14 -0
  366. data/app/javascript/phlex_kit/controllers/combobox_controller.js +303 -0
  367. data/app/javascript/phlex_kit/controllers/command_controller.js +161 -0
  368. data/app/javascript/phlex_kit/controllers/command_dialog_controller.js +37 -0
  369. data/app/javascript/phlex_kit/controllers/context_menu_controller.js +28 -0
  370. data/app/javascript/phlex_kit/controllers/data_table_column_visibility_controller.js +18 -0
  371. data/app/javascript/phlex_kit/controllers/data_table_controller.js +61 -0
  372. data/app/javascript/phlex_kit/controllers/data_table_search_controller.js +67 -0
  373. data/app/javascript/phlex_kit/controllers/dialog_controller.js +20 -0
  374. data/app/javascript/phlex_kit/controllers/dropdown_menu_controller.js +106 -0
  375. data/app/javascript/phlex_kit/controllers/form_field_controller.js +69 -0
  376. data/app/javascript/phlex_kit/controllers/hover_card_controller.js +11 -0
  377. data/app/javascript/phlex_kit/controllers/index.js +87 -0
  378. data/app/javascript/phlex_kit/controllers/input_otp_controller.js +66 -0
  379. data/app/javascript/phlex_kit/controllers/masked_input_controller.js +26 -0
  380. data/app/javascript/phlex_kit/controllers/menubar_controller.js +43 -0
  381. data/app/javascript/phlex_kit/controllers/message_scroller_controller.js +335 -0
  382. data/app/javascript/phlex_kit/controllers/popover_controller.js +12 -0
  383. data/app/javascript/phlex_kit/controllers/resizable_controller.js +42 -0
  384. data/app/javascript/phlex_kit/controllers/select_controller.js +141 -0
  385. data/app/javascript/phlex_kit/controllers/select_item_controller.js +14 -0
  386. data/app/javascript/phlex_kit/controllers/sheet_content_controller.js +6 -0
  387. data/app/javascript/phlex_kit/controllers/sheet_controller.js +10 -0
  388. data/app/javascript/phlex_kit/controllers/slider_controller.js +19 -0
  389. data/app/javascript/phlex_kit/controllers/tabs_controller.js +28 -0
  390. data/app/javascript/phlex_kit/controllers/theme_toggle_controller.js +22 -0
  391. data/app/javascript/phlex_kit/controllers/toast_controller.js +153 -0
  392. data/app/javascript/phlex_kit/controllers/toaster_controller.js +321 -0
  393. data/app/javascript/phlex_kit/controllers/toggle_controller.js +25 -0
  394. data/app/javascript/phlex_kit/controllers/toggle_group_controller.js +91 -0
  395. data/config/importmap.rb +7 -0
  396. data/lib/generators/phlex_kit/component/component_generator.rb +41 -0
  397. data/lib/generators/phlex_kit/install/install_generator.rb +51 -0
  398. data/lib/generators/phlex_kit/install/templates/phlex_kit.rb +11 -0
  399. data/lib/phlex_kit/base_component.rb +22 -0
  400. data/lib/phlex_kit/configuration.rb +46 -0
  401. data/lib/phlex_kit/engine.rb +50 -0
  402. data/lib/phlex_kit/propshaft_skip_source.rb +22 -0
  403. data/lib/phlex_kit/version.rb +5 -0
  404. data/lib/phlex_kit.rb +21 -0
  405. metadata +545 -0
@@ -0,0 +1,67 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ // Ported from ruby_ui's data-table-search controller (Stimulus-only upstream),
4
+ // identifiers renamed ruby-ui → phlex-kit. Debounces form submits and restores
5
+ // focus/caret across the Turbo Frame swap.
6
+
7
+ // Module-level map survives controller disconnect/connect across Turbo Frame swaps.
8
+ // Keyed by the search form's action URL.
9
+ const PENDING_FOCUS = new Map();
10
+
11
+ // Connects to data-controller="phlex-kit--data-table-search"
12
+ export default class extends Controller {
13
+ static values = { delay: { type: Number, default: 300 } };
14
+
15
+ connect() {
16
+ this.timer = null;
17
+ this.beforeFrameRender = this.captureBeforeRender.bind(this);
18
+ document.addEventListener("turbo:before-frame-render", this.beforeFrameRender);
19
+ // New instance after a Turbo Frame swap — check for captured state.
20
+ this.restoreIfPending();
21
+ }
22
+
23
+ disconnect() {
24
+ clearTimeout(this.timer);
25
+ document.removeEventListener("turbo:before-frame-render", this.beforeFrameRender);
26
+ }
27
+
28
+ submit(event) {
29
+ if (event && event.type !== "input") return;
30
+ clearTimeout(this.timer);
31
+ if (this.delayValue <= 0) return;
32
+ this.timer = setTimeout(() => this.element.requestSubmit(), this.delayValue);
33
+ }
34
+
35
+ captureBeforeRender() {
36
+ const input = this.input();
37
+ if (!input || document.activeElement !== input) return;
38
+ PENDING_FOCUS.set(this.key(), {
39
+ selectionStart: input.selectionStart,
40
+ selectionEnd: input.selectionEnd
41
+ });
42
+ }
43
+
44
+ restoreIfPending() {
45
+ const state = PENDING_FOCUS.get(this.key());
46
+ if (!state) return;
47
+ PENDING_FOCUS.delete(this.key());
48
+ const input = this.input();
49
+ if (!input) return;
50
+ input.focus();
51
+ const len = input.value.length;
52
+ try {
53
+ input.setSelectionRange(
54
+ Math.min(state.selectionStart ?? len, len),
55
+ Math.min(state.selectionEnd ?? len, len)
56
+ );
57
+ } catch (e) {}
58
+ }
59
+
60
+ input() {
61
+ return this.element.querySelector('input[type="search"]');
62
+ }
63
+
64
+ key() {
65
+ return this.element.action || "_";
66
+ }
67
+ }
@@ -0,0 +1,20 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Connects to data-controller="phlex-kit--dialog". Ported from ruby_ui.
4
+ export default class extends Controller {
5
+ static targets = ["dialog"]
6
+ static values = { open: { type: Boolean, default: false } }
7
+
8
+ connect() {
9
+ this.dialogTarget.addEventListener("close", this.handleClose)
10
+ if (this.openValue) this.open()
11
+ }
12
+ disconnect() {
13
+ this.dialogTarget.removeEventListener("close", this.handleClose)
14
+ document.body.style.removeProperty("overflow")
15
+ }
16
+ open(e) { e?.preventDefault(); this.dialogTarget.showModal(); document.body.style.overflow = "hidden" }
17
+ dismiss() { this.dialogTarget.close() }
18
+ backdropClick(e) { if (e.target === this.dialogTarget) this.dismiss() }
19
+ handleClose = () => { document.body.style.removeProperty("overflow") }
20
+ }
@@ -0,0 +1,106 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ // Ported from ruby_ui's phlex-kit--dropdown-menu controller. The ONE change from
4
+ // upstream: the @floating-ui/dom dependency is removed — the panel is positioned
5
+ // with plain CSS (.ui-dropdown-menu-content { position:absolute }), so this app
6
+ // needs no npm/build step. Toggle, click-outside, and arrow/enter keyboard nav
7
+ // are unchanged.
8
+ export default class extends Controller {
9
+ static targets = ["trigger", "content", "menuItem"];
10
+ static values = { open: { type: Boolean, default: false } };
11
+
12
+ connect() {
13
+ this.boundHandleKeydown = this.#handleKeydown.bind(this);
14
+ this.selectedIndex = -1;
15
+ }
16
+
17
+ disconnect() {
18
+ this.#removeEventListeners();
19
+ }
20
+
21
+ onClickOutside(event) {
22
+ if (!this.openValue) return;
23
+ if (this.element.contains(event.target)) return;
24
+
25
+ event.preventDefault();
26
+ this.close();
27
+ }
28
+
29
+ toggle() {
30
+ this.contentTarget.classList.contains("hidden") ? this.#open() : this.close();
31
+ }
32
+
33
+ #open() {
34
+ this.openValue = true;
35
+ this.#deselectAll();
36
+ this.#addEventListeners();
37
+ // Lift the open menu above siblings (the container has no static z-index).
38
+ this.element.style.zIndex = "50";
39
+ this.contentTarget.classList.remove("hidden");
40
+ }
41
+
42
+ close() {
43
+ this.openValue = false;
44
+ this.#removeEventListeners();
45
+ this.element.style.zIndex = "";
46
+ this.contentTarget.classList.add("hidden");
47
+ }
48
+
49
+ #handleKeydown(e) {
50
+ if (this.menuItemTargets.length === 0) return;
51
+
52
+ if (e.key === "ArrowDown") {
53
+ e.preventDefault();
54
+ this.#updateSelectedItem(1);
55
+ } else if (e.key === "ArrowUp") {
56
+ e.preventDefault();
57
+ this.#updateSelectedItem(-1);
58
+ } else if (e.key === "Enter" && this.selectedIndex !== -1) {
59
+ e.preventDefault();
60
+ this.menuItemTargets[this.selectedIndex].click();
61
+ } else if (e.key === "Escape") {
62
+ this.close();
63
+ }
64
+ }
65
+
66
+ #updateSelectedItem(direction) {
67
+ this.menuItemTargets.forEach((item, index) => {
68
+ if (item.getAttribute("aria-selected") === "true") this.selectedIndex = index;
69
+ });
70
+
71
+ if (this.selectedIndex >= 0) {
72
+ this.#toggleAriaSelected(this.menuItemTargets[this.selectedIndex], false);
73
+ }
74
+
75
+ this.selectedIndex += direction;
76
+
77
+ if (this.selectedIndex < 0) {
78
+ this.selectedIndex = this.menuItemTargets.length - 1;
79
+ } else if (this.selectedIndex >= this.menuItemTargets.length) {
80
+ this.selectedIndex = 0;
81
+ }
82
+
83
+ this.#toggleAriaSelected(this.menuItemTargets[this.selectedIndex], true);
84
+ }
85
+
86
+ #toggleAriaSelected(element, isSelected) {
87
+ if (isSelected) {
88
+ element.setAttribute("aria-selected", "true");
89
+ } else {
90
+ element.removeAttribute("aria-selected");
91
+ }
92
+ }
93
+
94
+ #deselectAll() {
95
+ this.menuItemTargets.forEach((item) => this.#toggleAriaSelected(item, false));
96
+ this.selectedIndex = -1;
97
+ }
98
+
99
+ #addEventListeners() {
100
+ document.addEventListener("keydown", this.boundHandleKeydown);
101
+ }
102
+
103
+ #removeEventListeners() {
104
+ document.removeEventListener("keydown", this.boundHandleKeydown);
105
+ }
106
+ }
@@ -0,0 +1,69 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ // Ported from ruby_ui's form-field controller (Stimulus-only upstream),
4
+ // identifiers renamed ruby-ui → phlex-kit and the Tailwind hidden class swapped
5
+ // for .pk-hidden. Validation stays quiet until the control first goes invalid
6
+ // (or the error target renders with server content); after that the message
7
+ // live-updates on every input/change. Per-constraint messages come from
8
+ // data-* on the input (data-value-missing, data-type-mismatch, …), falling
9
+ // back to the browser's validationMessage.
10
+ // Connects to data-controller="phlex-kit--form-field"
11
+ export default class extends Controller {
12
+ static targets = ["input", "error"];
13
+ static values = { shouldValidate: false };
14
+
15
+ connect() {
16
+ if (this.hasErrorTarget) {
17
+ if (this.errorTarget.textContent) {
18
+ this.shouldValidateValue = true;
19
+ } else {
20
+ this.errorTarget.classList.add("pk-hidden");
21
+ }
22
+ }
23
+ }
24
+
25
+ onInvalid(error) {
26
+ error.preventDefault();
27
+
28
+ this.shouldValidateValue = true;
29
+ this.#setErrorMessage();
30
+ }
31
+
32
+ onInput() {
33
+ this.#setErrorMessage();
34
+ }
35
+
36
+ onChange() {
37
+ this.#setErrorMessage();
38
+ }
39
+
40
+ #setErrorMessage() {
41
+ if (!this.shouldValidateValue) return;
42
+
43
+ if (this.inputTarget.validity.valid) {
44
+ this.errorTarget.textContent = "";
45
+ this.errorTarget.classList.add("pk-hidden");
46
+ } else {
47
+ this.errorTarget.textContent = this.#getValidationMessage();
48
+ this.errorTarget.classList.remove("pk-hidden");
49
+ }
50
+ }
51
+
52
+ #getValidationMessage() {
53
+ let errorMessage;
54
+
55
+ const { validity, dataset, validationMessage } = this.inputTarget;
56
+
57
+ if (validity.tooLong) errorMessage = dataset.tooLong;
58
+ if (validity.tooShort) errorMessage = dataset.tooShort;
59
+ if (validity.badInput) errorMessage = dataset.badInput;
60
+ if (validity.typeMismatch) errorMessage = dataset.typeMismatch;
61
+ if (validity.stepMismatch) errorMessage = dataset.stepMismatch;
62
+ if (validity.valueMissing) errorMessage = dataset.valueMissing;
63
+ if (validity.rangeOverflow) errorMessage = dataset.rangeOverflow;
64
+ if (validity.rangeUnderflow) errorMessage = dataset.rangeUnderflow;
65
+ if (validity.patternMismatch) errorMessage = dataset.patternMismatch;
66
+
67
+ return errorMessage || validationMessage;
68
+ }
69
+ }
@@ -0,0 +1,11 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Connects to data-controller="phlex-kit--hover-card". Show on hover/focus with a
4
+ // small open/close delay. CSS positions the card under the trigger.
5
+ export default class extends Controller {
6
+ static targets = ["content"]
7
+ static values = { openDelay: { type: Number, default: 200 }, closeDelay: { type: Number, default: 200 } }
8
+ show() { clearTimeout(this.t); this.t = setTimeout(() => { this.contentTarget.classList.remove("pk-hidden"); this.contentTarget.dataset.state = "open" }, this.openDelayValue) }
9
+ hide() { clearTimeout(this.t); this.t = setTimeout(() => { this.contentTarget.classList.add("pk-hidden"); this.contentTarget.dataset.state = "closed" }, this.closeDelayValue) }
10
+ disconnect() { clearTimeout(this.t) }
11
+ }
@@ -0,0 +1,87 @@
1
+ // Register PhlexKit's Stimulus controllers under their phlex-kit--* identifiers.
2
+ // Call once from your app's Stimulus entrypoint:
3
+ //
4
+ // import { Application } from "@hotwired/stimulus"
5
+ // import { registerPhlexKitControllers } from "phlex_kit/controllers"
6
+ // const application = Application.start()
7
+ // registerPhlexKitControllers(application)
8
+ //
9
+ // The identifiers here MUST match the data-controller names emitted by the
10
+ // components (e.g. phlex-kit--dropdown-menu).
11
+ import AccordionController from "phlex_kit/controllers/accordion_controller"
12
+ import AlertDialogController from "phlex_kit/controllers/alert_dialog_controller"
13
+ import AvatarController from "phlex_kit/controllers/avatar_controller"
14
+ import CalendarController from "phlex_kit/controllers/calendar_controller"
15
+ import CalendarInputController from "phlex_kit/controllers/calendar_input_controller"
16
+ import CarouselController from "phlex_kit/controllers/carousel_controller"
17
+ import ChartController from "phlex_kit/controllers/chart_controller"
18
+ import ClipboardController from "phlex_kit/controllers/clipboard_controller"
19
+ import CollapsibleController from "phlex_kit/controllers/collapsible_controller"
20
+ import ComboboxController from "phlex_kit/controllers/combobox_controller"
21
+ import CommandController from "phlex_kit/controllers/command_controller"
22
+ import CommandDialogController from "phlex_kit/controllers/command_dialog_controller"
23
+ import ContextMenuController from "phlex_kit/controllers/context_menu_controller"
24
+ import DataTableController from "phlex_kit/controllers/data_table_controller"
25
+ import DataTableColumnVisibilityController from "phlex_kit/controllers/data_table_column_visibility_controller"
26
+ import DataTableSearchController from "phlex_kit/controllers/data_table_search_controller"
27
+ import DialogController from "phlex_kit/controllers/dialog_controller"
28
+ import DropdownMenuController from "phlex_kit/controllers/dropdown_menu_controller"
29
+ import FormFieldController from "phlex_kit/controllers/form_field_controller"
30
+ import HoverCardController from "phlex_kit/controllers/hover_card_controller"
31
+ import InputOtpController from "phlex_kit/controllers/input_otp_controller"
32
+ import MaskedInputController from "phlex_kit/controllers/masked_input_controller"
33
+ import MenubarController from "phlex_kit/controllers/menubar_controller"
34
+ import MessageScrollerController from "phlex_kit/controllers/message_scroller_controller"
35
+ import PopoverController from "phlex_kit/controllers/popover_controller"
36
+ import ResizableController from "phlex_kit/controllers/resizable_controller"
37
+ import SelectController from "phlex_kit/controllers/select_controller"
38
+ import SelectItemController from "phlex_kit/controllers/select_item_controller"
39
+ import SheetController from "phlex_kit/controllers/sheet_controller"
40
+ import SheetContentController from "phlex_kit/controllers/sheet_content_controller"
41
+ import SliderController from "phlex_kit/controllers/slider_controller"
42
+ import TabsController from "phlex_kit/controllers/tabs_controller"
43
+ import ThemeToggleController from "phlex_kit/controllers/theme_toggle_controller"
44
+ import ToastController from "phlex_kit/controllers/toast_controller"
45
+ import ToasterController from "phlex_kit/controllers/toaster_controller"
46
+ import ToggleController from "phlex_kit/controllers/toggle_controller"
47
+ import ToggleGroupController from "phlex_kit/controllers/toggle_group_controller"
48
+
49
+ export function registerPhlexKitControllers(application) {
50
+ application.register("phlex-kit--accordion", AccordionController)
51
+ application.register("phlex-kit--alert-dialog", AlertDialogController)
52
+ application.register("phlex-kit--avatar", AvatarController)
53
+ application.register("phlex-kit--calendar", CalendarController)
54
+ application.register("phlex-kit--calendar-input", CalendarInputController)
55
+ application.register("phlex-kit--carousel", CarouselController)
56
+ application.register("phlex-kit--chart", ChartController)
57
+ application.register("phlex-kit--clipboard", ClipboardController)
58
+ application.register("phlex-kit--collapsible", CollapsibleController)
59
+ application.register("phlex-kit--combobox", ComboboxController)
60
+ application.register("phlex-kit--command", CommandController)
61
+ application.register("phlex-kit--command-dialog", CommandDialogController)
62
+ application.register("phlex-kit--context-menu", ContextMenuController)
63
+ application.register("phlex-kit--data-table", DataTableController)
64
+ application.register("phlex-kit--data-table-column-visibility", DataTableColumnVisibilityController)
65
+ application.register("phlex-kit--data-table-search", DataTableSearchController)
66
+ application.register("phlex-kit--dialog", DialogController)
67
+ application.register("phlex-kit--dropdown-menu", DropdownMenuController)
68
+ application.register("phlex-kit--form-field", FormFieldController)
69
+ application.register("phlex-kit--hover-card", HoverCardController)
70
+ application.register("phlex-kit--input-otp", InputOtpController)
71
+ application.register("phlex-kit--masked-input", MaskedInputController)
72
+ application.register("phlex-kit--menubar", MenubarController)
73
+ application.register("phlex-kit--message-scroller", MessageScrollerController)
74
+ application.register("phlex-kit--popover", PopoverController)
75
+ application.register("phlex-kit--resizable", ResizableController)
76
+ application.register("phlex-kit--select", SelectController)
77
+ application.register("phlex-kit--select-item", SelectItemController)
78
+ application.register("phlex-kit--sheet", SheetController)
79
+ application.register("phlex-kit--sheet-content", SheetContentController)
80
+ application.register("phlex-kit--slider", SliderController)
81
+ application.register("phlex-kit--tabs", TabsController)
82
+ application.register("phlex-kit--theme-toggle", ThemeToggleController)
83
+ application.register("phlex-kit--toast", ToastController)
84
+ application.register("phlex-kit--toaster", ToasterController)
85
+ application.register("phlex-kit--toggle", ToggleController)
86
+ application.register("phlex-kit--toggle-group", ToggleGroupController)
87
+ }
@@ -0,0 +1,66 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // PhlexKit's stand-in for the input-otp lib behind shadcn's InputOTP: per-slot
4
+ // single-character inputs with auto-advance, backspace retreat, arrow
5
+ // movement and paste distribution; the hidden value target carries the joined
6
+ // code for the form.
7
+ // Connects to data-controller="phlex-kit--input-otp"
8
+ export default class extends Controller {
9
+ static targets = ["slot", "value"]
10
+ static values = { length: Number }
11
+
12
+ connect() {
13
+ this.syncValue()
14
+ }
15
+
16
+ onInput(e) {
17
+ const slot = e.target
18
+ slot.value = slot.value.replace(/\s/g, "").slice(-1)
19
+ if (slot.value) this.focusSlot(this.slotTargets.indexOf(slot) + 1)
20
+ this.syncValue()
21
+ }
22
+
23
+ onKeydown(e) {
24
+ const index = this.slotTargets.indexOf(e.target)
25
+ if (e.key === "Backspace" && !e.target.value && index > 0) {
26
+ e.preventDefault()
27
+ const prev = this.slotTargets[index - 1]
28
+ prev.value = ""
29
+ prev.focus()
30
+ this.syncValue()
31
+ } else if (e.key === "ArrowLeft" && index > 0) {
32
+ e.preventDefault()
33
+ this.focusSlot(index - 1)
34
+ } else if (e.key === "ArrowRight") {
35
+ e.preventDefault()
36
+ this.focusSlot(index + 1)
37
+ }
38
+ }
39
+
40
+ onPaste(e) {
41
+ e.preventDefault()
42
+ const chars = (e.clipboardData?.getData("text") || "").replace(/\s/g, "").split("")
43
+ if (!chars.length) return
44
+ const start = this.slotTargets.indexOf(e.target)
45
+ this.slotTargets.slice(start).forEach((slot, i) => { if (chars[i] != null) slot.value = chars[i] })
46
+ this.focusSlot(Math.min(start + chars.length, this.slotTargets.length - 1))
47
+ this.syncValue()
48
+ }
49
+
50
+ onFocus(e) {
51
+ e.target.select()
52
+ }
53
+
54
+ focusSlot(index) {
55
+ const slot = this.slotTargets[Math.max(0, Math.min(index, this.slotTargets.length - 1))]
56
+ slot?.focus()
57
+ }
58
+
59
+ syncValue() {
60
+ if (!this.hasValueTarget) return
61
+ const code = this.slotTargets.map((slot) => slot.value).join("")
62
+ if (this.valueTarget.value === code) return
63
+ this.valueTarget.value = code
64
+ this.valueTarget.dispatchEvent(new Event("change", { bubbles: true }))
65
+ }
66
+ }
@@ -0,0 +1,26 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Connects to data-controller="phlex-kit--masked-input". Lightweight, dependency-
4
+ // free mask driven by a data-mask pattern (# = digit, A = letter, * = any). Swap
5
+ // in `maska` (ruby_ui's choice) here if you need a fuller mask engine.
6
+ export default class extends Controller {
7
+ connect() {
8
+ this.mask = this.element.getAttribute("data-mask") || ""
9
+ if (!this.mask) return
10
+ this.onInput = () => this.apply()
11
+ this.element.addEventListener("input", this.onInput)
12
+ }
13
+ disconnect() { if (this.onInput) this.element.removeEventListener("input", this.onInput) }
14
+ apply() {
15
+ const raw = this.element.value.replace(/[^0-9A-Za-z]/g, "")
16
+ let out = "", i = 0
17
+ for (const t of this.mask) {
18
+ if (i >= raw.length) break
19
+ if (t === "#") { if (/\d/.test(raw[i])) out += raw[i++]; else break }
20
+ else if (t === "A") { if (/[A-Za-z]/.test(raw[i])) out += raw[i++]; else break }
21
+ else if (t === "*") { out += raw[i++] }
22
+ else { out += t; if (raw[i] === t) i++ }
23
+ }
24
+ this.element.value = out
25
+ }
26
+ }
@@ -0,0 +1,43 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // PhlexKit's stand-in for Radix behind shadcn's Menubar and NavigationMenu:
4
+ // click (or hover, for nav menus) opens a menu's panel; while one is open,
5
+ // hovering a sibling trigger switches to it; Escape/outside/item click closes.
6
+ // Connects to data-controller="phlex-kit--menubar"
7
+ export default class extends Controller {
8
+ static targets = ["menu"]
9
+
10
+ toggle(e) {
11
+ const menu = e.currentTarget.closest("[data-phlex-kit--menubar-target=\"menu\"]")
12
+ this.openMenu === menu ? this.close() : this.show(menu)
13
+ }
14
+
15
+ // Hover: switches between menus while one is open (menubar), or opens
16
+ // directly when the bar declares data-hover-open (navigation menu).
17
+ switch(e) {
18
+ const menu = e.currentTarget.closest("[data-phlex-kit--menubar-target=\"menu\"]")
19
+ if (this.element.dataset.hoverOpen !== undefined) return this.show(menu)
20
+ if (this.openMenu && this.openMenu !== menu) this.show(menu)
21
+ }
22
+
23
+ show(menu) {
24
+ if (this.openMenu === menu) return
25
+ this.close()
26
+ menu.querySelector("[role=\"menu\"], .pk-menubar-content, .pk-navigation-menu-content")?.classList.remove("pk-hidden")
27
+ menu.querySelector("[aria-expanded]")?.setAttribute("aria-expanded", "true")
28
+ this.openMenu = menu
29
+ }
30
+
31
+ close() {
32
+ const menu = this.openMenu
33
+ if (!menu) return
34
+ menu.querySelector("[role=\"menu\"], .pk-menubar-content, .pk-navigation-menu-content")?.classList.add("pk-hidden")
35
+ menu.querySelector("[aria-expanded]")?.setAttribute("aria-expanded", "false")
36
+ this.openMenu = null
37
+ }
38
+
39
+ onClickOutside(e) {
40
+ if (this.element.contains(e.target)) return
41
+ this.close()
42
+ }
43
+ }