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,141 +1,306 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
|
+
import { maskDate, toIso, toTyped } from './_internal/date_format.js';
|
|
2
3
|
|
|
3
4
|
// Connects to data-controller="ui--date-picker"
|
|
4
5
|
//
|
|
5
|
-
//
|
|
6
|
-
// actually submits.
|
|
6
|
+
// One typed field, or two for a range, over hidden ISO inputs the form
|
|
7
|
+
// actually submits, and a calendar under them.
|
|
7
8
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
9
|
+
// The fields take digits and put the separators in as you type, in the
|
|
10
|
+
// locale's order, which Ruby derives from date.formats.typed and passes in as
|
|
11
|
+
// "DMY" plus a separator. Clicking or tabbing into a field opens the calendar;
|
|
12
|
+
// a date or range picked there, or a preset, fills the fields and fires
|
|
13
|
+
// `change`.
|
|
11
14
|
//
|
|
12
|
-
// The
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
// The calendar is Vanilla Calendar Pro, and its stylesheet, both loaded the
|
|
16
|
+
// first time it opens.
|
|
17
|
+
type CalendarInstance = {
|
|
18
|
+
init: () => void;
|
|
19
|
+
destroy: () => void;
|
|
20
|
+
set: (options: Record<string, unknown>) => void;
|
|
21
|
+
context: { selectedDates: string[] };
|
|
22
|
+
};
|
|
23
|
+
type CalendarClass = new (element: HTMLElement, options: Record<string, unknown>) => CalendarInstance;
|
|
24
|
+
type Labels = { pickEnd: string; previous: string; next: string; days: string };
|
|
25
|
+
|
|
26
|
+
const WIDE = '(min-width: 640px)';
|
|
27
|
+
let calendarModule: Promise<{ Calendar: CalendarClass; months: unknown }> | null = null;
|
|
28
|
+
const stylesheets = new Map<string, Promise<void>>();
|
|
20
29
|
|
|
21
30
|
export default class extends Controller<HTMLElement> {
|
|
22
|
-
static targets = ['
|
|
31
|
+
static targets = ['field', 'hidden', 'panel', 'calendar', 'toggle', 'clear', 'preset', 'status'];
|
|
23
32
|
static values = {
|
|
24
33
|
moduleUrl: String,
|
|
34
|
+
styleUrl: String,
|
|
25
35
|
order: { type: String, default: 'DMY' },
|
|
26
36
|
separator: { type: String, default: '/' },
|
|
37
|
+
range: Boolean,
|
|
38
|
+
min: String,
|
|
39
|
+
max: String,
|
|
40
|
+
locale: { type: String, default: 'en-IN' },
|
|
41
|
+
labels: Object,
|
|
27
42
|
};
|
|
28
43
|
|
|
29
|
-
declare readonly
|
|
30
|
-
declare readonly
|
|
31
|
-
declare readonly calendarTarget: HTMLElement;
|
|
44
|
+
declare readonly fieldTargets: HTMLInputElement[];
|
|
45
|
+
declare readonly hiddenTargets: HTMLInputElement[];
|
|
32
46
|
declare readonly panelTarget: HTMLElement;
|
|
47
|
+
declare readonly calendarTarget: HTMLElement;
|
|
33
48
|
declare readonly toggleTarget: HTMLButtonElement;
|
|
49
|
+
declare readonly clearTarget: HTMLButtonElement;
|
|
50
|
+
declare readonly presetTargets: HTMLButtonElement[];
|
|
51
|
+
declare readonly hasStatusTarget: boolean;
|
|
52
|
+
declare readonly statusTarget: HTMLElement;
|
|
34
53
|
declare readonly moduleUrlValue: string;
|
|
54
|
+
declare readonly styleUrlValue: string;
|
|
35
55
|
declare readonly orderValue: string;
|
|
36
56
|
declare readonly separatorValue: string;
|
|
57
|
+
declare readonly rangeValue: boolean;
|
|
58
|
+
declare readonly minValue: string;
|
|
59
|
+
declare readonly maxValue: string;
|
|
60
|
+
declare readonly localeValue: string;
|
|
61
|
+
declare readonly labelsValue: Labels;
|
|
37
62
|
|
|
38
|
-
private
|
|
63
|
+
private calendar: CalendarInstance | null = null;
|
|
64
|
+
private calendarMonths = 0;
|
|
65
|
+
private quiet = false;
|
|
39
66
|
|
|
40
67
|
connect() {
|
|
41
|
-
|
|
42
|
-
// the record shows in the locale's written format.
|
|
43
|
-
this.inputTarget.value = this.toTyped(this.hiddenTarget.value);
|
|
68
|
+
this.fieldTargets.forEach((field, i) => (field.value = this.typedOf(this.hiddenTargets[i].value)));
|
|
44
69
|
}
|
|
45
70
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const iso = this.toIso(this.inputTarget.value);
|
|
50
|
-
this.hiddenTarget.value = iso ?? '';
|
|
51
|
-
this.inputTarget.setAttribute('aria-invalid', this.invalid() ? 'true' : 'false');
|
|
52
|
-
if (iso && this.loaded) this.calendarTarget.setAttribute('value', iso);
|
|
71
|
+
disconnect() {
|
|
72
|
+
this.calendar?.destroy();
|
|
73
|
+
this.calendar = null;
|
|
53
74
|
}
|
|
54
75
|
|
|
55
|
-
|
|
76
|
+
// ── Typing ───────────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
// Masked as it's typed, then parsed: a half-typed date clears its hidden
|
|
79
|
+
// field rather than submitting the last one. A To before the From is marked
|
|
80
|
+
// and not submitted.
|
|
81
|
+
typed(event: Event) {
|
|
82
|
+
const field = event.target as HTMLInputElement;
|
|
83
|
+
const growing = (event as InputEvent).inputType?.startsWith('insert') ?? true;
|
|
84
|
+
const masked = maskDate(field.value, this.orderValue, this.separatorValue, growing);
|
|
85
|
+
if (masked !== field.value) field.value = masked;
|
|
86
|
+
|
|
87
|
+
const dates = this.fieldTargets.map((f) => toIso(f.value, this.orderValue));
|
|
88
|
+
const backwards = this.rangeValue && !!(dates[0] && dates[1] && dates[1] < dates[0]);
|
|
89
|
+
this.fieldTargets.forEach((f, i) => {
|
|
90
|
+
const bad = (f.value.trim() !== '' && dates[i] === null) || (backwards && i === 1);
|
|
91
|
+
this.hiddenTargets[i].value = bad ? '' : (dates[i] ?? '');
|
|
92
|
+
f.setAttribute('aria-invalid', String(bad));
|
|
93
|
+
});
|
|
94
|
+
this.afterChange(false);
|
|
95
|
+
|
|
96
|
+
const chosen = this.hiddenTargets.map((h) => h.value).filter(Boolean);
|
|
97
|
+
if (this.calendar && chosen.length === this.fieldTargets.length) this.showOnCalendar(chosen);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ArrowDown from a field moves into the calendar.
|
|
101
|
+
keydown(event: KeyboardEvent) {
|
|
102
|
+
if (event.key !== 'ArrowDown') return;
|
|
103
|
+
|
|
56
104
|
event.preventDefault();
|
|
57
|
-
|
|
105
|
+
this.open().then(() => {
|
|
106
|
+
const day = this.calendarTarget.querySelector<HTMLElement>('[data-vc-date-selected] button, [data-vc-date-today] button, [data-vc-date] button');
|
|
107
|
+
day?.focus();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ── Opening and closing ─────────────────────────────────────────────────
|
|
112
|
+
|
|
113
|
+
async open() {
|
|
114
|
+
if (this.quiet || !this.panelTarget.hidden || this.fieldTargets[0].disabled) return;
|
|
58
115
|
|
|
59
|
-
await this.
|
|
116
|
+
await this.build();
|
|
60
117
|
this.panelTarget.hidden = false;
|
|
61
118
|
this.toggleTarget.setAttribute('aria-expanded', 'true');
|
|
62
|
-
|
|
119
|
+
this.keepOnScreen();
|
|
63
120
|
}
|
|
64
121
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.close();
|
|
74
|
-
this.inputTarget.focus();
|
|
122
|
+
async toggle(event: Event) {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
if (this.panelTarget.hidden) {
|
|
125
|
+
await this.open();
|
|
126
|
+
this.fieldTargets[0].focus();
|
|
127
|
+
} else {
|
|
128
|
+
this.close();
|
|
129
|
+
}
|
|
75
130
|
}
|
|
76
131
|
|
|
77
132
|
close() {
|
|
133
|
+
if (this.panelTarget.hidden) return;
|
|
134
|
+
|
|
78
135
|
this.panelTarget.hidden = true;
|
|
79
136
|
this.toggleTarget.setAttribute('aria-expanded', 'false');
|
|
137
|
+
if (this.hasStatusTarget) this.statusTarget.textContent = '';
|
|
80
138
|
}
|
|
81
139
|
|
|
82
|
-
//
|
|
83
|
-
// the
|
|
140
|
+
// By the path the click took when it happened: the calendar redraws its
|
|
141
|
+
// heading as it's clicked, so by now the clicked button may have left the page.
|
|
84
142
|
closeOnOutsideClick(event: Event) {
|
|
85
|
-
if (this.
|
|
86
|
-
|
|
143
|
+
if (!event.composedPath().includes(this.element)) this.close();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
closeOnEscape(event: KeyboardEvent) {
|
|
147
|
+
if (event.key !== 'Escape' || this.panelTarget.hidden) return;
|
|
87
148
|
|
|
88
149
|
this.close();
|
|
150
|
+
this.focusField();
|
|
89
151
|
}
|
|
90
152
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
153
|
+
// Tabbing out of the whole picker closes it.
|
|
154
|
+
leave(event: FocusEvent) {
|
|
155
|
+
const next = event.relatedTarget as Node | null;
|
|
156
|
+
if (next && !this.element.contains(next)) this.close();
|
|
96
157
|
}
|
|
97
158
|
|
|
98
|
-
|
|
99
|
-
if (this.loaded) return;
|
|
159
|
+
// ── Choosing ─────────────────────────────────────────────────────────────
|
|
100
160
|
|
|
101
|
-
|
|
102
|
-
this.
|
|
103
|
-
if (this.hiddenTarget.value) this.calendarTarget.setAttribute('value', this.hiddenTarget.value);
|
|
161
|
+
preset(event: Event & { params: { from: string; to: string } }) {
|
|
162
|
+
this.choose([event.params.from, event.params.to]);
|
|
104
163
|
}
|
|
105
164
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
165
|
+
clear() {
|
|
166
|
+
this.fieldTargets.forEach((f) => {
|
|
167
|
+
f.value = '';
|
|
168
|
+
f.setAttribute('aria-invalid', 'false');
|
|
169
|
+
});
|
|
170
|
+
this.hiddenTargets.forEach((h) => (h.value = ''));
|
|
171
|
+
this.calendar?.set({ selectedDates: [] });
|
|
172
|
+
this.afterChange(true);
|
|
173
|
+
this.focusField();
|
|
109
174
|
}
|
|
110
175
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
176
|
+
private choose(dates: string[]) {
|
|
177
|
+
this.hiddenTargets.forEach((h, i) => (h.value = dates[i] ?? ''));
|
|
178
|
+
this.fieldTargets.forEach((f, i) => {
|
|
179
|
+
f.value = this.typedOf(dates[i] ?? '');
|
|
180
|
+
f.setAttribute('aria-invalid', 'false');
|
|
181
|
+
});
|
|
182
|
+
if (this.calendar) this.showOnCalendar(dates);
|
|
183
|
+
this.afterChange(true);
|
|
184
|
+
this.close();
|
|
185
|
+
this.focusField();
|
|
186
|
+
}
|
|
117
187
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
188
|
+
// The clear button and the pressed preset follow the value; a choice also
|
|
189
|
+
// tells the form.
|
|
190
|
+
private afterChange(announce: boolean) {
|
|
191
|
+
const values = this.hiddenTargets.map((h) => h.value);
|
|
192
|
+
const filled = values.some(Boolean);
|
|
193
|
+
if (!this.fieldTargets[0].required) this.clearTarget.hidden = !filled;
|
|
194
|
+
this.presetTargets.forEach((button) => {
|
|
195
|
+
const on = button.getAttribute('data-ui--date-picker-from-param') === values[0] &&
|
|
196
|
+
button.getAttribute('data-ui--date-picker-to-param') === values[1];
|
|
197
|
+
button.setAttribute('aria-pressed', String(on));
|
|
198
|
+
});
|
|
199
|
+
if (announce) this.hiddenTargets[this.hiddenTargets.length - 1].dispatchEvent(new Event('change', { bubbles: true }));
|
|
200
|
+
}
|
|
123
201
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
202
|
+
private focusField() {
|
|
203
|
+
this.quiet = true;
|
|
204
|
+
this.fieldTargets[0].focus();
|
|
205
|
+
this.quiet = false;
|
|
206
|
+
}
|
|
127
207
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
208
|
+
// ── The calendar ─────────────────────────────────────────────────────────
|
|
209
|
+
|
|
210
|
+
private async build() {
|
|
211
|
+
const months = this.rangeValue && window.matchMedia(WIDE).matches ? 2 : 1;
|
|
212
|
+
if (this.calendar && this.calendarMonths === months) return;
|
|
213
|
+
|
|
214
|
+
const [{ Calendar, months: monthsExtension }] = await Promise.all([this.loadModule(), this.loadStyles()]);
|
|
215
|
+
this.calendar?.destroy();
|
|
216
|
+
this.calendarTarget.replaceChildren();
|
|
217
|
+
const selected = this.hiddenTargets.map((h) => h.value).filter(Boolean);
|
|
218
|
+
const first = selected[0] ? new Date(`${selected[0]}T00:00:00`) : null;
|
|
219
|
+
|
|
220
|
+
this.calendar = new Calendar(this.calendarTarget, {
|
|
221
|
+
// Two months side by side need the library's months extension.
|
|
222
|
+
...(months > 1 ? { extensions: [monthsExtension] } : {}),
|
|
223
|
+
type: months > 1 ? 'multiple' : 'default',
|
|
224
|
+
displayMonthsCount: months,
|
|
225
|
+
monthsToSwitch: 1,
|
|
226
|
+
selectionDatesMode: this.rangeValue ? 'multiple-ranged' : 'single',
|
|
227
|
+
enableEdgeDatesOnly: true,
|
|
228
|
+
enableDateToggle: false,
|
|
229
|
+
enableJumpToSelectedDate: true,
|
|
230
|
+
displayDatesOutside: months === 1,
|
|
231
|
+
selectedDates: this.rangeValue && selected.length < 2 ? [] : selected,
|
|
232
|
+
...(first ? { selectedMonth: first.getMonth(), selectedYear: first.getFullYear() } : {}),
|
|
233
|
+
...(this.minValue ? { dateMin: this.minValue } : {}),
|
|
234
|
+
...(this.maxValue ? { dateMax: this.maxValue } : {}),
|
|
235
|
+
firstWeekday: 1,
|
|
236
|
+
locale: this.localeValue,
|
|
237
|
+
// Weekends aren't marked: in a shop, Saturday is a working day.
|
|
238
|
+
selectedWeekends: [],
|
|
239
|
+
selectedTheme: 'light',
|
|
240
|
+
themeAttrDetect: false,
|
|
241
|
+
labels: { arrowPrev: { month: this.labelsValue.previous }, arrowNext: { month: this.labelsValue.next } },
|
|
242
|
+
onClickDate: (self: CalendarInstance) => this.picked(self),
|
|
243
|
+
});
|
|
244
|
+
this.calendar.init();
|
|
245
|
+
this.calendarMonths = months;
|
|
131
246
|
}
|
|
132
247
|
|
|
133
|
-
private
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
248
|
+
private picked(self: CalendarInstance) {
|
|
249
|
+
const dates = [...self.context.selectedDates].sort();
|
|
250
|
+
if (!this.rangeValue) {
|
|
251
|
+
if (dates[0]) this.choose([dates[0]]);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (dates.length >= 2) {
|
|
256
|
+
this.choose([dates[0], dates[dates.length - 1]]);
|
|
257
|
+
} else if (this.hasStatusTarget) {
|
|
258
|
+
this.statusTarget.textContent = this.labelsValue.pickEnd;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private showOnCalendar(dates: string[]) {
|
|
263
|
+
const first = new Date(`${dates[0]}T00:00:00`);
|
|
264
|
+
this.calendar?.set({ selectedDates: dates, selectedMonth: first.getMonth(), selectedYear: first.getFullYear() });
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Kept inside the window: the panel lines up with the field's right edge
|
|
268
|
+
// when there isn't room to its right. A phone gets it as a sheet instead.
|
|
269
|
+
private keepOnScreen() {
|
|
270
|
+
const panel = this.panelTarget;
|
|
271
|
+
panel.style.left = '';
|
|
272
|
+
panel.style.right = '';
|
|
273
|
+
if (!window.matchMedia(WIDE).matches) return;
|
|
274
|
+
|
|
275
|
+
if (panel.getBoundingClientRect().right > document.documentElement.clientWidth - 8) {
|
|
276
|
+
panel.style.left = 'auto';
|
|
277
|
+
panel.style.right = '0';
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private loadModule() {
|
|
282
|
+
calendarModule ??= import(this.moduleUrlValue);
|
|
283
|
+
return calendarModule;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// The stylesheet once per page, waited for, so the calendar never shows unstyled.
|
|
287
|
+
private loadStyles(): Promise<void> {
|
|
288
|
+
const url = this.styleUrlValue;
|
|
289
|
+
if (!url) return Promise.resolve();
|
|
290
|
+
if (!stylesheets.has(url)) {
|
|
291
|
+
stylesheets.set(url, new Promise((resolve) => {
|
|
292
|
+
const link = document.createElement('link');
|
|
293
|
+
link.rel = 'stylesheet';
|
|
294
|
+
link.href = url;
|
|
295
|
+
link.onload = () => resolve();
|
|
296
|
+
link.onerror = () => resolve();
|
|
297
|
+
document.head.append(link);
|
|
298
|
+
}));
|
|
299
|
+
}
|
|
300
|
+
return stylesheets.get(url)!;
|
|
301
|
+
}
|
|
136
302
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return this.orderValue.split('').map((key) => parts[key]).join(this.separatorValue);
|
|
303
|
+
private typedOf(iso: string) {
|
|
304
|
+
return toTyped(iso, this.orderValue, this.separatorValue);
|
|
140
305
|
}
|
|
141
306
|
}
|