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,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class UI::ConfirmDialogTest < ViewComponent::TestCase
|
|
6
|
+
def setup_fixtures(*); end
|
|
7
|
+
def teardown_fixtures(*); end
|
|
8
|
+
|
|
9
|
+
def dialog = page.find("dialog", visible: :all)
|
|
10
|
+
|
|
11
|
+
def test_a_native_dialog_wired_to_the_controller
|
|
12
|
+
render_inline(UI::ConfirmDialog.new)
|
|
13
|
+
assert_equal "ui--confirm-dialog", dialog["data-controller"]
|
|
14
|
+
assert_equal "confirm-dialog", dialog["data-slot"]
|
|
15
|
+
assert_equal "ui-confirm-dialog", dialog[:id]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_labelled_by_its_title_and_described_by_its_description
|
|
19
|
+
render_inline(UI::ConfirmDialog.new)
|
|
20
|
+
id = dialog[:id]
|
|
21
|
+
assert_equal "#{id}-title", dialog["aria-labelledby"]
|
|
22
|
+
assert_equal "#{id}-description", dialog["aria-describedby"]
|
|
23
|
+
assert_selector "h2##{id}-title[data-ui--confirm-dialog-target='title']", visible: :all
|
|
24
|
+
assert_selector "p##{id}-description[hidden]", visible: :all
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_buttons_submit_a_dialog_form_with_their_answer
|
|
28
|
+
render_inline(UI::ConfirmDialog.new)
|
|
29
|
+
assert_selector "dialog form[method='dialog']", visible: :all
|
|
30
|
+
assert_selector "button[type='submit'][value='cancel'][autofocus]", text: "Cancel", visible: :all
|
|
31
|
+
assert_selector "button[type='submit'][value='confirm'][data-ui--confirm-dialog-target='confirm']",
|
|
32
|
+
text: "Confirm", visible: :all
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_a_hidden_destructive_confirm_for_the_controller_to_swap_in
|
|
36
|
+
render_inline(UI::ConfirmDialog.new)
|
|
37
|
+
button = page.find("[data-ui--confirm-dialog-target='destructive']", visible: :all)
|
|
38
|
+
assert button[:hidden]
|
|
39
|
+
assert_includes button[:class].split, "bg-destructive"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_labels_are_passed_to_the_controller
|
|
43
|
+
render_inline(UI::ConfirmDialog.new(confirm_label: "Yes", cancel_label: "No"))
|
|
44
|
+
assert_equal "Yes", dialog["data-ui--confirm-dialog-confirm-label-value"]
|
|
45
|
+
assert_equal "No", dialog["data-ui--confirm-dialog-cancel-label-value"]
|
|
46
|
+
assert_selector "button[value='cancel']", text: "No", visible: :all
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_labels_come_from_i18n
|
|
50
|
+
# Built from the dotted scope so the namespaced run stores it under its own scope.
|
|
51
|
+
labels = "ui.confirm_dialog".split(".").reverse.inject({ confirm: "OK", cancel: "Never mind" }) { |h, k| { k => h } }
|
|
52
|
+
I18n.backend.store_translations(:en, labels)
|
|
53
|
+
render_inline(UI::ConfirmDialog.new)
|
|
54
|
+
assert_equal "OK", dialog["data-ui--confirm-dialog-confirm-label-value"]
|
|
55
|
+
assert_equal "Never mind", dialog["data-ui--confirm-dialog-cancel-label-value"]
|
|
56
|
+
ensure
|
|
57
|
+
I18n.reload!
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_id_class_and_attrs
|
|
61
|
+
render_inline(UI::ConfirmDialog.new(id: "confirm", class: "p-8", data: { test_id: "c" }))
|
|
62
|
+
assert_equal "confirm", dialog[:id]
|
|
63
|
+
assert_equal "confirm-title", dialog["aria-labelledby"]
|
|
64
|
+
assert_equal "c", dialog["data-test-id"]
|
|
65
|
+
assert_includes dialog[:class].split, "p-8"
|
|
66
|
+
refute_includes dialog[:class].split, "p-4"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -7,176 +7,194 @@ class UI::DatePickerTest < ViewComponent::TestCase
|
|
|
7
7
|
def teardown_fixtures(*); end
|
|
8
8
|
|
|
9
9
|
def render_picker(**options)
|
|
10
|
-
render_inline(UI::DatePicker.new(**
|
|
10
|
+
render_inline(UI::DatePicker.new(**options))
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def typed = page.find("input[type='text']")
|
|
14
|
-
def hidden = page.find("input[type='hidden']", visible: :all)
|
|
15
13
|
def root = page.find("div[data-controller='ui--date-picker']")
|
|
14
|
+
def typed = page.all("input[data-ui--date-picker-target='field']")
|
|
15
|
+
def hidden(name) = page.find("input[type='hidden'][name='#{name}']", visible: :all)
|
|
16
|
+
def presets = page.all("button[data-ui--date-picker-target='preset']", visible: :all)
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
def with_format(format)
|
|
19
|
+
original = I18n.backend.translate(:en, "date.formats.typed")
|
|
20
|
+
I18n.backend.store_translations(:en, date: { formats: { typed: format } })
|
|
21
|
+
yield
|
|
22
|
+
ensure
|
|
23
|
+
I18n.backend.store_translations(:en, date: { formats: { typed: original } })
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# ── A single date ─────────────────────────────────────────────────────────
|
|
18
27
|
|
|
19
|
-
# The typed field carries no name, so a half-typed date can never reach the
|
|
20
|
-
# server: only the hidden ISO field is submitted.
|
|
21
28
|
def test_only_the_hidden_field_is_submitted
|
|
22
|
-
render_picker
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
render_picker(name: "event[date]", value: Date.new(2026, 8, 15))
|
|
30
|
+
assert_equal "2026-08-15", hidden("event[date]").value
|
|
31
|
+
assert_nil typed.first[:name]
|
|
25
32
|
end
|
|
26
33
|
|
|
27
|
-
def
|
|
28
|
-
render_picker(
|
|
29
|
-
assert_equal "
|
|
30
|
-
assert_equal "
|
|
34
|
+
def test_the_typed_field_shows_the_locale_format
|
|
35
|
+
render_picker(name: "d", value: "2026-08-15")
|
|
36
|
+
assert_equal "15/08/2026", typed.first.value
|
|
37
|
+
assert_equal "dd/mm/yyyy", typed.first[:placeholder]
|
|
38
|
+
assert_equal "10", typed.first[:maxlength]
|
|
39
|
+
assert_equal "numeric", typed.first[:inputmode]
|
|
31
40
|
end
|
|
32
41
|
|
|
33
42
|
def test_both_fields_are_empty_without_a_value
|
|
34
|
-
render_picker
|
|
35
|
-
assert_equal "", typed
|
|
36
|
-
assert_equal "", hidden
|
|
43
|
+
render_picker(name: "d")
|
|
44
|
+
assert_equal "", typed.first.value.to_s
|
|
45
|
+
assert_equal "", hidden("d").value.to_s
|
|
37
46
|
end
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
render_picker
|
|
46
|
-
assert_equal "DD/MM/YYYY", typed[:placeholder]
|
|
48
|
+
def test_the_field_opens_the_calendar_on_focus_and_click
|
|
49
|
+
render_picker(name: "d")
|
|
50
|
+
action = typed.first["data-action"]
|
|
51
|
+
assert_includes action, "focus->ui--date-picker#open"
|
|
52
|
+
assert_includes action, "click->ui--date-picker#open"
|
|
53
|
+
assert_includes action, "input->ui--date-picker#typed"
|
|
47
54
|
end
|
|
48
55
|
|
|
49
|
-
def
|
|
50
|
-
render_picker
|
|
56
|
+
def test_order_and_separator_come_from_the_locale_format
|
|
57
|
+
render_picker(name: "d")
|
|
51
58
|
assert_equal "DMY", root["data-ui--date-picker-order-value"]
|
|
52
59
|
assert_equal "/", root["data-ui--date-picker-separator-value"]
|
|
53
60
|
end
|
|
54
61
|
|
|
55
|
-
# A locale that writes dates the other way round changes all three together
|
|
56
|
-
# and needs no change here.
|
|
57
62
|
def test_a_different_locale_format_changes_the_placeholder_and_the_parser
|
|
58
63
|
with_format("%m-%d-%Y") do
|
|
59
|
-
render_picker(
|
|
60
|
-
assert_equal "
|
|
64
|
+
render_picker(name: "d", value: "2026-08-15")
|
|
65
|
+
assert_equal "mm-dd-yyyy", typed.first[:placeholder]
|
|
66
|
+
assert_equal "08-15-2026", typed.first.value
|
|
61
67
|
assert_equal "MDY", root["data-ui--date-picker-order-value"]
|
|
62
68
|
assert_equal "-", root["data-ui--date-picker-separator-value"]
|
|
63
|
-
assert_equal "05-02-2012", typed[:value]
|
|
64
69
|
end
|
|
65
70
|
end
|
|
66
71
|
|
|
67
|
-
def
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
def test_the_calendar_loads_with_its_stylesheet_and_starts_hidden
|
|
73
|
+
render_picker(name: "d", min: Date.new(2026, 1, 1), max: "2026-12-31")
|
|
74
|
+
assert_match(/vanilla_calendar.*\.js\z/, root["data-ui--date-picker-module-url-value"])
|
|
75
|
+
assert_match(/vanilla_calendar.*\.css\z/, root["data-ui--date-picker-style-url-value"])
|
|
76
|
+
assert_equal "2026-01-01", root["data-ui--date-picker-min-value"]
|
|
77
|
+
assert_equal "2026-12-31", root["data-ui--date-picker-max-value"]
|
|
78
|
+
assert_selector "[role='dialog'][hidden] .velvetkit-calendar > [data-ui--date-picker-target='calendar']", visible: :all
|
|
79
|
+
assert_selector "button[aria-haspopup='dialog'][aria-expanded='false'][aria-label='Open the calendar']"
|
|
73
80
|
end
|
|
74
81
|
|
|
75
|
-
|
|
82
|
+
def test_a_single_date_has_no_presets_or_range_prompt
|
|
83
|
+
render_picker(name: "d")
|
|
84
|
+
assert_empty presets
|
|
85
|
+
assert_no_selector "[data-ui--date-picker-target='status']", visible: :all
|
|
86
|
+
assert_equal "false", root["data-ui--date-picker-range-value"]
|
|
87
|
+
end
|
|
76
88
|
|
|
77
|
-
|
|
89
|
+
def test_clear_shows_only_with_a_value_that_can_be_emptied
|
|
90
|
+
render_picker(name: "d")
|
|
91
|
+
assert_selector "button[aria-label='Clear'][hidden]", visible: :all
|
|
92
|
+
render_picker(name: "d", value: "2026-08-15")
|
|
93
|
+
assert_selector "button[aria-label='Clear']:not([hidden])"
|
|
94
|
+
render_picker(name: "d", value: "2026-08-15", required: true)
|
|
95
|
+
assert_selector "button[aria-label='Clear'][hidden]", visible: :all
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
Holiday = Struct.new(:starts_on) do
|
|
78
99
|
def self.human_attribute_name(name, *) = name.to_s.humanize
|
|
79
100
|
def to_model = self
|
|
80
101
|
def model_name = ActiveModel::Name.new(self.class, nil, "Holiday")
|
|
81
102
|
def persisted? = false
|
|
82
103
|
end
|
|
83
104
|
|
|
84
|
-
def
|
|
85
|
-
ActionView::Helpers::FormBuilder.new(:holiday, record, vc_test_controller.view_context, {})
|
|
86
|
-
end
|
|
105
|
+
def builder(record) = ActionView::Helpers::FormBuilder.new(:holiday, record, vc_test_controller.view_context, {})
|
|
87
106
|
|
|
88
|
-
def
|
|
89
|
-
|
|
90
|
-
assert_equal "
|
|
91
|
-
|
|
92
|
-
assert_equal "15/08/2026", typed[:value]
|
|
107
|
+
def test_form_binding_names_the_hidden_field_reads_the_value_and_derives_the_label
|
|
108
|
+
render_picker(form: builder(Holiday.new(Date.new(2026, 8, 15))), field: :starts_on)
|
|
109
|
+
assert_equal "2026-08-15", hidden("holiday[starts_on]").value
|
|
110
|
+
assert_selector "label[for='#{typed.first[:id]}']", text: "Starts on"
|
|
93
111
|
end
|
|
94
112
|
|
|
95
|
-
def
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
def test_required_marks_the_field_and_the_label
|
|
114
|
+
render_picker(name: "d", label: "Date", required: true)
|
|
115
|
+
assert typed.first[:required]
|
|
116
|
+
assert_selector "label span", text: "*"
|
|
99
117
|
end
|
|
100
118
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
119
|
+
def test_the_hint_explains_the_format_and_can_be_turned_off
|
|
120
|
+
render_picker(name: "d")
|
|
121
|
+
assert_text "Type the date as dd/mm/yyyy"
|
|
122
|
+
assert_includes typed.first["aria-describedby"], "-hint"
|
|
123
|
+
render_picker(name: "d", hint: false)
|
|
124
|
+
assert_no_text "Type the date as"
|
|
106
125
|
end
|
|
107
126
|
|
|
108
|
-
def
|
|
109
|
-
render_picker(
|
|
110
|
-
|
|
127
|
+
def test_error_message_shows_and_describes_the_field
|
|
128
|
+
render_picker(name: "d", error: "Too early")
|
|
129
|
+
assert_text "Too early"
|
|
130
|
+
assert_equal "true", typed.first["aria-invalid"]
|
|
131
|
+
assert_includes typed.first["aria-describedby"], page.find("p", text: "Too early")[:id]
|
|
111
132
|
end
|
|
112
133
|
|
|
113
|
-
|
|
114
|
-
render_picker(min: "2026-04-01", max: "2027-03-31")
|
|
115
|
-
calendar = page.find("calendar-date", visible: :all)
|
|
116
|
-
assert_equal "2026-04-01", calendar[:min]
|
|
117
|
-
assert_equal "2027-03-31", calendar[:max]
|
|
118
|
-
end
|
|
134
|
+
# ── A range ───────────────────────────────────────────────────────────────
|
|
119
135
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
def test_a_range_submits_from_and_to_as_iso
|
|
137
|
+
render_picker(range: true, from: Date.new(2026, 11, 1), to: "2026-11-30")
|
|
138
|
+
assert_equal "2026-11-01", hidden("from").value
|
|
139
|
+
assert_equal "2026-11-30", hidden("to").value
|
|
140
|
+
assert_equal %w[01/11/2026 30/11/2026], typed.map(&:value)
|
|
141
|
+
assert_equal [ "Start date", "End date" ], typed.map { _1["aria-label"] }
|
|
142
|
+
assert_equal "true", root["data-ui--date-picker-range-value"]
|
|
126
143
|
end
|
|
127
144
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
assert_selector "p", text: "DD/MM/YYYY"
|
|
134
|
-
assert_equal "#{typed[:id]}-hint", typed["aria-describedby"]
|
|
145
|
+
def test_a_range_can_rename_its_fields
|
|
146
|
+
render_picker(range: true, from_name: "period[start]", to_name: "period[end]")
|
|
147
|
+
assert hidden("period[start]")
|
|
148
|
+
assert hidden("period[end]")
|
|
149
|
+
end
|
|
135
150
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
151
|
+
Report = Struct.new(:starts_on, :ends_on) do
|
|
152
|
+
def to_model = self
|
|
153
|
+
def model_name = ActiveModel::Name.new(self.class, nil, "Report")
|
|
154
|
+
def persisted? = false
|
|
139
155
|
end
|
|
140
156
|
|
|
141
|
-
def
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
assert_equal "
|
|
145
|
-
assert_equal
|
|
157
|
+
def test_a_range_binds_to_a_form
|
|
158
|
+
form = ActionView::Helpers::FormBuilder.new(:report, Report.new(Date.new(2026, 4, 1), Date.new(2027, 3, 31)), vc_test_controller.view_context, {})
|
|
159
|
+
render_picker(range: true, form: form, from_field: :starts_on, to_field: :ends_on)
|
|
160
|
+
assert_equal "2026-04-01", hidden("report[starts_on]").value
|
|
161
|
+
assert_equal "2027-03-31", hidden("report[ends_on]").value
|
|
146
162
|
end
|
|
147
163
|
|
|
148
|
-
|
|
164
|
+
def test_a_range_says_to_pick_an_end_date_after_the_first
|
|
165
|
+
render_picker(range: true)
|
|
166
|
+
assert_selector "[data-ui--date-picker-target='status'][role='status']", visible: :all
|
|
167
|
+
assert_includes JSON.parse(root["data-ui--date-picker-labels-value"])["pickEnd"], "end date"
|
|
168
|
+
end
|
|
149
169
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
170
|
+
def test_range_presets_are_worked_out_from_today
|
|
171
|
+
travel_to(Date.new(2026, 11, 6)) do
|
|
172
|
+
render_picker(range: true)
|
|
173
|
+
by_label = presets.to_h { |b| [ b.text, [ b["data-ui--date-picker-from-param"], b["data-ui--date-picker-to-param"] ] ] }
|
|
174
|
+
assert_equal %w[2026-11-06 2026-11-06], by_label["Today"]
|
|
175
|
+
assert_equal %w[2026-10-31 2026-11-06], by_label["Last 7 days"]
|
|
176
|
+
assert_equal %w[2026-11-01 2026-11-06], by_label["This month"]
|
|
177
|
+
assert_equal %w[2026-10-01 2026-10-31], by_label["Last month"]
|
|
178
|
+
assert_equal %w[2026-01-01 2026-11-06], by_label["This year"]
|
|
179
|
+
end
|
|
157
180
|
end
|
|
158
181
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
arrow = page.find("calendar-date [slot='#{slot}']", visible: :all)
|
|
164
|
-
refute_equal "button", arrow.tag_name
|
|
165
|
-
assert_includes arrow.text(:all), I18n.t(key)
|
|
182
|
+
def test_the_preset_matching_the_range_is_pressed
|
|
183
|
+
travel_to(Date.new(2026, 11, 6)) do
|
|
184
|
+
render_picker(range: true, from: "2026-11-01", to: "2026-11-06")
|
|
185
|
+
assert_equal [ "This month" ], presets.select { _1["aria-pressed"] == "true" }.map(&:text)
|
|
166
186
|
end
|
|
167
187
|
end
|
|
168
188
|
|
|
169
|
-
def
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
189
|
+
def test_range_presets_can_be_replaced_or_left_out
|
|
190
|
+
render_picker(range: true, presets: [ [ "Q1", "2026-01-01", "2026-03-31" ] ])
|
|
191
|
+
assert_equal [ "Q1" ], presets.map(&:text)
|
|
192
|
+
render_picker(range: true, presets: false)
|
|
193
|
+
assert_empty presets
|
|
174
194
|
end
|
|
175
195
|
|
|
176
|
-
def
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
assert_equal "#{input[:id]}-hint", input["aria-describedby"]
|
|
180
|
-
refute input["aria-invalid"]
|
|
196
|
+
def test_class_and_attributes_pass_through
|
|
197
|
+
render_picker(name: "d", class: "max-w-xs", id: "when", data: { foo: "bar" })
|
|
198
|
+
assert_selector "#when.max-w-xs[data-foo='bar'][data-controller='ui--date-picker']"
|
|
181
199
|
end
|
|
182
200
|
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class UI::EmptyStateTest < ViewComponent::TestCase
|
|
6
|
+
def setup_fixtures(*); end
|
|
7
|
+
def teardown_fixtures(*); end
|
|
8
|
+
|
|
9
|
+
def test_renders_title_description_and_icon
|
|
10
|
+
render_inline(UI::EmptyState.new(icon: "inbox", title: "No messages", description: "You're all caught up."))
|
|
11
|
+
assert_selector "[data-slot='empty-state'] h3", text: "No messages"
|
|
12
|
+
assert_selector "[data-slot='empty-state'] p", text: "You're all caught up."
|
|
13
|
+
assert_selector "[data-slot='empty-state'] svg[data-icon='inbox']", visible: :all
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_block_is_the_actions_row
|
|
17
|
+
render_inline(UI::EmptyState.new(title: "No projects")) { "<button>Create project</button>".html_safe }
|
|
18
|
+
assert_selector "[data-slot='empty-state'] div.flex-wrap button", text: "Create project"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_no_actions_row_without_a_block
|
|
22
|
+
render_inline(UI::EmptyState.new(title: "No projects"))
|
|
23
|
+
assert_no_selector "div.flex-wrap"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_no_icon_box_without_an_icon
|
|
27
|
+
render_inline(UI::EmptyState.new(title: "No projects"))
|
|
28
|
+
assert_no_selector "svg", visible: :all
|
|
29
|
+
assert_no_selector "div.bg-muted"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_media_replaces_the_icon
|
|
33
|
+
render_inline(UI::EmptyState.new(icon: "inbox", title: "No team")) do |empty|
|
|
34
|
+
empty.with_media { "<img alt='Team' src='/team.png'>".html_safe }
|
|
35
|
+
end
|
|
36
|
+
assert_selector "img[alt='Team']"
|
|
37
|
+
assert_no_selector "svg[data-icon='inbox']", visible: :all
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_heading_level
|
|
41
|
+
render_inline(UI::EmptyState.new(title: "Nothing here", heading_level: 2))
|
|
42
|
+
assert_selector "h2", text: "Nothing here"
|
|
43
|
+
assert_no_selector "h3"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_heading_level_is_kept_in_range
|
|
47
|
+
render_inline(UI::EmptyState.new(title: "Nothing here", heading_level: 9))
|
|
48
|
+
assert_selector "h6", text: "Nothing here"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_description_keeps_html
|
|
52
|
+
render_inline(UI::EmptyState.new(description: "Read <a href='/docs'>the guide</a>.".html_safe))
|
|
53
|
+
assert_selector "p a[href='/docs']", text: "the guide"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_description_escapes_plain_strings
|
|
57
|
+
render_inline(UI::EmptyState.new(description: "<b>bold</b>"))
|
|
58
|
+
assert_no_selector "p b"
|
|
59
|
+
assert_selector "p", text: "<b>bold</b>"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_default_variant_has_no_border
|
|
63
|
+
render_inline(UI::EmptyState.new(title: "x"))
|
|
64
|
+
classes = page.find("[data-slot='empty-state']")[:class].split
|
|
65
|
+
assert_includes classes, "text-center"
|
|
66
|
+
refute_includes classes, "border-dashed"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_outline_variant
|
|
70
|
+
render_inline(UI::EmptyState.new(title: "x", variant: :outline))
|
|
71
|
+
classes = page.find("[data-slot='empty-state']")[:class].split
|
|
72
|
+
assert_includes classes, "border"
|
|
73
|
+
assert_includes classes, "border-dashed"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_user_class_merges
|
|
77
|
+
render_inline(UI::EmptyState.new(title: "x", class: "p-2"))
|
|
78
|
+
classes = page.find("[data-slot='empty-state']")[:class].split
|
|
79
|
+
assert_includes classes, "p-2"
|
|
80
|
+
refute_includes classes, "p-6"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_html_attrs_pass_through_and_keep_the_slot
|
|
84
|
+
render_inline(UI::EmptyState.new(title: "x", id: "projects-empty", data: { test_id: "empty" }))
|
|
85
|
+
assert_selector "#projects-empty[data-slot='empty-state'][data-test-id='empty']"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -25,19 +25,20 @@ class UI::FileFieldTest < ViewComponent::TestCase
|
|
|
25
25
|
assert_equal input[:id], label[:for]
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def
|
|
28
|
+
def root = page.find("[data-controller='ui--file-field']")
|
|
29
|
+
|
|
30
|
+
def test_controller_wraps_the_dropzone_and_takes_drops
|
|
29
31
|
render_inline(UI::FileField.new)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
assert_includes
|
|
33
|
-
assert_includes
|
|
34
|
-
assert_includes label["data-action"], "drop->ui--file-field#drop"
|
|
32
|
+
assert_selector "[data-controller='ui--file-field'] > label[data-ui--file-field-target='dropzone']"
|
|
33
|
+
assert_includes root["data-action"], "dragover->ui--file-field#dragOver"
|
|
34
|
+
assert_includes root["data-action"], "dragleave->ui--file-field#dragLeave"
|
|
35
|
+
assert_includes root["data-action"], "drop->ui--file-field#drop"
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
def
|
|
38
|
+
def test_input_wired_to_the_controller_on_change
|
|
38
39
|
render_inline(UI::FileField.new)
|
|
39
|
-
input = page.find("input", visible: :all)
|
|
40
|
-
assert_includes input["data-action"], "change->ui--file-field#
|
|
40
|
+
input = page.find("input[type='file']", visible: :all)
|
|
41
|
+
assert_includes input["data-action"], "change->ui--file-field#chosen"
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
def test_not_multiple_by_default
|
|
@@ -98,4 +99,99 @@ class UI::FileFieldTest < ViewComponent::TestCase
|
|
|
98
99
|
render_inline(UI::FileField.new(id: "my-id", data: { test_id: "f" }))
|
|
99
100
|
assert_selector "input#my-id[data-test-id='f']", visible: :all
|
|
100
101
|
end
|
|
102
|
+
|
|
103
|
+
# ── Previews ────────────────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
def test_previews_by_default_with_a_list_and_a_tile_template
|
|
106
|
+
render_inline(UI::FileField.new(name: "photos"))
|
|
107
|
+
assert_equal "true", root["data-ui--file-field-preview-value"]
|
|
108
|
+
assert_selector "ul[data-ui--file-field-target='list']", visible: :all
|
|
109
|
+
template = rendered_content[%r{<template data-ui--file-field-target="template">.*?</template>}m]
|
|
110
|
+
assert template, "no tile template"
|
|
111
|
+
%w[thumb icon remove progress bar name meta retry].each { |role| assert_includes template, %(data-role="#{role}") }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_preview_false_lists_names_instead
|
|
115
|
+
render_inline(UI::FileField.new(preview: false))
|
|
116
|
+
assert_equal "false", root["data-ui--file-field-preview-value"]
|
|
117
|
+
assert_selector "[data-ui--file-field-target='filenames']", visible: :all
|
|
118
|
+
assert_no_selector "ul[data-ui--file-field-target='list']", visible: :all
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_checks_accept_and_max_size_and_says_the_limit
|
|
122
|
+
render_inline(UI::FileField.new(accept: "image/*", max_size: 5.megabytes))
|
|
123
|
+
assert_equal "image/*", root["data-ui--file-field-accept-value"]
|
|
124
|
+
assert_equal 5.megabytes.to_s, root["data-ui--file-field-max-size-value"]
|
|
125
|
+
assert_equal "5 MB", JSON.parse(root["data-ui--file-field-labels-value"])["max"]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# ── Direct upload ───────────────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
def test_direct_upload_points_at_active_storage
|
|
131
|
+
render_inline(UI::FileField.new(name: "photos", direct_upload: true))
|
|
132
|
+
assert_equal "true", root["data-ui--file-field-direct-upload-value"]
|
|
133
|
+
assert_match %r{/rails/active_storage/direct_uploads\z}, root["data-ui--file-field-url-value"]
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_without_direct_upload_there_is_no_upload_url
|
|
137
|
+
render_inline(UI::FileField.new(name: "photos"))
|
|
138
|
+
assert_nil root["data-ui--file-field-url-value"]
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def test_signed_ids_post_under_the_fields_name
|
|
142
|
+
render_inline(UI::FileField.new(name: "product[photos]", multiple: true, direct_upload: true))
|
|
143
|
+
assert_equal "product[photos][]", root["data-ui--file-field-name-value"]
|
|
144
|
+
render_inline(UI::FileField.new(name: "store[logo]", direct_upload: true))
|
|
145
|
+
assert_equal "store[logo]", root["data-ui--file-field-name-value"]
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# ── Files already kept ──────────────────────────────────────────────────
|
|
149
|
+
|
|
150
|
+
Kept = Struct.new(:signed_id, :filename, :byte_size, :content_type, :url, keyword_init: true)
|
|
151
|
+
|
|
152
|
+
def kept
|
|
153
|
+
[ Kept.new(signed_id: "abc", filename: "front.jpg", byte_size: 2_097_152, content_type: "image/jpeg", url: "/front.jpg"),
|
|
154
|
+
Kept.new(signed_id: "def", filename: "manual.pdf", byte_size: 51_200, content_type: "application/pdf", url: "/manual.pdf") ]
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def test_kept_files_show_as_tiles_kept_by_their_signed_ids
|
|
158
|
+
render_inline(UI::FileField.new(name: "product[photos][]", multiple: true, existing: kept))
|
|
159
|
+
tiles = page.all("ul li[data-ui--file-field-target='item'][data-state='kept']")
|
|
160
|
+
assert_equal 2, tiles.size
|
|
161
|
+
assert_selector "li input[type='hidden'][name='product[photos][]'][value='abc']", visible: :all
|
|
162
|
+
assert_selector "li img[data-role='thumb'][src='/front.jpg']"
|
|
163
|
+
assert_selector "li", text: "front.jpg"
|
|
164
|
+
assert_selector "li", text: "2 MB"
|
|
165
|
+
assert_selector "li button[aria-label='Remove manual.pdf']"
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def test_a_kept_file_that_isnt_an_image_shows_an_icon
|
|
169
|
+
render_inline(UI::FileField.new(name: "docs[]", multiple: true, existing: kept))
|
|
170
|
+
pdf = page.all("li[data-ui--file-field-target='item']").last
|
|
171
|
+
assert pdf.has_css?("img[data-role='thumb'][hidden]", visible: :all)
|
|
172
|
+
assert pdf.has_css?("svg[data-icon='file']")
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def test_a_kept_file_fills_a_required_field
|
|
176
|
+
render_inline(UI::FileField.new(name: "photos[]", multiple: true, required: true, existing: kept))
|
|
177
|
+
assert_nil page.find("input[type='file']", visible: :all)[:required]
|
|
178
|
+
assert_equal "true", root["data-ui--file-field-required-value"]
|
|
179
|
+
render_inline(UI::FileField.new(name: "photos[]", multiple: true, required: true))
|
|
180
|
+
assert page.find("input[type='file']", visible: :all)[:required]
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
Product = Struct.new(:photos) do
|
|
184
|
+
def to_model = self
|
|
185
|
+
def model_name = ActiveModel::Name.new(self.class, nil, "Product")
|
|
186
|
+
def persisted? = true
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
Many = Struct.new(:attachments)
|
|
190
|
+
|
|
191
|
+
def test_bound_to_a_form_it_shows_the_records_attachments
|
|
192
|
+
builder = ActionView::Helpers::FormBuilder.new(:product, Product.new(Many.new(kept)), vc_test_controller.view_context, {})
|
|
193
|
+
render_inline(UI::FileField.new(form: builder, field: :photos, multiple: true))
|
|
194
|
+
assert_selector "li input[type='hidden'][name='product[photos][]'][value='def']", visible: :all
|
|
195
|
+
assert_equal "product[photos][]", root["data-ui--file-field-name-value"]
|
|
196
|
+
end
|
|
101
197
|
end
|