shadcn-rails 0.1.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/.dockerignore +40 -0
- data/CHANGELOG.md +54 -0
- data/CLAUDE.md +463 -0
- data/PROGRESS.md +485 -0
- data/README.md +1483 -0
- data/Rakefile +29 -0
- data/__tests__/controllers/__snapshots__/calendar_controller.test.js.snap +13 -0
- data/__tests__/controllers/__snapshots__/popover_controller.test.js.snap +46 -0
- data/__tests__/controllers/__snapshots__/sheet_controller.test.js.snap +111 -0
- data/__tests__/controllers/__snapshots__/tabs_controller.test.js.snap +27 -0
- data/__tests__/controllers/accordion_controller.test.js +904 -0
- data/__tests__/controllers/calendar_controller.test.js +1370 -0
- data/__tests__/controllers/carousel_controller.test.js +912 -0
- data/__tests__/controllers/checkbox_controller.test.js +454 -0
- data/__tests__/controllers/collapsible_controller.test.js +407 -0
- data/__tests__/controllers/combobox_controller.test.js +966 -0
- data/__tests__/controllers/context_menu_controller.test.js +627 -0
- data/__tests__/controllers/date_picker_controller.test.js +636 -0
- data/__tests__/controllers/dialog_controller.test.js +878 -0
- data/__tests__/controllers/drawer_controller.test.js +995 -0
- data/__tests__/controllers/menubar_controller.test.js +736 -0
- data/__tests__/controllers/navigation_menu_controller.test.js +598 -0
- data/__tests__/controllers/popover_controller.test.js +1007 -0
- data/__tests__/controllers/radio_group_controller.test.js +640 -0
- data/__tests__/controllers/resizable_controller.test.js +680 -0
- data/__tests__/controllers/select_controller.test.js +674 -0
- data/__tests__/controllers/sheet_controller.test.js +986 -0
- data/__tests__/controllers/slider_controller.test.js +1036 -0
- data/__tests__/controllers/switch_controller.test.js +424 -0
- data/__tests__/controllers/tabs_controller.test.js +907 -0
- data/__tests__/controllers/toggle_group_controller.test.js +839 -0
- data/__tests__/controllers/tooltip_controller.test.js +808 -0
- data/__tests__/helpers/stimulus-test-helper.js +203 -0
- data/app/assets/config/manifest.js +1 -0
- data/app/assets/javascripts/shadcn/controllers/accordion_controller.d.ts +53 -0
- data/app/assets/javascripts/shadcn/controllers/accordion_controller.js +140 -0
- data/app/assets/javascripts/shadcn/controllers/avatar_controller.d.ts +22 -0
- data/app/assets/javascripts/shadcn/controllers/avatar_controller.js +26 -0
- data/app/assets/javascripts/shadcn/controllers/calendar_controller.js +592 -0
- data/app/assets/javascripts/shadcn/controllers/carousel_controller.js +263 -0
- data/app/assets/javascripts/shadcn/controllers/checkbox_controller.d.ts +31 -0
- data/app/assets/javascripts/shadcn/controllers/checkbox_controller.js +48 -0
- data/app/assets/javascripts/shadcn/controllers/collapsible_controller.d.ts +43 -0
- data/app/assets/javascripts/shadcn/controllers/collapsible_controller.js +73 -0
- data/app/assets/javascripts/shadcn/controllers/combobox_controller.js +234 -0
- data/app/assets/javascripts/shadcn/controllers/command_controller.js +141 -0
- data/app/assets/javascripts/shadcn/controllers/command_dialog_controller.js +162 -0
- data/app/assets/javascripts/shadcn/controllers/context_menu_controller.js +202 -0
- data/app/assets/javascripts/shadcn/controllers/date_picker_controller.js +282 -0
- data/app/assets/javascripts/shadcn/controllers/dialog_controller.d.ts +67 -0
- data/app/assets/javascripts/shadcn/controllers/dialog_controller.js +187 -0
- data/app/assets/javascripts/shadcn/controllers/drawer_controller.d.ts +58 -0
- data/app/assets/javascripts/shadcn/controllers/drawer_controller.js +112 -0
- data/app/assets/javascripts/shadcn/controllers/dropdown_controller.d.ts +83 -0
- data/app/assets/javascripts/shadcn/controllers/dropdown_controller.js +225 -0
- data/app/assets/javascripts/shadcn/controllers/hover_card_controller.d.ts +59 -0
- data/app/assets/javascripts/shadcn/controllers/hover_card_controller.js +143 -0
- data/app/assets/javascripts/shadcn/controllers/input_otp_controller.d.ts +44 -0
- data/app/assets/javascripts/shadcn/controllers/input_otp_controller.js +206 -0
- data/app/assets/javascripts/shadcn/controllers/menubar_controller.js +323 -0
- data/app/assets/javascripts/shadcn/controllers/navigation_menu_controller.js +251 -0
- data/app/assets/javascripts/shadcn/controllers/popover_controller.d.ts +56 -0
- data/app/assets/javascripts/shadcn/controllers/popover_controller.js +141 -0
- data/app/assets/javascripts/shadcn/controllers/radio_group_controller.d.ts +47 -0
- data/app/assets/javascripts/shadcn/controllers/radio_group_controller.js +108 -0
- data/app/assets/javascripts/shadcn/controllers/resizable_controller.js +272 -0
- data/app/assets/javascripts/shadcn/controllers/scroll_area_controller.d.ts +44 -0
- data/app/assets/javascripts/shadcn/controllers/scroll_area_controller.js +74 -0
- data/app/assets/javascripts/shadcn/controllers/select_controller.d.ts +84 -0
- data/app/assets/javascripts/shadcn/controllers/select_controller.js +222 -0
- data/app/assets/javascripts/shadcn/controllers/sheet_controller.d.ts +60 -0
- data/app/assets/javascripts/shadcn/controllers/sheet_controller.js +151 -0
- data/app/assets/javascripts/shadcn/controllers/sidebar_controller.js +148 -0
- data/app/assets/javascripts/shadcn/controllers/slider_controller.d.ts +102 -0
- data/app/assets/javascripts/shadcn/controllers/slider_controller.js +364 -0
- data/app/assets/javascripts/shadcn/controllers/switch_controller.d.ts +46 -0
- data/app/assets/javascripts/shadcn/controllers/switch_controller.js +78 -0
- data/app/assets/javascripts/shadcn/controllers/tabs_controller.d.ts +51 -0
- data/app/assets/javascripts/shadcn/controllers/tabs_controller.js +126 -0
- data/app/assets/javascripts/shadcn/controllers/toast_controller.d.ts +37 -0
- data/app/assets/javascripts/shadcn/controllers/toast_controller.js +58 -0
- data/app/assets/javascripts/shadcn/controllers/toggle_controller.d.ts +27 -0
- data/app/assets/javascripts/shadcn/controllers/toggle_controller.js +42 -0
- data/app/assets/javascripts/shadcn/controllers/toggle_group_controller.d.ts +44 -0
- data/app/assets/javascripts/shadcn/controllers/toggle_group_controller.js +68 -0
- data/app/assets/javascripts/shadcn/controllers/tooltip_controller.d.ts +56 -0
- data/app/assets/javascripts/shadcn/controllers/tooltip_controller.js +117 -0
- data/app/assets/javascripts/shadcn/index.d.ts +74 -0
- data/app/assets/javascripts/shadcn/index.js +133 -0
- data/app/assets/stylesheets/.keep +0 -0
- data/app/assets/stylesheets/shadcn/base.css +445 -0
- data/app/assets/stylesheets/shadcn/components.css +513 -0
- data/app/assets/stylesheets/shadcn/index.css +18 -0
- data/app/assets/stylesheets/shadcn/themes/gray.css +68 -0
- data/app/assets/stylesheets/shadcn/themes/slate.css +68 -0
- data/app/assets/stylesheets/shadcn/themes/stone.css +68 -0
- data/app/assets/stylesheets/shadcn/themes/zinc.css +68 -0
- data/app/components/shadcn/accordion_component.rb +63 -0
- data/app/components/shadcn/accordion_content_component.rb +29 -0
- data/app/components/shadcn/accordion_item_component.rb +40 -0
- data/app/components/shadcn/accordion_trigger_component.rb +49 -0
- data/app/components/shadcn/alert_component.rb +75 -0
- data/app/components/shadcn/alert_description_component.rb +12 -0
- data/app/components/shadcn/alert_dialog_action_component.rb +24 -0
- data/app/components/shadcn/alert_dialog_cancel_component.rb +24 -0
- data/app/components/shadcn/alert_dialog_component.rb +71 -0
- data/app/components/shadcn/alert_dialog_content_component.rb +57 -0
- data/app/components/shadcn/alert_dialog_description_component.rb +12 -0
- data/app/components/shadcn/alert_dialog_footer_component.rb +19 -0
- data/app/components/shadcn/alert_dialog_header_component.rb +19 -0
- data/app/components/shadcn/alert_dialog_title_component.rb +12 -0
- data/app/components/shadcn/alert_title_component.rb +12 -0
- data/app/components/shadcn/aspect_ratio_component.rb +49 -0
- data/app/components/shadcn/avatar_component.rb +107 -0
- data/app/components/shadcn/avatar_fallback_component.rb +17 -0
- data/app/components/shadcn/badge_component.rb +49 -0
- data/app/components/shadcn/base_component.rb +100 -0
- data/app/components/shadcn/breadcrumb_component.rb +70 -0
- data/app/components/shadcn/breadcrumb_item_component.rb +50 -0
- data/app/components/shadcn/button_component.rb +141 -0
- data/app/components/shadcn/button_group_component.rb +69 -0
- data/app/components/shadcn/calendar_component.rb +337 -0
- data/app/components/shadcn/card_action_component.rb +10 -0
- data/app/components/shadcn/card_component.rb +63 -0
- data/app/components/shadcn/card_content_component.rb +19 -0
- data/app/components/shadcn/card_description_component.rb +12 -0
- data/app/components/shadcn/card_footer_component.rb +12 -0
- data/app/components/shadcn/card_header_component.rb +24 -0
- data/app/components/shadcn/card_title_component.rb +18 -0
- data/app/components/shadcn/carousel_component.rb +275 -0
- data/app/components/shadcn/checkbox_component.rb +103 -0
- data/app/components/shadcn/collapsible_component.rb +66 -0
- data/app/components/shadcn/collapsible_content_component.rb +28 -0
- data/app/components/shadcn/combobox_component.rb +322 -0
- data/app/components/shadcn/command_component.rb +52 -0
- data/app/components/shadcn/command_dialog_component.rb +76 -0
- data/app/components/shadcn/command_empty_component.rb +12 -0
- data/app/components/shadcn/command_group_component.rb +34 -0
- data/app/components/shadcn/command_input_component.rb +59 -0
- data/app/components/shadcn/command_item_component.rb +48 -0
- data/app/components/shadcn/command_list_component.rb +38 -0
- data/app/components/shadcn/command_separator_component.rb +12 -0
- data/app/components/shadcn/command_shortcut_component.rb +12 -0
- data/app/components/shadcn/context_menu_component.rb +64 -0
- data/app/components/shadcn/context_menu_content_component.rb +44 -0
- data/app/components/shadcn/context_menu_item_component.rb +63 -0
- data/app/components/shadcn/context_menu_label_component.rb +18 -0
- data/app/components/shadcn/context_menu_separator_component.rb +12 -0
- data/app/components/shadcn/context_menu_shortcut_component.rb +12 -0
- data/app/components/shadcn/date_picker_component.rb +368 -0
- data/app/components/shadcn/dialog_component.rb +77 -0
- data/app/components/shadcn/dialog_content_component.rb +91 -0
- data/app/components/shadcn/dialog_description_component.rb +12 -0
- data/app/components/shadcn/dialog_footer_component.rb +12 -0
- data/app/components/shadcn/dialog_header_component.rb +19 -0
- data/app/components/shadcn/dialog_title_component.rb +12 -0
- data/app/components/shadcn/drawer_component.rb +72 -0
- data/app/components/shadcn/drawer_content_component.rb +76 -0
- data/app/components/shadcn/drawer_description_component.rb +12 -0
- data/app/components/shadcn/drawer_footer_component.rb +12 -0
- data/app/components/shadcn/drawer_header_component.rb +19 -0
- data/app/components/shadcn/drawer_title_component.rb +12 -0
- data/app/components/shadcn/dropdown_menu_component.rb +75 -0
- data/app/components/shadcn/dropdown_menu_content_component.rb +49 -0
- data/app/components/shadcn/dropdown_menu_group_component.rb +10 -0
- data/app/components/shadcn/dropdown_menu_item_component.rb +63 -0
- data/app/components/shadcn/dropdown_menu_label_component.rb +18 -0
- data/app/components/shadcn/dropdown_menu_separator_component.rb +12 -0
- data/app/components/shadcn/dropdown_menu_shortcut_component.rb +12 -0
- data/app/components/shadcn/empty_component.rb +48 -0
- data/app/components/shadcn/empty_content_component.rb +12 -0
- data/app/components/shadcn/empty_description_component.rb +12 -0
- data/app/components/shadcn/empty_header_component.rb +29 -0
- data/app/components/shadcn/empty_media_component.rb +21 -0
- data/app/components/shadcn/empty_title_component.rb +12 -0
- data/app/components/shadcn/field_component.rb +113 -0
- data/app/components/shadcn/hover_card_component.rb +64 -0
- data/app/components/shadcn/hover_card_content_component.rb +36 -0
- data/app/components/shadcn/input_component.rb +108 -0
- data/app/components/shadcn/input_group_component.rb +70 -0
- data/app/components/shadcn/input_otp_component.rb +183 -0
- data/app/components/shadcn/item_actions_component.rb +12 -0
- data/app/components/shadcn/item_component.rb +98 -0
- data/app/components/shadcn/item_content_component.rb +24 -0
- data/app/components/shadcn/item_description_component.rb +12 -0
- data/app/components/shadcn/item_footer_component.rb +12 -0
- data/app/components/shadcn/item_group_component.rb +24 -0
- data/app/components/shadcn/item_header_component.rb +12 -0
- data/app/components/shadcn/item_media_component.rb +22 -0
- data/app/components/shadcn/item_separator_component.rb +12 -0
- data/app/components/shadcn/item_title_component.rb +12 -0
- data/app/components/shadcn/kbd_component.rb +36 -0
- data/app/components/shadcn/label_component.rb +49 -0
- data/app/components/shadcn/menubar_checkbox_item_component.rb +76 -0
- data/app/components/shadcn/menubar_component.rb +56 -0
- data/app/components/shadcn/menubar_content_component.rb +64 -0
- data/app/components/shadcn/menubar_item_component.rb +65 -0
- data/app/components/shadcn/menubar_label_component.rb +27 -0
- data/app/components/shadcn/menubar_menu_component.rb +34 -0
- data/app/components/shadcn/menubar_radio_group_component.rb +42 -0
- data/app/components/shadcn/menubar_radio_item_component.rb +76 -0
- data/app/components/shadcn/menubar_separator_component.rb +22 -0
- data/app/components/shadcn/menubar_shortcut_component.rb +21 -0
- data/app/components/shadcn/menubar_sub_component.rb +38 -0
- data/app/components/shadcn/menubar_sub_content_component.rb +45 -0
- data/app/components/shadcn/menubar_sub_trigger_component.rb +59 -0
- data/app/components/shadcn/menubar_trigger_component.rb +31 -0
- data/app/components/shadcn/native_select_component.rb +150 -0
- data/app/components/shadcn/navigation_menu_component.rb +76 -0
- data/app/components/shadcn/navigation_menu_content_component.rb +30 -0
- data/app/components/shadcn/navigation_menu_item_component.rb +39 -0
- data/app/components/shadcn/navigation_menu_link_component.rb +38 -0
- data/app/components/shadcn/navigation_menu_list_component.rb +29 -0
- data/app/components/shadcn/navigation_menu_trigger_component.rb +59 -0
- data/app/components/shadcn/pagination_component.rb +195 -0
- data/app/components/shadcn/pagination_content_component.rb +47 -0
- data/app/components/shadcn/pagination_ellipsis_component.rb +30 -0
- data/app/components/shadcn/pagination_item_component.rb +53 -0
- data/app/components/shadcn/pagination_next_component.rb +48 -0
- data/app/components/shadcn/pagination_previous_component.rb +48 -0
- data/app/components/shadcn/popover_component.rb +76 -0
- data/app/components/shadcn/popover_content_component.rb +25 -0
- data/app/components/shadcn/progress_component.rb +77 -0
- data/app/components/shadcn/radio_group_component.rb +129 -0
- data/app/components/shadcn/radio_group_item_component.rb +109 -0
- data/app/components/shadcn/resizable_handle_component.rb +98 -0
- data/app/components/shadcn/resizable_panel_component.rb +56 -0
- data/app/components/shadcn/resizable_panel_group_component.rb +94 -0
- data/app/components/shadcn/scroll_area_component.rb +110 -0
- data/app/components/shadcn/select_component.rb +151 -0
- data/app/components/shadcn/select_group_component.rb +32 -0
- data/app/components/shadcn/select_item_component.rb +59 -0
- data/app/components/shadcn/select_separator_component.rb +12 -0
- data/app/components/shadcn/separator_component.rb +54 -0
- data/app/components/shadcn/sheet_component.rb +82 -0
- data/app/components/shadcn/sheet_content_component.rb +95 -0
- data/app/components/shadcn/sheet_description_component.rb +12 -0
- data/app/components/shadcn/sheet_footer_component.rb +12 -0
- data/app/components/shadcn/sheet_header_component.rb +19 -0
- data/app/components/shadcn/sheet_title_component.rb +12 -0
- data/app/components/shadcn/sidebar_component.rb +180 -0
- data/app/components/shadcn/sidebar_content_component.rb +32 -0
- data/app/components/shadcn/sidebar_footer_component.rb +24 -0
- data/app/components/shadcn/sidebar_group_action_component.rb +26 -0
- data/app/components/shadcn/sidebar_group_component.rb +38 -0
- data/app/components/shadcn/sidebar_group_content_component.rb +32 -0
- data/app/components/shadcn/sidebar_group_label_component.rb +25 -0
- data/app/components/shadcn/sidebar_header_component.rb +24 -0
- data/app/components/shadcn/sidebar_inset_component.rb +25 -0
- data/app/components/shadcn/sidebar_menu_action_component.rb +37 -0
- data/app/components/shadcn/sidebar_menu_badge_component.rb +25 -0
- data/app/components/shadcn/sidebar_menu_button_component.rb +52 -0
- data/app/components/shadcn/sidebar_menu_component.rb +32 -0
- data/app/components/shadcn/sidebar_menu_item_component.rb +41 -0
- data/app/components/shadcn/sidebar_menu_skeleton_component.rb +46 -0
- data/app/components/shadcn/sidebar_menu_sub_button_component.rb +43 -0
- data/app/components/shadcn/sidebar_menu_sub_component.rb +33 -0
- data/app/components/shadcn/sidebar_menu_sub_item_component.rb +30 -0
- data/app/components/shadcn/sidebar_provider_component.rb +57 -0
- data/app/components/shadcn/sidebar_rail_component.rb +30 -0
- data/app/components/shadcn/sidebar_separator_component.rb +24 -0
- data/app/components/shadcn/sidebar_trigger_component.rb +51 -0
- data/app/components/shadcn/skeleton_component.rb +29 -0
- data/app/components/shadcn/slider_component.rb +76 -0
- data/app/components/shadcn/spinner_component.rb +67 -0
- data/app/components/shadcn/switch_component.rb +147 -0
- data/app/components/shadcn/table_body_component.rb +16 -0
- data/app/components/shadcn/table_caption_component.rb +12 -0
- data/app/components/shadcn/table_cell_component.rb +12 -0
- data/app/components/shadcn/table_component.rb +57 -0
- data/app/components/shadcn/table_footer_component.rb +16 -0
- data/app/components/shadcn/table_head_component.rb +12 -0
- data/app/components/shadcn/table_header_component.rb +16 -0
- data/app/components/shadcn/table_row_component.rb +40 -0
- data/app/components/shadcn/tabs_component.rb +78 -0
- data/app/components/shadcn/tabs_content_component.rb +32 -0
- data/app/components/shadcn/tabs_list_component.rb +30 -0
- data/app/components/shadcn/tabs_trigger_component.rb +37 -0
- data/app/components/shadcn/textarea_component.rb +84 -0
- data/app/components/shadcn/toast_action_component.rb +18 -0
- data/app/components/shadcn/toast_component.rb +114 -0
- data/app/components/shadcn/toast_description_component.rb +12 -0
- data/app/components/shadcn/toast_title_component.rb +12 -0
- data/app/components/shadcn/toast_viewport_component.rb +12 -0
- data/app/components/shadcn/toggle_component.rb +77 -0
- data/app/components/shadcn/toggle_group_component.rb +96 -0
- data/app/components/shadcn/toggle_group_item_component.rb +62 -0
- data/app/components/shadcn/tooltip_component.rb +89 -0
- data/app/components/shadcn/typography_component.rb +112 -0
- data/babel.config.cjs +5 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/config/importmap.rb +5 -0
- data/fly.toml +26 -0
- data/jest.config.js +19 -0
- data/jest.setup.js +8 -0
- data/lib/generators/shadcn/component/component_generator.rb +188 -0
- data/lib/generators/shadcn/install/install_generator.rb +140 -0
- data/lib/generators/shadcn/install/templates/initializer.rb.tt +35 -0
- data/lib/generators/shadcn/install/templates/shadcn.yml.tt +35 -0
- data/lib/generators/shadcn/theme/theme_generator.rb +128 -0
- data/lib/shadcn/rails/class_merger.rb +228 -0
- data/lib/shadcn/rails/configuration.rb +341 -0
- data/lib/shadcn/rails/engine.rb +59 -0
- data/lib/shadcn/rails/helpers/class_name_helper.rb +35 -0
- data/lib/shadcn/rails/helpers/component_helper.rb +60 -0
- data/lib/shadcn/rails/helpers/pagination_helper.rb +187 -0
- data/lib/shadcn/rails/version.rb +7 -0
- data/lib/shadcn/rails.rb +179 -0
- data/package-lock.json +7415 -0
- data/package.json +68 -0
- data/rollup.config.js +29 -0
- data/sig/shadcn/rails.rbs +6 -0
- metadata +526 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dropdown controller for dropdown menus
|
|
5
|
+
* Handles opening, closing, keyboard navigation, and item selection
|
|
6
|
+
*/
|
|
7
|
+
export default class DropdownController extends Controller {
|
|
8
|
+
static targets: ["trigger", "content", "item"];
|
|
9
|
+
static values: {
|
|
10
|
+
open: { type: "Boolean"; default: false };
|
|
11
|
+
align: { type: "String"; default: "end" };
|
|
12
|
+
side: { type: "String"; default: "bottom" };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Dropdown trigger target */
|
|
16
|
+
readonly triggerTarget: HTMLElement;
|
|
17
|
+
readonly hasTriggerTarget: boolean;
|
|
18
|
+
|
|
19
|
+
/** Dropdown content target */
|
|
20
|
+
readonly contentTarget: HTMLElement;
|
|
21
|
+
readonly hasContentTarget: boolean;
|
|
22
|
+
|
|
23
|
+
/** Dropdown item targets */
|
|
24
|
+
readonly itemTargets: HTMLElement[];
|
|
25
|
+
readonly hasItemTarget: boolean;
|
|
26
|
+
|
|
27
|
+
/** Whether the dropdown is open */
|
|
28
|
+
openValue: boolean;
|
|
29
|
+
readonly hasOpenValue: boolean;
|
|
30
|
+
|
|
31
|
+
/** Horizontal alignment: "start", "center", "end" */
|
|
32
|
+
alignValue: "start" | "center" | "end";
|
|
33
|
+
readonly hasAlignValue: boolean;
|
|
34
|
+
|
|
35
|
+
/** Side to display: "top", "bottom" */
|
|
36
|
+
sideValue: "top" | "bottom";
|
|
37
|
+
readonly hasSideValue: boolean;
|
|
38
|
+
|
|
39
|
+
/** Currently focused item index */
|
|
40
|
+
focusedIndex: number;
|
|
41
|
+
|
|
42
|
+
/** Toggle dropdown open/closed */
|
|
43
|
+
toggle(event?: Event): void;
|
|
44
|
+
|
|
45
|
+
/** Show the dropdown */
|
|
46
|
+
show(): void;
|
|
47
|
+
|
|
48
|
+
/** Hide the dropdown */
|
|
49
|
+
hide(): void;
|
|
50
|
+
|
|
51
|
+
/** Close the dropdown (alias for hide) */
|
|
52
|
+
close(): void;
|
|
53
|
+
|
|
54
|
+
/** Select a menu item */
|
|
55
|
+
selectItem(event: Event): void;
|
|
56
|
+
|
|
57
|
+
/** Handle clicks outside the dropdown */
|
|
58
|
+
handleClickOutside(event: MouseEvent): void;
|
|
59
|
+
|
|
60
|
+
/** Handle keyboard navigation */
|
|
61
|
+
handleKeydown(event: KeyboardEvent): void;
|
|
62
|
+
|
|
63
|
+
/** Focus next menu item */
|
|
64
|
+
focusNextItem(): void;
|
|
65
|
+
|
|
66
|
+
/** Focus previous menu item */
|
|
67
|
+
focusPreviousItem(): void;
|
|
68
|
+
|
|
69
|
+
/** Focus first menu item */
|
|
70
|
+
focusFirstItem(): void;
|
|
71
|
+
|
|
72
|
+
/** Focus last menu item */
|
|
73
|
+
focusLastItem(): void;
|
|
74
|
+
|
|
75
|
+
/** Select the currently focused item */
|
|
76
|
+
selectFocusedItem(): void;
|
|
77
|
+
|
|
78
|
+
/** Get enabled (non-disabled) items */
|
|
79
|
+
readonly enabledItems: HTMLElement[];
|
|
80
|
+
|
|
81
|
+
/** Position the dropdown content */
|
|
82
|
+
positionContent(): void;
|
|
83
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dropdown controller for dropdown menus
|
|
5
|
+
* Handles opening, closing, keyboard navigation, and item selection
|
|
6
|
+
*/
|
|
7
|
+
export default class extends Controller {
|
|
8
|
+
static targets = ["trigger", "content", "item"]
|
|
9
|
+
static values = {
|
|
10
|
+
open: { type: Boolean, default: false },
|
|
11
|
+
align: { type: String, default: "end" },
|
|
12
|
+
side: { type: String, default: "bottom" }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
connect() {
|
|
16
|
+
this.focusedIndex = -1
|
|
17
|
+
this.boundHandleClickOutside = this.handleClickOutside.bind(this)
|
|
18
|
+
this.boundHandleKeydown = this.handleKeydown.bind(this)
|
|
19
|
+
|
|
20
|
+
if (this.openValue) {
|
|
21
|
+
this.show()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
disconnect() {
|
|
26
|
+
this.hide()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
toggle(event) {
|
|
30
|
+
event?.preventDefault()
|
|
31
|
+
if (this.openValue) {
|
|
32
|
+
this.hide()
|
|
33
|
+
} else {
|
|
34
|
+
this.show()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
show() {
|
|
39
|
+
if (this.openValue) return
|
|
40
|
+
|
|
41
|
+
this.openValue = true
|
|
42
|
+
|
|
43
|
+
if (this.hasContentTarget) {
|
|
44
|
+
this.contentTarget.hidden = false
|
|
45
|
+
this.contentTarget.dataset.state = "open"
|
|
46
|
+
this.contentTarget.dataset.side = this.sideValue
|
|
47
|
+
this.positionContent()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (this.hasTriggerTarget) {
|
|
51
|
+
this.triggerTarget.setAttribute("aria-expanded", "true")
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Add event listeners
|
|
55
|
+
document.addEventListener("click", this.boundHandleClickOutside)
|
|
56
|
+
document.addEventListener("keydown", this.boundHandleKeydown)
|
|
57
|
+
|
|
58
|
+
// Focus first item
|
|
59
|
+
this.focusedIndex = -1
|
|
60
|
+
this.focusNextItem()
|
|
61
|
+
|
|
62
|
+
this.dispatch("opened")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
hide() {
|
|
66
|
+
if (!this.openValue) return
|
|
67
|
+
|
|
68
|
+
this.openValue = false
|
|
69
|
+
|
|
70
|
+
if (this.hasContentTarget) {
|
|
71
|
+
this.contentTarget.dataset.state = "closed"
|
|
72
|
+
// Hide after animation
|
|
73
|
+
setTimeout(() => {
|
|
74
|
+
if (!this.openValue) {
|
|
75
|
+
this.contentTarget.hidden = true
|
|
76
|
+
}
|
|
77
|
+
}, 150)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (this.hasTriggerTarget) {
|
|
81
|
+
this.triggerTarget.setAttribute("aria-expanded", "false")
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Remove event listeners
|
|
85
|
+
document.removeEventListener("click", this.boundHandleClickOutside)
|
|
86
|
+
document.removeEventListener("keydown", this.boundHandleKeydown)
|
|
87
|
+
|
|
88
|
+
// Reset focus index
|
|
89
|
+
this.focusedIndex = -1
|
|
90
|
+
|
|
91
|
+
this.dispatch("closed")
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
close() {
|
|
95
|
+
this.hide()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
selectItem(event) {
|
|
99
|
+
const item = event.currentTarget
|
|
100
|
+
if (item.dataset.disabled !== undefined) return
|
|
101
|
+
|
|
102
|
+
this.dispatch("select", { detail: { item } })
|
|
103
|
+
this.hide()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
handleClickOutside(event) {
|
|
107
|
+
if (!this.element.contains(event.target)) {
|
|
108
|
+
this.hide()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
handleKeydown(event) {
|
|
113
|
+
switch (event.key) {
|
|
114
|
+
case "Escape":
|
|
115
|
+
this.hide()
|
|
116
|
+
this.triggerTarget?.focus()
|
|
117
|
+
break
|
|
118
|
+
case "ArrowDown":
|
|
119
|
+
event.preventDefault()
|
|
120
|
+
this.focusNextItem()
|
|
121
|
+
break
|
|
122
|
+
case "ArrowUp":
|
|
123
|
+
event.preventDefault()
|
|
124
|
+
this.focusPreviousItem()
|
|
125
|
+
break
|
|
126
|
+
case "Home":
|
|
127
|
+
event.preventDefault()
|
|
128
|
+
this.focusFirstItem()
|
|
129
|
+
break
|
|
130
|
+
case "End":
|
|
131
|
+
event.preventDefault()
|
|
132
|
+
this.focusLastItem()
|
|
133
|
+
break
|
|
134
|
+
case "Enter":
|
|
135
|
+
case " ":
|
|
136
|
+
event.preventDefault()
|
|
137
|
+
this.selectFocusedItem()
|
|
138
|
+
break
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
focusNextItem() {
|
|
143
|
+
const items = this.enabledItems
|
|
144
|
+
if (items.length === 0) return
|
|
145
|
+
|
|
146
|
+
this.focusedIndex = (this.focusedIndex + 1) % items.length
|
|
147
|
+
items[this.focusedIndex].focus()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
focusPreviousItem() {
|
|
151
|
+
const items = this.enabledItems
|
|
152
|
+
if (items.length === 0) return
|
|
153
|
+
|
|
154
|
+
this.focusedIndex = this.focusedIndex <= 0 ? items.length - 1 : this.focusedIndex - 1
|
|
155
|
+
items[this.focusedIndex].focus()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
focusFirstItem() {
|
|
159
|
+
const items = this.enabledItems
|
|
160
|
+
if (items.length === 0) return
|
|
161
|
+
|
|
162
|
+
this.focusedIndex = 0
|
|
163
|
+
items[0].focus()
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
focusLastItem() {
|
|
167
|
+
const items = this.enabledItems
|
|
168
|
+
if (items.length === 0) return
|
|
169
|
+
|
|
170
|
+
this.focusedIndex = items.length - 1
|
|
171
|
+
items[this.focusedIndex].focus()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
selectFocusedItem() {
|
|
175
|
+
const items = this.enabledItems
|
|
176
|
+
if (this.focusedIndex >= 0 && this.focusedIndex < items.length) {
|
|
177
|
+
items[this.focusedIndex].click()
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
get enabledItems() {
|
|
182
|
+
return this.itemTargets.filter(item => item.dataset.disabled === undefined)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
positionContent() {
|
|
186
|
+
if (!this.hasContentTarget || !this.hasTriggerTarget) return
|
|
187
|
+
|
|
188
|
+
const trigger = this.triggerTarget.getBoundingClientRect()
|
|
189
|
+
const content = this.contentTarget
|
|
190
|
+
|
|
191
|
+
// Position based on side and align
|
|
192
|
+
content.style.position = "absolute"
|
|
193
|
+
content.style.minWidth = `${trigger.width}px`
|
|
194
|
+
|
|
195
|
+
switch (this.sideValue) {
|
|
196
|
+
case "top":
|
|
197
|
+
content.style.bottom = "100%"
|
|
198
|
+
content.style.top = "auto"
|
|
199
|
+
content.style.marginBottom = "4px"
|
|
200
|
+
break
|
|
201
|
+
case "bottom":
|
|
202
|
+
default:
|
|
203
|
+
content.style.top = "100%"
|
|
204
|
+
content.style.bottom = "auto"
|
|
205
|
+
content.style.marginTop = "4px"
|
|
206
|
+
break
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
switch (this.alignValue) {
|
|
210
|
+
case "start":
|
|
211
|
+
content.style.left = "0"
|
|
212
|
+
content.style.right = "auto"
|
|
213
|
+
break
|
|
214
|
+
case "center":
|
|
215
|
+
content.style.left = "50%"
|
|
216
|
+
content.style.transform = "translateX(-50%)"
|
|
217
|
+
break
|
|
218
|
+
case "end":
|
|
219
|
+
default:
|
|
220
|
+
content.style.right = "0"
|
|
221
|
+
content.style.left = "auto"
|
|
222
|
+
break
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hover Card Controller
|
|
5
|
+
* Handles showing/hiding content on hover with delays
|
|
6
|
+
*/
|
|
7
|
+
export default class HoverCardController extends Controller {
|
|
8
|
+
static targets: ["trigger", "content"];
|
|
9
|
+
static values: {
|
|
10
|
+
openDelay: { type: "Number"; default: 700 };
|
|
11
|
+
closeDelay: { type: "Number"; default: 300 };
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Hover card trigger target */
|
|
15
|
+
readonly triggerTarget: HTMLElement;
|
|
16
|
+
readonly hasTriggerTarget: boolean;
|
|
17
|
+
|
|
18
|
+
/** Hover card content target */
|
|
19
|
+
readonly contentTarget: HTMLElement;
|
|
20
|
+
readonly hasContentTarget: boolean;
|
|
21
|
+
|
|
22
|
+
/** Delay before opening (ms) */
|
|
23
|
+
openDelayValue: number;
|
|
24
|
+
readonly hasOpenDelayValue: boolean;
|
|
25
|
+
|
|
26
|
+
/** Delay before closing (ms) */
|
|
27
|
+
closeDelayValue: number;
|
|
28
|
+
readonly hasCloseDelayValue: boolean;
|
|
29
|
+
|
|
30
|
+
/** Open timeout handle */
|
|
31
|
+
openTimeout: ReturnType<typeof setTimeout> | null;
|
|
32
|
+
|
|
33
|
+
/** Close timeout handle */
|
|
34
|
+
closeTimeout: ReturnType<typeof setTimeout> | null;
|
|
35
|
+
|
|
36
|
+
/** Whether the card is currently open */
|
|
37
|
+
isOpen: boolean;
|
|
38
|
+
|
|
39
|
+
/** Schedule opening the card */
|
|
40
|
+
scheduleOpen(): void;
|
|
41
|
+
|
|
42
|
+
/** Schedule closing the card */
|
|
43
|
+
scheduleClose(): void;
|
|
44
|
+
|
|
45
|
+
/** Cancel a pending close */
|
|
46
|
+
cancelClose(): void;
|
|
47
|
+
|
|
48
|
+
/** Clear all timeouts */
|
|
49
|
+
clearTimeouts(): void;
|
|
50
|
+
|
|
51
|
+
/** Open the hover card */
|
|
52
|
+
open(): void;
|
|
53
|
+
|
|
54
|
+
/** Close the hover card */
|
|
55
|
+
close(): void;
|
|
56
|
+
|
|
57
|
+
/** Position the card content */
|
|
58
|
+
positionContent(): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hover Card Controller
|
|
5
|
+
* Handles showing/hiding content on hover with delays
|
|
6
|
+
*/
|
|
7
|
+
export default class extends Controller {
|
|
8
|
+
static targets = ["trigger", "content"]
|
|
9
|
+
static values = {
|
|
10
|
+
openDelay: { type: Number, default: 700 },
|
|
11
|
+
closeDelay: { type: Number, default: 300 }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
connect() {
|
|
15
|
+
this.openTimeout = null
|
|
16
|
+
this.closeTimeout = null
|
|
17
|
+
this.isOpen = false
|
|
18
|
+
|
|
19
|
+
this.triggerTarget.addEventListener("mouseenter", this.scheduleOpen.bind(this))
|
|
20
|
+
this.triggerTarget.addEventListener("mouseleave", this.scheduleClose.bind(this))
|
|
21
|
+
this.triggerTarget.addEventListener("focus", this.scheduleOpen.bind(this))
|
|
22
|
+
this.triggerTarget.addEventListener("blur", this.scheduleClose.bind(this))
|
|
23
|
+
|
|
24
|
+
this.contentTarget.addEventListener("mouseenter", this.cancelClose.bind(this))
|
|
25
|
+
this.contentTarget.addEventListener("mouseleave", this.scheduleClose.bind(this))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
disconnect() {
|
|
29
|
+
this.clearTimeouts()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
scheduleOpen() {
|
|
33
|
+
this.clearTimeouts()
|
|
34
|
+
this.openTimeout = setTimeout(() => {
|
|
35
|
+
this.open()
|
|
36
|
+
}, this.openDelayValue)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
scheduleClose() {
|
|
40
|
+
this.clearTimeouts()
|
|
41
|
+
this.closeTimeout = setTimeout(() => {
|
|
42
|
+
this.close()
|
|
43
|
+
}, this.closeDelayValue)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
cancelClose() {
|
|
47
|
+
if (this.closeTimeout) {
|
|
48
|
+
clearTimeout(this.closeTimeout)
|
|
49
|
+
this.closeTimeout = null
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
clearTimeouts() {
|
|
54
|
+
if (this.openTimeout) {
|
|
55
|
+
clearTimeout(this.openTimeout)
|
|
56
|
+
this.openTimeout = null
|
|
57
|
+
}
|
|
58
|
+
if (this.closeTimeout) {
|
|
59
|
+
clearTimeout(this.closeTimeout)
|
|
60
|
+
this.closeTimeout = null
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
open() {
|
|
65
|
+
if (this.isOpen) return
|
|
66
|
+
|
|
67
|
+
this.isOpen = true
|
|
68
|
+
this.contentTarget.style.display = "block"
|
|
69
|
+
this.contentTarget.setAttribute("data-state", "open")
|
|
70
|
+
this.positionContent()
|
|
71
|
+
|
|
72
|
+
this.dispatch("open")
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
close() {
|
|
76
|
+
if (!this.isOpen) return
|
|
77
|
+
|
|
78
|
+
this.isOpen = false
|
|
79
|
+
this.contentTarget.setAttribute("data-state", "closed")
|
|
80
|
+
|
|
81
|
+
// Wait for animation to complete
|
|
82
|
+
setTimeout(() => {
|
|
83
|
+
if (!this.isOpen) {
|
|
84
|
+
this.contentTarget.style.display = "none"
|
|
85
|
+
}
|
|
86
|
+
}, 150)
|
|
87
|
+
|
|
88
|
+
this.dispatch("close")
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
positionContent() {
|
|
92
|
+
const trigger = this.triggerTarget.getBoundingClientRect()
|
|
93
|
+
const content = this.contentTarget
|
|
94
|
+
const side = content.dataset.side || "bottom"
|
|
95
|
+
const align = content.dataset.align || "center"
|
|
96
|
+
|
|
97
|
+
// Reset position
|
|
98
|
+
content.style.top = ""
|
|
99
|
+
content.style.left = ""
|
|
100
|
+
content.style.right = ""
|
|
101
|
+
content.style.bottom = ""
|
|
102
|
+
|
|
103
|
+
const gap = 8 // Gap between trigger and content
|
|
104
|
+
|
|
105
|
+
switch (side) {
|
|
106
|
+
case "top":
|
|
107
|
+
content.style.bottom = "100%"
|
|
108
|
+
content.style.marginBottom = `${gap}px`
|
|
109
|
+
break
|
|
110
|
+
case "bottom":
|
|
111
|
+
content.style.top = "100%"
|
|
112
|
+
content.style.marginTop = `${gap}px`
|
|
113
|
+
break
|
|
114
|
+
case "left":
|
|
115
|
+
content.style.right = "100%"
|
|
116
|
+
content.style.marginRight = `${gap}px`
|
|
117
|
+
content.style.top = "0"
|
|
118
|
+
break
|
|
119
|
+
case "right":
|
|
120
|
+
content.style.left = "100%"
|
|
121
|
+
content.style.marginLeft = `${gap}px`
|
|
122
|
+
content.style.top = "0"
|
|
123
|
+
break
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Handle alignment for top/bottom
|
|
127
|
+
if (side === "top" || side === "bottom") {
|
|
128
|
+
switch (align) {
|
|
129
|
+
case "start":
|
|
130
|
+
content.style.left = "0"
|
|
131
|
+
break
|
|
132
|
+
case "end":
|
|
133
|
+
content.style.right = "0"
|
|
134
|
+
break
|
|
135
|
+
case "center":
|
|
136
|
+
default:
|
|
137
|
+
content.style.left = "50%"
|
|
138
|
+
content.style.transform = "translateX(-50%)"
|
|
139
|
+
break
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
export default class InputOtpController extends Controller {
|
|
4
|
+
static targets: ["slot", "input", "hiddenInput", "caret"];
|
|
5
|
+
static values: {
|
|
6
|
+
length: { type: "Number"; default: 6 };
|
|
7
|
+
pattern: { type: "String"; default: "" };
|
|
8
|
+
disabled: { type: "Boolean"; default: false };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Targets
|
|
12
|
+
readonly slotTargets: HTMLElement[];
|
|
13
|
+
readonly inputTargets: HTMLInputElement[];
|
|
14
|
+
readonly hiddenInputTarget: HTMLInputElement;
|
|
15
|
+
readonly caretTargets: HTMLElement[];
|
|
16
|
+
readonly hasHiddenInputTarget: boolean;
|
|
17
|
+
|
|
18
|
+
// Values
|
|
19
|
+
lengthValue: number;
|
|
20
|
+
patternValue: string;
|
|
21
|
+
disabledValue: boolean;
|
|
22
|
+
|
|
23
|
+
// Lifecycle
|
|
24
|
+
connect(): void;
|
|
25
|
+
|
|
26
|
+
// Event handlers
|
|
27
|
+
handleInput(event: InputEvent): void;
|
|
28
|
+
handleKeydown(event: KeyboardEvent): void;
|
|
29
|
+
handleFocus(event: FocusEvent): void;
|
|
30
|
+
handleBlur(event: FocusEvent): void;
|
|
31
|
+
handlePaste(event: ClipboardEvent): void;
|
|
32
|
+
focusSlot(event: Event): void;
|
|
33
|
+
|
|
34
|
+
// Methods
|
|
35
|
+
focusInput(index: number): void;
|
|
36
|
+
findNextEmptySlot(startIndex: number): number;
|
|
37
|
+
updateHiddenInput(): void;
|
|
38
|
+
updateCarets(): void;
|
|
39
|
+
clear(): void;
|
|
40
|
+
|
|
41
|
+
// Getters
|
|
42
|
+
readonly value: string;
|
|
43
|
+
readonly isComplete: boolean;
|
|
44
|
+
}
|