moi-computer 0.11.0 → 0.11.1-dev.be1ed10
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.
- package/README.md +2 -2
- package/client/AGENTS.md +2 -2
- package/client/app/AppRouter.tsx +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +7 -9
- package/client/app/shell/SidebarLayout.tsx +18 -15
- package/client/components/shared/BottomPanel.tsx +26 -14
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/components/shared/ReorderableList.tsx +7 -2
- package/client/components/shared/WorkspaceIcon.tsx +92 -0
- package/client/components/ui/alert-dialog.tsx +1 -0
- package/client/components/ui/button.tsx +1 -53
- package/client/components/ui/checkbox.tsx +1 -0
- package/client/components/ui/collapsible.tsx +1 -15
- package/client/components/ui/dialog.tsx +1 -58
- package/client/components/ui/dropdown-menu.tsx +1 -254
- package/client/components/ui/hover-card.tsx +1 -44
- package/client/components/ui/inline-input.tsx +84 -0
- package/client/components/ui/input.tsx +1 -21
- package/client/components/ui/popover.tsx +1 -88
- package/client/components/ui/resizable.tsx +1 -40
- package/client/components/ui/skeleton.tsx +1 -13
- package/client/components/ui/slider.tsx +1 -70
- package/client/components/ui/spinner.tsx +1 -18
- package/client/components/ui/switch.tsx +1 -23
- package/client/components/ui/tabs.tsx +1 -0
- package/client/components/ui/textarea.tsx +1 -18
- package/client/components/ui/toast.tsx +2 -2
- package/client/components/ui/tooltip.tsx +1 -51
- package/client/features/applets/AppletMount.tsx +1 -1
- package/client/features/applets/applet-cache.ts +3 -3
- package/client/features/applets/applet-runtime.ts +147 -108
- package/client/features/applets/applet-styles.ts +2 -2
- package/client/features/applets/applet-thumbnail.ts +6 -8
- package/client/features/applets/useApplet.ts +10 -9
- package/client/features/chat/ChatPanel.tsx +24 -15
- package/client/features/chat/ChatPopup.tsx +9 -5
- package/client/features/chat/applet-chat-intents.ts +170 -0
- package/client/features/chat/chat-send.ts +116 -64
- package/client/features/chat/chat-store.ts +51 -62
- package/client/features/chat/composer/ChatComposer.tsx +43 -128
- package/client/features/chat/composer/ModelPicker.tsx +47 -60
- package/client/features/chat/composer/attachments/AttachmentChip.tsx +99 -0
- package/client/features/chat/composer/attachments/DrawingAttachmentChip.tsx +37 -0
- package/client/features/chat/composer/attachments/FileAttachmentChip.tsx +22 -0
- package/client/features/chat/composer/attachments/TextAttachmentChip.tsx +11 -0
- package/client/features/chat/composer/attachments/draft-attachments.ts +168 -0
- package/client/features/chat/composer/attachments/types.ts +25 -0
- package/client/features/chat/composer/attachments/uploads.ts +26 -0
- package/client/features/chat/composer/banners/ErrorBanner.tsx +20 -12
- package/client/features/chat/composer/model-order.ts +15 -0
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +15 -7
- package/client/features/chat/{chat-connection.ts → connection/chat-connection.ts} +1 -1
- package/client/features/chat/{chat-frames.ts → connection/chat-frames.ts} +10 -8
- package/client/features/chat/{ChatEmptyState.tsx → messages/ChatEmptyState.tsx} +16 -11
- package/client/features/chat/{MarkdownContent.tsx → messages/MarkdownContent.tsx} +16 -1
- package/client/features/chat/{TurnView.tsx → messages/TurnView.tsx} +27 -19
- package/client/features/chat/{group-turns.ts → messages/group-turns.ts} +12 -0
- package/client/features/chat/{interleave-notices.ts → messages/interleave-notices.ts} +7 -11
- package/client/features/chat/{tool-group → messages/tool-group}/SubagentCard.tsx +1 -1
- package/client/features/chat/{tool-group → messages/tool-group}/TimelineRow.tsx +2 -2
- package/client/features/chat/{tool-group → messages/tool-group}/ToolCallGroup.tsx +2 -5
- package/client/features/chat/{tool-group → messages/tool-group}/format/codex.ts +4 -1
- package/client/features/chat/{ChatSelector.tsx → sessions/ChatSelector.tsx} +3 -3
- package/client/features/chat/{api.ts → sessions/api.ts} +5 -14
- package/client/features/chat/sessions/session-view.ts +53 -0
- package/client/features/chat/useChat.ts +42 -24
- package/client/features/dev/ChatStatesPage.tsx +8 -7
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- package/client/features/dev/HarnessDebugPage.tsx +11 -8
- package/client/features/dev/ToolCallsPage.tsx +1 -1
- package/client/features/dev/UiComponentPreviews.tsx +855 -0
- package/client/features/dev/UiComponentsPage.tsx +60 -0
- package/client/features/dev/chat-states-fixtures.ts +13 -2
- package/client/features/drawings/useChatAnnotation.ts +17 -17
- package/client/features/drawings/useDrawingLayer.ts +7 -9
- package/client/features/drawings/useViewBuilderSketch.ts +18 -15
- package/client/features/home/HomePage.tsx +8 -7
- package/client/features/home/WorkspacePreview.tsx +2 -2
- package/client/features/home/workspace-presentation.tsx +1 -11
- package/client/features/home/workspace-setup/DemoDialog.tsx +3 -2
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +5 -8
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +2 -4
- package/client/features/home/workspace-setup/WorkspaceDialogContent.tsx +7 -20
- package/client/features/overview/HiddenPanel.tsx +109 -0
- package/client/features/overview/Overview.tsx +302 -0
- package/client/features/overview/WidgetCanvas.tsx +164 -0
- package/client/features/{widgets → overview}/WidgetFrame.tsx +25 -17
- package/client/features/overview/WorkspaceName.tsx +60 -0
- package/client/features/overview/api.ts +30 -0
- package/client/features/overview/default/ViewsWidget.tsx +252 -0
- package/client/features/overview/default/registry.tsx +36 -0
- package/client/features/{widgets → overview}/grid.ts +36 -0
- package/client/features/overview/useGridReconcile.ts +94 -0
- package/client/features/scratchpad/Scratchpad.tsx +7 -8
- package/client/features/scratchpad/ScratchpadControls.tsx +0 -1
- package/client/features/scratchpad/useScratchpadSnapshot.tsx +23 -13
- package/client/features/settings/GeneralSettings.tsx +55 -58
- package/client/features/settings/SettingsLayout.tsx +2 -2
- package/client/features/settings/WorkspaceIconPicker.tsx +318 -0
- package/client/features/settings/WorkspaceSettingsDialog.tsx +65 -0
- package/client/features/settings/api.ts +48 -24
- package/client/features/views/ViewBuilder.tsx +5 -4
- package/client/features/views/ViewManager.tsx +25 -22
- package/client/features/views/api.ts +36 -2
- package/client/features/views/useViewBuilderActions.ts +8 -5
- package/client/features/views/useViewBuilderDrafts.ts +23 -21
- package/client/features/views/view-presentation.ts +13 -0
- package/client/features/workspace/{CustomizePanel.tsx → ThemePanel.tsx} +26 -31
- package/client/features/workspace/UnavailablePage.tsx +21 -0
- package/client/features/workspace/WorkspaceLayoutContext.tsx +4 -7
- package/client/features/workspace/WorkspaceScreen.tsx +210 -162
- package/client/features/workspace/WorkspaceSplitLayout.tsx +7 -2
- package/client/features/workspace/WorkspaceTabs.tsx +2 -0
- package/client/features/workspace/api.ts +2 -30
- package/client/features/workspace/moi-context.ts +8 -9
- package/client/features/workspace/tab-resolution.ts +10 -33
- package/client/features/workspace/useWorkspaceNavigation.ts +164 -101
- package/client/index.css +23 -30
- package/client/lib/app-icon-registry.ts +2 -0
- package/client/lib/use-latest-ref.ts +11 -0
- package/client/main.tsx +1 -1
- package/client/runtime/useWorkspaceEvents.ts +59 -14
- package/client/theme.css +5 -5
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-691pqsj6.js +2 -0
- package/dist/chunk-7a5nm4k9.css +1 -0
- package/dist/chunk-amb8y04y.js +1 -0
- package/dist/chunk-cf3pgy7j.js +546 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-mzrgr577.js +5 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-q6a0g26x.js +1 -0
- package/dist/chunk-twgdemkc.js +74 -0
- package/dist/chunk-x90k0f5c.js +2 -0
- package/dist/chunk-yq00csvd.js +2 -0
- package/dist/index.html +1 -1
- package/lib/app-icons.ts +1 -0
- package/lib/applet-selector.ts +24 -0
- package/lib/chat-title.ts +6 -1
- package/lib/default-widgets.ts +32 -0
- package/lib/format.ts +67 -7
- package/lib/message-attachments.ts +40 -0
- package/lib/moi-attachments.ts +204 -0
- package/lib/moi-context.ts +20 -35
- package/lib/navigation.ts +84 -0
- package/lib/themes.ts +6 -6
- package/lib/types.ts +91 -34
- package/lib/workspace-icon.ts +20 -0
- package/lib/workspace-layout.ts +22 -2
- package/lib/workspace-tabs.ts +9 -33
- package/package.json +42 -32
- package/registry.json +656 -0
- package/server/AGENTS.md +2 -0
- package/server/agent.ts +1 -1
- package/server/api.ts +139 -66
- package/server/applet-typecheck.ts +95 -0
- package/server/applets/applet-css.ts +55 -0
- package/server/{bundler → applets}/build-applet.ts +13 -242
- package/server/applets/build-worker.ts +178 -0
- package/server/applets/config.ts +226 -0
- package/server/applets/dependencies.ts +206 -0
- package/server/{applets.ts → applets/index.ts} +44 -189
- package/server/applets/runtime/base.ts +4 -0
- package/server/applets/runtime/moi.ts +42 -0
- package/server/applets/runtime/rpc.ts +17 -0
- package/server/applets/view-source.ts +67 -0
- package/server/attachment-message.ts +95 -0
- package/server/cli-ui-components.ts +28 -33
- package/server/cli.ts +169 -108
- package/server/control.ts +63 -42
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +45 -50
- package/server/harness/acp/NOTES.md +426 -0
- package/server/harness/acp/adapter.ts +7 -21
- package/server/harness/acp/discovery.ts +27 -30
- package/server/harness/acp/model-state.ts +57 -0
- package/server/harness/acp/session.ts +49 -56
- package/server/harness/claude-code/NOTES.md +54 -13
- package/server/harness/claude-code/adapter.ts +8 -25
- package/server/harness/claude-code/cli.ts +40 -0
- package/server/harness/claude-code/index.ts +13 -5
- package/server/harness/claude-code/models.ts +72 -19
- package/server/harness/claude-code/session.ts +447 -343
- package/server/harness/claude-code/sessions.ts +9 -4
- package/server/harness/codex/NOTES.md +222 -350
- package/server/harness/codex/adapter.ts +102 -52
- package/server/harness/codex/auth.ts +1 -3
- package/server/harness/codex/client.ts +169 -249
- package/server/harness/codex/discovery.ts +9 -17
- package/server/harness/codex/index.ts +3 -1
- package/server/harness/codex/pagination.ts +24 -0
- package/server/harness/codex/permissions.ts +32 -8
- package/server/harness/codex/probe.ts +10 -13
- package/server/harness/codex/session.ts +567 -181
- package/server/harness/codex/transport.ts +184 -0
- package/server/harness/debug.ts +1 -1
- package/server/harness/hermes/NOTES.md +19 -1
- package/server/harness/hermes/discovery.ts +20 -0
- package/server/harness/hermes/index.ts +13 -0
- package/server/harness/hermes/models.ts +28 -8
- package/server/harness/openclaw/NOTES.md +1 -1
- package/server/harness/openclaw/adapter.ts +22 -4
- package/server/harness/openclaw/gateway.ts +5 -3
- package/server/harness/openclaw/session.ts +27 -27
- package/server/harness/types.ts +9 -5
- package/server/layout.ts +9 -14
- package/server/moi-scaffold.ts +22 -14
- package/server/navigation-relay.ts +110 -0
- package/server/preview.ts +3 -1
- package/server/registry.ts +71 -41
- package/server/scratchpad-executor.ts +79 -56
- package/server/scratchpad-shape-defaults.ts +82 -0
- package/server/selected-session.ts +24 -4
- package/server/skill-update.ts +5 -3
- package/server/skill-version.ts +4 -7
- package/server/skills-template.ts +48 -9
- package/server/tabs.ts +19 -33
- package/server/tldraw-package.d.ts +4 -0
- package/server/ui-components.ts +101 -434
- package/server/uploads.ts +0 -0
- package/server/view-builders.ts +20 -2
- package/server/views.ts +126 -6
- package/server/web.ts +46 -13
- package/server/widgets.ts +12 -5
- package/server/workspace-config.ts +13 -9
- package/server/workspace-env.ts +3 -2
- package/tsconfig.json +0 -1
- package/ui-components/accordion.tsx +71 -0
- package/ui-components/alert-dialog.tsx +165 -0
- package/ui-components/alert.tsx +68 -0
- package/ui-components/attachment.tsx +195 -0
- package/ui-components/avatar.tsx +90 -0
- package/ui-components/badge.tsx +49 -0
- package/ui-components/button-group.tsx +78 -0
- package/ui-components/button.tsx +55 -0
- package/ui-components/calendar.tsx +180 -0
- package/ui-components/card.tsx +84 -0
- package/ui-components/carousel.tsx +235 -0
- package/ui-components/chart.tsx +338 -0
- package/ui-components/checkbox.tsx +28 -0
- package/ui-components/collapsible.tsx +15 -0
- package/ui-components/combobox.tsx +267 -0
- package/ui-components/context-menu.tsx +244 -0
- package/ui-components/dialog.tsx +138 -0
- package/ui-components/docs/accordion.md +463 -0
- package/ui-components/docs/alert-dialog.md +481 -0
- package/ui-components/docs/alert.md +301 -0
- package/ui-components/docs/attachment.md +689 -0
- package/ui-components/docs/avatar.md +495 -0
- package/ui-components/docs/badge.md +258 -0
- package/ui-components/docs/button-group.md +879 -0
- package/ui-components/docs/button.md +26 -0
- package/ui-components/docs/calendar.md +862 -0
- package/ui-components/docs/card.md +265 -0
- package/ui-components/docs/carousel.md +627 -0
- package/ui-components/docs/chart.md +1256 -0
- package/ui-components/docs/checkbox.md +477 -0
- package/ui-components/docs/collapsible.md +446 -0
- package/ui-components/docs/combobox.md +1003 -0
- package/ui-components/docs/context-menu.md +860 -0
- package/ui-components/docs/data-table.md +1580 -0
- package/ui-components/docs/date-picker.md +614 -0
- package/ui-components/docs/dialog.md +414 -0
- package/ui-components/docs/drawer.md +51 -0
- package/ui-components/docs/dropdown-menu.md +1000 -0
- package/ui-components/docs/field.md +1192 -0
- package/ui-components/docs/hover-card.md +275 -0
- package/ui-components/docs/input-group.md +866 -0
- package/ui-components/docs/input.md +456 -0
- package/ui-components/docs/kbd.md +191 -0
- package/ui-components/docs/label.md +295 -0
- package/ui-components/docs/pagination.md +416 -0
- package/ui-components/docs/popover.md +348 -0
- package/ui-components/docs/progress.md +214 -0
- package/ui-components/docs/radio-group.md +389 -0
- package/ui-components/docs/resizable.md +265 -0
- package/ui-components/docs/select.md +616 -0
- package/ui-components/docs/separator.md +216 -0
- package/ui-components/docs/skeleton.md +205 -0
- package/ui-components/docs/slider.md +226 -0
- package/ui-components/docs/spinner.md +332 -0
- package/ui-components/docs/switch.md +236 -0
- package/ui-components/docs/table.md +551 -0
- package/ui-components/docs/tabs.md +379 -0
- package/ui-components/docs/textarea.md +187 -0
- package/ui-components/docs/toggle-group.md +370 -0
- package/ui-components/docs/toggle.md +91 -0
- package/ui-components/docs/tooltip.md +290 -0
- package/ui-components/drawer.tsx +213 -0
- package/ui-components/dropdown-menu.tsx +263 -0
- package/ui-components/field.tsx +224 -0
- package/ui-components/hover-card.tsx +46 -0
- package/ui-components/input-group.tsx +146 -0
- package/ui-components/input.tsx +20 -0
- package/ui-components/kbd.tsx +32 -0
- package/ui-components/label.tsx +17 -0
- package/ui-components/pagination.tsx +124 -0
- package/ui-components/popover.tsx +81 -0
- package/ui-components/progress.tsx +63 -0
- package/ui-components/radio-group.tsx +38 -0
- package/ui-components/resizable.tsx +40 -0
- package/ui-components/scoped-portal.tsx +31 -0
- package/ui-components/select.tsx +195 -0
- package/ui-components/separator.tsx +18 -0
- package/ui-components/skeleton.tsx +15 -0
- package/ui-components/slider.tsx +75 -0
- package/ui-components/spinner.tsx +20 -0
- package/ui-components/switch.tsx +27 -0
- package/ui-components/table.tsx +86 -0
- package/ui-components/tabs.tsx +75 -0
- package/ui-components/textarea.tsx +17 -0
- package/ui-components/toggle-group.tsx +85 -0
- package/ui-components/toggle.tsx +42 -0
- package/ui-components/tooltip.tsx +61 -0
- package/ui-components/utils.ts +8 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +295 -248
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +100 -152
- package/workspace/.claude/skills/moi-workspace/references/INTENTS.md +156 -0
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +67 -203
- package/client/features/chat/attachment-staging.ts +0 -153
- package/client/features/chat/uploads.ts +0 -18
- package/client/features/chat/useAppletChatMessage.ts +0 -68
- package/client/features/settings/IconPicker.tsx +0 -442
- package/client/features/settings/WorkspaceSettings.tsx +0 -92
- package/client/features/settings/render-icon.ts +0 -173
- package/client/features/widgets/HiddenPanel.tsx +0 -80
- package/client/features/widgets/WidgetGrid.tsx +0 -123
- package/client/features/widgets/Widgets.tsx +0 -264
- package/client/features/widgets/useGridReconcile.ts +0 -73
- package/dist/chunk-104m57qw.js +0 -2
- package/dist/chunk-59zf0m6n.js +0 -1
- package/dist/chunk-bj3akjs2.js +0 -1
- package/dist/chunk-c9pjqx9m.js +0 -14
- package/dist/chunk-j2w2vak4.js +0 -546
- package/dist/chunk-k2r9c95m.js +0 -10
- package/dist/chunk-kmbxhgwv.js +0 -1
- package/dist/chunk-p1yqa71k.js +0 -83
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-r5xrenjy.css +0 -1
- package/dist/chunk-tny85yt2.js +0 -2
- package/dist/chunk-v7wr1df4.js +0 -2
- package/server/bundler/applet-css.ts +0 -155
- /package/client/features/chat/{ChatPromptBubbles.tsx → messages/ChatPromptBubbles.tsx} +0 -0
- /package/client/features/chat/{ShimmerText.tsx → messages/ShimmerText.tsx} +0 -0
- /package/client/features/chat/{preview-turn.ts → messages/preview-turn.ts} +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/CodeBlock.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/Collapse.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ReadImagePreview.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/ToolOutput.tsx +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/detect.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/fixtures.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/claude.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/hermes.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/index.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/mcp.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/openclaw.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shared.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/format/shell.ts +0 -0
- /package/client/features/chat/{tool-group → messages/tool-group}/index.ts +0 -0
- /package/client/features/chat/{useStickToBottom.ts → messages/useStickToBottom.ts} +0 -0
- /package/client/features/chat/{useSelectedSession.ts → sessions/useSelectedSession.ts} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Button as ButtonPrimitive } from '@base-ui/react/button'
|
|
2
|
+
import { type VariantProps, cva } from 'class-variance-authority'
|
|
3
|
+
|
|
4
|
+
import { cn } from './utils'
|
|
5
|
+
|
|
6
|
+
const buttonVariants = cva(
|
|
7
|
+
'inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg text-sm font-medium whitespace-nowrap transition-all duration-100 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default:
|
|
12
|
+
'bg-primary text-primary-foreground inset-shadow-[0_0_8px_color-mix(in_oklab,var(--color-white)_20%,transparent)] hover:bg-primary/90 disabled:bg-accent disabled:text-muted-foreground disabled:opacity-100 disabled:shadow-none',
|
|
13
|
+
secondary:
|
|
14
|
+
'bg-accent text-accent-foreground hover:bg-[color-mix(in_oklch,var(--accent),var(--foreground)_3%)]',
|
|
15
|
+
outline:
|
|
16
|
+
'border bg-background text-foreground hover:bg-[color-mix(in_oklch,var(--background),var(--foreground)_3%)]',
|
|
17
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
18
|
+
destructive:
|
|
19
|
+
'bg-destructive text-white inset-shadow-[0_0_8px_color-mix(in_oklab,var(--color-white)_20%,transparent)] hover:bg-destructive/90 focus-visible:border-destructive/40 focus-visible:ring-destructive/20'
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
xs: 'h-6 gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg]:size-3',
|
|
23
|
+
sm: 'h-7 gap-1.5 rounded-md px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg]:size-4',
|
|
24
|
+
default:
|
|
25
|
+
'h-8 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 [&_svg]:size-5',
|
|
26
|
+
lg: 'h-9 rounded-xl px-3.5 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 [&_svg]:size-5',
|
|
27
|
+
'icon-xs': 'size-6 rounded-md [&_svg]:size-3',
|
|
28
|
+
'icon-sm': 'size-7 rounded-md [&_svg]:size-4',
|
|
29
|
+
icon: 'size-8 [&_svg]:size-5',
|
|
30
|
+
'icon-lg': 'size-9 rounded-xl [&_svg]:size-5'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: 'default',
|
|
35
|
+
size: 'default'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
function Button({
|
|
41
|
+
className,
|
|
42
|
+
variant = 'default',
|
|
43
|
+
size = 'default',
|
|
44
|
+
...props
|
|
45
|
+
}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
|
|
46
|
+
return (
|
|
47
|
+
<ButtonPrimitive
|
|
48
|
+
data-slot="button"
|
|
49
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { Button, buttonVariants }
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { cn } from './utils'
|
|
3
|
+
import { DayPicker, getDefaultClassNames, type DayButton, type Locale } from 'react-day-picker'
|
|
4
|
+
|
|
5
|
+
import { Button, buttonVariants } from './button'
|
|
6
|
+
import { IconChevronLeft, IconChevronRight, IconChevronDown } from '@tabler/icons-react'
|
|
7
|
+
|
|
8
|
+
function Calendar({
|
|
9
|
+
className,
|
|
10
|
+
classNames,
|
|
11
|
+
showOutsideDays = true,
|
|
12
|
+
captionLayout = 'label',
|
|
13
|
+
buttonVariant = 'ghost',
|
|
14
|
+
locale,
|
|
15
|
+
formatters,
|
|
16
|
+
components,
|
|
17
|
+
...props
|
|
18
|
+
}: React.ComponentProps<typeof DayPicker> & {
|
|
19
|
+
buttonVariant?: React.ComponentProps<typeof Button>['variant']
|
|
20
|
+
}) {
|
|
21
|
+
const defaultClassNames = getDefaultClassNames()
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<DayPicker
|
|
25
|
+
showOutsideDays={showOutsideDays}
|
|
26
|
+
className={cn(
|
|
27
|
+
'group/calendar p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent',
|
|
28
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
29
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
32
|
+
captionLayout={captionLayout}
|
|
33
|
+
locale={locale}
|
|
34
|
+
formatters={{
|
|
35
|
+
formatMonthDropdown: date => date.toLocaleString(locale?.code, { month: 'short' }),
|
|
36
|
+
...formatters
|
|
37
|
+
}}
|
|
38
|
+
classNames={{
|
|
39
|
+
root: cn('w-fit', defaultClassNames.root),
|
|
40
|
+
months: cn('relative flex flex-col gap-4 md:flex-row', defaultClassNames.months),
|
|
41
|
+
month: cn('flex w-full flex-col gap-4', defaultClassNames.month),
|
|
42
|
+
nav: cn(
|
|
43
|
+
'absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1',
|
|
44
|
+
defaultClassNames.nav
|
|
45
|
+
),
|
|
46
|
+
button_previous: cn(
|
|
47
|
+
buttonVariants({ variant: buttonVariant }),
|
|
48
|
+
'size-(--cell-size) p-0 select-none aria-disabled:opacity-50',
|
|
49
|
+
defaultClassNames.button_previous
|
|
50
|
+
),
|
|
51
|
+
button_next: cn(
|
|
52
|
+
buttonVariants({ variant: buttonVariant }),
|
|
53
|
+
'size-(--cell-size) p-0 select-none aria-disabled:opacity-50',
|
|
54
|
+
defaultClassNames.button_next
|
|
55
|
+
),
|
|
56
|
+
month_caption: cn(
|
|
57
|
+
'flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)',
|
|
58
|
+
defaultClassNames.month_caption
|
|
59
|
+
),
|
|
60
|
+
dropdowns: cn(
|
|
61
|
+
'flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium',
|
|
62
|
+
defaultClassNames.dropdowns
|
|
63
|
+
),
|
|
64
|
+
dropdown_root: cn('relative rounded-(--cell-radius)', defaultClassNames.dropdown_root),
|
|
65
|
+
dropdown: cn('absolute inset-0 bg-popover opacity-0', defaultClassNames.dropdown),
|
|
66
|
+
caption_label: cn(
|
|
67
|
+
'font-medium select-none',
|
|
68
|
+
captionLayout === 'label'
|
|
69
|
+
? 'text-sm'
|
|
70
|
+
: 'flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-4 [&>svg]:text-muted-foreground',
|
|
71
|
+
defaultClassNames.caption_label
|
|
72
|
+
),
|
|
73
|
+
month_grid: cn('w-full border-collapse', defaultClassNames.month_grid),
|
|
74
|
+
weekdays: cn('flex', defaultClassNames.weekdays),
|
|
75
|
+
weekday: cn(
|
|
76
|
+
'flex-1 rounded-(--cell-radius) text-xs font-normal text-muted-foreground select-none',
|
|
77
|
+
defaultClassNames.weekday
|
|
78
|
+
),
|
|
79
|
+
week: cn('mt-2 flex w-full', defaultClassNames.week),
|
|
80
|
+
week_number_header: cn('w-(--cell-size) select-none', defaultClassNames.week_number_header),
|
|
81
|
+
week_number: cn('text-xs text-muted-foreground select-none', defaultClassNames.week_number),
|
|
82
|
+
day: cn(
|
|
83
|
+
'group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)',
|
|
84
|
+
props.showWeekNumber
|
|
85
|
+
? '[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)'
|
|
86
|
+
: '[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)',
|
|
87
|
+
defaultClassNames.day
|
|
88
|
+
),
|
|
89
|
+
range_start: cn(
|
|
90
|
+
'relative isolate z-0 rounded-l-(--cell-radius) bg-accent after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-accent',
|
|
91
|
+
defaultClassNames.range_start
|
|
92
|
+
),
|
|
93
|
+
range_middle: cn('rounded-none', defaultClassNames.range_middle),
|
|
94
|
+
range_end: cn(
|
|
95
|
+
'relative isolate z-0 rounded-r-(--cell-radius) bg-accent after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-accent',
|
|
96
|
+
defaultClassNames.range_end
|
|
97
|
+
),
|
|
98
|
+
today: cn(
|
|
99
|
+
'rounded-(--cell-radius) bg-accent text-foreground data-[selected=true]:rounded-none',
|
|
100
|
+
defaultClassNames.today
|
|
101
|
+
),
|
|
102
|
+
outside: cn(
|
|
103
|
+
'text-muted-foreground aria-selected:text-muted-foreground',
|
|
104
|
+
defaultClassNames.outside
|
|
105
|
+
),
|
|
106
|
+
disabled: cn('text-muted-foreground opacity-50', defaultClassNames.disabled),
|
|
107
|
+
hidden: cn('invisible', defaultClassNames.hidden),
|
|
108
|
+
...classNames
|
|
109
|
+
}}
|
|
110
|
+
components={{
|
|
111
|
+
Root: ({ className, rootRef, ...props }) => {
|
|
112
|
+
return <div data-slot="calendar" ref={rootRef} className={cn(className)} {...props} />
|
|
113
|
+
},
|
|
114
|
+
Chevron: ({ className, orientation, ...props }) => {
|
|
115
|
+
if (orientation === 'left') {
|
|
116
|
+
return <IconChevronLeft stroke={1.75} className={cn('size-4', className)} {...props} />
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (orientation === 'right') {
|
|
120
|
+
return <IconChevronRight stroke={1.75} className={cn('size-4', className)} {...props} />
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return <IconChevronDown stroke={1.75} className={cn('size-4', className)} {...props} />
|
|
124
|
+
},
|
|
125
|
+
DayButton: ({ ...props }) => <CalendarDayButton locale={locale} {...props} />,
|
|
126
|
+
WeekNumber: ({ children, ...props }) => {
|
|
127
|
+
return (
|
|
128
|
+
<td {...props}>
|
|
129
|
+
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
|
130
|
+
{children}
|
|
131
|
+
</div>
|
|
132
|
+
</td>
|
|
133
|
+
)
|
|
134
|
+
},
|
|
135
|
+
...components
|
|
136
|
+
}}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function CalendarDayButton({
|
|
143
|
+
className,
|
|
144
|
+
day,
|
|
145
|
+
modifiers,
|
|
146
|
+
locale,
|
|
147
|
+
...props
|
|
148
|
+
}: React.ComponentProps<typeof DayButton> & { locale?: Partial<Locale> }) {
|
|
149
|
+
const defaultClassNames = getDefaultClassNames()
|
|
150
|
+
|
|
151
|
+
const ref = React.useRef<HTMLButtonElement>(null)
|
|
152
|
+
React.useEffect(() => {
|
|
153
|
+
if (modifiers.focused) ref.current?.focus()
|
|
154
|
+
}, [modifiers.focused])
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<Button
|
|
158
|
+
variant="ghost"
|
|
159
|
+
size="icon"
|
|
160
|
+
data-day={day.date.toLocaleDateString(locale?.code)}
|
|
161
|
+
data-selected-single={
|
|
162
|
+
modifiers.selected &&
|
|
163
|
+
!modifiers.range_start &&
|
|
164
|
+
!modifiers.range_end &&
|
|
165
|
+
!modifiers.range_middle
|
|
166
|
+
}
|
|
167
|
+
data-range-start={modifiers.range_start}
|
|
168
|
+
data-range-end={modifiers.range_end}
|
|
169
|
+
data-range-middle={modifiers.range_middle}
|
|
170
|
+
className={cn(
|
|
171
|
+
'relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70',
|
|
172
|
+
defaultClassNames.day,
|
|
173
|
+
className
|
|
174
|
+
)}
|
|
175
|
+
{...props}
|
|
176
|
+
/>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { Calendar, CalendarDayButton }
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { cn } from './utils'
|
|
3
|
+
|
|
4
|
+
function Card({
|
|
5
|
+
className,
|
|
6
|
+
size = 'default',
|
|
7
|
+
...props
|
|
8
|
+
}: React.ComponentProps<'div'> & { size?: 'default' | 'sm' }) {
|
|
9
|
+
return (
|
|
10
|
+
<div
|
|
11
|
+
data-slot="card"
|
|
12
|
+
data-size={size}
|
|
13
|
+
className={cn(
|
|
14
|
+
'group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-border [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl',
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
23
|
+
return (
|
|
24
|
+
<div
|
|
25
|
+
data-slot="card-header"
|
|
26
|
+
className={cn(
|
|
27
|
+
'group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)',
|
|
28
|
+
className
|
|
29
|
+
)}
|
|
30
|
+
{...props}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
data-slot="card-title"
|
|
39
|
+
className={cn(
|
|
40
|
+
'text-base leading-snug font-medium group-data-[size=sm]/card:text-sm',
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
|
|
49
|
+
return (
|
|
50
|
+
<div
|
|
51
|
+
data-slot="card-description"
|
|
52
|
+
className={cn('text-sm text-muted-foreground', className)}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
data-slot="card-action"
|
|
62
|
+
className={cn('col-start-2 row-span-2 row-start-1 self-start justify-self-end', className)}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
69
|
+
return (
|
|
70
|
+
<div data-slot="card-content" className={cn('px-(--card-spacing)', className)} {...props} />
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
data-slot="card-footer"
|
|
78
|
+
className={cn('flex items-center rounded-b-xl border-t p-(--card-spacing)', className)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent }
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { cn } from './utils'
|
|
5
|
+
import useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react'
|
|
6
|
+
|
|
7
|
+
import { Button } from './button'
|
|
8
|
+
import { IconChevronLeft, IconChevronRight } from '@tabler/icons-react'
|
|
9
|
+
|
|
10
|
+
type CarouselApi = UseEmblaCarouselType[1]
|
|
11
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
|
|
12
|
+
type CarouselOptions = UseCarouselParameters[0]
|
|
13
|
+
type CarouselPlugin = UseCarouselParameters[1]
|
|
14
|
+
|
|
15
|
+
type CarouselProps = {
|
|
16
|
+
opts?: CarouselOptions
|
|
17
|
+
plugins?: CarouselPlugin
|
|
18
|
+
orientation?: 'horizontal' | 'vertical'
|
|
19
|
+
setApi?: (api: CarouselApi) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type CarouselContextProps = {
|
|
23
|
+
carouselRef: ReturnType<typeof useEmblaCarousel>[0]
|
|
24
|
+
api: ReturnType<typeof useEmblaCarousel>[1]
|
|
25
|
+
scrollPrev: () => void
|
|
26
|
+
scrollNext: () => void
|
|
27
|
+
canScrollPrev: boolean
|
|
28
|
+
canScrollNext: boolean
|
|
29
|
+
} & CarouselProps
|
|
30
|
+
|
|
31
|
+
const CarouselContext = React.createContext<CarouselContextProps | null>(null)
|
|
32
|
+
|
|
33
|
+
function useCarousel() {
|
|
34
|
+
const context = React.useContext(CarouselContext)
|
|
35
|
+
|
|
36
|
+
if (!context) {
|
|
37
|
+
throw new Error('useCarousel must be used within a <Carousel />')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return context
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Carousel({
|
|
44
|
+
orientation = 'horizontal',
|
|
45
|
+
opts,
|
|
46
|
+
setApi,
|
|
47
|
+
plugins,
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
...props
|
|
51
|
+
}: React.ComponentProps<'div'> & CarouselProps) {
|
|
52
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
53
|
+
{
|
|
54
|
+
...opts,
|
|
55
|
+
axis: orientation === 'horizontal' ? 'x' : 'y'
|
|
56
|
+
},
|
|
57
|
+
plugins
|
|
58
|
+
)
|
|
59
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false)
|
|
60
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false)
|
|
61
|
+
|
|
62
|
+
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
63
|
+
if (!api) return
|
|
64
|
+
setCanScrollPrev(api.canScrollPrev())
|
|
65
|
+
setCanScrollNext(api.canScrollNext())
|
|
66
|
+
}, [])
|
|
67
|
+
|
|
68
|
+
const scrollPrev = React.useCallback(() => {
|
|
69
|
+
api?.scrollPrev()
|
|
70
|
+
}, [api])
|
|
71
|
+
|
|
72
|
+
const scrollNext = React.useCallback(() => {
|
|
73
|
+
api?.scrollNext()
|
|
74
|
+
}, [api])
|
|
75
|
+
|
|
76
|
+
const handleKeyDown = React.useCallback(
|
|
77
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
78
|
+
if (event.key === 'ArrowLeft') {
|
|
79
|
+
event.preventDefault()
|
|
80
|
+
scrollPrev()
|
|
81
|
+
} else if (event.key === 'ArrowRight') {
|
|
82
|
+
event.preventDefault()
|
|
83
|
+
scrollNext()
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
[scrollPrev, scrollNext]
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
if (!api || !setApi) return
|
|
91
|
+
setApi(api)
|
|
92
|
+
}, [api, setApi])
|
|
93
|
+
|
|
94
|
+
React.useEffect(() => {
|
|
95
|
+
if (!api) return
|
|
96
|
+
onSelect(api)
|
|
97
|
+
api.on('reInit', onSelect)
|
|
98
|
+
api.on('select', onSelect)
|
|
99
|
+
|
|
100
|
+
return () => {
|
|
101
|
+
api?.off('select', onSelect)
|
|
102
|
+
}
|
|
103
|
+
}, [api, onSelect])
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<CarouselContext.Provider
|
|
107
|
+
value={{
|
|
108
|
+
carouselRef,
|
|
109
|
+
api: api,
|
|
110
|
+
opts,
|
|
111
|
+
orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
|
|
112
|
+
scrollPrev,
|
|
113
|
+
scrollNext,
|
|
114
|
+
canScrollPrev,
|
|
115
|
+
canScrollNext
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
<div
|
|
119
|
+
onKeyDownCapture={handleKeyDown}
|
|
120
|
+
className={cn('relative', className)}
|
|
121
|
+
role="region"
|
|
122
|
+
aria-roledescription="carousel"
|
|
123
|
+
data-slot="carousel"
|
|
124
|
+
{...props}
|
|
125
|
+
>
|
|
126
|
+
{children}
|
|
127
|
+
</div>
|
|
128
|
+
</CarouselContext.Provider>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
133
|
+
const { carouselRef, orientation } = useCarousel()
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div ref={carouselRef} className="overflow-hidden" data-slot="carousel-content">
|
|
137
|
+
<div
|
|
138
|
+
className={cn('flex', orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col', className)}
|
|
139
|
+
{...props}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
|
|
146
|
+
const { orientation } = useCarousel()
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<div
|
|
150
|
+
role="group"
|
|
151
|
+
aria-roledescription="slide"
|
|
152
|
+
data-slot="carousel-item"
|
|
153
|
+
className={cn(
|
|
154
|
+
'min-w-0 shrink-0 grow-0 basis-full',
|
|
155
|
+
orientation === 'horizontal' ? 'pl-4' : 'pt-4',
|
|
156
|
+
className
|
|
157
|
+
)}
|
|
158
|
+
{...props}
|
|
159
|
+
/>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function CarouselPrevious({
|
|
164
|
+
className,
|
|
165
|
+
variant = 'outline',
|
|
166
|
+
size = 'icon-sm',
|
|
167
|
+
...props
|
|
168
|
+
}: React.ComponentProps<typeof Button>) {
|
|
169
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel()
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Button
|
|
173
|
+
data-slot="carousel-previous"
|
|
174
|
+
variant={variant}
|
|
175
|
+
size={size}
|
|
176
|
+
className={cn(
|
|
177
|
+
'absolute touch-manipulation rounded-full',
|
|
178
|
+
orientation === 'horizontal'
|
|
179
|
+
? 'inset-y-0 -left-12 my-auto'
|
|
180
|
+
: '-top-12 left-1/2 -translate-x-1/2 rotate-90',
|
|
181
|
+
className
|
|
182
|
+
)}
|
|
183
|
+
disabled={!canScrollPrev}
|
|
184
|
+
onClick={scrollPrev}
|
|
185
|
+
{...props}
|
|
186
|
+
>
|
|
187
|
+
<IconChevronLeft
|
|
188
|
+
stroke={['xs', 'sm', 'icon-xs', 'icon-sm'].includes(size ?? '') ? 1.75 : 1.5}
|
|
189
|
+
/>
|
|
190
|
+
<span className="sr-only">Previous slide</span>
|
|
191
|
+
</Button>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function CarouselNext({
|
|
196
|
+
className,
|
|
197
|
+
variant = 'outline',
|
|
198
|
+
size = 'icon-sm',
|
|
199
|
+
...props
|
|
200
|
+
}: React.ComponentProps<typeof Button>) {
|
|
201
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel()
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<Button
|
|
205
|
+
data-slot="carousel-next"
|
|
206
|
+
variant={variant}
|
|
207
|
+
size={size}
|
|
208
|
+
className={cn(
|
|
209
|
+
'absolute touch-manipulation rounded-full',
|
|
210
|
+
orientation === 'horizontal'
|
|
211
|
+
? 'inset-y-0 -right-12 my-auto'
|
|
212
|
+
: '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
|
|
213
|
+
className
|
|
214
|
+
)}
|
|
215
|
+
disabled={!canScrollNext}
|
|
216
|
+
onClick={scrollNext}
|
|
217
|
+
{...props}
|
|
218
|
+
>
|
|
219
|
+
<IconChevronRight
|
|
220
|
+
stroke={['xs', 'sm', 'icon-xs', 'icon-sm'].includes(size ?? '') ? 1.75 : 1.5}
|
|
221
|
+
/>
|
|
222
|
+
<span className="sr-only">Next slide</span>
|
|
223
|
+
</Button>
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export {
|
|
228
|
+
type CarouselApi,
|
|
229
|
+
Carousel,
|
|
230
|
+
CarouselContent,
|
|
231
|
+
CarouselItem,
|
|
232
|
+
CarouselPrevious,
|
|
233
|
+
CarouselNext,
|
|
234
|
+
useCarousel
|
|
235
|
+
}
|