velvetkit 0.2.2 → 0.4.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 +4 -4
- data/CHANGELOG.md +80 -0
- data/README.md +30 -8
- data/lib/generators/velvetkit/add/add_generator.rb +77 -0
- data/lib/generators/velvetkit/helpers.rb +29 -2
- data/lib/generators/velvetkit/icons/icons_generator.rb +71 -0
- data/lib/generators/velvetkit/install/install_generator.rb +9 -12
- data/lib/velvetkit/icons.rb +148 -0
- data/lib/velvetkit/registry.rb +5 -2
- data/lib/velvetkit/version.rb +4 -1
- data/lib/velvetkit.rb +8 -0
- data/registry/app/assets/tailwind/velvetkit.css +90 -155
- data/registry/app/components/ui/alert.rb +1 -1
- data/registry/app/components/ui/chart.html.erb +47 -0
- data/registry/app/components/ui/chart.rb +177 -0
- data/registry/app/components/ui/command/group.rb +27 -0
- data/registry/app/components/ui/command/item.rb +64 -0
- data/registry/app/components/ui/command.html.erb +41 -0
- data/registry/app/components/ui/command.rb +122 -0
- data/registry/app/components/ui/confirm_dialog.html.erb +13 -0
- data/registry/app/components/ui/confirm_dialog.rb +55 -0
- data/registry/app/components/ui/date_picker.html.erb +58 -64
- data/registry/app/components/ui/date_picker.rb +199 -75
- data/registry/app/components/ui/empty_state.html.erb +20 -0
- data/registry/app/components/ui/empty_state.rb +46 -0
- data/registry/app/components/ui/file_field.html.erb +14 -4
- data/registry/app/components/ui/file_field.rb +179 -28
- data/registry/app/components/ui/gallery/image.rb +20 -0
- data/registry/app/components/ui/gallery.html.erb +52 -0
- data/registry/app/components/ui/gallery.rb +164 -0
- data/registry/app/components/ui/icon.html.erb +1 -1
- data/registry/app/components/ui/icon.rb +80 -8
- data/registry/app/components/ui/kbd.html.erb +27 -0
- data/registry/app/components/ui/kbd.rb +134 -0
- data/registry/app/components/ui/number_input.html.erb +11 -0
- data/registry/app/components/ui/number_input.rb +103 -0
- data/registry/app/components/ui/password_input.html.erb +1 -1
- data/registry/app/components/ui/progress/segment.rb +25 -0
- data/registry/app/components/ui/progress.html.erb +25 -0
- data/registry/app/components/ui/progress.rb +182 -0
- data/registry/app/components/ui/select.html.erb +24 -5
- data/registry/app/components/ui/select.rb +44 -5
- data/registry/app/components/ui/stepper/step.html.erb +27 -0
- data/registry/app/components/ui/stepper/step.rb +213 -0
- data/registry/app/components/ui/stepper.html.erb +19 -0
- data/registry/app/components/ui/stepper.rb +145 -0
- data/registry/app/components/ui/theme_toggle.rb +2 -4
- data/registry/app/components/ui/timeline/item.html.erb +21 -0
- data/registry/app/components/ui/timeline/item.rb +145 -0
- data/registry/app/components/ui/timeline.html.erb +1 -0
- data/registry/app/components/ui/timeline.rb +42 -0
- data/registry/app/components/ui/toast.rb +6 -6
- data/registry/app/components/ui/toggle_group/item.html.erb +1 -0
- data/registry/app/components/ui/toggle_group/item.rb +85 -0
- data/registry/app/components/ui/toggle_group.html.erb +1 -0
- data/registry/app/components/ui/toggle_group.rb +79 -0
- data/registry/app/javascript/chart_js.ts +37 -0
- data/registry/app/javascript/controllers/ui/_internal/date_format.ts +74 -0
- data/registry/app/javascript/controllers/ui/_internal/shortcut.ts +80 -0
- data/registry/app/javascript/controllers/ui/chart_controller.ts +585 -0
- data/registry/app/javascript/controllers/ui/command_controller.ts +454 -0
- data/registry/app/javascript/controllers/ui/confirm_dialog_controller.ts +110 -0
- data/registry/app/javascript/controllers/ui/date_picker_controller.ts +247 -82
- data/registry/app/javascript/controllers/ui/file_field_controller.ts +288 -16
- data/registry/app/javascript/controllers/ui/gallery_controller.ts +568 -0
- data/registry/app/javascript/controllers/ui/kbd_controller.ts +60 -0
- data/registry/app/javascript/controllers/ui/number_input_controller.ts +111 -0
- data/registry/app/javascript/controllers/ui/progress_controller.ts +87 -0
- data/registry/app/javascript/controllers/ui/select_controller.ts +198 -8
- data/registry/app/javascript/controllers/ui/stepper_controller.ts +187 -0
- data/registry/app/javascript/vanilla_calendar.ts +15 -0
- data/registry/components.yml +28 -5
- data/registry/config/locales/velvetkit.en.yml +84 -0
- data/registry/docs/agents.md +7 -4
- data/registry/icons/lucide/LICENSE +39 -0
- data/registry/icons/lucide/align-center.svg +17 -0
- data/registry/icons/lucide/align-left.svg +17 -0
- data/registry/icons/lucide/align-right.svg +17 -0
- data/registry/icons/lucide/arrow-left.svg +16 -0
- data/registry/icons/lucide/arrow-right.svg +16 -0
- data/registry/icons/lucide/badge-check.svg +16 -0
- data/registry/icons/lucide/bar-chart-3.svg +18 -0
- data/registry/icons/lucide/bell.svg +16 -0
- data/registry/icons/lucide/bold.svg +15 -0
- data/registry/icons/lucide/book-open.svg +16 -0
- data/registry/icons/lucide/calendar.svg +18 -0
- data/registry/icons/lucide/chart-column.svg +18 -0
- data/registry/icons/lucide/check.svg +15 -0
- data/registry/icons/lucide/chevron-down.svg +15 -0
- data/registry/icons/lucide/chevron-left.svg +15 -0
- data/registry/icons/lucide/chevron-right.svg +15 -0
- data/registry/icons/lucide/chevrons-up-down.svg +16 -0
- data/registry/icons/lucide/circle-alert.svg +17 -0
- data/registry/icons/lucide/circle-check.svg +16 -0
- data/registry/icons/lucide/cloud.svg +15 -0
- data/registry/icons/lucide/credit-card.svg +16 -0
- data/registry/icons/lucide/download.svg +17 -0
- data/registry/icons/lucide/ellipsis-vertical.svg +17 -0
- data/registry/icons/lucide/ellipsis.svg +17 -0
- data/registry/icons/lucide/eye-off.svg +18 -0
- data/registry/icons/lucide/eye.svg +16 -0
- data/registry/icons/lucide/file-plus.svg +18 -0
- data/registry/icons/lucide/file-text.svg +19 -0
- data/registry/icons/lucide/file.svg +16 -0
- data/registry/icons/lucide/folder-kanban.svg +18 -0
- data/registry/icons/lucide/folder.svg +15 -0
- data/registry/icons/lucide/git-branch.svg +18 -0
- data/registry/icons/lucide/globe.svg +17 -0
- data/registry/icons/lucide/graduation-cap.svg +17 -0
- data/registry/icons/lucide/grip-vertical.svg +20 -0
- data/registry/icons/lucide/home.svg +16 -0
- data/registry/icons/lucide/inbox.svg +16 -0
- data/registry/icons/lucide/info.svg +17 -0
- data/registry/icons/lucide/italic.svg +17 -0
- data/registry/icons/lucide/keyboard.svg +23 -0
- data/registry/icons/lucide/layout-dashboard.svg +18 -0
- data/registry/icons/lucide/layout-grid.svg +18 -0
- data/registry/icons/lucide/life-buoy.svg +20 -0
- data/registry/icons/lucide/list.svg +20 -0
- data/registry/icons/lucide/loader.svg +22 -0
- data/registry/icons/lucide/lock.svg +16 -0
- data/registry/icons/lucide/log-out.svg +17 -0
- data/registry/icons/lucide/mail.svg +16 -0
- data/registry/icons/lucide/menu.svg +17 -0
- data/registry/icons/lucide/message-circle.svg +15 -0
- data/registry/icons/lucide/minus.svg +15 -0
- data/registry/icons/lucide/monitor.svg +17 -0
- data/registry/icons/lucide/moon.svg +15 -0
- data/registry/icons/lucide/newspaper.svg +18 -0
- data/registry/icons/lucide/package.svg +18 -0
- data/registry/icons/lucide/panel-left.svg +16 -0
- data/registry/icons/lucide/pause.svg +16 -0
- data/registry/icons/lucide/percent.svg +17 -0
- data/registry/icons/lucide/plus.svg +16 -0
- data/registry/icons/lucide/printer.svg +17 -0
- data/registry/icons/lucide/qr-code.svg +26 -0
- data/registry/icons/lucide/receipt.svg +17 -0
- data/registry/icons/lucide/rocket.svg +18 -0
- data/registry/icons/lucide/rotate-cw.svg +16 -0
- data/registry/icons/lucide/search.svg +16 -0
- data/registry/icons/lucide/settings.svg +16 -0
- data/registry/icons/lucide/shield-check.svg +16 -0
- data/registry/icons/lucide/shield.svg +15 -0
- data/registry/icons/lucide/store.svg +17 -0
- data/registry/icons/lucide/sun-moon.svg +19 -0
- data/registry/icons/lucide/sun.svg +23 -0
- data/registry/icons/lucide/trash-2.svg +19 -0
- data/registry/icons/lucide/truck.svg +19 -0
- data/registry/icons/lucide/underline.svg +16 -0
- data/registry/icons/lucide/upload.svg +17 -0
- data/registry/icons/lucide/user-plus.svg +18 -0
- data/registry/icons/lucide/user.svg +16 -0
- data/registry/icons/lucide/users.svg +18 -0
- data/registry/icons/lucide/workflow.svg +17 -0
- data/registry/icons/lucide/x.svg +16 -0
- data/registry/icons/lucide/zoom-in.svg +18 -0
- data/registry/icons/lucide/zoom-out.svg +17 -0
- data/registry/icons/phosphor/LICENSE +21 -0
- data/registry/icons/phosphor/arrow-clockwise.svg +2 -0
- data/registry/icons/phosphor/arrow-left.svg +2 -0
- data/registry/icons/phosphor/arrow-right.svg +2 -0
- data/registry/icons/phosphor/bell.svg +2 -0
- data/registry/icons/phosphor/book-open.svg +2 -0
- data/registry/icons/phosphor/calendar-blank.svg +2 -0
- data/registry/icons/phosphor/caret-down.svg +2 -0
- data/registry/icons/phosphor/caret-left.svg +2 -0
- data/registry/icons/phosphor/caret-right.svg +2 -0
- data/registry/icons/phosphor/caret-up-down.svg +2 -0
- data/registry/icons/phosphor/chart-bar.svg +2 -0
- data/registry/icons/phosphor/chat-circle.svg +2 -0
- data/registry/icons/phosphor/check-circle.svg +2 -0
- data/registry/icons/phosphor/check.svg +2 -0
- data/registry/icons/phosphor/circle-half.svg +2 -0
- data/registry/icons/phosphor/cloud.svg +2 -0
- data/registry/icons/phosphor/credit-card.svg +2 -0
- data/registry/icons/phosphor/desktop.svg +2 -0
- data/registry/icons/phosphor/dots-six-vertical.svg +2 -0
- data/registry/icons/phosphor/dots-three-vertical.svg +2 -0
- data/registry/icons/phosphor/dots-three.svg +2 -0
- data/registry/icons/phosphor/download-simple.svg +2 -0
- data/registry/icons/phosphor/envelope.svg +2 -0
- data/registry/icons/phosphor/eye-slash.svg +2 -0
- data/registry/icons/phosphor/eye.svg +2 -0
- data/registry/icons/phosphor/file-plus.svg +2 -0
- data/registry/icons/phosphor/file-text.svg +2 -0
- data/registry/icons/phosphor/file.svg +2 -0
- data/registry/icons/phosphor/flow-arrow.svg +2 -0
- data/registry/icons/phosphor/folder.svg +2 -0
- data/registry/icons/phosphor/gear.svg +2 -0
- data/registry/icons/phosphor/git-branch.svg +2 -0
- data/registry/icons/phosphor/globe.svg +2 -0
- data/registry/icons/phosphor/graduation-cap.svg +2 -0
- data/registry/icons/phosphor/grid-four.svg +2 -0
- data/registry/icons/phosphor/house.svg +2 -0
- data/registry/icons/phosphor/info.svg +2 -0
- data/registry/icons/phosphor/kanban.svg +2 -0
- data/registry/icons/phosphor/keyboard.svg +2 -0
- data/registry/icons/phosphor/lifebuoy.svg +2 -0
- data/registry/icons/phosphor/list.svg +2 -0
- data/registry/icons/phosphor/lock.svg +2 -0
- data/registry/icons/phosphor/magnifying-glass-minus.svg +2 -0
- data/registry/icons/phosphor/magnifying-glass-plus.svg +2 -0
- data/registry/icons/phosphor/magnifying-glass.svg +2 -0
- data/registry/icons/phosphor/minus.svg +2 -0
- data/registry/icons/phosphor/moon.svg +2 -0
- data/registry/icons/phosphor/newspaper.svg +2 -0
- data/registry/icons/phosphor/package.svg +2 -0
- data/registry/icons/phosphor/pause.svg +2 -0
- data/registry/icons/phosphor/percent.svg +2 -0
- data/registry/icons/phosphor/plus.svg +2 -0
- data/registry/icons/phosphor/printer.svg +2 -0
- data/registry/icons/phosphor/qr-code.svg +2 -0
- data/registry/icons/phosphor/receipt.svg +2 -0
- data/registry/icons/phosphor/rocket.svg +2 -0
- data/registry/icons/phosphor/seal-check.svg +2 -0
- data/registry/icons/phosphor/shield-check.svg +2 -0
- data/registry/icons/phosphor/shield.svg +2 -0
- data/registry/icons/phosphor/sidebar.svg +2 -0
- data/registry/icons/phosphor/sign-out.svg +2 -0
- data/registry/icons/phosphor/spinner.svg +2 -0
- data/registry/icons/phosphor/squares-four.svg +2 -0
- data/registry/icons/phosphor/storefront.svg +2 -0
- data/registry/icons/phosphor/sun.svg +2 -0
- data/registry/icons/phosphor/text-align-center.svg +2 -0
- data/registry/icons/phosphor/text-align-left.svg +2 -0
- data/registry/icons/phosphor/text-align-right.svg +2 -0
- data/registry/icons/phosphor/text-b.svg +2 -0
- data/registry/icons/phosphor/text-italic.svg +2 -0
- data/registry/icons/phosphor/text-underline.svg +2 -0
- data/registry/icons/phosphor/trash.svg +2 -0
- data/registry/icons/phosphor/tray.svg +2 -0
- data/registry/icons/phosphor/truck.svg +2 -0
- data/registry/icons/phosphor/upload-simple.svg +2 -0
- data/registry/icons/phosphor/user-plus.svg +2 -0
- data/registry/icons/phosphor/user.svg +2 -0
- data/registry/icons/phosphor/users.svg +2 -0
- data/registry/icons/phosphor/warning-circle.svg +2 -0
- data/registry/icons/phosphor/x.svg +2 -0
- data/registry/icons/tabler/LICENSE +21 -0
- data/registry/icons/tabler/alert-circle.svg +18 -0
- data/registry/icons/tabler/align-center.svg +18 -0
- data/registry/icons/tabler/align-left.svg +18 -0
- data/registry/icons/tabler/align-right.svg +18 -0
- data/registry/icons/tabler/arrow-left.svg +18 -0
- data/registry/icons/tabler/arrow-right.svg +18 -0
- data/registry/icons/tabler/bell.svg +17 -0
- data/registry/icons/tabler/bold.svg +17 -0
- data/registry/icons/tabler/book.svg +20 -0
- data/registry/icons/tabler/building-store.svg +20 -0
- data/registry/icons/tabler/calendar.svg +21 -0
- data/registry/icons/tabler/chart-bar.svg +19 -0
- data/registry/icons/tabler/check.svg +16 -0
- data/registry/icons/tabler/chevron-down.svg +16 -0
- data/registry/icons/tabler/chevron-left.svg +16 -0
- data/registry/icons/tabler/chevron-right.svg +16 -0
- data/registry/icons/tabler/circle-check.svg +17 -0
- data/registry/icons/tabler/cloud.svg +16 -0
- data/registry/icons/tabler/credit-card.svg +19 -0
- data/registry/icons/tabler/device-desktop.svg +19 -0
- data/registry/icons/tabler/dots-vertical.svg +18 -0
- data/registry/icons/tabler/dots.svg +18 -0
- data/registry/icons/tabler/download.svg +18 -0
- data/registry/icons/tabler/eye-off.svg +18 -0
- data/registry/icons/tabler/eye.svg +17 -0
- data/registry/icons/tabler/file-plus.svg +19 -0
- data/registry/icons/tabler/file-text.svg +20 -0
- data/registry/icons/tabler/file.svg +17 -0
- data/registry/icons/tabler/folder.svg +16 -0
- data/registry/icons/tabler/git-branch.svg +21 -0
- data/registry/icons/tabler/grip-vertical.svg +21 -0
- data/registry/icons/tabler/home.svg +18 -0
- data/registry/icons/tabler/inbox.svg +17 -0
- data/registry/icons/tabler/info-circle.svg +18 -0
- data/registry/icons/tabler/italic.svg +18 -0
- data/registry/icons/tabler/keyboard.svg +23 -0
- data/registry/icons/tabler/layout-dashboard.svg +19 -0
- data/registry/icons/tabler/layout-grid.svg +19 -0
- data/registry/icons/tabler/layout-kanban.svg +19 -0
- data/registry/icons/tabler/layout-sidebar.svg +17 -0
- data/registry/icons/tabler/lifebuoy.svg +21 -0
- data/registry/icons/tabler/list.svg +21 -0
- data/registry/icons/tabler/loader.svg +23 -0
- data/registry/icons/tabler/lock.svg +18 -0
- data/registry/icons/tabler/logout.svg +18 -0
- data/registry/icons/tabler/mail.svg +17 -0
- data/registry/icons/tabler/menu-2.svg +18 -0
- data/registry/icons/tabler/message-circle.svg +16 -0
- data/registry/icons/tabler/minus.svg +16 -0
- data/registry/icons/tabler/moon.svg +16 -0
- data/registry/icons/tabler/news.svg +19 -0
- data/registry/icons/tabler/package.svg +20 -0
- data/registry/icons/tabler/percentage.svg +18 -0
- data/registry/icons/tabler/player-pause.svg +17 -0
- data/registry/icons/tabler/plus.svg +17 -0
- data/registry/icons/tabler/printer.svg +18 -0
- data/registry/icons/tabler/qrcode.svg +27 -0
- data/registry/icons/tabler/receipt.svg +16 -0
- data/registry/icons/tabler/rocket.svg +18 -0
- data/registry/icons/tabler/rosette-discount-check.svg +17 -0
- data/registry/icons/tabler/rotate-clockwise.svg +16 -0
- data/registry/icons/tabler/school.svg +17 -0
- data/registry/icons/tabler/search.svg +17 -0
- data/registry/icons/tabler/selector.svg +17 -0
- data/registry/icons/tabler/settings.svg +17 -0
- data/registry/icons/tabler/shield-check.svg +17 -0
- data/registry/icons/tabler/shield.svg +16 -0
- data/registry/icons/tabler/sitemap.svg +20 -0
- data/registry/icons/tabler/sun-moon.svg +21 -0
- data/registry/icons/tabler/sun.svg +17 -0
- data/registry/icons/tabler/trash.svg +20 -0
- data/registry/icons/tabler/truck.svg +18 -0
- data/registry/icons/tabler/underline.svg +17 -0
- data/registry/icons/tabler/upload.svg +18 -0
- data/registry/icons/tabler/user-plus.svg +19 -0
- data/registry/icons/tabler/user.svg +17 -0
- data/registry/icons/tabler/users.svg +19 -0
- data/registry/icons/tabler/world.svg +20 -0
- data/registry/icons/tabler/x.svg +17 -0
- data/registry/icons/tabler/zoom-in.svg +19 -0
- data/registry/icons/tabler/zoom-out.svg +18 -0
- data/registry/icons.yml +90 -0
- data/registry/test/components/previews/ui/chart_preview/cash_flow.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/donut.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/margin.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/pie.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/sales.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/stock.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/takings.html.erb +8 -0
- data/registry/test/components/previews/ui/chart_preview.rb +46 -0
- data/registry/test/components/previews/ui/command_preview/_picked.html.erb +14 -0
- data/registry/test/components/previews/ui/command_preview/dialog.html.erb +24 -0
- data/registry/test/components/previews/ui/command_preview/inline.html.erb +16 -0
- data/registry/test/components/previews/ui/command_preview/playground.html.erb +15 -0
- data/registry/test/components/previews/ui/command_preview/server_search.html.erb +24 -0
- data/registry/test/components/previews/ui/command_preview/shortcuts.html.erb +12 -0
- data/registry/test/components/previews/ui/command_preview/till.html.erb +17 -0
- data/registry/test/components/previews/ui/command_preview.rb +25 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/destructive.html.erb +7 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/in_form.html.erb +6 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/on_link.html.erb +5 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/plain.html.erb +3 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/with_description.html.erb +4 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview.rb +20 -0
- data/registry/test/components/previews/ui/date_picker_preview/custom_presets.html.erb +6 -0
- data/registry/test/components/previews/ui/date_picker_preview/in_form.html.erb +11 -0
- data/registry/test/components/previews/ui/date_picker_preview/range.html.erb +5 -0
- data/registry/test/components/previews/ui/date_picker_preview/states.html.erb +4 -3
- data/registry/test/components/previews/ui/date_picker_preview.rb +26 -6
- data/registry/test/components/previews/ui/empty_state_preview/in_card.html.erb +7 -0
- data/registry/test/components/previews/ui/empty_state_preview/no_results.html.erb +3 -0
- data/registry/test/components/previews/ui/empty_state_preview/outline.html.erb +3 -0
- data/registry/test/components/previews/ui/empty_state_preview/with_actions.html.erb +4 -0
- data/registry/test/components/previews/ui/empty_state_preview/with_media.html.erb +8 -0
- data/registry/test/components/previews/ui/empty_state_preview.rb +26 -0
- data/registry/test/components/previews/ui/file_field_preview/multiple_files.html.erb +1 -1
- data/registry/test/components/previews/ui/file_field_preview/product_photos.html.erb +12 -0
- data/registry/test/components/previews/ui/file_field_preview/single_image.html.erb +4 -0
- data/registry/test/components/previews/ui/file_field_preview.rb +32 -5
- data/registry/test/components/previews/ui/gallery_preview/hover_zoom.html.erb +13 -0
- data/registry/test/components/previews/ui/gallery_preview/landscape.html.erb +5 -0
- data/registry/test/components/previews/ui/gallery_preview/product_page.html.erb +13 -0
- data/registry/test/components/previews/ui/gallery_preview/single.html.erb +3 -0
- data/registry/test/components/previews/ui/gallery_preview.rb +45 -0
- data/registry/test/components/previews/ui/icon_preview/common.html.erb +19 -3
- data/registry/test/components/previews/ui/icon_preview/labelled.html.erb +4 -0
- data/registry/test/components/previews/ui/icon_preview/missing.html.erb +3 -0
- data/registry/test/components/previews/ui/icon_preview.rb +18 -3
- data/registry/test/components/previews/ui/input_group_preview/playground.html.erb +2 -2
- data/registry/test/components/previews/ui/input_group_preview.rb +3 -3
- data/registry/test/components/previews/ui/kbd_preview/bound.html.erb +20 -0
- data/registry/test/components/previews/ui/kbd_preview/keys.html.erb +13 -0
- data/registry/test/components/previews/ui/kbd_preview/menu.html.erb +13 -0
- data/registry/test/components/previews/ui/kbd_preview/search_field.html.erb +8 -0
- data/registry/test/components/previews/ui/kbd_preview/shortcuts_list.html.erb +17 -0
- data/registry/test/components/previews/ui/kbd_preview/till.html.erb +23 -0
- data/registry/test/components/previews/ui/kbd_preview/tooltip_and_buttons.html.erb +14 -0
- data/registry/test/components/previews/ui/kbd_preview.rb +32 -0
- data/registry/test/components/previews/ui/number_input_preview/cart.html.erb +11 -0
- data/registry/test/components/previews/ui/number_input_preview/decimals.html.erb +4 -0
- data/registry/test/components/previews/ui/number_input_preview/sizes.html.erb +5 -0
- data/registry/test/components/previews/ui/number_input_preview/states.html.erb +7 -0
- data/registry/test/components/previews/ui/number_input_preview/stock_adjustment.html.erb +3 -0
- data/registry/test/components/previews/ui/number_input_preview.rb +36 -0
- data/registry/test/components/previews/ui/progress_preview/file_upload.html.erb +36 -0
- data/registry/test/components/previews/ui/progress_preview/free_shipping.html.erb +4 -0
- data/registry/test/components/previews/ui/progress_preview/indeterminate.html.erb +4 -0
- data/registry/test/components/previews/ui/progress_preview/sizes_and_tones.html.erb +8 -0
- data/registry/test/components/previews/ui/progress_preview/steps.html.erb +9 -0
- data/registry/test/components/previews/ui/progress_preview/storage.html.erb +8 -0
- data/registry/test/components/previews/ui/progress_preview/storage_by_category.html.erb +7 -0
- data/registry/test/components/previews/ui/progress_preview/tasks_by_status.html.erb +14 -0
- data/registry/test/components/previews/ui/progress_preview/traffic_by_source.html.erb +15 -0
- data/registry/test/components/previews/ui/progress_preview.rb +46 -0
- data/registry/test/components/previews/ui/select_preview/server_search.html.erb +22 -0
- data/registry/test/components/previews/ui/select_preview.rb +5 -0
- data/registry/test/components/previews/ui/stepper_preview/approvals.html.erb +9 -0
- data/registry/test/components/previews/ui/stepper_preview/checklist.html.erb +12 -0
- data/registry/test/components/previews/ui/stepper_preview/dot_wizard.html.erb +41 -0
- data/registry/test/components/previews/ui/stepper_preview/failed_deploy.html.erb +13 -0
- data/registry/test/components/previews/ui/stepper_preview/inline.html.erb +31 -0
- data/registry/test/components/previews/ui/stepper_preview/onboarding.html.erb +12 -0
- data/registry/test/components/previews/ui/stepper_preview/order_tracking.html.erb +10 -0
- data/registry/test/components/previews/ui/stepper_preview/price_calculator.html.erb +14 -0
- data/registry/test/components/previews/ui/stepper_preview/server_driven.html.erb +20 -0
- data/registry/test/components/previews/ui/stepper_preview/sidebar.html.erb +43 -0
- data/registry/test/components/previews/ui/stepper_preview/wizard.html.erb +55 -0
- data/registry/test/components/previews/ui/stepper_preview.rb +57 -0
- data/registry/test/components/previews/ui/timeline_preview/activity_log.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/colored.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/colored_by_meaning.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/failed_delivery.html.erb +6 -0
- data/registry/test/components/previews/ui/timeline_preview/order_status.html.erb +9 -0
- data/registry/test/components/previews/ui/timeline_preview/real_dates.html.erb +5 -0
- data/registry/test/components/previews/ui/timeline_preview/stock_history.html.erb +6 -0
- data/registry/test/components/previews/ui/timeline_preview.rb +40 -0
- data/registry/test/components/previews/ui/toggle_group_preview/icon_only.html.erb +5 -0
- data/registry/test/components/previews/ui/toggle_group_preview/in_form.html.erb +11 -0
- data/registry/test/components/previews/ui/toggle_group_preview/multiple.html.erb +5 -0
- data/registry/test/components/previews/ui/toggle_group_preview/outline.html.erb +5 -0
- data/registry/test/components/previews/ui/toggle_group_preview/sizes.html.erb +9 -0
- data/registry/test/components/previews/ui/toggle_group_preview/with_icons.html.erb +5 -0
- data/registry/test/components/previews/ui/toggle_group_preview.rb +36 -0
- data/registry/test/components/ui/accordion/trigger_test.rb +1 -1
- data/registry/test/components/ui/alert_test.rb +10 -10
- data/registry/test/components/ui/badge_test.rb +3 -3
- data/registry/test/components/ui/banner_test.rb +3 -3
- data/registry/test/components/ui/breadcrumb/ellipsis_test.rb +2 -2
- data/registry/test/components/ui/button_test.rb +17 -14
- data/registry/test/components/ui/button_to_test.rb +2 -2
- data/registry/test/components/ui/chart_test.rb +187 -0
- data/registry/test/components/ui/checkbox_test.rb +2 -2
- data/registry/test/components/ui/command/group_test.rb +19 -0
- data/registry/test/components/ui/command/item_test.rb +47 -0
- data/registry/test/components/ui/command_test.rb +110 -0
- data/registry/test/components/ui/confirm_dialog_test.rb +68 -0
- data/registry/test/components/ui/date_picker_test.rb +129 -111
- data/registry/test/components/ui/empty_state_test.rb +87 -0
- data/registry/test/components/ui/file_field_test.rb +105 -9
- data/registry/test/components/ui/gallery_test.rb +192 -0
- data/registry/test/components/ui/icon_test.rb +60 -20
- data/registry/test/components/ui/input_group_test.rb +1 -1
- data/registry/test/components/ui/kbd_test.rb +150 -0
- data/registry/test/components/ui/link_test.rb +3 -3
- data/registry/test/components/ui/navigation_menu_test.rb +2 -2
- data/registry/test/components/ui/number_input_test.rb +155 -0
- data/registry/test/components/ui/progress_test.rb +188 -0
- data/registry/test/components/ui/select_test.rb +62 -0
- data/registry/test/components/ui/session_tabs_test.rb +3 -3
- data/registry/test/components/ui/spinner_test.rb +9 -9
- data/registry/test/components/ui/stepper_test.rb +239 -0
- data/registry/test/components/ui/tabs/trigger_test.rb +2 -2
- data/registry/test/components/ui/theme_toggle_test.rb +6 -8
- data/registry/test/components/ui/timeline_test.rb +175 -0
- data/registry/test/components/ui/toast_test.rb +11 -10
- data/registry/test/components/ui/toggle_group_test.rb +162 -0
- metadata +399 -3
- data/registry/app/javascript/cally.ts +0 -8
- data/registry/app/javascript/velvetkit_icons.ts +0 -78
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class UI::NumberInputTest < ViewComponent::TestCase
|
|
6
|
+
def setup_fixtures(*); end
|
|
7
|
+
def teardown_fixtures(*); end
|
|
8
|
+
|
|
9
|
+
def render_input(**opts) = render_inline(UI::NumberInput.new(name: "quantity", **opts))
|
|
10
|
+
|
|
11
|
+
def test_renders_a_number_input_in_a_group_with_the_controller
|
|
12
|
+
render_input
|
|
13
|
+
assert_selector "[data-slot='input-group'][data-controller='ui--number-input']"
|
|
14
|
+
assert_selector "input[type='number'][name='quantity'][data-ui--number-input-target='input']"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_passes_value_and_limits_to_the_input
|
|
18
|
+
render_input(value: 3, min: 1, max: 9, step: 2)
|
|
19
|
+
assert_selector "input[value='3'][min='1'][max='9'][step='2']"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_leaves_out_limits_that_are_not_set
|
|
23
|
+
render_input
|
|
24
|
+
assert_no_selector "input[min]"
|
|
25
|
+
assert_no_selector "input[max]"
|
|
26
|
+
assert_no_selector "input[step]"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_buttons_are_named_and_point_at_the_input
|
|
30
|
+
render_input(id: "qty")
|
|
31
|
+
assert_selector "button[aria-label='Decrease'][aria-controls='qty'][data-ui--number-input-target='decrement']"
|
|
32
|
+
assert_selector "button[aria-label='Increase'][aria-controls='qty'][data-ui--number-input-target='increment']"
|
|
33
|
+
assert_selector "input#qty"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_buttons_do_not_submit_and_stay_out_of_the_tab_order
|
|
37
|
+
render_input
|
|
38
|
+
assert_selector "button[type='button'][tabindex='-1']", count: 2
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_buttons_are_wired_to_step_in_their_direction
|
|
42
|
+
render_input
|
|
43
|
+
assert_selector "button[data-ui--number-input-direction-param='down'] svg[data-icon='minus']"
|
|
44
|
+
assert_selector "button[data-ui--number-input-direction-param='up'] svg[data-icon='plus']"
|
|
45
|
+
assert_includes page.find("button[aria-label='Increase']")["data-action"], "pointerdown->ui--number-input#press"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_buttons_keep_the_kits_focus_ring
|
|
49
|
+
render_input
|
|
50
|
+
assert_selector "button.focus\\:ring-2.focus\\:ring-primary.focus\\:z-10", count: 2
|
|
51
|
+
assert_no_selector "button.focus\\:ring-0"
|
|
52
|
+
assert_no_selector "[data-slot='input-group'].overflow-hidden"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_decrease_comes_before_the_field_and_increase_after_it
|
|
56
|
+
render_input
|
|
57
|
+
assert_selector "[data-align='inline-start'] button[aria-label='Decrease']"
|
|
58
|
+
assert_selector "[data-align='inline-end'] button[aria-label='Increase']"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_label_points_at_the_field
|
|
62
|
+
render_input(label: "Quantity", id: "qty")
|
|
63
|
+
assert_selector "label[for='qty']", text: "Quantity"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_generates_an_id_for_the_label_and_buttons_to_share
|
|
67
|
+
render_input(label: "Quantity")
|
|
68
|
+
id = page.find("input")[:id]
|
|
69
|
+
assert_selector "label[for='#{id}']"
|
|
70
|
+
assert_selector "button[aria-controls='#{id}']", count: 2
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_hint_describes_the_field
|
|
74
|
+
render_input(hint: "Up to 10")
|
|
75
|
+
assert_text "Up to 10"
|
|
76
|
+
assert page.find("input")["aria-describedby"].present?
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_error_marks_the_field_invalid
|
|
80
|
+
render_input(error: "Too many")
|
|
81
|
+
assert_text "Too many"
|
|
82
|
+
assert_selector "input[aria-invalid='true']"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_disabled_turns_off_the_field_and_both_buttons
|
|
86
|
+
render_input(disabled: true)
|
|
87
|
+
assert_selector "input[disabled]"
|
|
88
|
+
assert_selector "button[disabled]", count: 2
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_readonly_keeps_the_field_and_turns_off_both_buttons
|
|
92
|
+
render_input(readonly: true)
|
|
93
|
+
assert_selector "input[readonly]"
|
|
94
|
+
assert_no_selector "input[disabled]"
|
|
95
|
+
assert_selector "button[disabled]", count: 2
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_required_reaches_the_field
|
|
99
|
+
render_input(required: true)
|
|
100
|
+
assert_selector "input[required]"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_sizes_set_the_height_of_the_group_and_width_of_the_buttons
|
|
104
|
+
{ sm: %w[h-8 w-8], default: %w[h-9 w-9], lg: %w[h-12 w-12] }.each do |size, (height, width)|
|
|
105
|
+
render_input(size: size)
|
|
106
|
+
assert_selector "[data-slot='input-group'].#{height}"
|
|
107
|
+
assert_selector "button.#{width}", count: 2
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_unknown_size_falls_back_to_default
|
|
112
|
+
render_input(size: :huge)
|
|
113
|
+
assert_selector "[data-slot='input-group'].h-9"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_keypad_suits_what_the_field_takes
|
|
117
|
+
{ { min: 0 } => "numeric", { min: 1, step: 2 } => "numeric", { step: 0.25 } => "decimal",
|
|
118
|
+
{ min: 0, step: 0.5 } => "decimal", { step: "any" } => "decimal" }.each do |opts, mode|
|
|
119
|
+
render_input(**opts)
|
|
120
|
+
assert_selector "input[inputmode='#{mode}']"
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_no_numeric_keypad_when_the_field_can_go_negative
|
|
125
|
+
render_input
|
|
126
|
+
assert_no_selector "input[inputmode]"
|
|
127
|
+
render_input(min: -5)
|
|
128
|
+
assert_no_selector "input[inputmode]"
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def test_inputmode_can_be_overridden
|
|
132
|
+
render_input(min: 0, inputmode: "text")
|
|
133
|
+
assert_selector "input[inputmode='text']"
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_data_and_actions_from_the_caller_join_the_controllers
|
|
137
|
+
render_input(data: { foo: "bar", action: "change->cart#update" })
|
|
138
|
+
input = page.find("input")
|
|
139
|
+
assert_equal "bar", input["data-foo"]
|
|
140
|
+
assert_includes input["data-action"], "change->cart#update"
|
|
141
|
+
assert_includes input["data-action"], "input->ui--number-input#sync"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def test_class_reaches_the_group
|
|
145
|
+
render_input(class: "w-32")
|
|
146
|
+
assert_selector "[data-slot='input-group'].w-32"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_form_builder_names_the_field_and_fills_it_in
|
|
150
|
+
item = Struct.new(:quantity).new(4)
|
|
151
|
+
builder = ActionView::Helpers::FormBuilder.new(:item, item, vc_test_controller.view_context, {})
|
|
152
|
+
render_inline(UI::NumberInput.new(form: builder, field: :quantity, min: 1))
|
|
153
|
+
assert_selector "input[type='number'][name='item[quantity]'][value='4'][min='1']"
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class UI::ProgressTest < ViewComponent::TestCase
|
|
6
|
+
def setup_fixtures(*); end
|
|
7
|
+
def teardown_fixtures(*); end
|
|
8
|
+
|
|
9
|
+
def render_progress(**opts) = render_inline(UI::Progress.new(**opts))
|
|
10
|
+
|
|
11
|
+
def test_renders_a_progressbar_filled_to_its_value
|
|
12
|
+
render_progress(value: 40)
|
|
13
|
+
assert_selector "[data-slot='progress'][data-controller='ui--progress']"
|
|
14
|
+
assert_selector "[role='progressbar'][aria-valuemin='0'][aria-valuemax='100'][aria-valuenow='40'][aria-valuetext='40%']"
|
|
15
|
+
assert_selector "[data-slot='progress-indicator'][style='width: 40%']"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_scales_to_max_and_says_it_with_value_text
|
|
19
|
+
render_progress(value: 3, max: 12, value_text: "%{value} of %{max} files", show_value: true)
|
|
20
|
+
assert_selector "[role='progressbar'][aria-valuenow='3'][aria-valuemax='12'][aria-valuetext='3 of 12 files']"
|
|
21
|
+
assert_selector "[data-slot='progress-indicator'][style='width: 25%']"
|
|
22
|
+
assert_selector "[data-ui--progress-target='text']", text: "3 of 12 files"
|
|
23
|
+
assert_selector "[data-ui--progress-format-value='%{value} of %{max} files']"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_rounds_down_so_it_never_says_done_too_early
|
|
27
|
+
render_progress(value: 99.7)
|
|
28
|
+
assert_selector "[role='progressbar'][aria-valuetext='99%']"
|
|
29
|
+
assert_selector "[data-slot='progress-indicator'][style='width: 99%']"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_keeps_the_value_inside_the_bar
|
|
33
|
+
render_progress(value: 150)
|
|
34
|
+
assert_selector "[role='progressbar'][aria-valuenow='100'][data-state='complete']"
|
|
35
|
+
render_progress(value: -5)
|
|
36
|
+
assert_selector "[role='progressbar'][aria-valuenow='0'][data-state='loading']"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_is_busy_until_complete
|
|
40
|
+
render_progress(value: 50)
|
|
41
|
+
assert_selector "[role='progressbar'][aria-busy='true'][data-state='loading']"
|
|
42
|
+
render_progress(value: 100)
|
|
43
|
+
assert_selector "[role='progressbar'][data-state='complete']"
|
|
44
|
+
assert_no_selector "[aria-busy]"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_with_no_value_it_shows_work_going_on_without_an_amount
|
|
48
|
+
render_progress(label: "Preparing your export", show_value: true)
|
|
49
|
+
assert_selector "[role='progressbar'][data-state='indeterminate'][aria-busy='true']"
|
|
50
|
+
assert_no_selector "[aria-valuenow]"
|
|
51
|
+
assert_no_selector "[aria-valuetext]"
|
|
52
|
+
assert_no_selector "[data-ui--progress-value-value]"
|
|
53
|
+
assert_selector "[data-slot='progress-indicator'].animate-\\[velvetkit-progress_1\\.4s_ease-in-out_infinite\\]"
|
|
54
|
+
assert_no_selector "[data-slot='progress-indicator'][style]"
|
|
55
|
+
assert_selector "[data-ui--progress-target='text'].hidden"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_the_label_names_the_bar
|
|
59
|
+
render_progress(value: 10, label: "Uploading report.pdf")
|
|
60
|
+
id = page.find("span", text: "Uploading report.pdf")["id"]
|
|
61
|
+
assert_selector "[role='progressbar'][aria-labelledby='#{id}']"
|
|
62
|
+
assert_no_selector "[role='progressbar'][aria-label]"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_without_a_label_it_has_a_default_name_that_can_be_replaced
|
|
66
|
+
render_progress(value: 10)
|
|
67
|
+
assert_selector "[role='progressbar'][aria-label='Progress']"
|
|
68
|
+
assert_no_selector "[data-slot='progress'] > div.flex"
|
|
69
|
+
render_progress(value: 10, aria: { label: "Storage used" })
|
|
70
|
+
assert_selector "[role='progressbar'][aria-label='Storage used']"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_value_is_shown_only_when_asked
|
|
74
|
+
render_progress(value: 40, label: "Profile")
|
|
75
|
+
assert_selector "[data-ui--progress-target='text'].hidden"
|
|
76
|
+
render_progress(value: 40, label: "Profile", show_value: true)
|
|
77
|
+
assert_selector "[data-ui--progress-target='text']:not(.hidden)", text: "40%"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_sizes_and_tones
|
|
81
|
+
render_progress(value: 5, size: :lg, tone: :warning)
|
|
82
|
+
assert_selector "[role='progressbar'].h-3.bg-amber-500\\/15"
|
|
83
|
+
assert_selector "[data-slot='progress-indicator'].bg-amber-500"
|
|
84
|
+
render_progress(value: 5, size: :nonsense, tone: :nonsense)
|
|
85
|
+
assert_selector "[role='progressbar'].h-2.bg-primary\\/15"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_gives_the_controller_what_it_needs_to_move_the_bar
|
|
89
|
+
render_progress(value: 2.5, max: 10)
|
|
90
|
+
assert_selector "[data-ui--progress-value-value='2.5'][data-ui--progress-max-value='10']"
|
|
91
|
+
assert_selector "[data-ui--progress-determinate-class][data-ui--progress-indeterminate-class]"
|
|
92
|
+
assert_selector "[role='progressbar'][data-ui--progress-target='bar'] [data-ui--progress-target='indicator']"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def render_storage(**opts)
|
|
96
|
+
render_inline(UI::Progress.new(max: 15, label: "Storage", value_text: "%{value} GB of %{max} GB",
|
|
97
|
+
segment_text: "%{value} GB", show_value: true, **opts)) do |progress|
|
|
98
|
+
progress.with_segment(value: 6.4, label: "Photos")
|
|
99
|
+
progress.with_segment(value: 3.1, label: "Mail")
|
|
100
|
+
progress.with_segment(value: 2, label: "Documents", color: 5)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_segments_add_up_to_the_bars_value
|
|
105
|
+
render_storage
|
|
106
|
+
assert_selector "[role='progressbar'][aria-valuenow='11.5'][aria-valuetext='11.5 GB of 15 GB']"
|
|
107
|
+
assert_selector "[data-ui--progress-target='text']", text: "11.5 GB of 15 GB"
|
|
108
|
+
assert_selector "[data-slot='progress-indicator'][style='width: 76%']"
|
|
109
|
+
assert_selector "[data-ui--progress-value-value='11.5']"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_each_segment_is_sized_by_its_share_and_coloured_in_turn
|
|
113
|
+
render_storage
|
|
114
|
+
segments = page.all("[data-slot='progress-indicator'] > [data-slot='progress-segment']")
|
|
115
|
+
assert_equal [ "flex: 6.4 1 0%", "flex: 3.1 1 0%", "flex: 2 1 0%" ], segments.map { |s| s["style"] }
|
|
116
|
+
assert_equal %w[bg-chart-1 bg-chart-2 bg-chart-5], segments.map { |s| s["class"][/bg-chart-\d/] }
|
|
117
|
+
assert_equal "Photos: 6.4 GB", segments.first["title"]
|
|
118
|
+
assert_selector "[data-slot='progress-indicator'].flex:not(.bg-primary)"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_a_legend_names_each_segment_with_its_amount
|
|
122
|
+
render_storage
|
|
123
|
+
items = page.all("[data-slot='progress-legend'] li").map { |li| li.text.squish }
|
|
124
|
+
assert_equal [ "Photos 6.4 GB", "Mail 3.1 GB", "Documents 2 GB" ], items
|
|
125
|
+
assert_selector "[data-slot='progress-legend'] li span.bg-chart-5.rounded-full", count: 1
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_the_legend_can_be_left_out_and_the_amounts_written_per_segment
|
|
129
|
+
render_inline(UI::Progress.new(max: 100, legend: false, segment_text: "%{percent}%")) do |progress|
|
|
130
|
+
progress.with_segment(value: 30, label: "Done")
|
|
131
|
+
progress.with_segment(value: 10, label: "In review", value_text: "10 tasks")
|
|
132
|
+
end
|
|
133
|
+
assert_no_selector "[data-slot='progress-legend']"
|
|
134
|
+
assert_equal [ "Done: 30%", "In review: 10 tasks" ], page.all("[data-slot='progress-segment']").map { |s| s["title"] }
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def test_segments_past_max_are_capped_at_a_full_bar
|
|
138
|
+
render_inline(UI::Progress.new(max: 10)) do |progress|
|
|
139
|
+
progress.with_segment(value: 8, label: "A")
|
|
140
|
+
progress.with_segment(value: 7, label: "B")
|
|
141
|
+
progress.with_segment(value: -3, label: "C")
|
|
142
|
+
end
|
|
143
|
+
assert_selector "[role='progressbar'][aria-valuenow='10'][data-state='complete']"
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def test_segments_with_no_max_fill_the_bar_as_shares_of_a_whole
|
|
147
|
+
render_inline(UI::Progress.new(label: "Visits by source")) do |progress|
|
|
148
|
+
progress.with_segment(value: 5_210, label: "Search")
|
|
149
|
+
progress.with_segment(value: 2_870, label: "Direct")
|
|
150
|
+
progress.with_segment(value: 1_420, label: "Social")
|
|
151
|
+
end
|
|
152
|
+
assert_selector "[role='progressbar'][aria-valuenow='9500'][aria-valuemax='9500'][data-state='complete']"
|
|
153
|
+
assert_selector "[data-slot='progress-indicator'][style='width: 100%']"
|
|
154
|
+
assert_selector "[data-ui--progress-max-value='9500']"
|
|
155
|
+
assert_no_selector "[aria-busy]"
|
|
156
|
+
items = page.all("[data-slot='progress-legend'] li").map { |li| li.text.squish }
|
|
157
|
+
assert_equal [ "Search 55%", "Direct 30%", "Social 15%" ], items
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def test_shares_of_a_whole_can_still_show_their_values
|
|
161
|
+
render_inline(UI::Progress.new(segment_text: "%{value} visits")) do |progress|
|
|
162
|
+
progress.with_segment(value: 30, label: "Search")
|
|
163
|
+
progress.with_segment(value: 10, label: "Direct")
|
|
164
|
+
end
|
|
165
|
+
assert_equal [ "Search 30 visits", "Direct 10 visits" ],
|
|
166
|
+
page.all("[data-slot='progress-legend'] li").map { |li| li.text.squish }
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def test_segments_that_add_up_to_nothing_leave_the_bar_empty
|
|
170
|
+
render_inline(UI::Progress.new(label: "Nothing yet")) do |progress|
|
|
171
|
+
progress.with_segment(value: 0, label: "Search")
|
|
172
|
+
end
|
|
173
|
+
assert_selector "[role='progressbar'][aria-valuenow='0'][aria-valuemax='100'][data-state='loading']"
|
|
174
|
+
assert_selector "[data-slot='progress-indicator'][style='width: 0%']"
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_a_single_bar_has_no_segments_or_legend
|
|
178
|
+
render_progress(value: 40, label: "Upload")
|
|
179
|
+
assert_no_selector "[data-slot='progress-segment']"
|
|
180
|
+
assert_no_selector "[data-slot='progress-legend']"
|
|
181
|
+
assert_selector "[data-slot='progress-indicator'].bg-primary"
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def test_passes_class_and_attributes_through
|
|
185
|
+
render_progress(value: 1, id: "upload", class: "max-w-sm", data: { turbo_permanent: true })
|
|
186
|
+
assert_selector "#upload.w-full.max-w-sm[data-turbo-permanent][data-controller='ui--progress']"
|
|
187
|
+
end
|
|
188
|
+
end
|
|
@@ -192,4 +192,66 @@ class UI::SelectTest < ViewComponent::TestCase
|
|
|
192
192
|
refute_selector "button[aria-describedby]"
|
|
193
193
|
refute_selector "p.text-destructive"
|
|
194
194
|
end
|
|
195
|
+
|
|
196
|
+
# ── Searching the server ──────────────────────────────────────────────────
|
|
197
|
+
|
|
198
|
+
def render_remote(**opts)
|
|
199
|
+
render_inline(UI::Select.new(name: "order[customer_id]", url: "/customers/search", **opts))
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def test_url_searches_the_server_with_a_search_box
|
|
203
|
+
render_remote
|
|
204
|
+
root = page.find("[data-controller='ui--select']")
|
|
205
|
+
assert_equal "/customers/search", root["data-ui--select-url-value"]
|
|
206
|
+
assert_equal "q", root["data-ui--select-param-value"]
|
|
207
|
+
assert_selector "input[type='search'][data-ui--select-target='search']", visible: :all
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def test_param_renames_the_query
|
|
211
|
+
render_remote(param: "term")
|
|
212
|
+
assert_equal "term", page.find("[data-controller='ui--select']")["data-ui--select-param-value"]
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def test_remote_says_when_searching_or_failing
|
|
216
|
+
render_remote
|
|
217
|
+
root = page.find("[data-controller='ui--select']")
|
|
218
|
+
assert_equal "Searching…", root["data-ui--select-searching-value"]
|
|
219
|
+
assert_includes root["data-ui--select-failed-value"], "Couldn't load"
|
|
220
|
+
assert_selector "[data-ui--select-target='status'][role='status']", visible: :all
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def test_remote_search_box_has_a_spinner_in_waiting
|
|
224
|
+
render_remote
|
|
225
|
+
assert_selector "[data-ui--select-target='searchIcon'] svg[data-icon='search']", visible: :all
|
|
226
|
+
assert_selector "[data-ui--select-target='spinner'].hidden[aria-hidden='true'] svg[data-icon='loader'].animate-spin", visible: :all
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def test_remote_options_are_built_from_a_template_with_the_options_classes
|
|
230
|
+
render_remote
|
|
231
|
+
template = rendered_content[%r{<template data-ui--select-target="template">.*?</template>}m]
|
|
232
|
+
assert template, "no option template"
|
|
233
|
+
assert_includes template, 'role="option"'
|
|
234
|
+
assert_includes template, 'data-ui--select-target="check"'
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def test_remote_starts_with_the_options_given_so_an_edit_form_names_its_choice
|
|
238
|
+
render_remote(options: [ [ "Acme Traders", 7 ] ], selected: 7)
|
|
239
|
+
assert_selector "[role='option'][data-value='7'][aria-selected='true']", text: "Acme Traders", visible: :all
|
|
240
|
+
assert_selector "button[role='combobox']", text: "Acme Traders"
|
|
241
|
+
assert_selector "select[name='order[customer_id]'] option[value='7'][selected]", visible: :all
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def test_remote_with_nothing_chosen_shows_the_prompt
|
|
245
|
+
render_remote(prompt: "Find a customer")
|
|
246
|
+
assert_selector "button[role='combobox']", text: "Find a customer"
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def test_without_url_there_is_no_server_search
|
|
250
|
+
render_inline(UI::Select.new(name: "plan", options: %w[Free Pro], searchable: true))
|
|
251
|
+
root = page.find("[data-controller='ui--select']")
|
|
252
|
+
assert_nil root["data-ui--select-url-value"]
|
|
253
|
+
assert_no_selector "template", visible: :all
|
|
254
|
+
assert_no_selector "[data-ui--select-target='spinner']", visible: :all
|
|
255
|
+
assert_no_selector "[data-ui--select-target='status']", visible: :all
|
|
256
|
+
end
|
|
195
257
|
end
|
|
@@ -169,16 +169,16 @@ class UI::SessionTabsTest < ViewComponent::TestCase
|
|
|
169
169
|
assert_equal "pointerdown->ui--session-tabs#dragStart", handle["data-action"]
|
|
170
170
|
assert_equal "true", handle["aria-hidden"]
|
|
171
171
|
assert_includes handle[:class], "touch-none"
|
|
172
|
-
assert handle.has_selector?("[data-
|
|
172
|
+
assert handle.has_selector?("[data-icon='grip-vertical']", visible: :all)
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
def test_controls_reveal_on_hover_and_slide_in
|
|
176
176
|
render_tabs do |t|
|
|
177
177
|
t.with_tab(value: "a", move: true, rename: true) { "Alpha" }
|
|
178
178
|
end
|
|
179
|
-
grip = page.find("[data-ui--session-tabs-target='handle'] [data-
|
|
179
|
+
grip = page.find("[data-ui--session-tabs-target='handle'] [data-icon]", visible: :all)[:class]
|
|
180
180
|
menu = page.find("[data-ui--session-tabs-target='menuTrigger']")[:class]
|
|
181
|
-
dots = page.find("[data-ui--session-tabs-target='menuTrigger'] [data-
|
|
181
|
+
dots = page.find("[data-ui--session-tabs-target='menuTrigger'] [data-icon]", visible: :all)[:class]
|
|
182
182
|
[ grip, menu ].each do |classes|
|
|
183
183
|
assert_includes classes, "opacity-0"
|
|
184
184
|
assert_includes classes, "group-hover/tab:opacity-100"
|
|
@@ -8,56 +8,56 @@ class UI::SpinnerTest < ViewComponent::TestCase
|
|
|
8
8
|
|
|
9
9
|
def test_renders_loader_icon_with_animate_spin
|
|
10
10
|
render_inline UI::Spinner.new
|
|
11
|
-
icon = page.find("
|
|
12
|
-
|
|
11
|
+
icon = page.find("svg", visible: :all)
|
|
12
|
+
assert icon.matches_css?("[data-icon='loader']")
|
|
13
13
|
assert_includes icon[:class].split, "animate-spin"
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def test_default_size_classes
|
|
17
17
|
render_inline UI::Spinner.new
|
|
18
|
-
classes = page.find("
|
|
18
|
+
classes = page.find("svg", visible: :all)[:class].split
|
|
19
19
|
assert_includes classes, "w-5"
|
|
20
20
|
assert_includes classes, "h-5"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def test_size_xs
|
|
24
24
|
render_inline UI::Spinner.new(size: :xs)
|
|
25
|
-
classes = page.find("
|
|
25
|
+
classes = page.find("svg", visible: :all)[:class].split
|
|
26
26
|
assert_includes classes, "w-3"
|
|
27
27
|
assert_includes classes, "h-3"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def test_size_sm
|
|
31
31
|
render_inline UI::Spinner.new(size: :sm)
|
|
32
|
-
classes = page.find("
|
|
32
|
+
classes = page.find("svg", visible: :all)[:class].split
|
|
33
33
|
assert_includes classes, "w-4"
|
|
34
34
|
assert_includes classes, "h-4"
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def test_size_lg
|
|
38
38
|
render_inline UI::Spinner.new(size: :lg)
|
|
39
|
-
classes = page.find("
|
|
39
|
+
classes = page.find("svg", visible: :all)[:class].split
|
|
40
40
|
assert_includes classes, "w-6"
|
|
41
41
|
assert_includes classes, "h-6"
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def test_size_xl
|
|
45
45
|
render_inline UI::Spinner.new(size: :xl)
|
|
46
|
-
classes = page.find("
|
|
46
|
+
classes = page.find("svg", visible: :all)[:class].split
|
|
47
47
|
assert_includes classes, "w-8"
|
|
48
48
|
assert_includes classes, "h-8"
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def test_user_class_merges
|
|
52
52
|
render_inline UI::Spinner.new(class: "text-primary")
|
|
53
|
-
classes = page.find("
|
|
53
|
+
classes = page.find("svg", visible: :all)[:class].split
|
|
54
54
|
assert_includes classes, "text-primary"
|
|
55
55
|
assert_includes classes, "animate-spin"
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def test_html_attrs_pass_through
|
|
59
59
|
render_inline UI::Spinner.new(aria: { label: "Loading" })
|
|
60
|
-
icon = page.find("
|
|
60
|
+
icon = page.find("svg", visible: :all)
|
|
61
61
|
assert_equal "Loading", icon["aria-label"]
|
|
62
62
|
end
|
|
63
63
|
end
|