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
|
@@ -1,119 +1,243 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
#
|
|
6
|
-
# (ISO, hidden), and the calendar. The typed field comes first because people
|
|
7
|
-
# who know the date type it in a second: reaching a date years away in a
|
|
8
|
-
# calendar means clicking back month after month.
|
|
3
|
+
require "securerandom"
|
|
4
|
+
|
|
5
|
+
# UI::DatePicker — a typed date with a calendar under it, or a range of two.
|
|
9
6
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
# says, together, with nothing hardcoded.
|
|
7
|
+
# <%= render(UI::DatePicker.new(form: f, field: :starts_on, required: true)) %>
|
|
8
|
+
# <%= render(UI::DatePicker.new(name: "event[date]", value: @date, label: "Date")) %>
|
|
9
|
+
# <%= render(UI::DatePicker.new(range: true, label: "Period", from: params[:from], to: params[:to])) %>
|
|
10
|
+
# <%= render(UI::DatePicker.new(range: true, form: f, from_field: :starts_on, to_field: :ends_on)) %>
|
|
15
11
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
12
|
+
# People who know a date type it; the rest pick it. The field takes digits
|
|
13
|
+
# only and puts the separators in as you go, in the locale's order
|
|
14
|
+
# (`date.formats.typed`, dd/mm/yyyy in English), and the form gets an ISO date
|
|
15
|
+
# in a hidden field, so a date typed for a British office isn't read the
|
|
16
|
+
# American way. Clicking or tabbing into the field opens the calendar, whose
|
|
17
|
+
# month and year headings jump to a month or a year.
|
|
20
18
|
#
|
|
21
|
-
#
|
|
22
|
-
# a
|
|
19
|
+
# `range: true` is two dates, From and To, for report filters: typed, picked
|
|
20
|
+
# on a calendar of two months (one on a phone), or chosen from presets such as
|
|
21
|
+
# "Last 7 days", worked out from `Date.current`. `presets: false` leaves those
|
|
22
|
+
# out; an array of `[label, from, to]` replaces them. Choosing a range, a date
|
|
23
|
+
# or a preset, or clearing it, fires `change` on the field, so a filter form
|
|
24
|
+
# can send itself.
|
|
23
25
|
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
# <%= render(UI::DatePicker.new(name: "event[date]", value: @date, label: "Date")) %>
|
|
26
|
+
# The calendar is Vanilla Calendar Pro, loaded with its stylesheet the first
|
|
27
|
+
# time a calendar opens, so a page nobody opens one on downloads neither.
|
|
27
28
|
class UI::DatePicker < UI::Base
|
|
28
29
|
def initialize(name: nil, value: nil, form: nil, field: nil, label: nil,
|
|
29
|
-
|
|
30
|
+
range: false, from: nil, to: nil, from_name: "from", to_name: "to", from_field: nil, to_field: nil,
|
|
31
|
+
presets: true, required: false, error: nil, disabled: false, hint: true,
|
|
30
32
|
min: nil, max: nil, class: nil, **html_attrs)
|
|
31
|
-
@name
|
|
32
|
-
@value
|
|
33
|
-
@form
|
|
34
|
-
@field
|
|
35
|
-
@label
|
|
36
|
-
@
|
|
33
|
+
@name = name
|
|
34
|
+
@value = value
|
|
35
|
+
@form = form
|
|
36
|
+
@field = field
|
|
37
|
+
@label = label
|
|
38
|
+
@range = range
|
|
39
|
+
@from = from
|
|
40
|
+
@to = to
|
|
41
|
+
@from_name = from_name
|
|
42
|
+
@to_name = to_name
|
|
43
|
+
@from_field = from_field
|
|
44
|
+
@to_field = to_field
|
|
45
|
+
@presets = presets
|
|
46
|
+
@required = required
|
|
37
47
|
# The hint teaches the format, which a form field wants and a filter
|
|
38
|
-
# toolbar does not
|
|
39
|
-
|
|
40
|
-
@
|
|
41
|
-
@
|
|
42
|
-
@
|
|
43
|
-
@
|
|
44
|
-
@max = max
|
|
48
|
+
# toolbar does not: there the value is already on screen in that format.
|
|
49
|
+
@hint = hint
|
|
50
|
+
@error = error
|
|
51
|
+
@disabled = disabled
|
|
52
|
+
@min = min
|
|
53
|
+
@max = max
|
|
45
54
|
@user_class = binding.local_variable_get(:class)
|
|
46
55
|
@html_attrs = html_attrs
|
|
47
56
|
# Only for the error: the label and the format hint are laid out here.
|
|
48
|
-
@wrapper
|
|
57
|
+
@wrapper = UI::FormField.new(label: false, error: error, form: form, field: range ? from_field : field, for: input_id)
|
|
49
58
|
end
|
|
50
59
|
|
|
51
60
|
attr_reader :wrapper
|
|
52
61
|
|
|
53
|
-
def
|
|
62
|
+
def range? = @range
|
|
63
|
+
def required? = @required
|
|
64
|
+
def disabled? = @disabled
|
|
65
|
+
|
|
66
|
+
# ── The written format ────────────────────────────────────────────────────
|
|
67
|
+
|
|
68
|
+
# The one string everything else is derived from.
|
|
69
|
+
def self.date_format = I18n.t("date.formats.typed")
|
|
70
|
+
|
|
71
|
+
# "%d/%m/%Y" -> "dd/mm/yyyy": the placeholder and the hint, so what people
|
|
72
|
+
# are told matches what the field accepts by construction. Lower case, as
|
|
73
|
+
# browsers write it, which also takes about the width of a typed date.
|
|
74
|
+
def self.placeholder
|
|
75
|
+
date_format.gsub("%d", "dd").gsub("%m", "mm").gsub("%Y", "yyyy").gsub("%y", "yy")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# "%d/%m/%Y" -> "DMY", for the controller's mask and parser.
|
|
79
|
+
def self.part_order = date_format.scan(/%([dmyY])/).flatten.map(&:upcase).join
|
|
80
|
+
|
|
81
|
+
def self.separator = date_format[/[^%a-zA-Z]/] || "/"
|
|
54
82
|
|
|
55
|
-
#
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
# A Date or ISO string in the locale's written format, so the field is right
|
|
84
|
+
# before any JavaScript has run.
|
|
85
|
+
def self.typed(value)
|
|
86
|
+
return nil if value.blank?
|
|
87
|
+
|
|
88
|
+
date = value.respond_to?(:strftime) ? value : Date.parse(value.to_s)
|
|
89
|
+
I18n.l(date, format: :typed)
|
|
90
|
+
rescue Date::Error
|
|
91
|
+
value
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def self.iso(value)
|
|
95
|
+
value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d") : value.presence
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def placeholder = self.class.placeholder
|
|
99
|
+
|
|
100
|
+
# ── Fields ────────────────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
def input_id = @input_id ||= "ui-date-#{SecureRandom.hex(4)}"
|
|
103
|
+
def to_id = "#{input_id}-to"
|
|
104
|
+
def panel_id = "#{input_id}-panel"
|
|
105
|
+
def hint_id = "#{input_id}-hint"
|
|
106
|
+
|
|
107
|
+
# What each typed field submits through: [target, hidden name, ISO value].
|
|
108
|
+
def fields
|
|
109
|
+
if range?
|
|
110
|
+
[ [ :from, hidden_name(@from_field, @from_name), self.class.iso(bound(@from_field) || @from) ],
|
|
111
|
+
[ :to, hidden_name(@to_field, @to_name), self.class.iso(bound(@to_field) || @to) ] ]
|
|
112
|
+
else
|
|
113
|
+
[ [ :input, hidden_name(@field, @name), self.class.iso(bound(@field) || @value) ] ]
|
|
114
|
+
end
|
|
59
115
|
end
|
|
60
116
|
|
|
117
|
+
def value? = fields.any? { |_, _, iso| iso.present? }
|
|
118
|
+
|
|
61
119
|
def label_text
|
|
62
120
|
return @label if @label.present?
|
|
63
|
-
return nil unless @form && @field
|
|
121
|
+
return nil unless @form && (@field || @from_field)
|
|
64
122
|
|
|
65
|
-
@form.object.class.try(:human_attribute_name, @field) || @field.to_s.humanize
|
|
123
|
+
@form.object.class.try(:human_attribute_name, @field || @from_field) || (@field || @from_field).to_s.humanize
|
|
66
124
|
end
|
|
67
125
|
|
|
68
126
|
def render_label? = @label != false && label_text.present?
|
|
69
127
|
def render_hint? = @hint != false
|
|
70
128
|
|
|
71
|
-
def
|
|
129
|
+
def hint_text
|
|
130
|
+
key = range? ? "hint_range" : "hint"
|
|
131
|
+
default = range? ? "Type the dates as %{pattern}, or pick them" : "Type the date as %{pattern}, or use the calendar"
|
|
132
|
+
t("ui.date_picker.#{key}", pattern: placeholder, default: default)
|
|
133
|
+
end
|
|
72
134
|
|
|
73
135
|
def describedby
|
|
74
|
-
[ (
|
|
136
|
+
[ (hint_id if render_hint?), (wrapper.error_id if wrapper.error_message) ].compact.join(" ").presence
|
|
75
137
|
end
|
|
76
|
-
def panel_id = "#{input_id}-panel"
|
|
77
138
|
|
|
78
|
-
def
|
|
139
|
+
def input_attrs(target, iso)
|
|
140
|
+
from = target == :to ? false : true
|
|
141
|
+
{ type: "text", id: from ? input_id : to_id, inputmode: "numeric", autocomplete: "off",
|
|
142
|
+
placeholder: placeholder, value: self.class.typed(iso), maxlength: placeholder.length,
|
|
143
|
+
required: required?, disabled: disabled?, size: placeholder.length,
|
|
144
|
+
class: input_classes,
|
|
145
|
+
aria: { label: (t("ui.date_picker.#{target}", default: target == :from ? "Start date" : "End date") if range?),
|
|
146
|
+
describedby: describedby, invalid: ("true" if wrapper.error?) },
|
|
147
|
+
data: { "ui--date-picker-target": "field", action: "input->ui--date-picker#typed focus->ui--date-picker#open " \
|
|
148
|
+
"click->ui--date-picker#open keydown->ui--date-picker#keydown" } }
|
|
149
|
+
end
|
|
79
150
|
|
|
151
|
+
# Sized to a date, so a range reads "01/09/2026 – 30/09/2026" with nothing
|
|
152
|
+
# between the dates and the buttons.
|
|
153
|
+
# A range on a phone is snugger, so both dates fit beside the clear button.
|
|
80
154
|
def input_classes
|
|
81
|
-
cn(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"focus:ring-2 focus:ring-primary focus:ring-offset-1 ring-offset-background",
|
|
85
|
-
"disabled:cursor-not-allowed disabled:opacity-50 h-9 pl-3 pr-10 py-2 text-sm",
|
|
86
|
-
# aria-invalid rather than a Ruby flag, so a date the user mistypes is
|
|
87
|
-
# marked without a round trip.
|
|
88
|
-
"aria-invalid:border-destructive aria-invalid:ring-destructive",
|
|
89
|
-
wrapper.error? && "border-destructive"
|
|
90
|
-
)
|
|
155
|
+
cn("h-full w-[calc(10ch+1.5rem)] min-w-0 bg-transparent px-3 tabular-nums outline-none",
|
|
156
|
+
"placeholder:text-muted-foreground disabled:cursor-not-allowed",
|
|
157
|
+
{ "max-sm:w-[calc(10ch+1rem)] max-sm:px-2" => range? })
|
|
91
158
|
end
|
|
92
159
|
|
|
93
|
-
#
|
|
94
|
-
|
|
160
|
+
# On a phone, a range drops the calendar icon: tapping a date opens the
|
|
161
|
+
# calendar anyway, and the room goes to the dates.
|
|
162
|
+
def toggle_classes
|
|
163
|
+
cn("flex h-full w-9 items-center justify-center rounded-r-md text-muted-foreground hover:text-foreground focus:outline-none",
|
|
164
|
+
{ "max-sm:hidden" => range? })
|
|
165
|
+
end
|
|
95
166
|
|
|
96
|
-
#
|
|
97
|
-
# what
|
|
98
|
-
|
|
99
|
-
|
|
167
|
+
# The typed fields share one border, lit while either has focus. It's as
|
|
168
|
+
# wide as what's in it, since a date is always the same length; it shrinks
|
|
169
|
+
# with a narrow screen.
|
|
170
|
+
def group_classes
|
|
171
|
+
cn("flex h-9 w-fit max-w-full items-center rounded-md border border-input bg-background text-sm text-foreground",
|
|
172
|
+
"transition-all ring-offset-background has-[input:focus]:ring-2 has-[input:focus]:ring-primary has-[input:focus]:ring-offset-1",
|
|
173
|
+
"has-[[aria-invalid=true]]:border-destructive",
|
|
174
|
+
{ "border-destructive" => wrapper.error?, "cursor-not-allowed opacity-50" => disabled? })
|
|
100
175
|
end
|
|
101
176
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
177
|
+
def root_attrs
|
|
178
|
+
attrs = @html_attrs.except(:data)
|
|
179
|
+
attrs[:class] = cn("relative w-full", @user_class)
|
|
180
|
+
attrs[:data] = { controller: "ui--date-picker",
|
|
181
|
+
# Propshaft digests the filenames, so the URLs come from Ruby.
|
|
182
|
+
"ui--date-picker-module-url-value": helpers.asset_path("vanilla_calendar.js"),
|
|
183
|
+
"ui--date-picker-style-url-value": helpers.asset_path("vanilla_calendar.css"),
|
|
184
|
+
"ui--date-picker-order-value": self.class.part_order,
|
|
185
|
+
"ui--date-picker-separator-value": self.class.separator,
|
|
186
|
+
"ui--date-picker-range-value": range?,
|
|
187
|
+
"ui--date-picker-min-value": self.class.iso(@min),
|
|
188
|
+
"ui--date-picker-max-value": self.class.iso(@max),
|
|
189
|
+
"ui--date-picker-locale-value": I18n.locale == :en ? "en-IN" : I18n.locale.to_s,
|
|
190
|
+
"ui--date-picker-labels-value": labels.to_json,
|
|
191
|
+
action: "click@window->ui--date-picker#closeOnOutsideClick keydown@window->ui--date-picker#closeOnEscape " \
|
|
192
|
+
"focusout->ui--date-picker#leave" }
|
|
193
|
+
.merge(@html_attrs[:data] || {}).compact
|
|
194
|
+
attrs
|
|
195
|
+
end
|
|
105
196
|
|
|
106
|
-
|
|
197
|
+
# Words the calendar shows or says, from the locale.
|
|
198
|
+
def labels
|
|
199
|
+
{ pickEnd: t("ui.date_picker.pick_end", default: "Now pick an end date"),
|
|
200
|
+
previous: t("ui.date_picker.previous", default: "Previous month"),
|
|
201
|
+
next: t("ui.date_picker.next", default: "Next month"),
|
|
202
|
+
days: t("ui.date_picker.days", default: "%{count} days") }
|
|
203
|
+
end
|
|
107
204
|
|
|
108
|
-
#
|
|
109
|
-
# before any JavaScript has loaded.
|
|
110
|
-
def typed_value
|
|
111
|
-
iso = iso_value
|
|
112
|
-
return nil if iso.blank?
|
|
205
|
+
# ── Presets ───────────────────────────────────────────────────────────────
|
|
113
206
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
207
|
+
# [label, from, to], as ISO dates. Only for a range.
|
|
208
|
+
def preset_list
|
|
209
|
+
return [] unless range?
|
|
210
|
+
|
|
211
|
+
list = @presets == true ? default_presets : Array(@presets.presence)
|
|
212
|
+
list.map { |name, from, to| [ name, self.class.iso(from), self.class.iso(to) ] }
|
|
118
213
|
end
|
|
214
|
+
|
|
215
|
+
def preset_pressed?(from, to) = fields.map(&:last) == [ from, to ]
|
|
216
|
+
|
|
217
|
+
private
|
|
218
|
+
|
|
219
|
+
def hidden_name(field, name)
|
|
220
|
+
return "#{@form.object_name}[#{field}]" if @form && field
|
|
221
|
+
|
|
222
|
+
name
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def bound(field)
|
|
226
|
+
return nil unless @form && field && @form.object.respond_to?(field)
|
|
227
|
+
|
|
228
|
+
@form.object.public_send(field)
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def default_presets
|
|
232
|
+
today = Date.current
|
|
233
|
+
[ [ preset(:today, "Today"), today, today ],
|
|
234
|
+
[ preset(:yesterday, "Yesterday"), today - 1, today - 1 ],
|
|
235
|
+
[ preset(:last_7_days, "Last 7 days"), today - 6, today ],
|
|
236
|
+
[ preset(:last_30_days, "Last 30 days"), today - 29, today ],
|
|
237
|
+
[ preset(:this_month, "This month"), today.beginning_of_month, today ],
|
|
238
|
+
[ preset(:last_month, "Last month"), today.prev_month.beginning_of_month, today.prev_month.end_of_month ],
|
|
239
|
+
[ preset(:this_year, "This year"), today.beginning_of_year, today ] ]
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def preset(key, default) = t("ui.date_picker.presets.#{key}", default: default)
|
|
119
243
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%= tag.div class: classes, data: { slot: "empty-state" }.merge(@html_attrs[:data] || {}), **@html_attrs.except(:data) do %>
|
|
2
|
+
<% if header? %>
|
|
3
|
+
<div class="flex max-w-sm flex-col items-center gap-2">
|
|
4
|
+
<% if media? %>
|
|
5
|
+
<div class="mb-2"><%= media %></div>
|
|
6
|
+
<% elsif icon? %>
|
|
7
|
+
<div class="mb-2 flex size-12 items-center justify-center rounded-lg bg-muted text-foreground">
|
|
8
|
+
<%= render(UI::Icon.new(name: @icon, size: :lg)) %>
|
|
9
|
+
</div>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% if @title.present? %><%= heading %><% end %>
|
|
12
|
+
<% if @description.present? %>
|
|
13
|
+
<p class="text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary"><%= @description %></p>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% if content.present? %>
|
|
18
|
+
<div class="flex flex-wrap items-center justify-center gap-2"><%= content %></div>
|
|
19
|
+
<% end %>
|
|
20
|
+
<% end %>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# What a page shows in place of a list with nothing in it: an icon, a title,
|
|
4
|
+
# a line saying why, and the buttons that get someone started. The block is
|
|
5
|
+
# the actions row; `with_media` replaces the icon with an avatar, image or
|
|
6
|
+
# anything else.
|
|
7
|
+
#
|
|
8
|
+
# `variant: :outline` draws a dashed border, for an empty area inside a page
|
|
9
|
+
# rather than the whole page. `heading_level:` sets the title's <h1>–<h6> so
|
|
10
|
+
# it fits the page's outline (default 3).
|
|
11
|
+
class UI::EmptyState < UI::Base
|
|
12
|
+
variants(
|
|
13
|
+
base: "flex w-full flex-col items-center justify-center gap-6 rounded-lg p-6 text-center text-balance md:p-12",
|
|
14
|
+
variants: {
|
|
15
|
+
variant: {
|
|
16
|
+
default: "",
|
|
17
|
+
outline: "border border-dashed"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
defaults: { variant: :default }
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
renders_one :media
|
|
24
|
+
|
|
25
|
+
def initialize(title: nil, description: nil, icon: nil, variant: :default, heading_level: 3,
|
|
26
|
+
class: nil, **html_attrs)
|
|
27
|
+
@title = title
|
|
28
|
+
@description = description
|
|
29
|
+
@icon = icon
|
|
30
|
+
@variant = variant
|
|
31
|
+
@heading_level = heading_level.to_i.clamp(1, 6)
|
|
32
|
+
@user_class = binding.local_variable_get(:class)
|
|
33
|
+
@html_attrs = html_attrs
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def classes
|
|
37
|
+
cn(variant_classes(variant: @variant), @user_class)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def heading
|
|
41
|
+
content_tag(:"h#{@heading_level}", @title, class: "text-lg font-semibold tracking-tight text-foreground")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def icon? = @icon.present?
|
|
45
|
+
def header? = media? || icon? || @title.present? || @description.present?
|
|
46
|
+
end
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
<%= render(wrapper) do %><%= tag.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<%= render(wrapper) do %><%= tag.div class: "w-full", data: root_data do %>
|
|
2
|
+
<%= tag.label for: @input_id, class: dropzone_classes, data: { "ui--file-field-target": "dropzone" } do %>
|
|
3
|
+
<%= render(UI::Icon.new(name: "upload", size: :lg, class: "text-muted-foreground", aria: { hidden: true })) %>
|
|
4
|
+
<p class="text-sm text-muted-foreground"><span class="font-medium text-primary"><%= t("ui.file_field.browse", default: "Click to upload") %></span> <%= t("ui.file_field.drop", default: "or drag and drop") %></p>
|
|
5
|
+
<% unless preview? %><p class="text-xs text-muted-foreground empty:hidden" data-ui--file-field-target="filenames"></p><% end %>
|
|
6
|
+
<% if form_field? %><%= @form.file_field(@field, **form_field_options) %><% else %><%= tag.input(**html_options) %><% end %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% if preview? %>
|
|
9
|
+
<%= tag.ul class: "mt-3 grid grid-cols-[repeat(auto-fill,minmax(7.5rem,1fr))] gap-3 empty:hidden", data: { "ui--file-field-target": "list" } do %><% existing_files.each do |file| %><%= tile(**file) %><% end %><% end %>
|
|
10
|
+
<template data-ui--file-field-target="template"><%= tile(state: "chosen") %></template>
|
|
11
|
+
<p class="mt-2 text-xs text-muted-foreground empty:hidden" data-ui--file-field-target="notice"></p>
|
|
12
|
+
<p class="sr-only" aria-live="polite" data-ui--file-field-target="status"></p>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %><% end %>
|