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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +21 -0
- data/README.md +135 -0
- data/app/assets/stylesheets/phlex_kit/_tokens.css +91 -0
- data/app/assets/stylesheets/phlex_kit/phlex_kit.css +82 -0
- data/app/components/phlex_kit/accordion/accordion.css +14 -0
- data/app/components/phlex_kit/accordion/accordion.rb +10 -0
- data/app/components/phlex_kit/accordion/accordion_content.rb +8 -0
- data/app/components/phlex_kit/accordion/accordion_default_content.rb +6 -0
- data/app/components/phlex_kit/accordion/accordion_default_trigger.rb +12 -0
- data/app/components/phlex_kit/accordion/accordion_icon.rb +16 -0
- data/app/components/phlex_kit/accordion/accordion_item.rb +12 -0
- data/app/components/phlex_kit/accordion/accordion_trigger.rb +8 -0
- data/app/components/phlex_kit/alert/alert.css +32 -0
- data/app/components/phlex_kit/alert/alert.rb +37 -0
- data/app/components/phlex_kit/alert/alert_description.rb +12 -0
- data/app/components/phlex_kit/alert/alert_title.rb +12 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog.css +37 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog.rb +20 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog_action.rb +14 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog_cancel.rb +13 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog_content.rb +19 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog_description.rb +12 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog_footer.rb +12 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog_header.rb +12 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog_title.rb +12 -0
- data/app/components/phlex_kit/alert_dialog/alert_dialog_trigger.rb +12 -0
- data/app/components/phlex_kit/aspect_ratio/aspect_ratio.css +12 -0
- data/app/components/phlex_kit/aspect_ratio/aspect_ratio.rb +27 -0
- data/app/components/phlex_kit/attachment/attachment.css +62 -0
- data/app/components/phlex_kit/attachment/attachment.rb +16 -0
- data/app/components/phlex_kit/attachment/attachment_action.rb +24 -0
- data/app/components/phlex_kit/attachment/attachment_actions.rb +7 -0
- data/app/components/phlex_kit/attachment/attachment_content.rb +7 -0
- data/app/components/phlex_kit/attachment/attachment_description.rb +7 -0
- data/app/components/phlex_kit/attachment/attachment_media.rb +8 -0
- data/app/components/phlex_kit/attachment/attachment_title.rb +7 -0
- data/app/components/phlex_kit/avatar/avatar.css +35 -0
- data/app/components/phlex_kit/avatar/avatar.rb +25 -0
- data/app/components/phlex_kit/avatar/avatar_fallback.rb +13 -0
- data/app/components/phlex_kit/avatar/avatar_group.rb +7 -0
- data/app/components/phlex_kit/avatar/avatar_image.rb +24 -0
- data/app/components/phlex_kit/badge/badge.css +50 -0
- data/app/components/phlex_kit/badge/badge.rb +39 -0
- data/app/components/phlex_kit/breadcrumb/breadcrumb.css +18 -0
- data/app/components/phlex_kit/breadcrumb/breadcrumb.rb +8 -0
- data/app/components/phlex_kit/breadcrumb/breadcrumb_ellipsis.rb +15 -0
- data/app/components/phlex_kit/breadcrumb/breadcrumb_item.rb +6 -0
- data/app/components/phlex_kit/breadcrumb/breadcrumb_link.rb +9 -0
- data/app/components/phlex_kit/breadcrumb/breadcrumb_list.rb +6 -0
- data/app/components/phlex_kit/breadcrumb/breadcrumb_page.rb +8 -0
- data/app/components/phlex_kit/breadcrumb/breadcrumb_separator.rb +10 -0
- data/app/components/phlex_kit/bubble/bubble.css +32 -0
- data/app/components/phlex_kit/bubble/bubble.rb +17 -0
- data/app/components/phlex_kit/bubble/bubble_content.rb +11 -0
- data/app/components/phlex_kit/bubble/bubble_group.rb +6 -0
- data/app/components/phlex_kit/bubble/bubble_reactions.rb +12 -0
- data/app/components/phlex_kit/button/button.css +72 -0
- data/app/components/phlex_kit/button/button.rb +51 -0
- data/app/components/phlex_kit/button_group/button_group.css +8 -0
- data/app/components/phlex_kit/button_group/button_group.rb +14 -0
- data/app/components/phlex_kit/calendar/calendar.css +109 -0
- data/app/components/phlex_kit/calendar/calendar.rb +47 -0
- data/app/components/phlex_kit/calendar/calendar_body.rb +13 -0
- data/app/components/phlex_kit/calendar/calendar_days.rb +98 -0
- data/app/components/phlex_kit/calendar/calendar_header.rb +13 -0
- data/app/components/phlex_kit/calendar/calendar_next.rb +40 -0
- data/app/components/phlex_kit/calendar/calendar_prev.rb +40 -0
- data/app/components/phlex_kit/calendar/calendar_title.rb +19 -0
- data/app/components/phlex_kit/calendar/calendar_weekdays.rb +27 -0
- data/app/components/phlex_kit/card/card.css +15 -0
- data/app/components/phlex_kit/card/card.rb +29 -0
- data/app/components/phlex_kit/card/card_content.rb +12 -0
- data/app/components/phlex_kit/card/card_description.rb +12 -0
- data/app/components/phlex_kit/card/card_footer.rb +12 -0
- data/app/components/phlex_kit/card/card_header.rb +12 -0
- data/app/components/phlex_kit/card/card_title.rb +12 -0
- data/app/components/phlex_kit/carousel/carousel.css +41 -0
- data/app/components/phlex_kit/carousel/carousel.rb +37 -0
- data/app/components/phlex_kit/carousel/carousel_content.rb +16 -0
- data/app/components/phlex_kit/carousel/carousel_item.rb +17 -0
- data/app/components/phlex_kit/carousel/carousel_next.rb +39 -0
- data/app/components/phlex_kit/carousel/carousel_previous.rb +40 -0
- data/app/components/phlex_kit/chart/chart.css +9 -0
- data/app/components/phlex_kit/chart/chart.rb +31 -0
- data/app/components/phlex_kit/checkbox/checkbox.css +27 -0
- data/app/components/phlex_kit/checkbox/checkbox.rb +26 -0
- data/app/components/phlex_kit/clipboard/clipboard.css +8 -0
- data/app/components/phlex_kit/clipboard/clipboard.rb +19 -0
- data/app/components/phlex_kit/clipboard/clipboard_popover.rb +14 -0
- data/app/components/phlex_kit/clipboard/clipboard_source.rb +6 -0
- data/app/components/phlex_kit/clipboard/clipboard_trigger.rb +6 -0
- data/app/components/phlex_kit/codeblock/codeblock.css +7 -0
- data/app/components/phlex_kit/codeblock/codeblock.rb +23 -0
- data/app/components/phlex_kit/collapsible/collapsible.css +3 -0
- data/app/components/phlex_kit/collapsible/collapsible.rb +13 -0
- data/app/components/phlex_kit/collapsible/collapsible_content.rb +8 -0
- data/app/components/phlex_kit/collapsible/collapsible_trigger.rb +8 -0
- data/app/components/phlex_kit/combobox/combobox.css +310 -0
- data/app/components/phlex_kit/combobox/combobox.rb +33 -0
- data/app/components/phlex_kit/combobox/combobox_badge.rb +15 -0
- data/app/components/phlex_kit/combobox/combobox_badge_trigger.rb +55 -0
- data/app/components/phlex_kit/combobox/combobox_checkbox.rb +21 -0
- data/app/components/phlex_kit/combobox/combobox_clear_button.rb +39 -0
- data/app/components/phlex_kit/combobox/combobox_empty_state.rb +17 -0
- data/app/components/phlex_kit/combobox/combobox_input_trigger.rb +69 -0
- data/app/components/phlex_kit/combobox/combobox_item.rb +19 -0
- data/app/components/phlex_kit/combobox/combobox_item_indicator.rb +27 -0
- data/app/components/phlex_kit/combobox/combobox_list.rb +12 -0
- data/app/components/phlex_kit/combobox/combobox_list_group.rb +14 -0
- data/app/components/phlex_kit/combobox/combobox_popover.rb +27 -0
- data/app/components/phlex_kit/combobox/combobox_radio.rb +26 -0
- data/app/components/phlex_kit/combobox/combobox_search_input.rb +49 -0
- data/app/components/phlex_kit/combobox/combobox_toggle_all_checkbox.rb +21 -0
- data/app/components/phlex_kit/combobox/combobox_trigger.rb +48 -0
- data/app/components/phlex_kit/command/command.css +104 -0
- data/app/components/phlex_kit/command/command.rb +18 -0
- data/app/components/phlex_kit/command/command_dialog.rb +19 -0
- data/app/components/phlex_kit/command/command_dialog_content.rb +37 -0
- data/app/components/phlex_kit/command/command_dialog_trigger.rb +22 -0
- data/app/components/phlex_kit/command/command_empty.rb +17 -0
- data/app/components/phlex_kit/command/command_group.rb +32 -0
- data/app/components/phlex_kit/command/command_input.rb +56 -0
- data/app/components/phlex_kit/command/command_item.rb +22 -0
- data/app/components/phlex_kit/command/command_list.rb +12 -0
- data/app/components/phlex_kit/context_menu/context_menu.css +19 -0
- data/app/components/phlex_kit/context_menu/context_menu.rb +11 -0
- data/app/components/phlex_kit/context_menu/context_menu_content.rb +8 -0
- data/app/components/phlex_kit/context_menu/context_menu_item.rb +25 -0
- data/app/components/phlex_kit/context_menu/context_menu_label.rb +11 -0
- data/app/components/phlex_kit/context_menu/context_menu_separator.rb +8 -0
- data/app/components/phlex_kit/context_menu/context_menu_trigger.rb +8 -0
- data/app/components/phlex_kit/data_table/data_table.css +110 -0
- data/app/components/phlex_kit/data_table/data_table.rb +25 -0
- data/app/components/phlex_kit/data_table/data_table_bulk_actions.rb +15 -0
- data/app/components/phlex_kit/data_table/data_table_column_toggle.rb +61 -0
- data/app/components/phlex_kit/data_table/data_table_expand_toggle.rb +40 -0
- data/app/components/phlex_kit/data_table/data_table_form.rb +36 -0
- data/app/components/phlex_kit/data_table/data_table_kaminari_adapter.rb +17 -0
- data/app/components/phlex_kit/data_table/data_table_manual_adapter.rb +18 -0
- data/app/components/phlex_kit/data_table/data_table_pagination.rb +98 -0
- data/app/components/phlex_kit/data_table/data_table_pagination_bar.rb +13 -0
- data/app/components/phlex_kit/data_table/data_table_pagy_adapter.rb +17 -0
- data/app/components/phlex_kit/data_table/data_table_per_page_select.rb +29 -0
- data/app/components/phlex_kit/data_table/data_table_row_checkbox.rb +24 -0
- data/app/components/phlex_kit/data_table/data_table_search.rb +51 -0
- data/app/components/phlex_kit/data_table/data_table_select_all_checkbox.rb +19 -0
- data/app/components/phlex_kit/data_table/data_table_selection_summary.rb +19 -0
- data/app/components/phlex_kit/data_table/data_table_sort_head.rb +82 -0
- data/app/components/phlex_kit/data_table/data_table_toolbar.rb +13 -0
- data/app/components/phlex_kit/date_picker/date_picker.css +28 -0
- data/app/components/phlex_kit/date_picker/date_picker.rb +71 -0
- data/app/components/phlex_kit/dialog/dialog.css +32 -0
- data/app/components/phlex_kit/dialog/dialog.rb +14 -0
- data/app/components/phlex_kit/dialog/dialog_content.rb +21 -0
- data/app/components/phlex_kit/dialog/dialog_description.rb +6 -0
- data/app/components/phlex_kit/dialog/dialog_footer.rb +6 -0
- data/app/components/phlex_kit/dialog/dialog_header.rb +6 -0
- data/app/components/phlex_kit/dialog/dialog_middle.rb +6 -0
- data/app/components/phlex_kit/dialog/dialog_title.rb +6 -0
- data/app/components/phlex_kit/dialog/dialog_trigger.rb +8 -0
- data/app/components/phlex_kit/drawer/drawer.css +54 -0
- data/app/components/phlex_kit/drawer/drawer.rb +18 -0
- data/app/components/phlex_kit/drawer/drawer_close.rb +9 -0
- data/app/components/phlex_kit/drawer/drawer_content.rb +21 -0
- data/app/components/phlex_kit/drawer/drawer_description.rb +7 -0
- data/app/components/phlex_kit/drawer/drawer_footer.rb +7 -0
- data/app/components/phlex_kit/drawer/drawer_header.rb +7 -0
- data/app/components/phlex_kit/drawer/drawer_title.rb +7 -0
- data/app/components/phlex_kit/drawer/drawer_trigger.rb +9 -0
- data/app/components/phlex_kit/dropdown_menu/dropdown_menu.css +38 -0
- data/app/components/phlex_kit/dropdown_menu/dropdown_menu.rb +22 -0
- data/app/components/phlex_kit/dropdown_menu/dropdown_menu_content.rb +23 -0
- data/app/components/phlex_kit/dropdown_menu/dropdown_menu_item.rb +22 -0
- data/app/components/phlex_kit/dropdown_menu/dropdown_menu_label.rb +12 -0
- data/app/components/phlex_kit/dropdown_menu/dropdown_menu_separator.rb +12 -0
- data/app/components/phlex_kit/dropdown_menu/dropdown_menu_trigger.rb +15 -0
- data/app/components/phlex_kit/empty/empty.css +25 -0
- data/app/components/phlex_kit/empty/empty.rb +6 -0
- data/app/components/phlex_kit/empty/empty_content.rb +6 -0
- data/app/components/phlex_kit/empty/empty_description.rb +6 -0
- data/app/components/phlex_kit/empty/empty_header.rb +6 -0
- data/app/components/phlex_kit/empty/empty_media.rb +14 -0
- data/app/components/phlex_kit/empty/empty_title.rb +6 -0
- data/app/components/phlex_kit/form/form.css +15 -0
- data/app/components/phlex_kit/form/form.rb +27 -0
- data/app/components/phlex_kit/form_field/form_field.css +31 -0
- data/app/components/phlex_kit/form_field/form_field.rb +31 -0
- data/app/components/phlex_kit/form_field/form_field_error.rb +19 -0
- data/app/components/phlex_kit/form_field/form_field_hint.rb +13 -0
- data/app/components/phlex_kit/form_field/form_field_label.rb +13 -0
- data/app/components/phlex_kit/hover_card/hover_card.css +8 -0
- data/app/components/phlex_kit/hover_card/hover_card.rb +10 -0
- data/app/components/phlex_kit/hover_card/hover_card_content.rb +8 -0
- data/app/components/phlex_kit/hover_card/hover_card_trigger.rb +6 -0
- data/app/components/phlex_kit/input/input.css +29 -0
- data/app/components/phlex_kit/input/input.rb +34 -0
- data/app/components/phlex_kit/input_group/input_group.css +35 -0
- data/app/components/phlex_kit/input_group/input_group.rb +15 -0
- data/app/components/phlex_kit/input_group/input_group_addon.rb +16 -0
- data/app/components/phlex_kit/input_group/input_group_text.rb +7 -0
- data/app/components/phlex_kit/input_otp/input_otp.css +32 -0
- data/app/components/phlex_kit/input_otp/input_otp.rb +29 -0
- data/app/components/phlex_kit/input_otp/input_otp_group.rb +7 -0
- data/app/components/phlex_kit/input_otp/input_otp_separator.rb +7 -0
- data/app/components/phlex_kit/input_otp/input_otp_slot.rb +27 -0
- data/app/components/phlex_kit/item/item.css +32 -0
- data/app/components/phlex_kit/item/item.rb +18 -0
- data/app/components/phlex_kit/item/item_actions.rb +7 -0
- data/app/components/phlex_kit/item/item_content.rb +7 -0
- data/app/components/phlex_kit/item/item_description.rb +7 -0
- data/app/components/phlex_kit/item/item_group.rb +7 -0
- data/app/components/phlex_kit/item/item_media.rb +7 -0
- data/app/components/phlex_kit/item/item_title.rb +7 -0
- data/app/components/phlex_kit/kbd/kbd.css +17 -0
- data/app/components/phlex_kit/kbd/kbd.rb +14 -0
- data/app/components/phlex_kit/kbd/kbd_group.rb +12 -0
- data/app/components/phlex_kit/label/label.css +12 -0
- data/app/components/phlex_kit/label/label.rb +14 -0
- data/app/components/phlex_kit/link/link.css +6 -0
- data/app/components/phlex_kit/link/link.rb +47 -0
- data/app/components/phlex_kit/masked_input/masked_input.rb +12 -0
- data/app/components/phlex_kit/menubar/menubar.css +66 -0
- data/app/components/phlex_kit/menubar/menubar.rb +24 -0
- data/app/components/phlex_kit/menubar/menubar_content.rb +9 -0
- data/app/components/phlex_kit/menubar/menubar_item.rb +26 -0
- data/app/components/phlex_kit/menubar/menubar_menu.rb +9 -0
- data/app/components/phlex_kit/menubar/menubar_separator.rb +7 -0
- data/app/components/phlex_kit/menubar/menubar_trigger.rb +14 -0
- data/app/components/phlex_kit/message/message.css +20 -0
- data/app/components/phlex_kit/message/message.rb +14 -0
- data/app/components/phlex_kit/message/message_avatar.rb +6 -0
- data/app/components/phlex_kit/message/message_content.rb +6 -0
- data/app/components/phlex_kit/message/message_footer.rb +6 -0
- data/app/components/phlex_kit/message/message_group.rb +6 -0
- data/app/components/phlex_kit/message/message_header.rb +6 -0
- data/app/components/phlex_kit/message_scroller/message_scroller.css +2 -0
- data/app/components/phlex_kit/message_scroller/message_scroller.rb +11 -0
- data/app/components/phlex_kit/native_select/native_select.css +51 -0
- data/app/components/phlex_kit/native_select/native_select.rb +48 -0
- data/app/components/phlex_kit/native_select/native_select_group.rb +13 -0
- data/app/components/phlex_kit/native_select/native_select_icon.rb +32 -0
- data/app/components/phlex_kit/native_select/native_select_option.rb +14 -0
- data/app/components/phlex_kit/navigation_menu/navigation_menu.css +67 -0
- data/app/components/phlex_kit/navigation_menu/navigation_menu.rb +23 -0
- data/app/components/phlex_kit/navigation_menu/navigation_menu_content.rb +9 -0
- data/app/components/phlex_kit/navigation_menu/navigation_menu_item.rb +9 -0
- data/app/components/phlex_kit/navigation_menu/navigation_menu_link.rb +13 -0
- data/app/components/phlex_kit/navigation_menu/navigation_menu_list.rb +7 -0
- data/app/components/phlex_kit/navigation_menu/navigation_menu_trigger.rb +27 -0
- data/app/components/phlex_kit/pagination/pagination.css +5 -0
- data/app/components/phlex_kit/pagination/pagination.rb +10 -0
- data/app/components/phlex_kit/pagination/pagination_content.rb +6 -0
- data/app/components/phlex_kit/pagination/pagination_ellipsis.rb +17 -0
- data/app/components/phlex_kit/pagination/pagination_item.rb +14 -0
- data/app/components/phlex_kit/popover/popover.css +9 -0
- data/app/components/phlex_kit/popover/popover.rb +11 -0
- data/app/components/phlex_kit/popover/popover_content.rb +8 -0
- data/app/components/phlex_kit/popover/popover_trigger.rb +8 -0
- data/app/components/phlex_kit/progress/progress.css +17 -0
- data/app/components/phlex_kit/progress/progress.rb +25 -0
- data/app/components/phlex_kit/radio_button/radio_button.css +9 -0
- data/app/components/phlex_kit/radio_button/radio_button.rb +19 -0
- data/app/components/phlex_kit/radio_group/radio_group.css +3 -0
- data/app/components/phlex_kit/radio_group/radio_group.rb +14 -0
- data/app/components/phlex_kit/resizable/resizable.css +23 -0
- data/app/components/phlex_kit/resizable/resizable_handle.rb +21 -0
- data/app/components/phlex_kit/resizable/resizable_panel.rb +19 -0
- data/app/components/phlex_kit/resizable/resizable_panel_group.rb +26 -0
- data/app/components/phlex_kit/scroll_area/scroll_area.css +21 -0
- data/app/components/phlex_kit/scroll_area/scroll_area.rb +15 -0
- data/app/components/phlex_kit/select/select.css +80 -0
- data/app/components/phlex_kit/select/select.rb +43 -0
- data/app/components/phlex_kit/select/select_content.rb +24 -0
- data/app/components/phlex_kit/select/select_group.rb +13 -0
- data/app/components/phlex_kit/select/select_input.rb +23 -0
- data/app/components/phlex_kit/select/select_item.rb +52 -0
- data/app/components/phlex_kit/select/select_label.rb +13 -0
- data/app/components/phlex_kit/select/select_trigger.rb +42 -0
- data/app/components/phlex_kit/select/select_value.rb +21 -0
- data/app/components/phlex_kit/separator/separator.css +6 -0
- data/app/components/phlex_kit/separator/separator.rb +30 -0
- data/app/components/phlex_kit/sheet/sheet.css +17 -0
- data/app/components/phlex_kit/sheet/sheet.rb +14 -0
- data/app/components/phlex_kit/sheet/sheet_content.rb +25 -0
- data/app/components/phlex_kit/sheet/sheet_description.rb +6 -0
- data/app/components/phlex_kit/sheet/sheet_footer.rb +6 -0
- data/app/components/phlex_kit/sheet/sheet_header.rb +6 -0
- data/app/components/phlex_kit/sheet/sheet_middle.rb +6 -0
- data/app/components/phlex_kit/sheet/sheet_title.rb +6 -0
- data/app/components/phlex_kit/sheet/sheet_trigger.rb +6 -0
- data/app/components/phlex_kit/shortcut_key/shortcut_key.css +17 -0
- data/app/components/phlex_kit/shortcut_key/shortcut_key.rb +9 -0
- data/app/components/phlex_kit/sidebar/sidebar.css +42 -0
- data/app/components/phlex_kit/sidebar/sidebar.rb +19 -0
- data/app/components/phlex_kit/sidebar/sidebar_content.rb +12 -0
- data/app/components/phlex_kit/sidebar/sidebar_footer.rb +12 -0
- data/app/components/phlex_kit/sidebar/sidebar_group.rb +12 -0
- data/app/components/phlex_kit/sidebar/sidebar_header.rb +12 -0
- data/app/components/phlex_kit/sidebar/sidebar_inset.rb +14 -0
- data/app/components/phlex_kit/sidebar/sidebar_menu.rb +12 -0
- data/app/components/phlex_kit/sidebar/sidebar_menu_button.rb +17 -0
- data/app/components/phlex_kit/sidebar/sidebar_menu_item.rb +12 -0
- data/app/components/phlex_kit/sidebar/sidebar_wrapper.rb +13 -0
- data/app/components/phlex_kit/skeleton/skeleton.css +7 -0
- data/app/components/phlex_kit/skeleton/skeleton.rb +9 -0
- data/app/components/phlex_kit/slider/slider.css +52 -0
- data/app/components/phlex_kit/slider/slider.rb +39 -0
- data/app/components/phlex_kit/spinner/spinner.css +5 -0
- data/app/components/phlex_kit/spinner/spinner.rb +27 -0
- data/app/components/phlex_kit/stars/stars.css +4 -0
- data/app/components/phlex_kit/stars/stars.rb +19 -0
- data/app/components/phlex_kit/switch/switch.css +28 -0
- data/app/components/phlex_kit/switch/switch.rb +21 -0
- data/app/components/phlex_kit/table/table.css +24 -0
- data/app/components/phlex_kit/table/table.rb +35 -0
- data/app/components/phlex_kit/table/table_body.rb +12 -0
- data/app/components/phlex_kit/table/table_caption.rb +12 -0
- data/app/components/phlex_kit/table/table_cell.rb +12 -0
- data/app/components/phlex_kit/table/table_footer.rb +12 -0
- data/app/components/phlex_kit/table/table_head.rb +12 -0
- data/app/components/phlex_kit/table/table_header.rb +12 -0
- data/app/components/phlex_kit/table/table_row.rb +12 -0
- data/app/components/phlex_kit/tabs/tabs.css +13 -0
- data/app/components/phlex_kit/tabs/tabs.rb +13 -0
- data/app/components/phlex_kit/tabs/tabs_content.rb +11 -0
- data/app/components/phlex_kit/tabs/tabs_list.rb +6 -0
- data/app/components/phlex_kit/tabs/tabs_trigger.rb +17 -0
- data/app/components/phlex_kit/textarea/textarea.css +27 -0
- data/app/components/phlex_kit/textarea/textarea.rb +24 -0
- data/app/components/phlex_kit/theme_toggle/theme_toggle.rb +15 -0
- data/app/components/phlex_kit/toast/toast.css +163 -0
- data/app/components/phlex_kit/toast/toast.rb +21 -0
- data/app/components/phlex_kit/toast/toast_action.rb +19 -0
- data/app/components/phlex_kit/toast/toast_cancel.rb +18 -0
- data/app/components/phlex_kit/toast/toast_close.rb +35 -0
- data/app/components/phlex_kit/toast/toast_description.rb +13 -0
- data/app/components/phlex_kit/toast/toast_icon.rb +63 -0
- data/app/components/phlex_kit/toast/toast_item.rb +70 -0
- data/app/components/phlex_kit/toast/toast_region.rb +121 -0
- data/app/components/phlex_kit/toast/toast_title.rb +13 -0
- data/app/components/phlex_kit/toggle/toggle.css +16 -0
- data/app/components/phlex_kit/toggle/toggle.rb +59 -0
- data/app/components/phlex_kit/toggle_group/toggle_group.css +10 -0
- data/app/components/phlex_kit/toggle_group/toggle_group.rb +65 -0
- data/app/components/phlex_kit/toggle_group/toggle_group_item.rb +37 -0
- data/app/components/phlex_kit/tooltip/tooltip.css +28 -0
- data/app/components/phlex_kit/tooltip/tooltip.rb +15 -0
- data/app/components/phlex_kit/tooltip/tooltip_content.rb +12 -0
- data/app/components/phlex_kit/tooltip/tooltip_trigger.rb +13 -0
- data/app/components/phlex_kit/typography/blockquote.rb +12 -0
- data/app/components/phlex_kit/typography/heading.rb +38 -0
- data/app/components/phlex_kit/typography/inline_code.rb +13 -0
- data/app/components/phlex_kit/typography/inline_link.rb +15 -0
- data/app/components/phlex_kit/typography/text.rb +48 -0
- data/app/components/phlex_kit/typography/typography.css +50 -0
- data/app/javascript/phlex_kit/controllers/accordion_controller.js +59 -0
- data/app/javascript/phlex_kit/controllers/alert_dialog_controller.js +24 -0
- data/app/javascript/phlex_kit/controllers/avatar_controller.js +30 -0
- data/app/javascript/phlex_kit/controllers/calendar_controller.js +316 -0
- data/app/javascript/phlex_kit/controllers/calendar_input_controller.js +10 -0
- data/app/javascript/phlex_kit/controllers/carousel_controller.js +189 -0
- data/app/javascript/phlex_kit/controllers/chart_controller.js +135 -0
- data/app/javascript/phlex_kit/controllers/clipboard_controller.js +30 -0
- data/app/javascript/phlex_kit/controllers/collapsible_controller.js +14 -0
- data/app/javascript/phlex_kit/controllers/combobox_controller.js +303 -0
- data/app/javascript/phlex_kit/controllers/command_controller.js +161 -0
- data/app/javascript/phlex_kit/controllers/command_dialog_controller.js +37 -0
- data/app/javascript/phlex_kit/controllers/context_menu_controller.js +28 -0
- data/app/javascript/phlex_kit/controllers/data_table_column_visibility_controller.js +18 -0
- data/app/javascript/phlex_kit/controllers/data_table_controller.js +61 -0
- data/app/javascript/phlex_kit/controllers/data_table_search_controller.js +67 -0
- data/app/javascript/phlex_kit/controllers/dialog_controller.js +20 -0
- data/app/javascript/phlex_kit/controllers/dropdown_menu_controller.js +106 -0
- data/app/javascript/phlex_kit/controllers/form_field_controller.js +69 -0
- data/app/javascript/phlex_kit/controllers/hover_card_controller.js +11 -0
- data/app/javascript/phlex_kit/controllers/index.js +87 -0
- data/app/javascript/phlex_kit/controllers/input_otp_controller.js +66 -0
- data/app/javascript/phlex_kit/controllers/masked_input_controller.js +26 -0
- data/app/javascript/phlex_kit/controllers/menubar_controller.js +43 -0
- data/app/javascript/phlex_kit/controllers/message_scroller_controller.js +335 -0
- data/app/javascript/phlex_kit/controllers/popover_controller.js +12 -0
- data/app/javascript/phlex_kit/controllers/resizable_controller.js +42 -0
- data/app/javascript/phlex_kit/controllers/select_controller.js +141 -0
- data/app/javascript/phlex_kit/controllers/select_item_controller.js +14 -0
- data/app/javascript/phlex_kit/controllers/sheet_content_controller.js +6 -0
- data/app/javascript/phlex_kit/controllers/sheet_controller.js +10 -0
- data/app/javascript/phlex_kit/controllers/slider_controller.js +19 -0
- data/app/javascript/phlex_kit/controllers/tabs_controller.js +28 -0
- data/app/javascript/phlex_kit/controllers/theme_toggle_controller.js +22 -0
- data/app/javascript/phlex_kit/controllers/toast_controller.js +153 -0
- data/app/javascript/phlex_kit/controllers/toaster_controller.js +321 -0
- data/app/javascript/phlex_kit/controllers/toggle_controller.js +25 -0
- data/app/javascript/phlex_kit/controllers/toggle_group_controller.js +91 -0
- data/config/importmap.rb +7 -0
- data/lib/generators/phlex_kit/component/component_generator.rb +41 -0
- data/lib/generators/phlex_kit/install/install_generator.rb +51 -0
- data/lib/generators/phlex_kit/install/templates/phlex_kit.rb +11 -0
- data/lib/phlex_kit/base_component.rb +22 -0
- data/lib/phlex_kit/configuration.rb +46 -0
- data/lib/phlex_kit/engine.rb +50 -0
- data/lib/phlex_kit/propshaft_skip_source.rb +22 -0
- data/lib/phlex_kit/version.rb +5 -0
- data/lib/phlex_kit.rb +21 -0
- metadata +545 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Connects to data-controller="phlex-kit--clipboard". Copies the source text and
|
|
4
|
+
// flashes a success/error popover (CSS-positioned, no @floating-ui). Ported from ruby_ui.
|
|
5
|
+
export default class extends Controller {
|
|
6
|
+
static targets = ["trigger", "source", "successPopover", "errorPopover"]
|
|
7
|
+
|
|
8
|
+
copy() {
|
|
9
|
+
const el = this.sourceTarget.children[0]
|
|
10
|
+
if (!el) { this.show(this.errorPopoverTarget); return }
|
|
11
|
+
const text = el.tagName === "INPUT" ? el.value : el.innerText
|
|
12
|
+
navigator.clipboard.writeText(text)
|
|
13
|
+
.then(() => this.show(this.successPopoverTarget))
|
|
14
|
+
.catch(() => this.show(this.errorPopoverTarget))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
onClickOutside(e) { if (!this.element.contains(e.target)) this.hideAll() }
|
|
18
|
+
|
|
19
|
+
show(target) {
|
|
20
|
+
this.hideAll()
|
|
21
|
+
target.classList.remove("pk-hidden")
|
|
22
|
+
clearTimeout(this.timer)
|
|
23
|
+
this.timer = setTimeout(() => target.classList.add("pk-hidden"), 1500)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
hideAll() {
|
|
27
|
+
this.successPopoverTarget.classList.add("pk-hidden")
|
|
28
|
+
this.errorPopoverTarget.classList.add("pk-hidden")
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Connects to data-controller="phlex-kit--collapsible"
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
static targets = ["content"]
|
|
6
|
+
static values = { open: { type: Boolean, default: false } }
|
|
7
|
+
|
|
8
|
+
connect() { this.openValue ? this.open() : this.close() }
|
|
9
|
+
toggle() { this.openValue = !this.openValue }
|
|
10
|
+
openValueChanged(isOpen) { isOpen ? this.open() : this.close() }
|
|
11
|
+
|
|
12
|
+
open() { if (this.hasContentTarget) { this.contentTarget.classList.remove("pk-hidden"); this.openValue = true } }
|
|
13
|
+
close() { if (this.hasContentTarget) { this.contentTarget.classList.add("pk-hidden"); this.openValue = false } }
|
|
14
|
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
// Ported from ruby_ui's combobox controller. TWO changes from upstream: the
|
|
4
|
+
// @floating-ui/dom dependency and the native Popover API are removed — the panel
|
|
5
|
+
// is a CSS-positioned child of the combobox (.pk-combobox-popover, toggled with
|
|
6
|
+
// .pk-hidden) with click-outside handled by a window action, so only
|
|
7
|
+
// @hotwired/stimulus is needed. PhlexKit also COMPLETES upstream's unfinished
|
|
8
|
+
// input/badge trigger variants: the inputTrigger / badgeContainer / badgeInput /
|
|
9
|
+
// clearButton targets, filtering from whichever field fired, chip rendering
|
|
10
|
+
// with per-chip remove, backspace removal, and clearAll all had no upstream
|
|
11
|
+
// implementation. Core behaviour (trigger label, filtering, keyboard nav,
|
|
12
|
+
// toggle-all) is unchanged.
|
|
13
|
+
// Connects to data-controller="phlex-kit--combobox"
|
|
14
|
+
export default class extends Controller {
|
|
15
|
+
static values = {
|
|
16
|
+
term: String,
|
|
17
|
+
minPopoverWidth: { type: Number, default: 240 }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static targets = [
|
|
21
|
+
"input",
|
|
22
|
+
"toggleAll",
|
|
23
|
+
"popover",
|
|
24
|
+
"item",
|
|
25
|
+
"emptyState",
|
|
26
|
+
"searchInput",
|
|
27
|
+
"trigger",
|
|
28
|
+
"triggerContent",
|
|
29
|
+
"inputTrigger",
|
|
30
|
+
"badgeContainer",
|
|
31
|
+
"badgeInput",
|
|
32
|
+
"clearButton"
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
selectedItemIndex = null
|
|
36
|
+
|
|
37
|
+
connect() {
|
|
38
|
+
this.updateTriggerContent()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
inputChanged(e) {
|
|
42
|
+
this.updateTriggerContent()
|
|
43
|
+
|
|
44
|
+
if (e.target.type == "radio") {
|
|
45
|
+
this.closePopover()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (this.hasToggleAllTarget && !e.target.checked) {
|
|
49
|
+
this.toggleAllTarget.checked = false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Selecting from a chip trigger consumes the query: clear it and reshow
|
|
53
|
+
// the full list for the next pick.
|
|
54
|
+
if (this.hasBadgeInputTarget && this.badgeInputTarget.value !== "") {
|
|
55
|
+
this.badgeInputTarget.value = ""
|
|
56
|
+
this.applyFilter("")
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
inputContent(input) {
|
|
61
|
+
return (input.dataset.text || input.parentElement.textContent).trim()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
checkedInputs() {
|
|
65
|
+
return this.inputTargets.filter(input => input.checked)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
selectionLabel(checkedInputs) {
|
|
69
|
+
if (checkedInputs.length === 0) return ""
|
|
70
|
+
if (this.termValue && checkedInputs.length > 1) return `${checkedInputs.length} ${this.termValue}`
|
|
71
|
+
return checkedInputs.map((input) => this.inputContent(input)).join(", ")
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
toggleAllItems() {
|
|
75
|
+
const isChecked = this.toggleAllTarget.checked
|
|
76
|
+
this.inputTargets.forEach(input => input.checked = isChecked)
|
|
77
|
+
this.updateTriggerContent()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
updateTriggerContent() {
|
|
81
|
+
const checked = this.checkedInputs()
|
|
82
|
+
|
|
83
|
+
if (this.hasTriggerContentTarget) {
|
|
84
|
+
this.triggerContentTarget.innerText = this.selectionLabel(checked) || this.triggerTarget.dataset.placeholder
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Input trigger: the field is also the filter, so only reflect the
|
|
88
|
+
// selection while the popover is closed — never stomp a query mid-typing.
|
|
89
|
+
if (this.hasInputTriggerTarget && this.triggerTarget.ariaExpanded !== "true") {
|
|
90
|
+
this.inputTriggerTarget.value = this.selectionLabel(checked)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.hasBadgeContainerTarget) {
|
|
94
|
+
this.renderBadges(checked)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (this.hasClearButtonTarget) {
|
|
98
|
+
this.clearButtonTarget.classList.toggle("pk-hidden", checked.length === 0)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
renderBadges(checked) {
|
|
103
|
+
this.badgeContainerTarget.replaceChildren(...checked.map((input) => this.buildBadge(input)))
|
|
104
|
+
this.badgeContainerTarget.classList.toggle("pk-hidden", checked.length === 0)
|
|
105
|
+
this.triggerTarget.classList.toggle("has-badges", checked.length > 0)
|
|
106
|
+
if (this.hasBadgeInputTarget) {
|
|
107
|
+
this.badgeInputTarget.placeholder = checked.length === 0 ? (this.triggerTarget.dataset.placeholder || "") : ""
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
buildBadge(input) {
|
|
112
|
+
const text = this.inputContent(input)
|
|
113
|
+
const badge = document.createElement("span")
|
|
114
|
+
badge.className = "pk-combobox-badge"
|
|
115
|
+
badge.append(text)
|
|
116
|
+
|
|
117
|
+
const remove = document.createElement("button")
|
|
118
|
+
remove.type = "button"
|
|
119
|
+
remove.className = "pk-combobox-badge-remove"
|
|
120
|
+
remove.setAttribute("aria-label", `Remove ${text}`)
|
|
121
|
+
remove.textContent = "×"
|
|
122
|
+
remove.addEventListener("click", (e) => {
|
|
123
|
+
e.stopPropagation() // don't reopen the popover via the trigger's click action
|
|
124
|
+
this.uncheck(input)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
badge.append(remove)
|
|
128
|
+
return badge
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
uncheck(input) {
|
|
132
|
+
input.checked = false
|
|
133
|
+
input.dispatchEvent(new Event("change", { bubbles: true })) // form-field & host listeners
|
|
134
|
+
this.updateTriggerContent()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
handleBadgeInputBackspace(e) {
|
|
138
|
+
if (this.badgeInputTarget.value !== "") return
|
|
139
|
+
|
|
140
|
+
const checked = this.checkedInputs()
|
|
141
|
+
const last = checked[checked.length - 1]
|
|
142
|
+
if (!last) return
|
|
143
|
+
|
|
144
|
+
e.preventDefault()
|
|
145
|
+
this.uncheck(last)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
clearAll(e) {
|
|
149
|
+
if (e) {
|
|
150
|
+
e.preventDefault()
|
|
151
|
+
e.stopPropagation() // the button sits inside the trigger's click-to-open area
|
|
152
|
+
}
|
|
153
|
+
this.inputTargets.forEach(input => input.checked = false)
|
|
154
|
+
if (this.hasToggleAllTarget) this.toggleAllTarget.checked = false
|
|
155
|
+
this.updateTriggerContent()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
togglePopover(event) {
|
|
159
|
+
event.preventDefault()
|
|
160
|
+
|
|
161
|
+
if (this.triggerTarget.ariaExpanded === "true") {
|
|
162
|
+
this.closePopover()
|
|
163
|
+
} else {
|
|
164
|
+
this.openPopover(event)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
openPopover(event) {
|
|
169
|
+
if (event) event.preventDefault()
|
|
170
|
+
if (this.triggerTarget.ariaExpanded === "true") return
|
|
171
|
+
|
|
172
|
+
this.updatePopoverWidth()
|
|
173
|
+
this.triggerTarget.ariaExpanded = "true"
|
|
174
|
+
this.selectedItemIndex = null
|
|
175
|
+
this.itemTargets.forEach(item => item.ariaCurrent = "false")
|
|
176
|
+
this.popoverTarget.classList.remove("pk-hidden")
|
|
177
|
+
|
|
178
|
+
const field = this.filterField()
|
|
179
|
+
if (field) {
|
|
180
|
+
field.focus()
|
|
181
|
+
// In the input trigger the field holds the last selection — select it so
|
|
182
|
+
// typing starts a fresh query.
|
|
183
|
+
if (field === (this.hasInputTriggerTarget ? this.inputTriggerTarget : null)) field.select()
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
closePopover() {
|
|
188
|
+
this.triggerTarget.ariaExpanded = "false"
|
|
189
|
+
this.popoverTarget.classList.add("pk-hidden")
|
|
190
|
+
this.updateTriggerContent() // reflect the selection into an input trigger
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
onClickOutside(event) {
|
|
194
|
+
if (this.triggerTarget.ariaExpanded !== "true") return
|
|
195
|
+
if (this.element.contains(event.target)) return
|
|
196
|
+
|
|
197
|
+
this.closePopover()
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Whichever filter field this layout has: popover search, input trigger, or
|
|
201
|
+
// badge trigger field.
|
|
202
|
+
filterField() {
|
|
203
|
+
if (this.hasSearchInputTarget) return this.searchInputTarget
|
|
204
|
+
if (this.hasInputTriggerTarget) return this.inputTriggerTarget
|
|
205
|
+
if (this.hasBadgeInputTarget) return this.badgeInputTarget
|
|
206
|
+
return null
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
filterItems(e) {
|
|
210
|
+
if (["ArrowDown", "ArrowUp", "Tab", "Enter"].includes(e.key)) {
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const field = (e.target instanceof HTMLInputElement) ? e.target : this.filterField()
|
|
215
|
+
if (!field) return
|
|
216
|
+
|
|
217
|
+
this.applyFilter(field.value.toLowerCase())
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
applyFilter(filterTerm) {
|
|
221
|
+
if (this.hasToggleAllTarget) {
|
|
222
|
+
if (filterTerm) this.toggleAllTarget.parentElement.classList.add("pk-hidden")
|
|
223
|
+
else this.toggleAllTarget.parentElement.classList.remove("pk-hidden")
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let resultCount = 0
|
|
227
|
+
|
|
228
|
+
this.selectedItemIndex = null
|
|
229
|
+
|
|
230
|
+
this.inputTargets.forEach((input) => {
|
|
231
|
+
const text = this.inputContent(input).toLowerCase()
|
|
232
|
+
|
|
233
|
+
if (text.indexOf(filterTerm) > -1) {
|
|
234
|
+
input.parentElement.classList.remove("pk-hidden")
|
|
235
|
+
resultCount++
|
|
236
|
+
} else {
|
|
237
|
+
input.parentElement.classList.add("pk-hidden")
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
if (this.hasEmptyStateTarget) {
|
|
242
|
+
this.emptyStateTarget.classList.toggle("pk-hidden", resultCount !== 0)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
keyDownPressed(e) {
|
|
247
|
+
if (e) e.preventDefault()
|
|
248
|
+
|
|
249
|
+
if (this.selectedItemIndex !== null) {
|
|
250
|
+
this.selectedItemIndex++
|
|
251
|
+
} else {
|
|
252
|
+
this.selectedItemIndex = 0
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
this.focusSelectedInput()
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
keyUpPressed(e) {
|
|
259
|
+
if (e) e.preventDefault()
|
|
260
|
+
|
|
261
|
+
if (this.selectedItemIndex !== null) {
|
|
262
|
+
this.selectedItemIndex--
|
|
263
|
+
} else {
|
|
264
|
+
this.selectedItemIndex = -1
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
this.focusSelectedInput()
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
focusSelectedInput() {
|
|
271
|
+
const visibleInputs = this.inputTargets.filter(input => !input.parentElement.classList.contains("pk-hidden"))
|
|
272
|
+
if (visibleInputs.length === 0) return
|
|
273
|
+
|
|
274
|
+
this.wrapSelectedInputIndex(visibleInputs.length)
|
|
275
|
+
|
|
276
|
+
visibleInputs.forEach((input, index) => {
|
|
277
|
+
if (index == this.selectedItemIndex) {
|
|
278
|
+
input.parentElement.ariaCurrent = "true"
|
|
279
|
+
input.parentElement.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' })
|
|
280
|
+
} else {
|
|
281
|
+
input.parentElement.ariaCurrent = "false"
|
|
282
|
+
}
|
|
283
|
+
})
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
keyEnterPressed(event) {
|
|
287
|
+
event.preventDefault()
|
|
288
|
+
const option = this.itemTargets.find(item => item.ariaCurrent === "true")
|
|
289
|
+
|
|
290
|
+
if (option) {
|
|
291
|
+
option.click()
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
wrapSelectedInputIndex(length) {
|
|
296
|
+
this.selectedItemIndex = ((this.selectedItemIndex % length) + length) % length
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
updatePopoverWidth() {
|
|
300
|
+
const width = Math.max(this.triggerTarget.offsetWidth, this.minPopoverWidthValue)
|
|
301
|
+
this.popoverTarget.style.width = `${width}px`
|
|
302
|
+
}
|
|
303
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
// Fuzzy subsequence score: every query character must appear in order in the
|
|
4
|
+
// value (else null = no match). Consecutive runs compound, word-starts score
|
|
5
|
+
// extra, and a verbatim substring outranks scattered hits — so "set" beats
|
|
6
|
+
// "*s*al*e*s repor*t*" with "settings" on top. Dependency-free stand-in for
|
|
7
|
+
// what fuse.js gave ruby_ui.
|
|
8
|
+
function fuzzyScore(query, value) {
|
|
9
|
+
if (!query) return 0;
|
|
10
|
+
let qi = 0;
|
|
11
|
+
let score = 0;
|
|
12
|
+
let streak = 0;
|
|
13
|
+
for (let vi = 0; vi < value.length && qi < query.length; vi++) {
|
|
14
|
+
if (value[vi] === query[qi]) {
|
|
15
|
+
streak++;
|
|
16
|
+
score += streak;
|
|
17
|
+
if (vi === 0 || /[\s\-_./]/.test(value[vi - 1])) score += 2;
|
|
18
|
+
qi++;
|
|
19
|
+
} else {
|
|
20
|
+
streak = 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (qi < query.length) return null;
|
|
24
|
+
if (value.includes(query)) score += query.length * 2;
|
|
25
|
+
return score;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Ported from ruby_ui's command controller. TWO changes from upstream: the
|
|
29
|
+
// fuse.js dependency is replaced with the dependency-free fuzzy matcher above
|
|
30
|
+
// (same search() shape, results sorted best-first), and show/hide + body
|
|
31
|
+
// scroll-lock use .pk-hidden / inline overflow (matching the shipped dialog)
|
|
32
|
+
// instead of Tailwind utility classes. Everything else (filtering, keyboard
|
|
33
|
+
// nav, dismiss) is unchanged.
|
|
34
|
+
// Connects to data-controller="phlex-kit--command"
|
|
35
|
+
export default class extends Controller {
|
|
36
|
+
static targets = ["input", "group", "item", "empty"];
|
|
37
|
+
|
|
38
|
+
connect() {
|
|
39
|
+
this.selectedIndex = -1;
|
|
40
|
+
|
|
41
|
+
if (!this.hasInputTarget) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.inputTarget.focus();
|
|
46
|
+
this.searchIndex = this.buildSearchIndex();
|
|
47
|
+
this.toggleVisibility(this.emptyTargets, false);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
dismiss() {
|
|
51
|
+
// allow scroll on body
|
|
52
|
+
document.body.style.removeProperty("overflow");
|
|
53
|
+
// remove the element
|
|
54
|
+
this.element.remove();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
focusInput() {
|
|
58
|
+
this.inputTarget?.focus();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
filter(e) {
|
|
62
|
+
// Deselect any previously selected item
|
|
63
|
+
this.deselectAll();
|
|
64
|
+
|
|
65
|
+
const query = e.target.value.toLowerCase();
|
|
66
|
+
if (query.length === 0) {
|
|
67
|
+
this.resetVisibility();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.toggleVisibility(this.itemTargets, false);
|
|
72
|
+
|
|
73
|
+
const results = this.searchIndex.search(query);
|
|
74
|
+
results.forEach((result) =>
|
|
75
|
+
this.toggleVisibility([result.item.element], true),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
this.toggleVisibility(this.emptyTargets, results.length === 0);
|
|
79
|
+
this.updateGroupVisibility();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
toggleVisibility(elements, isVisible) {
|
|
83
|
+
elements.forEach((el) => el.classList.toggle("pk-hidden", !isVisible));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
updateGroupVisibility() {
|
|
87
|
+
this.groupTargets.forEach((group) => {
|
|
88
|
+
const hasVisibleItems =
|
|
89
|
+
group.querySelectorAll(
|
|
90
|
+
"[data-phlex-kit--command-target='item']:not(.pk-hidden)",
|
|
91
|
+
).length > 0;
|
|
92
|
+
this.toggleVisibility([group], hasVisibleItems);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
resetVisibility() {
|
|
97
|
+
this.toggleVisibility(this.itemTargets, true);
|
|
98
|
+
this.toggleVisibility(this.groupTargets, true);
|
|
99
|
+
this.toggleVisibility(this.emptyTargets, false);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Upstream builds a Fuse index here; this keeps the same search() shape —
|
|
103
|
+
// [{ item }] sorted best-match-first — using the fuzzy scorer above.
|
|
104
|
+
buildSearchIndex() {
|
|
105
|
+
const items = this.itemTargets.map((el) => ({
|
|
106
|
+
value: (el.dataset.value || "").toLowerCase(),
|
|
107
|
+
element: el,
|
|
108
|
+
}));
|
|
109
|
+
return {
|
|
110
|
+
search(query) {
|
|
111
|
+
const q = query.toLowerCase();
|
|
112
|
+
return items
|
|
113
|
+
.map((item) => ({ item, score: fuzzyScore(q, item.value) }))
|
|
114
|
+
.filter((result) => result.score !== null)
|
|
115
|
+
.sort((a, b) => b.score - a.score);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
handleKeydown(e) {
|
|
121
|
+
const visibleItems = this.itemTargets.filter(
|
|
122
|
+
(item) => !item.classList.contains("pk-hidden"),
|
|
123
|
+
);
|
|
124
|
+
if (e.key === "ArrowDown") {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
this.updateSelectedItem(visibleItems, 1);
|
|
127
|
+
} else if (e.key === "ArrowUp") {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
this.updateSelectedItem(visibleItems, -1);
|
|
130
|
+
} else if (e.key === "Enter" && this.selectedIndex !== -1) {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
visibleItems[this.selectedIndex].click();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
updateSelectedItem(visibleItems, direction) {
|
|
137
|
+
if (this.selectedIndex >= 0) {
|
|
138
|
+
this.toggleAriaSelected(visibleItems[this.selectedIndex], false);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.selectedIndex += direction;
|
|
142
|
+
|
|
143
|
+
// Ensure the selected index is within the bounds of the visible items
|
|
144
|
+
if (this.selectedIndex < 0) {
|
|
145
|
+
this.selectedIndex = visibleItems.length - 1;
|
|
146
|
+
} else if (this.selectedIndex >= visibleItems.length) {
|
|
147
|
+
this.selectedIndex = 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
this.toggleAriaSelected(visibleItems[this.selectedIndex], true);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
toggleAriaSelected(element, isSelected) {
|
|
154
|
+
element.setAttribute("aria-selected", isSelected.toString());
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
deselectAll() {
|
|
158
|
+
this.itemTargets.forEach((item) => this.toggleAriaSelected(item, false));
|
|
159
|
+
this.selectedIndex = -1;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
// Ported from ruby_ui's command-dialog controller (Stimulus-only upstream),
|
|
4
|
+
// identifiers renamed ruby-ui → phlex-kit and the Tailwind body scroll-lock
|
|
5
|
+
// class swapped for inline overflow (matching the shipped dialog).
|
|
6
|
+
// Connects to data-controller="phlex-kit--command-dialog"
|
|
7
|
+
export default class extends Controller {
|
|
8
|
+
static targets = ["content"];
|
|
9
|
+
static outlets = ["phlex-kit--command"];
|
|
10
|
+
|
|
11
|
+
phlexKitCommandOutletConnected(controller) {
|
|
12
|
+
this.openOutlet = controller;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
phlexKitCommandOutletDisconnected() {
|
|
16
|
+
this.openOutlet = null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
open(e) {
|
|
20
|
+
if (e) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!this.hasContentTarget) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (this.openOutlet) {
|
|
29
|
+
this.openOutlet.focusInput();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
document.body.insertAdjacentHTML("beforeend", this.contentTarget.innerHTML);
|
|
34
|
+
// prevent scroll on body
|
|
35
|
+
document.body.style.overflow = "hidden";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Connects to data-controller="phlex-kit--context-menu". Opens at the cursor on
|
|
4
|
+
// contextmenu; closes on outside click or Escape. CSS positioning (no floating-ui).
|
|
5
|
+
export default class extends Controller {
|
|
6
|
+
static targets = ["content"]
|
|
7
|
+
connect() {
|
|
8
|
+
this.onDoc = (e) => { if (!this.contentTarget.contains(e.target)) this.close() }
|
|
9
|
+
this.onKey = (e) => { if (e.key === "Escape") this.close() }
|
|
10
|
+
}
|
|
11
|
+
disconnect() { document.removeEventListener("click", this.onDoc); document.removeEventListener("keydown", this.onKey) }
|
|
12
|
+
open(e) {
|
|
13
|
+
e.preventDefault()
|
|
14
|
+
const r = this.element.getBoundingClientRect()
|
|
15
|
+
this.contentTarget.style.left = `${e.clientX - r.left}px`
|
|
16
|
+
this.contentTarget.style.top = `${e.clientY - r.top}px`
|
|
17
|
+
this.contentTarget.classList.remove("pk-hidden")
|
|
18
|
+
this.contentTarget.dataset.state = "open"
|
|
19
|
+
document.addEventListener("click", this.onDoc)
|
|
20
|
+
document.addEventListener("keydown", this.onKey)
|
|
21
|
+
}
|
|
22
|
+
close() {
|
|
23
|
+
this.contentTarget.classList.add("pk-hidden")
|
|
24
|
+
this.contentTarget.dataset.state = "closed"
|
|
25
|
+
document.removeEventListener("click", this.onDoc)
|
|
26
|
+
document.removeEventListener("keydown", this.onKey)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
// Ported from ruby_ui's data-table-column-visibility controller (Stimulus-only
|
|
4
|
+
// upstream), identifiers renamed ruby-ui → phlex-kit and the Tailwind hidden
|
|
5
|
+
// class swapped for .pk-hidden. Toggles every cell carrying a matching
|
|
6
|
+
// data-column attribute inside the enclosing data table.
|
|
7
|
+
// Connects to data-controller="phlex-kit--data-table-column-visibility"
|
|
8
|
+
export default class extends Controller {
|
|
9
|
+
toggle(event) {
|
|
10
|
+
const key = event.target.dataset.columnKey;
|
|
11
|
+
const visible = event.target.checked;
|
|
12
|
+
const root = this.element.closest('[data-controller~="phlex-kit--data-table"]');
|
|
13
|
+
if (!root) return;
|
|
14
|
+
root
|
|
15
|
+
.querySelectorAll(`[data-column="${key}"]`)
|
|
16
|
+
.forEach((el) => el.classList.toggle("pk-hidden", !visible));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
// Ported from ruby_ui's data-table controller (Stimulus-only upstream),
|
|
4
|
+
// identifiers renamed ruby-ui → phlex-kit and the Tailwind hidden class swapped
|
|
5
|
+
// for the kit's .pk-hidden. Row selection, select-all indeterminate state,
|
|
6
|
+
// bulk-action visibility and row-detail expansion.
|
|
7
|
+
// Connects to data-controller="phlex-kit--data-table"
|
|
8
|
+
export default class extends Controller {
|
|
9
|
+
static targets = [
|
|
10
|
+
"selectAll",
|
|
11
|
+
"rowCheckbox",
|
|
12
|
+
"selectionSummary",
|
|
13
|
+
"selectionBar",
|
|
14
|
+
"bulkActions",
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
connect() {
|
|
18
|
+
this.updateState();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
toggleAll(event) {
|
|
22
|
+
const checked = event.target.checked;
|
|
23
|
+
this.rowCheckboxTargets.forEach((cb) => {
|
|
24
|
+
cb.checked = checked;
|
|
25
|
+
});
|
|
26
|
+
this.updateState();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
toggleRow() {
|
|
30
|
+
this.updateState();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
toggleRowDetail(event) {
|
|
34
|
+
const button = event.currentTarget;
|
|
35
|
+
const id = button.getAttribute("aria-controls");
|
|
36
|
+
if (!id) return;
|
|
37
|
+
const target = document.getElementById(id);
|
|
38
|
+
if (!target) return;
|
|
39
|
+
const expanded = button.getAttribute("aria-expanded") === "true";
|
|
40
|
+
button.setAttribute("aria-expanded", String(!expanded));
|
|
41
|
+
target.classList.toggle("pk-hidden", expanded);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
updateState() {
|
|
45
|
+
const total = this.rowCheckboxTargets.length;
|
|
46
|
+
const selected = this.rowCheckboxTargets.filter((cb) => cb.checked).length;
|
|
47
|
+
|
|
48
|
+
if (this.hasSelectAllTarget) {
|
|
49
|
+
this.selectAllTarget.checked = total > 0 && selected === total;
|
|
50
|
+
this.selectAllTarget.indeterminate = selected > 0 && selected < total;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (this.hasSelectionSummaryTarget) {
|
|
54
|
+
this.selectionSummaryTarget.textContent = `${selected} of ${total} row(s) selected.`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (this.hasBulkActionsTarget) {
|
|
58
|
+
this.bulkActionsTarget.classList.toggle("pk-hidden", selected === 0);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|