velvetkit 0.1.0.beta
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/CHANGELOG.md +16 -0
- data/LICENSE.txt +21 -0
- data/README.md +197 -0
- data/lib/generators/velvetkit/add/add_generator.rb +111 -0
- data/lib/generators/velvetkit/ai/ai_generator.rb +78 -0
- data/lib/generators/velvetkit/helpers.rb +64 -0
- data/lib/generators/velvetkit/install/install_generator.rb +108 -0
- data/lib/velvetkit/namespace.rb +57 -0
- data/lib/velvetkit/reference.rb +108 -0
- data/lib/velvetkit/registry.rb +162 -0
- data/lib/velvetkit/version.rb +5 -0
- data/lib/velvetkit.rb +28 -0
- data/registry/app/assets/tailwind/velvetkit.css +342 -0
- data/registry/app/components/ui/accordion/content.html.erb +5 -0
- data/registry/app/components/ui/accordion/content.rb +34 -0
- data/registry/app/components/ui/accordion/item.html.erb +1 -0
- data/registry/app/components/ui/accordion/item.rb +40 -0
- data/registry/app/components/ui/accordion/trigger.html.erb +1 -0
- data/registry/app/components/ui/accordion/trigger.rb +37 -0
- data/registry/app/components/ui/accordion.html.erb +7 -0
- data/registry/app/components/ui/accordion.rb +34 -0
- data/registry/app/components/ui/alert/description.html.erb +1 -0
- data/registry/app/components/ui/alert/description.rb +12 -0
- data/registry/app/components/ui/alert/title.html.erb +1 -0
- data/registry/app/components/ui/alert/title.rb +12 -0
- data/registry/app/components/ui/alert.html.erb +16 -0
- data/registry/app/components/ui/alert.rb +55 -0
- data/registry/app/components/ui/avatar/fallback.html.erb +1 -0
- data/registry/app/components/ui/avatar/fallback.rb +12 -0
- data/registry/app/components/ui/avatar/image.rb +20 -0
- data/registry/app/components/ui/avatar.html.erb +1 -0
- data/registry/app/components/ui/avatar.rb +56 -0
- data/registry/app/components/ui/avatar_group.html.erb +1 -0
- data/registry/app/components/ui/avatar_group.rb +35 -0
- data/registry/app/components/ui/badge.html.erb +1 -0
- data/registry/app/components/ui/badge.rb +38 -0
- data/registry/app/components/ui/banner.html.erb +10 -0
- data/registry/app/components/ui/banner.rb +47 -0
- data/registry/app/components/ui/base.rb +53 -0
- data/registry/app/components/ui/breadcrumb/auto_ellipsis.html.erb +23 -0
- data/registry/app/components/ui/breadcrumb/auto_ellipsis.rb +12 -0
- data/registry/app/components/ui/breadcrumb/ellipsis.html.erb +18 -0
- data/registry/app/components/ui/breadcrumb/ellipsis.rb +8 -0
- data/registry/app/components/ui/breadcrumb/item.html.erb +1 -0
- data/registry/app/components/ui/breadcrumb/item.rb +12 -0
- data/registry/app/components/ui/breadcrumb/item_slot.html.erb +10 -0
- data/registry/app/components/ui/breadcrumb/item_slot.rb +47 -0
- data/registry/app/components/ui/breadcrumb/list.html.erb +1 -0
- data/registry/app/components/ui/breadcrumb/list.rb +12 -0
- data/registry/app/components/ui/breadcrumb/separator.html.erb +1 -0
- data/registry/app/components/ui/breadcrumb/separator.rb +12 -0
- data/registry/app/components/ui/breadcrumb.html.erb +30 -0
- data/registry/app/components/ui/breadcrumb.rb +83 -0
- data/registry/app/components/ui/button.html.erb +1 -0
- data/registry/app/components/ui/button.rb +81 -0
- data/registry/app/components/ui/button_to.html.erb +1 -0
- data/registry/app/components/ui/button_to.rb +33 -0
- data/registry/app/components/ui/card/content.html.erb +1 -0
- data/registry/app/components/ui/card/content.rb +12 -0
- data/registry/app/components/ui/card/description.html.erb +1 -0
- data/registry/app/components/ui/card/description.rb +12 -0
- data/registry/app/components/ui/card/footer.html.erb +1 -0
- data/registry/app/components/ui/card/footer.rb +12 -0
- data/registry/app/components/ui/card/header.html.erb +1 -0
- data/registry/app/components/ui/card/header.rb +15 -0
- data/registry/app/components/ui/card/title.html.erb +1 -0
- data/registry/app/components/ui/card/title.rb +12 -0
- data/registry/app/components/ui/card.html.erb +1 -0
- data/registry/app/components/ui/card.rb +18 -0
- data/registry/app/components/ui/checkbox.html.erb +18 -0
- data/registry/app/components/ui/checkbox.rb +133 -0
- data/registry/app/components/ui/data_grid.html.erb +2 -0
- data/registry/app/components/ui/data_grid.rb +84 -0
- data/registry/app/components/ui/date_picker.html.erb +70 -0
- data/registry/app/components/ui/date_picker.rb +111 -0
- data/registry/app/components/ui/dialog/close.html.erb +7 -0
- data/registry/app/components/ui/dialog/close.rb +53 -0
- data/registry/app/components/ui/dialog/content.html.erb +26 -0
- data/registry/app/components/ui/dialog/content.rb +102 -0
- data/registry/app/components/ui/dialog/description.html.erb +1 -0
- data/registry/app/components/ui/dialog/description.rb +16 -0
- data/registry/app/components/ui/dialog/footer.html.erb +1 -0
- data/registry/app/components/ui/dialog/footer.rb +14 -0
- data/registry/app/components/ui/dialog/header.html.erb +1 -0
- data/registry/app/components/ui/dialog/header.rb +16 -0
- data/registry/app/components/ui/dialog/title.html.erb +1 -0
- data/registry/app/components/ui/dialog/title.rb +16 -0
- data/registry/app/components/ui/dialog/trigger.html.erb +5 -0
- data/registry/app/components/ui/dialog/trigger.rb +75 -0
- data/registry/app/components/ui/dialog.html.erb +3 -0
- data/registry/app/components/ui/dialog.rb +41 -0
- data/registry/app/components/ui/divider.html.erb +9 -0
- data/registry/app/components/ui/divider.rb +41 -0
- data/registry/app/components/ui/icon.html.erb +1 -0
- data/registry/app/components/ui/icon.rb +41 -0
- data/registry/app/components/ui/image.html.erb +1 -0
- data/registry/app/components/ui/image.rb +74 -0
- data/registry/app/components/ui/input.html.erb +9 -0
- data/registry/app/components/ui/input.rb +127 -0
- data/registry/app/components/ui/input_group/addon.html.erb +6 -0
- data/registry/app/components/ui/input_group/addon.rb +51 -0
- data/registry/app/components/ui/input_group/field.rb +26 -0
- data/registry/app/components/ui/input_group.html.erb +5 -0
- data/registry/app/components/ui/input_group.rb +55 -0
- data/registry/app/components/ui/label.html.erb +2 -0
- data/registry/app/components/ui/label.rb +48 -0
- data/registry/app/components/ui/link.html.erb +1 -0
- data/registry/app/components/ui/link.rb +64 -0
- data/registry/app/components/ui/menu/content.html.erb +5 -0
- data/registry/app/components/ui/menu/content.rb +106 -0
- data/registry/app/components/ui/menu/group.html.erb +1 -0
- data/registry/app/components/ui/menu/group.rb +19 -0
- data/registry/app/components/ui/menu/item.html.erb +1 -0
- data/registry/app/components/ui/menu/item.rb +68 -0
- data/registry/app/components/ui/menu/label.html.erb +1 -0
- data/registry/app/components/ui/menu/label.rb +33 -0
- data/registry/app/components/ui/menu/separator.html.erb +1 -0
- data/registry/app/components/ui/menu/separator.rb +20 -0
- data/registry/app/components/ui/menu/trigger.html.erb +1 -0
- data/registry/app/components/ui/menu/trigger.rb +29 -0
- data/registry/app/components/ui/menu.html.erb +3 -0
- data/registry/app/components/ui/menu.rb +23 -0
- data/registry/app/components/ui/native_select.html.erb +16 -0
- data/registry/app/components/ui/native_select.rb +109 -0
- data/registry/app/components/ui/pagination.html.erb +34 -0
- data/registry/app/components/ui/pagination.rb +62 -0
- data/registry/app/components/ui/password_input.html.erb +20 -0
- data/registry/app/components/ui/password_input.rb +94 -0
- data/registry/app/components/ui/popover/content.html.erb +12 -0
- data/registry/app/components/ui/popover/content.rb +83 -0
- data/registry/app/components/ui/popover/trigger.html.erb +1 -0
- data/registry/app/components/ui/popover/trigger.rb +29 -0
- data/registry/app/components/ui/popover.html.erb +3 -0
- data/registry/app/components/ui/popover.rb +24 -0
- data/registry/app/components/ui/radio_group/item.html.erb +18 -0
- data/registry/app/components/ui/radio_group/item.rb +97 -0
- data/registry/app/components/ui/radio_group.html.erb +1 -0
- data/registry/app/components/ui/radio_group.rb +35 -0
- data/registry/app/components/ui/select.html.erb +60 -0
- data/registry/app/components/ui/select.rb +181 -0
- data/registry/app/components/ui/sheet/close.rb +4 -0
- data/registry/app/components/ui/sheet/content.html.erb +24 -0
- data/registry/app/components/ui/sheet/content.rb +97 -0
- data/registry/app/components/ui/sheet/trigger.rb +4 -0
- data/registry/app/components/ui/sheet.html.erb +3 -0
- data/registry/app/components/ui/sheet.rb +37 -0
- data/registry/app/components/ui/sidebar/content.html.erb +1 -0
- data/registry/app/components/ui/sidebar/content.rb +18 -0
- data/registry/app/components/ui/sidebar/footer.html.erb +3 -0
- data/registry/app/components/ui/sidebar/footer.rb +16 -0
- data/registry/app/components/ui/sidebar/group.html.erb +1 -0
- data/registry/app/components/ui/sidebar/group.rb +19 -0
- data/registry/app/components/ui/sidebar/group_label.html.erb +1 -0
- data/registry/app/components/ui/sidebar/group_label.rb +18 -0
- data/registry/app/components/ui/sidebar/header.html.erb +1 -0
- data/registry/app/components/ui/sidebar/header.rb +16 -0
- data/registry/app/components/ui/sidebar/inset.html.erb +1 -0
- data/registry/app/components/ui/sidebar/inset.rb +17 -0
- data/registry/app/components/ui/sidebar/menu.html.erb +1 -0
- data/registry/app/components/ui/sidebar/menu.rb +18 -0
- data/registry/app/components/ui/sidebar/menu_button.html.erb +1 -0
- data/registry/app/components/ui/sidebar/menu_button.rb +30 -0
- data/registry/app/components/ui/sidebar/menu_item.html.erb +1 -0
- data/registry/app/components/ui/sidebar/menu_item.rb +23 -0
- data/registry/app/components/ui/sidebar/trigger.html.erb +1 -0
- data/registry/app/components/ui/sidebar/trigger.rb +24 -0
- data/registry/app/components/ui/sidebar/wrapper.html.erb +1 -0
- data/registry/app/components/ui/sidebar/wrapper.rb +40 -0
- data/registry/app/components/ui/sidebar.html.erb +11 -0
- data/registry/app/components/ui/sidebar.rb +29 -0
- data/registry/app/components/ui/spinner.html.erb +1 -0
- data/registry/app/components/ui/spinner.rb +20 -0
- data/registry/app/components/ui/switch.html.erb +12 -0
- data/registry/app/components/ui/switch.rb +109 -0
- data/registry/app/components/ui/table/cell.html.erb +1 -0
- data/registry/app/components/ui/table/cell.rb +16 -0
- data/registry/app/components/ui/table/column.html.erb +1 -0
- data/registry/app/components/ui/table/column.rb +18 -0
- data/registry/app/components/ui/table/head.html.erb +1 -0
- data/registry/app/components/ui/table/head.rb +13 -0
- data/registry/app/components/ui/table/row.html.erb +1 -0
- data/registry/app/components/ui/table/row.rb +26 -0
- data/registry/app/components/ui/table.html.erb +4 -0
- data/registry/app/components/ui/table.rb +45 -0
- data/registry/app/components/ui/tabs/content.html.erb +1 -0
- data/registry/app/components/ui/tabs/content.rb +43 -0
- data/registry/app/components/ui/tabs/list.html.erb +1 -0
- data/registry/app/components/ui/tabs/list.rb +28 -0
- data/registry/app/components/ui/tabs/trigger.html.erb +1 -0
- data/registry/app/components/ui/tabs/trigger.rb +91 -0
- data/registry/app/components/ui/tabs.html.erb +3 -0
- data/registry/app/components/ui/tabs.rb +27 -0
- data/registry/app/components/ui/text.html.erb +1 -0
- data/registry/app/components/ui/text.rb +48 -0
- data/registry/app/components/ui/theme_toggle.html.erb +9 -0
- data/registry/app/components/ui/theme_toggle.rb +63 -0
- data/registry/app/components/ui/tooltip/content.html.erb +1 -0
- data/registry/app/components/ui/tooltip/content.rb +65 -0
- data/registry/app/components/ui/tooltip/trigger.html.erb +1 -0
- data/registry/app/components/ui/tooltip/trigger.rb +33 -0
- data/registry/app/components/ui/tooltip.html.erb +3 -0
- data/registry/app/components/ui/tooltip.rb +24 -0
- data/registry/app/components/ui/typography/blockquote.html.erb +1 -0
- data/registry/app/components/ui/typography/blockquote.rb +15 -0
- data/registry/app/components/ui/typography/code.html.erb +1 -0
- data/registry/app/components/ui/typography/code.rb +25 -0
- data/registry/app/components/ui/typography/h1.rb +7 -0
- data/registry/app/components/ui/typography/h2.rb +7 -0
- data/registry/app/components/ui/typography/h3.rb +7 -0
- data/registry/app/components/ui/typography/h4.rb +7 -0
- data/registry/app/components/ui/typography/large.rb +7 -0
- data/registry/app/components/ui/typography/lead.rb +7 -0
- data/registry/app/components/ui/typography/muted.rb +7 -0
- data/registry/app/components/ui/typography/small.rb +7 -0
- data/registry/app/javascript/ag_grid.ts +26 -0
- data/registry/app/javascript/cally.ts +8 -0
- data/registry/app/javascript/controllers/ui/_internal/use_dismiss.ts +88 -0
- data/registry/app/javascript/controllers/ui/_internal/use_floating.ts +112 -0
- data/registry/app/javascript/controllers/ui/accordion_controller.ts +100 -0
- data/registry/app/javascript/controllers/ui/alert_controller.ts +7 -0
- data/registry/app/javascript/controllers/ui/banner_controller.ts +7 -0
- data/registry/app/javascript/controllers/ui/data_grid_controller.ts +198 -0
- data/registry/app/javascript/controllers/ui/date_picker_controller.ts +141 -0
- data/registry/app/javascript/controllers/ui/dialog_controller.ts +70 -0
- data/registry/app/javascript/controllers/ui/menu_controller.ts +201 -0
- data/registry/app/javascript/controllers/ui/password_visibility_controller.ts +43 -0
- data/registry/app/javascript/controllers/ui/popover_controller.ts +108 -0
- data/registry/app/javascript/controllers/ui/select_controller.ts +274 -0
- data/registry/app/javascript/controllers/ui/sidebar_controller.ts +64 -0
- data/registry/app/javascript/controllers/ui/tabs_controller.ts +74 -0
- data/registry/app/javascript/controllers/ui/theme_controller.ts +101 -0
- data/registry/app/javascript/controllers/ui/tooltip_controller.ts +102 -0
- data/registry/app/javascript/velvetkit_icons.ts +58 -0
- data/registry/app/views/layouts/_theme_script.html.erb +19 -0
- data/registry/components.yml +102 -0
- data/registry/config/locales/velvetkit.en.yml +56 -0
- data/registry/docs/agents.md +62 -0
- data/registry/test/components/previews/ui/accordion_preview/faq_style.html.erb +20 -0
- data/registry/test/components/previews/ui/accordion_preview/multiple.html.erb +27 -0
- data/registry/test/components/previews/ui/accordion_preview/single.html.erb +22 -0
- data/registry/test/components/previews/ui/accordion_preview.rb +31 -0
- data/registry/test/components/previews/ui/alert_preview/title_only.html.erb +12 -0
- data/registry/test/components/previews/ui/alert_preview/variants.html.erb +22 -0
- data/registry/test/components/previews/ui/alert_preview/with_icon.html.erb +12 -0
- data/registry/test/components/previews/ui/alert_preview/with_link.html.erb +18 -0
- data/registry/test/components/previews/ui/alert_preview.rb +34 -0
- data/registry/test/components/previews/ui/avatar_group_preview/default.html.erb +11 -0
- data/registry/test/components/previews/ui/avatar_group_preview/overflow.html.erb +23 -0
- data/registry/test/components/previews/ui/avatar_group_preview/small.html.erb +12 -0
- data/registry/test/components/previews/ui/avatar_group_preview.rb +23 -0
- data/registry/test/components/previews/ui/avatar_preview/colors.html.erb +8 -0
- data/registry/test/components/previews/ui/avatar_preview/shapes.html.erb +10 -0
- data/registry/test/components/previews/ui/avatar_preview/sizes.html.erb +8 -0
- data/registry/test/components/previews/ui/avatar_preview/with_image.html.erb +10 -0
- data/registry/test/components/previews/ui/avatar_preview.rb +24 -0
- data/registry/test/components/previews/ui/badge_preview/sizes.html.erb +5 -0
- data/registry/test/components/previews/ui/badge_preview/variants.html.erb +8 -0
- data/registry/test/components/previews/ui/badge_preview/with_icon.html.erb +14 -0
- data/registry/test/components/previews/ui/badge_preview.rb +20 -0
- data/registry/test/components/previews/ui/banner_preview/introduction.html.erb +9 -0
- data/registry/test/components/previews/ui/banner_preview/promotion.html.erb +9 -0
- data/registry/test/components/previews/ui/banner_preview/with_illustration.html.erb +12 -0
- data/registry/test/components/previews/ui/banner_preview.rb +25 -0
- data/registry/test/components/previews/ui/breadcrumb_preview/collapsed.html.erb +50 -0
- data/registry/test/components/previews/ui/breadcrumb_preview/default.html.erb +8 -0
- data/registry/test/components/previews/ui/breadcrumb_preview/long_path.html.erb +8 -0
- data/registry/test/components/previews/ui/breadcrumb_preview/medium.html.erb +7 -0
- data/registry/test/components/previews/ui/breadcrumb_preview/with_avatar.html.erb +8 -0
- data/registry/test/components/previews/ui/breadcrumb_preview.rb +66 -0
- data/registry/test/components/previews/ui/button_preview/disabled.html.erb +39 -0
- data/registry/test/components/previews/ui/button_preview/icon_only.html.erb +17 -0
- data/registry/test/components/previews/ui/button_preview/loading.html.erb +12 -0
- data/registry/test/components/previews/ui/button_preview/sizes.html.erb +6 -0
- data/registry/test/components/previews/ui/button_preview/variants.html.erb +8 -0
- data/registry/test/components/previews/ui/button_preview/with_both_icons.html.erb +12 -0
- data/registry/test/components/previews/ui/button_preview/with_leading_icon.html.erb +22 -0
- data/registry/test/components/previews/ui/button_preview/with_trailing_icon.html.erb +14 -0
- data/registry/test/components/previews/ui/button_preview.rb +65 -0
- data/registry/test/components/previews/ui/button_to_preview/states.html.erb +8 -0
- data/registry/test/components/previews/ui/button_to_preview/variants.html.erb +5 -0
- data/registry/test/components/previews/ui/button_to_preview/with_icon.html.erb +11 -0
- data/registry/test/components/previews/ui/button_to_preview.rb +21 -0
- data/registry/test/components/previews/ui/card_preview/complete.html.erb +31 -0
- data/registry/test/components/previews/ui/card_preview/default.html.erb +7 -0
- data/registry/test/components/previews/ui/card_preview/settings_form.html.erb +25 -0
- data/registry/test/components/previews/ui/card_preview/with_footer.html.erb +13 -0
- data/registry/test/components/previews/ui/card_preview/with_header.html.erb +11 -0
- data/registry/test/components/previews/ui/card_preview.rb +44 -0
- data/registry/test/components/previews/ui/checkbox_preview/in_form.html.erb +9 -0
- data/registry/test/components/previews/ui/checkbox_preview/states.html.erb +22 -0
- data/registry/test/components/previews/ui/checkbox_preview/with_label.html.erb +5 -0
- data/registry/test/components/previews/ui/checkbox_preview.rb +27 -0
- data/registry/test/components/previews/ui/data_grid_preview.rb +18 -0
- data/registry/test/components/previews/ui/date_picker_preview/default.html.erb +3 -0
- data/registry/test/components/previews/ui/date_picker_preview/states.html.erb +7 -0
- data/registry/test/components/previews/ui/date_picker_preview.rb +13 -0
- data/registry/test/components/previews/ui/dialog_preview/confirmation.html.erb +11 -0
- data/registry/test/components/previews/ui/dialog_preview/custom_trigger.html.erb +16 -0
- data/registry/test/components/previews/ui/dialog_preview/default.html.erb +15 -0
- data/registry/test/components/previews/ui/dialog_preview/long_content.html.erb +16 -0
- data/registry/test/components/previews/ui/dialog_preview/playground.html.erb +12 -0
- data/registry/test/components/previews/ui/dialog_preview/scrollable_body.html.erb +29 -0
- data/registry/test/components/previews/ui/dialog_preview/sizes.html.erb +46 -0
- data/registry/test/components/previews/ui/dialog_preview/without_close_button.html.erb +11 -0
- data/registry/test/components/previews/ui/dialog_preview/without_title.html.erb +13 -0
- data/registry/test/components/previews/ui/dialog_preview.rb +38 -0
- data/registry/test/components/previews/ui/divider_preview/horizontal.html.erb +5 -0
- data/registry/test/components/previews/ui/divider_preview/vertical.html.erb +9 -0
- data/registry/test/components/previews/ui/divider_preview/with_label.html.erb +5 -0
- data/registry/test/components/previews/ui/divider_preview.rb +19 -0
- data/registry/test/components/previews/ui/icon_preview/common.html.erb +8 -0
- data/registry/test/components/previews/ui/icon_preview/sizes.html.erb +7 -0
- data/registry/test/components/previews/ui/icon_preview.rb +20 -0
- data/registry/test/components/previews/ui/image_preview/radii.html.erb +8 -0
- data/registry/test/components/previews/ui/image_preview/sizing.html.erb +9 -0
- data/registry/test/components/previews/ui/image_preview.rb +16 -0
- data/registry/test/components/previews/ui/input_group_preview/addons.html.erb +29 -0
- data/registry/test/components/previews/ui/input_group_preview/playground.html.erb +12 -0
- data/registry/test/components/previews/ui/input_group_preview.rb +17 -0
- data/registry/test/components/previews/ui/input_preview/sizes.html.erb +5 -0
- data/registry/test/components/previews/ui/input_preview/states.html.erb +7 -0
- data/registry/test/components/previews/ui/input_preview/with_labels.html.erb +10 -0
- data/registry/test/components/previews/ui/input_preview.rb +33 -0
- data/registry/test/components/previews/ui/label_preview/sizes.html.erb +6 -0
- data/registry/test/components/previews/ui/label_preview/states.html.erb +6 -0
- data/registry/test/components/previews/ui/label_preview/weights.html.erb +5 -0
- data/registry/test/components/previews/ui/label_preview.rb +22 -0
- data/registry/test/components/previews/ui/link_preview/sizes.html.erb +5 -0
- data/registry/test/components/previews/ui/link_preview/variants.html.erb +8 -0
- data/registry/test/components/previews/ui/link_preview/with_icons.html.erb +11 -0
- data/registry/test/components/previews/ui/link_preview.rb +20 -0
- data/registry/test/components/previews/ui/menu_preview/positions.html.erb +122 -0
- data/registry/test/components/previews/ui/menu_preview/variants.html.erb +218 -0
- data/registry/test/components/previews/ui/menu_preview.rb +26 -0
- data/registry/test/components/previews/ui/native_select_preview/sizes.html.erb +6 -0
- data/registry/test/components/previews/ui/native_select_preview/states.html.erb +6 -0
- data/registry/test/components/previews/ui/native_select_preview.rb +23 -0
- data/registry/test/components/previews/ui/pagination_preview/states.html.erb +15 -0
- data/registry/test/components/previews/ui/pagination_preview.rb +15 -0
- data/registry/test/components/previews/ui/password_input_preview/states.html.erb +19 -0
- data/registry/test/components/previews/ui/password_input_preview.rb +21 -0
- data/registry/test/components/previews/ui/popover_preview/default.html.erb +7 -0
- data/registry/test/components/previews/ui/popover_preview/positions.html.erb +30 -0
- data/registry/test/components/previews/ui/popover_preview/with_close_button.html.erb +8 -0
- data/registry/test/components/previews/ui/popover_preview/with_rich_content.html.erb +17 -0
- data/registry/test/components/previews/ui/popover_preview/without_title.html.erb +9 -0
- data/registry/test/components/previews/ui/popover_preview.rb +32 -0
- data/registry/test/components/previews/ui/radio_group_preview/default.html.erb +10 -0
- data/registry/test/components/previews/ui/radio_group_preview/disabled.html.erb +17 -0
- data/registry/test/components/previews/ui/radio_group_preview/with_required.html.erb +10 -0
- data/registry/test/components/previews/ui/radio_group_preview.rb +25 -0
- data/registry/test/components/previews/ui/select_preview/default.html.erb +4 -0
- data/registry/test/components/previews/ui/select_preview/long_list.html.erb +5 -0
- data/registry/test/components/previews/ui/select_preview/multiple.html.erb +6 -0
- data/registry/test/components/previews/ui/select_preview/sizes.html.erb +5 -0
- data/registry/test/components/previews/ui/select_preview/states.html.erb +6 -0
- data/registry/test/components/previews/ui/select_preview.rb +45 -0
- data/registry/test/components/previews/ui/sheet_preview/bottom.html.erb +12 -0
- data/registry/test/components/previews/ui/sheet_preview/left.html.erb +10 -0
- data/registry/test/components/previews/ui/sheet_preview/playground.html.erb +15 -0
- data/registry/test/components/previews/ui/sheet_preview/right.html.erb +11 -0
- data/registry/test/components/previews/ui/sheet_preview/top.html.erb +8 -0
- data/registry/test/components/previews/ui/sheet_preview.rb +22 -0
- data/registry/test/components/previews/ui/sidebar_preview/_brand.html.erb +14 -0
- data/registry/test/components/previews/ui/sidebar_preview/_shell.html.erb +60 -0
- data/registry/test/components/previews/ui/sidebar_preview/collapsible.html.erb +55 -0
- data/registry/test/components/previews/ui/sidebar_preview/default.html.erb +17 -0
- data/registry/test/components/previews/ui/sidebar_preview/with_dropdown_header.html.erb +33 -0
- data/registry/test/components/previews/ui/sidebar_preview/with_groups.html.erb +22 -0
- data/registry/test/components/previews/ui/sidebar_preview.rb +15 -0
- data/registry/test/components/previews/ui/spinner_preview/in_buttons.html.erb +7 -0
- data/registry/test/components/previews/ui/spinner_preview/sizes.html.erb +7 -0
- data/registry/test/components/previews/ui/spinner_preview.rb +19 -0
- data/registry/test/components/previews/ui/switch_preview/default.html.erb +4 -0
- data/registry/test/components/previews/ui/switch_preview/sizes.html.erb +5 -0
- data/registry/test/components/previews/ui/switch_preview/states.html.erb +7 -0
- data/registry/test/components/previews/ui/switch_preview.rb +26 -0
- data/registry/test/components/previews/ui/table_preview/customers.html.erb +15 -0
- data/registry/test/components/previews/ui/table_preview/empty.html.erb +8 -0
- data/registry/test/components/previews/ui/table_preview/with_caption.html.erb +14 -0
- data/registry/test/components/previews/ui/table_preview.rb +12 -0
- data/registry/test/components/previews/ui/tabs_preview/default.html.erb +39 -0
- data/registry/test/components/previews/ui/tabs_preview/pill_variant.html.erb +18 -0
- data/registry/test/components/previews/ui/tabs_preview/settings_form.html.erb +42 -0
- data/registry/test/components/previews/ui/tabs_preview/with_icons.html.erb +34 -0
- data/registry/test/components/previews/ui/tabs_preview.rb +33 -0
- data/registry/test/components/previews/ui/text_preview/sizes.html.erb +10 -0
- data/registry/test/components/previews/ui/text_preview/tones.html.erb +5 -0
- data/registry/test/components/previews/ui/text_preview/weights.html.erb +6 -0
- data/registry/test/components/previews/ui/text_preview.rb +26 -0
- data/registry/test/components/previews/ui/theme_toggle_preview/in_a_header.html.erb +14 -0
- data/registry/test/components/previews/ui/theme_toggle_preview/palette.html.erb +47 -0
- data/registry/test/components/previews/ui/theme_toggle_preview.rb +15 -0
- data/registry/test/components/previews/ui/tooltip_preview/default.html.erb +8 -0
- data/registry/test/components/previews/ui/tooltip_preview/positions.html.erb +34 -0
- data/registry/test/components/previews/ui/tooltip_preview/with_button.html.erb +8 -0
- data/registry/test/components/previews/ui/tooltip_preview/with_icon.html.erb +10 -0
- data/registry/test/components/previews/ui/tooltip_preview.rb +29 -0
- data/registry/test/components/previews/ui/typography_preview/article.html.erb +11 -0
- data/registry/test/components/previews/ui/typography_preview/code_and_quotes.html.erb +6 -0
- data/registry/test/components/previews/ui/typography_preview/headings.html.erb +6 -0
- data/registry/test/components/previews/ui/typography_preview/text_styles.html.erb +7 -0
- data/registry/test/components/previews/ui/typography_preview.rb +23 -0
- data/registry/test/components/ui/accordion/content_test.rb +64 -0
- data/registry/test/components/ui/accordion/item_test.rb +61 -0
- data/registry/test/components/ui/accordion/trigger_test.rb +80 -0
- data/registry/test/components/ui/accordion_test.rb +96 -0
- data/registry/test/components/ui/alert/description_test.rb +37 -0
- data/registry/test/components/ui/alert/title_test.rb +38 -0
- data/registry/test/components/ui/alert_test.rb +184 -0
- data/registry/test/components/ui/avatar_group_test.rb +79 -0
- data/registry/test/components/ui/avatar_test.rb +129 -0
- data/registry/test/components/ui/badge_test.rb +112 -0
- data/registry/test/components/ui/banner_test.rb +116 -0
- data/registry/test/components/ui/base_test.rb +98 -0
- data/registry/test/components/ui/breadcrumb/ellipsis_test.rb +51 -0
- data/registry/test/components/ui/breadcrumb/item_test.rb +39 -0
- data/registry/test/components/ui/breadcrumb/list_test.rb +34 -0
- data/registry/test/components/ui/breadcrumb/separator_test.rb +36 -0
- data/registry/test/components/ui/breadcrumb_test.rb +276 -0
- data/registry/test/components/ui/button_test.rb +276 -0
- data/registry/test/components/ui/button_to_test.rb +74 -0
- data/registry/test/components/ui/card/content_test.rb +41 -0
- data/registry/test/components/ui/card/description_test.rb +32 -0
- data/registry/test/components/ui/card/footer_test.rb +34 -0
- data/registry/test/components/ui/card/header_test.rb +57 -0
- data/registry/test/components/ui/card/title_test.rb +34 -0
- data/registry/test/components/ui/card_test.rb +67 -0
- data/registry/test/components/ui/checkbox_test.rb +236 -0
- data/registry/test/components/ui/data_grid_test.rb +88 -0
- data/registry/test/components/ui/date_picker_test.rb +168 -0
- data/registry/test/components/ui/dialog/content_test.rb +156 -0
- data/registry/test/components/ui/dialog/trigger_test.rb +74 -0
- data/registry/test/components/ui/dialog_test.rb +54 -0
- data/registry/test/components/ui/divider_test.rb +69 -0
- data/registry/test/components/ui/icon_test.rb +82 -0
- data/registry/test/components/ui/image_test.rb +74 -0
- data/registry/test/components/ui/input_group_test.rb +143 -0
- data/registry/test/components/ui/input_test.rb +251 -0
- data/registry/test/components/ui/label_test.rb +96 -0
- data/registry/test/components/ui/link_test.rb +95 -0
- data/registry/test/components/ui/menu/content_test.rb +233 -0
- data/registry/test/components/ui/menu/group_test.rb +24 -0
- data/registry/test/components/ui/menu/item_test.rb +76 -0
- data/registry/test/components/ui/menu/label_test.rb +43 -0
- data/registry/test/components/ui/menu/separator_test.rb +32 -0
- data/registry/test/components/ui/menu/trigger_test.rb +109 -0
- data/registry/test/components/ui/menu_test.rb +152 -0
- data/registry/test/components/ui/native_select_test.rb +118 -0
- data/registry/test/components/ui/pagination_test.rb +92 -0
- data/registry/test/components/ui/password_input_test.rb +98 -0
- data/registry/test/components/ui/popover/content_test.rb +226 -0
- data/registry/test/components/ui/popover/trigger_test.rb +83 -0
- data/registry/test/components/ui/popover_test.rb +101 -0
- data/registry/test/components/ui/radio_group/item_test.rb +14 -0
- data/registry/test/components/ui/radio_group_test.rb +139 -0
- data/registry/test/components/ui/select_test.rb +181 -0
- data/registry/test/components/ui/sheet/content_test.rb +135 -0
- data/registry/test/components/ui/sheet/trigger_test.rb +23 -0
- data/registry/test/components/ui/sheet_test.rb +43 -0
- data/registry/test/components/ui/sidebar/menu_button_test.rb +43 -0
- data/registry/test/components/ui/sidebar/trigger_test.rb +17 -0
- data/registry/test/components/ui/sidebar/wrapper_test.rb +15 -0
- data/registry/test/components/ui/sidebar_test.rb +43 -0
- data/registry/test/components/ui/spinner_test.rb +63 -0
- data/registry/test/components/ui/switch_test.rb +206 -0
- data/registry/test/components/ui/table_test.rb +106 -0
- data/registry/test/components/ui/tabs/content_test.rb +93 -0
- data/registry/test/components/ui/tabs/list_test.rb +65 -0
- data/registry/test/components/ui/tabs/trigger_test.rb +159 -0
- data/registry/test/components/ui/tabs_test.rb +88 -0
- data/registry/test/components/ui/text_test.rb +84 -0
- data/registry/test/components/ui/theme_toggle_test.rb +88 -0
- data/registry/test/components/ui/tooltip/content_test.rb +135 -0
- data/registry/test/components/ui/tooltip/trigger_test.rb +52 -0
- data/registry/test/components/ui/tooltip_test.rb +97 -0
- data/registry/test/components/ui/typography/code_blockquote_test.rb +57 -0
- data/registry/test/components/ui/typography/heading_test.rb +71 -0
- data/registry/test/components/ui/typography/text_variants_test.rb +71 -0
- metadata +540 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::Icon < UI::Base
|
|
4
|
+
variants(
|
|
5
|
+
base: "inline-block shrink-0",
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
xs: "w-3 h-3",
|
|
9
|
+
sm: "w-4 h-4",
|
|
10
|
+
default: "w-5 h-5",
|
|
11
|
+
lg: "w-6 h-6",
|
|
12
|
+
xl: "w-8 h-8"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
defaults: { size: :default }
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
def initialize(name:, size: :default, label: nil, class: nil, **html_attrs)
|
|
19
|
+
@name = name
|
|
20
|
+
@size = size
|
|
21
|
+
@label = label
|
|
22
|
+
@user_class = binding.local_variable_get(:class)
|
|
23
|
+
@html_attrs = html_attrs
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def render?
|
|
27
|
+
@name.present?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def classes
|
|
31
|
+
cn(variant_classes(size: @size), @user_class)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def aria_attributes
|
|
35
|
+
if @label
|
|
36
|
+
{ label: @label }
|
|
37
|
+
else
|
|
38
|
+
{ hidden: true }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= tag.img(**html_options) %>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# UI::Image — asset-backed <img> with radius tokens and lazy loading.
|
|
4
|
+
#
|
|
5
|
+
# Replaces Velvet::Image, which wrapped every image in a Velvet::Box and passed
|
|
6
|
+
# `width:`/`height:` to that wrapper as inline styles — so the div was sized and
|
|
7
|
+
# the image itself was not. Here the dimensions land on the <img>.
|
|
8
|
+
#
|
|
9
|
+
# Usage:
|
|
10
|
+
# <%= render(UI::Image.new(src: "logo.png", rounded: :lg, width: "100px")) %>
|
|
11
|
+
class UI::Image < UI::Base
|
|
12
|
+
variants(
|
|
13
|
+
base: "block max-w-full",
|
|
14
|
+
variants: {
|
|
15
|
+
rounded: {
|
|
16
|
+
none: "rounded-none",
|
|
17
|
+
xs: "rounded-xs",
|
|
18
|
+
sm: "rounded-sm",
|
|
19
|
+
md: "rounded-md",
|
|
20
|
+
lg: "rounded-lg",
|
|
21
|
+
xl: "rounded-xl",
|
|
22
|
+
full: "rounded-full"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
defaults: { rounded: :sm }
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def initialize(src:, rounded: :sm, width: nil, height: nil, alt: nil,
|
|
29
|
+
loading: :lazy, class: nil, **html_attrs)
|
|
30
|
+
@src = src
|
|
31
|
+
@rounded = rounded
|
|
32
|
+
@width = width
|
|
33
|
+
@height = height
|
|
34
|
+
@alt = alt
|
|
35
|
+
@loading = loading
|
|
36
|
+
@user_class = binding.local_variable_get(:class)
|
|
37
|
+
@html_attrs = html_attrs
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def classes
|
|
41
|
+
cn(variant_classes(rounded: @rounded), @user_class)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Dimensions arrive as CSS strings ("100px", "14px"), so they go through
|
|
45
|
+
# `style` rather than the width/height attributes (which take bare pixels) or
|
|
46
|
+
# an interpolated Tailwind class (which the scanner cannot see).
|
|
47
|
+
def html_options
|
|
48
|
+
opts = @html_attrs.dup
|
|
49
|
+
opts[:src] = asset_path(@src)
|
|
50
|
+
opts[:class] = classes
|
|
51
|
+
opts[:alt] = @alt || default_alt
|
|
52
|
+
opts[:loading] = @loading if @loading
|
|
53
|
+
|
|
54
|
+
dimensions = []
|
|
55
|
+
dimensions << "width: #{css_length(@width)}" if @width.present?
|
|
56
|
+
dimensions << "height: #{css_length(@height)}" if @height.present?
|
|
57
|
+
unless dimensions.empty?
|
|
58
|
+
opts[:style] = [ dimensions.join("; "), opts[:style] ].compact.join("; ")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
opts
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
def css_length(value)
|
|
67
|
+
value.is_a?(Numeric) ? "#{value}px" : value
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Mirrors image_tag's behaviour so alt text does not regress to empty.
|
|
71
|
+
def default_alt
|
|
72
|
+
File.basename(@src.to_s, ".*").tr("-_", " ").capitalize
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%# frozen_string_literal: true %>
|
|
2
|
+
<% if render_label? %>
|
|
3
|
+
<div class="flex flex-col gap-2 w-full">
|
|
4
|
+
<%= render(label_component) { label_text } %>
|
|
5
|
+
<% if form_field? %><%= @form.public_send(form_builder_method, @field, **form_field_options) %><% else %><%= tag.input(**html_options) %><% end %>
|
|
6
|
+
</div>
|
|
7
|
+
<% else %>
|
|
8
|
+
<% if form_field? %><%= @form.public_send(form_builder_method, @field, **form_field_options) %><% else %><%= tag.input(**html_options) %><% end %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "securerandom"
|
|
4
|
+
|
|
5
|
+
class UI::Input < UI::Base
|
|
6
|
+
variants(
|
|
7
|
+
base: "flex w-full rounded-md border border-input bg-background " \
|
|
8
|
+
"text-foreground " \
|
|
9
|
+
"placeholder:text-muted-foreground " \
|
|
10
|
+
"#{UI::Base::FOCUS_RING} " \
|
|
11
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
12
|
+
variants: {
|
|
13
|
+
size: {
|
|
14
|
+
sm: "h-8 px-2.5 py-1 text-xs",
|
|
15
|
+
default: "h-9 px-3 py-2 text-sm",
|
|
16
|
+
lg: "h-10 px-4 py-2.5 text-base"
|
|
17
|
+
},
|
|
18
|
+
variant: {
|
|
19
|
+
default: "",
|
|
20
|
+
error: "border-destructive focus:ring-destructive",
|
|
21
|
+
with_label: ""
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaults: { size: :default, variant: :default }
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# `form:` + `field:` opt into Rails form-builder rendering (so the input gets
|
|
28
|
+
# a scoped name like `user[password]` and repopulates from the model). Without
|
|
29
|
+
# them a plain <input> is rendered and `name:` passes through html_attrs.
|
|
30
|
+
# Every type gets its own Rails helper rather than text_field with a type:
|
|
31
|
+
# option. Rails' TextField sets options["type"] ||= "text" against the
|
|
32
|
+
# STRING key, so a symbol :type never wins and the field silently renders as
|
|
33
|
+
# a plain text box — which is what date_of_birth was doing: no picker, no
|
|
34
|
+
# validation, and whatever the user typed accepted as a date.
|
|
35
|
+
BUILDER_METHODS = {
|
|
36
|
+
text: :text_field, email: :email_field, password: :password_field,
|
|
37
|
+
number: :number_field, search: :search_field, tel: :telephone_field,
|
|
38
|
+
url: :url_field, date: :date_field, time: :time_field,
|
|
39
|
+
datetime: :datetime_local_field, month: :month_field, week: :week_field,
|
|
40
|
+
color: :color_field, range: :range_field
|
|
41
|
+
}.freeze
|
|
42
|
+
|
|
43
|
+
def initialize(type: :text, size: :default, variant: :default,
|
|
44
|
+
label: nil, label_size: :default, label_weight: :medium,
|
|
45
|
+
required: false, error: false, disabled: false,
|
|
46
|
+
form: nil, field: nil,
|
|
47
|
+
class: nil, **html_attrs)
|
|
48
|
+
@form = form
|
|
49
|
+
@field = field
|
|
50
|
+
@type = type
|
|
51
|
+
@size = size
|
|
52
|
+
@variant = variant
|
|
53
|
+
@label = label
|
|
54
|
+
@label_size = label_size
|
|
55
|
+
@label_weight = label_weight
|
|
56
|
+
@required = required
|
|
57
|
+
@error = error
|
|
58
|
+
@disabled = disabled
|
|
59
|
+
@user_class = binding.local_variable_get(:class)
|
|
60
|
+
@html_attrs = html_attrs
|
|
61
|
+
@input_id = @html_attrs[:id] || (render_label? ? "ui-input-#{SecureRandom.hex(4)}" : nil)
|
|
62
|
+
@html_attrs[:id] = @input_id if @input_id
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def classes
|
|
66
|
+
cn(
|
|
67
|
+
variant_classes(size: @size, variant: @variant),
|
|
68
|
+
@user_class
|
|
69
|
+
)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def html_options
|
|
73
|
+
opts = @html_attrs.dup
|
|
74
|
+
# String key, for the same reason: Rails checks options["type"].
|
|
75
|
+
opts["type"] = @type
|
|
76
|
+
opts[:class] = classes
|
|
77
|
+
opts[:disabled] = true if @disabled
|
|
78
|
+
opts[:required] = true if @required
|
|
79
|
+
opts[:"aria-invalid"] = "true" if @error
|
|
80
|
+
opts
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def form_field?
|
|
84
|
+
@form.present? && @field.present?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# The builder derives the name itself, so drop any explicit one.
|
|
88
|
+
def form_field_options
|
|
89
|
+
html_options.except(:name, :type)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def form_builder_method
|
|
93
|
+
BUILDER_METHODS.fetch(@type.to_sym, :text_field)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Labels follow Rails' own convention: bound to a form object, the attribute
|
|
97
|
+
# name supplies the text (via human_attribute_name, so i18n and
|
|
98
|
+
# `activerecord.attributes.*` overrides apply) with no per-call-site string.
|
|
99
|
+
# Pass `label:` to override the text, or `label: false` to opt out entirely.
|
|
100
|
+
def render_label?
|
|
101
|
+
return false if @label == false
|
|
102
|
+
|
|
103
|
+
@label.present? || form_field?
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def label_text
|
|
107
|
+
return @label if @label.is_a?(String) && @label.present?
|
|
108
|
+
return nil unless form_field?
|
|
109
|
+
|
|
110
|
+
object = @form.object
|
|
111
|
+
if object.respond_to?(:class) && object.class.respond_to?(:human_attribute_name)
|
|
112
|
+
object.class.human_attribute_name(@field)
|
|
113
|
+
else
|
|
114
|
+
@field.to_s.humanize
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def label_component
|
|
119
|
+
UI::Label.new(
|
|
120
|
+
for: @input_id,
|
|
121
|
+
size: @label_size,
|
|
122
|
+
weight: @label_weight,
|
|
123
|
+
required: @required,
|
|
124
|
+
disabled: @disabled
|
|
125
|
+
)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# UI::InputGroup::Addon — positional decorator slot inside an InputGroup.
|
|
4
|
+
#
|
|
5
|
+
# align variants mirror UI::InputGroupItem:
|
|
6
|
+
# inline-start — left prefix (icon, text, button)
|
|
7
|
+
# inline-end — right suffix
|
|
8
|
+
# block-start — full-width top row (e.g. floating label)
|
|
9
|
+
# block-end — full-width bottom row (e.g. character count)
|
|
10
|
+
class UI::InputGroup::Addon < UI::Base
|
|
11
|
+
ALIGN_CLASSES = {
|
|
12
|
+
"inline-start" =>
|
|
13
|
+
"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
14
|
+
"inline-end" =>
|
|
15
|
+
"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
16
|
+
"block-start" =>
|
|
17
|
+
"order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5",
|
|
18
|
+
"block-end" =>
|
|
19
|
+
"order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5"
|
|
20
|
+
}.freeze
|
|
21
|
+
|
|
22
|
+
BASE_CLASSES =
|
|
23
|
+
"text-muted-foreground flex h-auto cursor-text items-center justify-center " \
|
|
24
|
+
"gap-2 py-1.5 text-sm font-medium select-none " \
|
|
25
|
+
"[&>svg:not([class*='size-'])]:size-4 " \
|
|
26
|
+
"group-data-[disabled=true]/input-group:opacity-50"
|
|
27
|
+
|
|
28
|
+
renders_one :icon, ->(name:, **opts) { UI::Icon.new(name: name, **opts) }
|
|
29
|
+
|
|
30
|
+
renders_one :icon_button, ->(**opts) {
|
|
31
|
+
UI::Button.new(
|
|
32
|
+
type: :button, variant: :ghost,
|
|
33
|
+
class: cn(
|
|
34
|
+
"text-sm flex gap-2 items-center h-6 gap-1 px-2",
|
|
35
|
+
"rounded-[calc(var(--radius)-5px)]",
|
|
36
|
+
"[&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2"
|
|
37
|
+
),
|
|
38
|
+
**opts
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
def initialize(align: "inline-start", class: nil, **html_attrs)
|
|
43
|
+
@align = align.to_s
|
|
44
|
+
@user_class = binding.local_variable_get(:class)
|
|
45
|
+
@html_attrs = html_attrs
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def classes
|
|
49
|
+
cn(BASE_CLASSES, ALIGN_CLASSES[@align], @user_class)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# UI::InputGroup::Field — a UI::Input variant stripped of its own
|
|
4
|
+
# border/shadow/ring so the parent wrapper owns those styles.
|
|
5
|
+
#
|
|
6
|
+
# The wrapper owns the focus treatment via :focus-within; the field strips
|
|
7
|
+
# its own outline + ring so there is no double indicator on focus.
|
|
8
|
+
class UI::InputGroup::Field < UI::Input
|
|
9
|
+
STRIPPED_CLASSES =
|
|
10
|
+
"flex-1 w-full h-9 px-3 py-2 text-sm rounded-md text-foreground " \
|
|
11
|
+
"placeholder:text-muted-foreground " \
|
|
12
|
+
"border-0! bg-transparent shadow-none! " \
|
|
13
|
+
"outline-none! focus:outline-none! focus:outline-none! focus:ring-0! " \
|
|
14
|
+
"dark:bg-transparent " \
|
|
15
|
+
"disabled:cursor-not-allowed disabled:opacity-50 disabled:bg-muted/50"
|
|
16
|
+
|
|
17
|
+
def initialize(**args)
|
|
18
|
+
super(**args)
|
|
19
|
+
@html_attrs[:data] ||= {}
|
|
20
|
+
@html_attrs[:data][:slot] = "input-group-control"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def classes
|
|
24
|
+
STRIPPED_CLASSES
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# UI::InputGroup — wrapper that visually merges a UI::Input with one or more
|
|
4
|
+
# Addon decorators (icons, text, icon-buttons). The wrapper owns the border and
|
|
5
|
+
# focus ring; the inner Field strips its own so there's no double border.
|
|
6
|
+
#
|
|
7
|
+
# The wrapper's focus ring inherits from UI::Base::FOCUS_RING (same as Button)
|
|
8
|
+
# wrapped in has-[] selectors, so changes propagate automatically.
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# <%= render(UI::InputGroup.new) do |g| %>
|
|
12
|
+
# <%= g.with_addon(align: "inline-start") { |a| a.with_icon(name: "mail") } %>
|
|
13
|
+
# <%= g.with_field(type: :email, placeholder: "you@example.com") %>
|
|
14
|
+
# <% end %>
|
|
15
|
+
class UI::InputGroup < UI::Base
|
|
16
|
+
# Wrapper owns the focus ring via :focus-within so it lights up on any
|
|
17
|
+
# descendant focus (mouse click or keyboard). focus-visible is too narrow.
|
|
18
|
+
WRAPPER_BASE =
|
|
19
|
+
"group/input-group relative flex w-full items-center rounded-md border " \
|
|
20
|
+
"border-input bg-background " \
|
|
21
|
+
"transition-all " \
|
|
22
|
+
"h-9 min-w-0 has-[>textarea]:h-auto " \
|
|
23
|
+
"has-[>[data-align=inline-start]]:[&>input]:pl-2 " \
|
|
24
|
+
"has-[>[data-align=inline-end]]:[&>input]:pr-2 " \
|
|
25
|
+
"has-[>[data-align=block-start]]:h-auto " \
|
|
26
|
+
"has-[>[data-align=block-start]]:flex-col " \
|
|
27
|
+
"has-[>[data-align=block-start]]:[&>input]:pb-3 " \
|
|
28
|
+
"has-[>[data-align=block-end]]:h-auto " \
|
|
29
|
+
"has-[>[data-align=block-end]]:flex-col " \
|
|
30
|
+
"has-[>[data-align=block-end]]:[&>input]:pt-3 " \
|
|
31
|
+
"focus-within:ring-2 " \
|
|
32
|
+
"focus-within:ring-primary " \
|
|
33
|
+
"focus-within:ring-offset-1 " \
|
|
34
|
+
"ring-offset-background " \
|
|
35
|
+
"has-[[data-slot][aria-invalid=true]:not(:has(input:disabled))]:border-destructive " \
|
|
36
|
+
"has-[[data-slot][aria-invalid=true]:not(:has(input:disabled))]:ring-destructive " \
|
|
37
|
+
"has-[input:disabled]:border-input " \
|
|
38
|
+
"has-[input:disabled]:bg-muted " \
|
|
39
|
+
"has-[input:disabled]:opacity-50"
|
|
40
|
+
|
|
41
|
+
renders_many :addons, UI::InputGroup::Addon
|
|
42
|
+
|
|
43
|
+
renders_one :field, UI::InputGroup::Field
|
|
44
|
+
|
|
45
|
+
def initialize(class: nil, **html_attrs)
|
|
46
|
+
@user_class = binding.local_variable_get(:class)
|
|
47
|
+
@html_attrs = html_attrs
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def wrapper_classes
|
|
51
|
+
# Propagate error styling to the wrapper when the field is in error state.
|
|
52
|
+
error = field&.instance_variable_get(:@error)
|
|
53
|
+
cn(WRAPPER_BASE, { "border-destructive" => error }, @user_class)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::Label < UI::Base
|
|
4
|
+
variants(
|
|
5
|
+
base: "leading-none",
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
xs: "text-xs",
|
|
9
|
+
sm: "text-sm",
|
|
10
|
+
default: "text-sm",
|
|
11
|
+
lg: "text-base"
|
|
12
|
+
},
|
|
13
|
+
weight: {
|
|
14
|
+
normal: "font-normal",
|
|
15
|
+
medium: "font-medium",
|
|
16
|
+
semibold: "font-semibold"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
defaults: { size: :default, weight: :medium }
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
def initialize(size: :default, weight: :medium,
|
|
23
|
+
required: false, disabled: false,
|
|
24
|
+
for: nil, class: nil, **html_attrs)
|
|
25
|
+
@size = size
|
|
26
|
+
@weight = weight
|
|
27
|
+
@required = required
|
|
28
|
+
@disabled = disabled
|
|
29
|
+
@for = binding.local_variable_get(:for)
|
|
30
|
+
@user_class = binding.local_variable_get(:class)
|
|
31
|
+
@html_attrs = html_attrs
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def classes
|
|
35
|
+
cn(
|
|
36
|
+
variant_classes(size: @size, weight: @weight),
|
|
37
|
+
{ "text-muted-foreground cursor-not-allowed" => @disabled },
|
|
38
|
+
@user_class
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def html_options
|
|
43
|
+
opts = @html_attrs.dup
|
|
44
|
+
opts[:for] = @for if @for
|
|
45
|
+
opts[:class] = classes
|
|
46
|
+
opts
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= link_to @href, **html_options do %><% if leading_icon? %><%= leading_icon %><% end %><%= content %><% if trailing_icon? %><%= trailing_icon %><% end %><% end %>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::Link < UI::Base
|
|
4
|
+
ICON_SIZE_FOR_LINK_SIZE = {
|
|
5
|
+
sm: :xs,
|
|
6
|
+
default: :sm,
|
|
7
|
+
lg: :default
|
|
8
|
+
}.freeze
|
|
9
|
+
|
|
10
|
+
variants(
|
|
11
|
+
base: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm text-sm font-medium " \
|
|
12
|
+
"#{UI::Base::FOCUS_RING}",
|
|
13
|
+
variants: {
|
|
14
|
+
variant: {
|
|
15
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
16
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
17
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus:ring-destructive",
|
|
18
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
19
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
20
|
+
ghost: "hover:bg-accent hover:text-accent-foreground"
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
sm: "h-8 rounded-sm px-3 text-xs",
|
|
24
|
+
default: "h-9 px-4 py-2",
|
|
25
|
+
lg: "h-10 rounded-sm px-8"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
defaults: { variant: :link, size: :default }
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
renders_one :leading_icon, ->(name:, size: nil, **opts) {
|
|
32
|
+
UI::Icon.new(name: name, size: size || ICON_SIZE_FOR_LINK_SIZE.fetch(@size, :default), **opts)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
renders_one :trailing_icon, ->(name:, size: nil, **opts) {
|
|
36
|
+
UI::Icon.new(name: name, size: size || ICON_SIZE_FOR_LINK_SIZE.fetch(@size, :default), **opts)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def initialize(href: "#", variant: :link, size: :default, button_variant: false, truncate: false, class: nil, **html_attrs)
|
|
40
|
+
@href = href
|
|
41
|
+
@variant = variant
|
|
42
|
+
@size = size
|
|
43
|
+
@button_variant = button_variant
|
|
44
|
+
@truncate = truncate
|
|
45
|
+
@user_class = binding.local_variable_get(:class)
|
|
46
|
+
@html_attrs = html_attrs
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def classes
|
|
50
|
+
base = if @button_variant
|
|
51
|
+
variant_classes(variant: @variant, size: @size)
|
|
52
|
+
else
|
|
53
|
+
cn(self.class.variant_config[:base], self.class.variant_config[:variants][:variant][:link])
|
|
54
|
+
end
|
|
55
|
+
cn(base, { "max-w-32 truncate" => @truncate }, @user_class)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def html_options
|
|
59
|
+
opts = @html_attrs.dup
|
|
60
|
+
opts[:href] = @href
|
|
61
|
+
opts[:class] = classes
|
|
62
|
+
opts
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::Menu::Content < UI::Base
|
|
4
|
+
variants(
|
|
5
|
+
base: "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md flex flex-col gap-[5px] " \
|
|
6
|
+
"animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 " \
|
|
7
|
+
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 " \
|
|
8
|
+
"data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
9
|
+
variants: {
|
|
10
|
+
side: {
|
|
11
|
+
top: "",
|
|
12
|
+
bottom: "",
|
|
13
|
+
left: "",
|
|
14
|
+
right: ""
|
|
15
|
+
},
|
|
16
|
+
align: {
|
|
17
|
+
start: "",
|
|
18
|
+
center: "",
|
|
19
|
+
end: ""
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
defaults: { side: :bottom, align: :start }
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def initialize(side: :bottom, align: :start, class: nil, **html_attrs)
|
|
26
|
+
@side = side
|
|
27
|
+
@align = align
|
|
28
|
+
@user_class = binding.local_variable_get(:class)
|
|
29
|
+
@html_attrs = html_attrs
|
|
30
|
+
@items = []
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def set_menu_context(menu)
|
|
34
|
+
@menu = menu
|
|
35
|
+
@id = @html_attrs[:id] || "ui-menu-content-#{menu.id}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def before_render
|
|
39
|
+
content
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def with_item(label = nil, href: nil, disabled: false, variant: :default, inset: false, **opts, &block)
|
|
43
|
+
item_class = opts.delete(:class)
|
|
44
|
+
@items << {
|
|
45
|
+
type: :item,
|
|
46
|
+
comp: UI::Menu::Item.new(
|
|
47
|
+
label,
|
|
48
|
+
href: href,
|
|
49
|
+
disabled: disabled,
|
|
50
|
+
variant: variant,
|
|
51
|
+
inset: inset,
|
|
52
|
+
class: item_class,
|
|
53
|
+
**opts,
|
|
54
|
+
&block
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def with_label(label = nil, inset: false, **opts, &block)
|
|
60
|
+
label_class = opts.delete(:class)
|
|
61
|
+
@items << {
|
|
62
|
+
type: :label,
|
|
63
|
+
comp: UI::Menu::Label.new(
|
|
64
|
+
label,
|
|
65
|
+
inset: inset,
|
|
66
|
+
class: label_class,
|
|
67
|
+
**opts,
|
|
68
|
+
&block
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def with_divider(**opts)
|
|
74
|
+
sep_class = opts.delete(:class)
|
|
75
|
+
@items << {
|
|
76
|
+
type: :separator,
|
|
77
|
+
comp: UI::Menu::Separator.new(
|
|
78
|
+
class: sep_class,
|
|
79
|
+
**opts
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def classes
|
|
85
|
+
cn(
|
|
86
|
+
variant_classes(side: @side, align: @align),
|
|
87
|
+
@user_class
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def html_options
|
|
92
|
+
opts = @html_attrs.dup
|
|
93
|
+
opts[:id] = @id
|
|
94
|
+
opts[:class] = classes
|
|
95
|
+
opts[:role] = :menu
|
|
96
|
+
opts[:"aria-orientation"] = :vertical
|
|
97
|
+
opts[:"data-ui--menu-target"] = "content"
|
|
98
|
+
opts[:hidden] = true
|
|
99
|
+
opts[:"data-side"] = @side
|
|
100
|
+
opts[:"data-align"] = @align
|
|
101
|
+
opts[:tabindex] = -1
|
|
102
|
+
opts
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
attr_reader :side, :align, :items
|
|
106
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= tag.div(**html_options) do %><%= content %><% end %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UI::Menu::Group < UI::Base
|
|
4
|
+
def initialize(class: nil, **html_attrs)
|
|
5
|
+
@user_class = binding.local_variable_get(:class)
|
|
6
|
+
@html_attrs = html_attrs
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def classes
|
|
10
|
+
cn(@user_class)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def html_options
|
|
14
|
+
opts = @html_attrs.dup
|
|
15
|
+
opts[:class] = classes
|
|
16
|
+
opts[:role] = :group
|
|
17
|
+
opts
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= tag.public_send(tag_name, **html_options, **href_attr) do %><%= render_label %><% end %>
|