pika-ux 1.0.0-beta.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.
- package/LICENSE +9 -0
- package/dist/icon-generator/generate-icon-ts-indices.js +78 -0
- package/dist/shadcn-postinstall/index.js +114 -0
- package/package.json +102 -0
- package/readme.md +50 -0
- package/scripts/setup.js +100 -0
- package/src/App.svelte +51 -0
- package/src/app.css +349 -0
- package/src/icons/ci/index.d.ts +5009 -0
- package/src/icons/lucide/index.d.ts +11274 -0
- package/src/index.ts +23 -0
- package/src/lib/docsite/Navigation.svelte +77 -0
- package/src/lib/docsite/pages/Colors.svelte +35 -0
- package/src/lib/docsite/pages/Components.svelte +50 -0
- package/src/lib/docsite/pages/GettingStarted.svelte +21 -0
- package/src/lib/docsite/pages/Icons.svelte +22 -0
- package/src/lib/docsite/pages/components/Button.svelte +40 -0
- package/src/main.ts +9 -0
- package/src/pika/chip/chip.svelte +95 -0
- package/src/pika/chip/index.ts +1 -0
- package/src/pika/combobox/combobox-types.ts +5 -0
- package/src/pika/combobox/combobox.svelte +221 -0
- package/src/pika/combobox/index.ts +2 -0
- package/src/pika/confirm-dialog/confirm-dialog.svelte +48 -0
- package/src/pika/confirm-dialog/index.ts +1 -0
- package/src/pika/copy-button/copy-button.svelte +134 -0
- package/src/pika/copy-button/index.ts +1 -0
- package/src/pika/create-copy-link-button/create-copy-link-button.svelte +133 -0
- package/src/pika/create-copy-link-button/index.ts +1 -0
- package/src/pika/date-picker/date-picker.svelte +33 -0
- package/src/pika/date-picker/index.ts +1 -0
- package/src/pika/date-range-picker/date-range-picker.svelte +48 -0
- package/src/pika/date-range-picker/index.ts +1 -0
- package/src/pika/date-time-picker/date-time-picker.svelte +336 -0
- package/src/pika/date-time-picker/index.ts +1 -0
- package/src/pika/expandable-container/expandable-container.svelte +155 -0
- package/src/pika/expandable-container/index.ts +1 -0
- package/src/pika/index.ts +29 -0
- package/src/pika/list/index.ts +2 -0
- package/src/pika/list/list-types.ts +5 -0
- package/src/pika/list/list.svelte +349 -0
- package/src/pika/markdown-editor/github.scss +87 -0
- package/src/pika/markdown-editor/index.ts +1 -0
- package/src/pika/markdown-editor/markdown-editor.svelte +44 -0
- package/src/pika/permanent-toast/index.ts +1 -0
- package/src/pika/permanent-toast/permanent-toast.svelte +47 -0
- package/src/pika/pika-alert/index.ts +1 -0
- package/src/pika/pika-alert/pika-alert.svelte +53 -0
- package/src/pika/pika-badge/index.ts +1 -0
- package/src/pika/pika-badge/pika-badge.svelte +61 -0
- package/src/pika/pika-table/index.ts +7 -0
- package/src/pika/pika-table/pika-table-cell.svelte +9 -0
- package/src/pika/pika-table/pika-table-checkbox.svelte +8 -0
- package/src/pika/pika-table/pika-table-column-header.svelte +88 -0
- package/src/pika/pika-table/pika-table-faceted-filter.svelte +109 -0
- package/src/pika/pika-table/pika-table-pagination.svelte +95 -0
- package/src/pika/pika-table/pika-table-row-actions.svelte +58 -0
- package/src/pika/pika-table/pika-table-toolbar.svelte +88 -0
- package/src/pika/pika-table/pika-table-view-options.svelte +35 -0
- package/src/pika/pika-table/pika-table.svelte +295 -0
- package/src/pika/pika-table/types.ts +106 -0
- package/src/pika/pika-tabs/index.ts +18 -0
- package/src/pika/pika-tabs/tabs-content.svelte +16 -0
- package/src/pika/pika-tabs/tabs-list.svelte +12 -0
- package/src/pika/pika-tabs/tabs-trigger.svelte +23 -0
- package/src/pika/popup-help/index.ts +1 -0
- package/src/pika/popup-help/popup-help.svelte +33 -0
- package/src/pika/simple-dropdown/index.ts +2 -0
- package/src/pika/simple-dropdown/simple-dropdown-types.ts +5 -0
- package/src/pika/simple-dropdown/simple-dropdown.svelte +288 -0
- package/src/pika/slideout/constants.ts +5 -0
- package/src/pika/slideout/context.svelte.ts +110 -0
- package/src/pika/slideout/index.ts +19 -0
- package/src/pika/slideout/slideout-content.svelte +36 -0
- package/src/pika/slideout/slideout-panel.svelte +126 -0
- package/src/pika/slideout/slideout-provider.svelte +49 -0
- package/src/pika/slideout/slideout-rail.svelte.die +69 -0
- package/src/pika/slideout/slideout.svelte +33 -0
- package/src/pika/slideout/slideout.svelte.old +113 -0
- package/src/pika/text-wave-shimmer/index.ts +1 -0
- package/src/pika/text-wave-shimmer/text-wave-shimmer.svelte +43 -0
- package/src/pika/tooltip-plus/index.ts +1 -0
- package/src/pika/tooltip-plus/tooltip-plus.svelte +42 -0
- package/src/shadcn/.DS_Store +0 -0
- package/src/shadcn/alert/alert-description.svelte +11 -0
- package/src/shadcn/alert/alert-title.svelte +24 -0
- package/src/shadcn/alert/alert.svelte +39 -0
- package/src/shadcn/alert/index.ts +14 -0
- package/src/shadcn/avatar/avatar-fallback.svelte +13 -0
- package/src/shadcn/avatar/avatar-image.svelte +13 -0
- package/src/shadcn/avatar/avatar.svelte +19 -0
- package/src/shadcn/avatar/index.ts +13 -0
- package/src/shadcn/badge/badge.svelte +48 -0
- package/src/shadcn/badge/index.ts +2 -0
- package/src/shadcn/breadcrumb/breadcrumb-ellipsis.svelte +12 -0
- package/src/shadcn/breadcrumb/breadcrumb-item.svelte +20 -0
- package/src/shadcn/breadcrumb/breadcrumb-link.svelte +31 -0
- package/src/shadcn/breadcrumb/breadcrumb-list.svelte +20 -0
- package/src/shadcn/breadcrumb/breadcrumb-page.svelte +23 -0
- package/src/shadcn/breadcrumb/breadcrumb-separator.svelte +15 -0
- package/src/shadcn/breadcrumb/breadcrumb.svelte +15 -0
- package/src/shadcn/breadcrumb/index.ts +25 -0
- package/src/shadcn/button/button.svelte +81 -0
- package/src/shadcn/button/index.ts +17 -0
- package/src/shadcn/calendar/calendar-caption.svelte +76 -0
- package/src/shadcn/calendar/calendar-cell.svelte +19 -0
- package/src/shadcn/calendar/calendar-day.svelte +31 -0
- package/src/shadcn/calendar/calendar-grid-body.svelte +12 -0
- package/src/shadcn/calendar/calendar-grid-head.svelte +12 -0
- package/src/shadcn/calendar/calendar-grid-row.svelte +12 -0
- package/src/shadcn/calendar/calendar-grid.svelte +16 -0
- package/src/shadcn/calendar/calendar-head-cell.svelte +16 -0
- package/src/shadcn/calendar/calendar-header.svelte +16 -0
- package/src/shadcn/calendar/calendar-heading.svelte +12 -0
- package/src/shadcn/calendar/calendar-month-select.svelte +25 -0
- package/src/shadcn/calendar/calendar-month.svelte +15 -0
- package/src/shadcn/calendar/calendar-months.svelte +20 -0
- package/src/shadcn/calendar/calendar-nav.svelte +19 -0
- package/src/shadcn/calendar/calendar-next-button.svelte +19 -0
- package/src/shadcn/calendar/calendar-prev-button.svelte +19 -0
- package/src/shadcn/calendar/calendar-year-select.svelte +25 -0
- package/src/shadcn/calendar/calendar.svelte +61 -0
- package/src/shadcn/calendar/index.ts +30 -0
- package/src/shadcn/card/card-content.svelte +16 -0
- package/src/shadcn/card/card-description.svelte +16 -0
- package/src/shadcn/card/card-footer.svelte +16 -0
- package/src/shadcn/card/card-header.svelte +16 -0
- package/src/shadcn/card/card-title.svelte +25 -0
- package/src/shadcn/card/card.svelte +20 -0
- package/src/shadcn/card/index.ts +22 -0
- package/src/shadcn/carousel/carousel-content.svelte +39 -0
- package/src/shadcn/carousel/carousel-item.svelte +26 -0
- package/src/shadcn/carousel/carousel-next.svelte +30 -0
- package/src/shadcn/carousel/carousel-previous.svelte +30 -0
- package/src/shadcn/carousel/carousel.svelte +88 -0
- package/src/shadcn/carousel/context.ts +51 -0
- package/src/shadcn/carousel/index.ts +19 -0
- package/src/shadcn/checkbox/checkbox.svelte +36 -0
- package/src/shadcn/checkbox/index.ts +6 -0
- package/src/shadcn/collapsible/collapsible-content.svelte +7 -0
- package/src/shadcn/collapsible/collapsible-trigger.svelte +7 -0
- package/src/shadcn/collapsible/collapsible.svelte +11 -0
- package/src/shadcn/collapsible/index.ts +13 -0
- package/src/shadcn/command/command-dialog.svelte +40 -0
- package/src/shadcn/command/command-empty.svelte +13 -0
- package/src/shadcn/command/command-group.svelte +30 -0
- package/src/shadcn/command/command-input.svelte +21 -0
- package/src/shadcn/command/command-item.svelte +16 -0
- package/src/shadcn/command/command-link-item.svelte +16 -0
- package/src/shadcn/command/command-list.svelte +13 -0
- package/src/shadcn/command/command-separator.svelte +13 -0
- package/src/shadcn/command/command-shortcut.svelte +20 -0
- package/src/shadcn/command/command.svelte +19 -0
- package/src/shadcn/command/index.ts +40 -0
- package/src/shadcn/data-table/data-table.svelte.ts +141 -0
- package/src/shadcn/data-table/flex-render.svelte +36 -0
- package/src/shadcn/data-table/index.ts +3 -0
- package/src/shadcn/data-table/render-helpers.ts +111 -0
- package/src/shadcn/dialog/dialog-close.svelte +7 -0
- package/src/shadcn/dialog/dialog-content.svelte +43 -0
- package/src/shadcn/dialog/dialog-description.svelte +13 -0
- package/src/shadcn/dialog/dialog-footer.svelte +20 -0
- package/src/shadcn/dialog/dialog-header.svelte +20 -0
- package/src/shadcn/dialog/dialog-overlay.svelte +16 -0
- package/src/shadcn/dialog/dialog-title.svelte +13 -0
- package/src/shadcn/dialog/dialog-trigger.svelte +7 -0
- package/src/shadcn/dialog/index.ts +37 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-checkbox-item.svelte +41 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-content.svelte +27 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-group-heading.svelte +22 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-group.svelte +7 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-item.svelte +27 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-label.svelte +24 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-radio-group.svelte +16 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-radio-item.svelte +26 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-separator.svelte +13 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-shortcut.svelte +20 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-sub-content.svelte +16 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-sub-trigger.svelte +29 -0
- package/src/shadcn/dropdown-menu/dropdown-menu-trigger.svelte +7 -0
- package/src/shadcn/dropdown-menu/index.ts +49 -0
- package/src/shadcn/index.ts +40 -0
- package/src/shadcn/input/index.ts +7 -0
- package/src/shadcn/input/input.svelte +51 -0
- package/src/shadcn/is-mobile.svelte.ts +9 -0
- package/src/shadcn/label/index.ts +7 -0
- package/src/shadcn/label/label.svelte +16 -0
- package/src/shadcn/popover/index.ts +17 -0
- package/src/shadcn/popover/popover-content.svelte +29 -0
- package/src/shadcn/popover/popover-trigger.svelte +8 -0
- package/src/shadcn/radio-group/index.ts +10 -0
- package/src/shadcn/radio-group/radio-group-item.svelte +25 -0
- package/src/shadcn/radio-group/radio-group.svelte +19 -0
- package/src/shadcn/range-calendar/index.ts +30 -0
- package/src/shadcn/range-calendar/range-calendar-cell.svelte +19 -0
- package/src/shadcn/range-calendar/range-calendar-day.svelte +35 -0
- package/src/shadcn/range-calendar/range-calendar-grid-body.svelte +12 -0
- package/src/shadcn/range-calendar/range-calendar-grid-head.svelte +12 -0
- package/src/shadcn/range-calendar/range-calendar-grid-row.svelte +12 -0
- package/src/shadcn/range-calendar/range-calendar-grid.svelte +16 -0
- package/src/shadcn/range-calendar/range-calendar-head-cell.svelte +16 -0
- package/src/shadcn/range-calendar/range-calendar-header.svelte +16 -0
- package/src/shadcn/range-calendar/range-calendar-heading.svelte +16 -0
- package/src/shadcn/range-calendar/range-calendar-months.svelte +20 -0
- package/src/shadcn/range-calendar/range-calendar-next-button.svelte +18 -0
- package/src/shadcn/range-calendar/range-calendar-prev-button.svelte +18 -0
- package/src/shadcn/range-calendar/range-calendar.svelte +57 -0
- package/src/shadcn/resizable/index.ts +13 -0
- package/src/shadcn/resizable/resizable-handle.svelte +30 -0
- package/src/shadcn/resizable/resizable-pane-group.svelte +22 -0
- package/src/shadcn/scroll-area/index.ts +10 -0
- package/src/shadcn/scroll-area/scroll-area-scrollbar.svelte +28 -0
- package/src/shadcn/scroll-area/scroll-area.svelte +35 -0
- package/src/shadcn/select/index.ts +37 -0
- package/src/shadcn/select/select-content.svelte +38 -0
- package/src/shadcn/select/select-group-heading.svelte +21 -0
- package/src/shadcn/select/select-group.svelte +7 -0
- package/src/shadcn/select/select-item.svelte +31 -0
- package/src/shadcn/select/select-label.svelte +20 -0
- package/src/shadcn/select/select-scroll-down-button.svelte +11 -0
- package/src/shadcn/select/select-scroll-up-button.svelte +11 -0
- package/src/shadcn/select/select-separator.svelte +14 -0
- package/src/shadcn/select/select-trigger.svelte +30 -0
- package/src/shadcn/separator/index.ts +7 -0
- package/src/shadcn/separator/separator.svelte +16 -0
- package/src/shadcn/sheet/index.ts +36 -0
- package/src/shadcn/sheet/sheet-close.svelte +7 -0
- package/src/shadcn/sheet/sheet-content.svelte +66 -0
- package/src/shadcn/sheet/sheet-description.svelte +13 -0
- package/src/shadcn/sheet/sheet-footer.svelte +15 -0
- package/src/shadcn/sheet/sheet-header.svelte +15 -0
- package/src/shadcn/sheet/sheet-overlay.svelte +16 -0
- package/src/shadcn/sheet/sheet-title.svelte +13 -0
- package/src/shadcn/sheet/sheet-trigger.svelte +7 -0
- package/src/shadcn/sidebar/constants.ts +6 -0
- package/src/shadcn/sidebar/context.svelte.ts +80 -0
- package/src/shadcn/sidebar/index.ts +75 -0
- package/src/shadcn/sidebar/sidebar-content.svelte +24 -0
- package/src/shadcn/sidebar/sidebar-footer.svelte +21 -0
- package/src/shadcn/sidebar/sidebar-group-action.svelte +36 -0
- package/src/shadcn/sidebar/sidebar-group-content.svelte +21 -0
- package/src/shadcn/sidebar/sidebar-group-label.svelte +34 -0
- package/src/shadcn/sidebar/sidebar-group.svelte +21 -0
- package/src/shadcn/sidebar/sidebar-header.svelte +21 -0
- package/src/shadcn/sidebar/sidebar-input.svelte +21 -0
- package/src/shadcn/sidebar/sidebar-inset.svelte +24 -0
- package/src/shadcn/sidebar/sidebar-menu-action.svelte +43 -0
- package/src/shadcn/sidebar/sidebar-menu-badge.svelte +29 -0
- package/src/shadcn/sidebar/sidebar-menu-button.svelte +101 -0
- package/src/shadcn/sidebar/sidebar-menu-item.svelte +21 -0
- package/src/shadcn/sidebar/sidebar-menu-skeleton.svelte +36 -0
- package/src/shadcn/sidebar/sidebar-menu-sub-button.svelte +43 -0
- package/src/shadcn/sidebar/sidebar-menu-sub-item.svelte +21 -0
- package/src/shadcn/sidebar/sidebar-menu-sub.svelte +25 -0
- package/src/shadcn/sidebar/sidebar-menu.svelte +21 -0
- package/src/shadcn/sidebar/sidebar-provider.svelte +46 -0
- package/src/shadcn/sidebar/sidebar-rail.svelte +36 -0
- package/src/shadcn/sidebar/sidebar-separator.svelte +15 -0
- package/src/shadcn/sidebar/sidebar-trigger.svelte +35 -0
- package/src/shadcn/sidebar/sidebar.svelte +94 -0
- package/src/shadcn/skeleton/index.ts +7 -0
- package/src/shadcn/skeleton/skeleton.svelte +17 -0
- package/src/shadcn/slider/index.ts +7 -0
- package/src/shadcn/slider/slider.svelte +44 -0
- package/src/shadcn/sonner/index.ts +1 -0
- package/src/shadcn/sonner/sonner.svelte +13 -0
- package/src/shadcn/switch/index.ts +7 -0
- package/src/shadcn/switch/switch.svelte +27 -0
- package/src/shadcn/table/index.ts +28 -0
- package/src/shadcn/table/table-body.svelte +15 -0
- package/src/shadcn/table/table-caption.svelte +20 -0
- package/src/shadcn/table/table-cell.svelte +20 -0
- package/src/shadcn/table/table-footer.svelte +20 -0
- package/src/shadcn/table/table-head.svelte +23 -0
- package/src/shadcn/table/table-header.svelte +15 -0
- package/src/shadcn/table/table-row.svelte +23 -0
- package/src/shadcn/table/table.svelte +17 -0
- package/src/shadcn/tabs/index.ts +18 -0
- package/src/shadcn/tabs/tabs-content.svelte +21 -0
- package/src/shadcn/tabs/tabs-list.svelte +19 -0
- package/src/shadcn/tabs/tabs-trigger.svelte +21 -0
- package/src/shadcn/textarea/index.ts +7 -0
- package/src/shadcn/textarea/textarea.svelte +22 -0
- package/src/shadcn/toggle/index.ts +13 -0
- package/src/shadcn/toggle/toggle.svelte +51 -0
- package/src/shadcn/toggle-group/index.ts +10 -0
- package/src/shadcn/toggle-group/toggle-group-item.svelte +30 -0
- package/src/shadcn/toggle-group/toggle-group.svelte +41 -0
- package/src/shadcn/tooltip/index.ts +21 -0
- package/src/shadcn/tooltip/tooltip-content.svelte +47 -0
- package/src/shadcn/tooltip/tooltip-trigger.svelte +7 -0
- package/src/shadcn/utils.ts +14 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Root from "./breadcrumb.svelte";
|
|
2
|
+
import Ellipsis from "./breadcrumb-ellipsis.svelte";
|
|
3
|
+
import Item from "./breadcrumb-item.svelte";
|
|
4
|
+
import Separator from "./breadcrumb-separator.svelte";
|
|
5
|
+
import Link from "./breadcrumb-link.svelte";
|
|
6
|
+
import List from "./breadcrumb-list.svelte";
|
|
7
|
+
import Page from "./breadcrumb-page.svelte";
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
Root,
|
|
11
|
+
Ellipsis,
|
|
12
|
+
Item,
|
|
13
|
+
Separator,
|
|
14
|
+
Link,
|
|
15
|
+
List,
|
|
16
|
+
Page,
|
|
17
|
+
//
|
|
18
|
+
Root as Breadcrumb,
|
|
19
|
+
Ellipsis as BreadcrumbEllipsis,
|
|
20
|
+
Item as BreadcrumbItem,
|
|
21
|
+
Separator as BreadcrumbSeparator,
|
|
22
|
+
Link as BreadcrumbLink,
|
|
23
|
+
List as BreadcrumbList,
|
|
24
|
+
Page as BreadcrumbPage,
|
|
25
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { cn, type WithElementRef } from '../utils.js';
|
|
3
|
+
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
4
|
+
import { type VariantProps, tv } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
export const buttonVariants = tv({
|
|
7
|
+
base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90 active:brightness-90',
|
|
11
|
+
destructive:
|
|
12
|
+
'bg-destructive shadow-xs hover:bg-destructive/90 active:bg-destructive/70 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 text-white',
|
|
13
|
+
outline:
|
|
14
|
+
'bg-background shadow-xs hover:bg-accent hover:text-accent-foreground active:brightness-90 active:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border',
|
|
15
|
+
secondary:
|
|
16
|
+
'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80 active:brightness-90',
|
|
17
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground active:bg-accent/80 active:brightness-90 dark:hover:bg-accent/50',
|
|
18
|
+
link: 'text-primary underline-offset-4 hover:underline active:text-primary/70',
|
|
19
|
+
},
|
|
20
|
+
size: {
|
|
21
|
+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
|
22
|
+
sm: 'h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5',
|
|
23
|
+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
|
|
24
|
+
icon: 'size-9',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
variant: 'default',
|
|
29
|
+
size: 'default',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
|
|
34
|
+
export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
|
|
35
|
+
|
|
36
|
+
export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
|
|
37
|
+
WithElementRef<HTMLAnchorAttributes> & {
|
|
38
|
+
variant?: ButtonVariant;
|
|
39
|
+
size?: ButtonSize;
|
|
40
|
+
};
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<script lang="ts">
|
|
44
|
+
let {
|
|
45
|
+
class: className,
|
|
46
|
+
variant = 'default',
|
|
47
|
+
size = 'default',
|
|
48
|
+
ref = $bindable(null),
|
|
49
|
+
href = undefined,
|
|
50
|
+
type = 'button',
|
|
51
|
+
disabled,
|
|
52
|
+
children,
|
|
53
|
+
...restProps
|
|
54
|
+
}: ButtonProps = $props();
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
{#if href}
|
|
58
|
+
<a
|
|
59
|
+
bind:this={ref}
|
|
60
|
+
data-slot="button"
|
|
61
|
+
class={cn(buttonVariants({ variant, size }), className)}
|
|
62
|
+
href={disabled ? undefined : href}
|
|
63
|
+
aria-disabled={disabled}
|
|
64
|
+
role={disabled ? 'link' : undefined}
|
|
65
|
+
tabindex={disabled ? -1 : undefined}
|
|
66
|
+
{...restProps}
|
|
67
|
+
>
|
|
68
|
+
{@render children?.()}
|
|
69
|
+
</a>
|
|
70
|
+
{:else}
|
|
71
|
+
<button
|
|
72
|
+
bind:this={ref}
|
|
73
|
+
data-slot="button"
|
|
74
|
+
class={cn(buttonVariants({ variant, size }), className)}
|
|
75
|
+
{type}
|
|
76
|
+
{disabled}
|
|
77
|
+
{...restProps}
|
|
78
|
+
>
|
|
79
|
+
{@render children?.()}
|
|
80
|
+
</button>
|
|
81
|
+
{/if}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Root, {
|
|
2
|
+
type ButtonProps,
|
|
3
|
+
type ButtonSize,
|
|
4
|
+
type ButtonVariant,
|
|
5
|
+
buttonVariants,
|
|
6
|
+
} from "./button.svelte";
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
Root,
|
|
10
|
+
type ButtonProps as Props,
|
|
11
|
+
//
|
|
12
|
+
Root as Button,
|
|
13
|
+
buttonVariants,
|
|
14
|
+
type ButtonProps,
|
|
15
|
+
type ButtonSize,
|
|
16
|
+
type ButtonVariant,
|
|
17
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from "svelte";
|
|
3
|
+
import type Calendar from "./calendar.svelte";
|
|
4
|
+
import CalendarMonthSelect from "./calendar-month-select.svelte";
|
|
5
|
+
import CalendarYearSelect from "./calendar-year-select.svelte";
|
|
6
|
+
import { DateFormatter, getLocalTimeZone, type DateValue } from "@internationalized/date";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
captionLayout,
|
|
10
|
+
months,
|
|
11
|
+
monthFormat,
|
|
12
|
+
years,
|
|
13
|
+
yearFormat,
|
|
14
|
+
month,
|
|
15
|
+
locale,
|
|
16
|
+
placeholder = $bindable(),
|
|
17
|
+
monthIndex = 0,
|
|
18
|
+
}: {
|
|
19
|
+
captionLayout: ComponentProps<typeof Calendar>["captionLayout"];
|
|
20
|
+
months: ComponentProps<typeof CalendarMonthSelect>["months"];
|
|
21
|
+
monthFormat: ComponentProps<typeof CalendarMonthSelect>["monthFormat"];
|
|
22
|
+
years: ComponentProps<typeof CalendarYearSelect>["years"];
|
|
23
|
+
yearFormat: ComponentProps<typeof CalendarYearSelect>["yearFormat"];
|
|
24
|
+
month: DateValue;
|
|
25
|
+
placeholder: DateValue | undefined;
|
|
26
|
+
locale: string;
|
|
27
|
+
monthIndex: number;
|
|
28
|
+
} = $props();
|
|
29
|
+
|
|
30
|
+
function formatYear(date: DateValue) {
|
|
31
|
+
const dateObj = date.toDate(getLocalTimeZone());
|
|
32
|
+
if (typeof yearFormat === "function") return yearFormat(dateObj.getFullYear());
|
|
33
|
+
return new DateFormatter(locale, { year: yearFormat }).format(dateObj);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function formatMonth(date: DateValue) {
|
|
37
|
+
const dateObj = date.toDate(getLocalTimeZone());
|
|
38
|
+
if (typeof monthFormat === "function") return monthFormat(dateObj.getMonth() + 1);
|
|
39
|
+
return new DateFormatter(locale, { month: monthFormat }).format(dateObj);
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
{#snippet MonthSelect()}
|
|
44
|
+
<CalendarMonthSelect
|
|
45
|
+
{months}
|
|
46
|
+
{monthFormat}
|
|
47
|
+
value={month.month}
|
|
48
|
+
onchange={(e) => {
|
|
49
|
+
if (!placeholder) return;
|
|
50
|
+
const v = Number.parseInt(e.currentTarget.value);
|
|
51
|
+
const newPlaceholder = placeholder.set({ month: v });
|
|
52
|
+
placeholder = newPlaceholder.subtract({ months: monthIndex });
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
{/snippet}
|
|
56
|
+
|
|
57
|
+
{#snippet YearSelect()}
|
|
58
|
+
<CalendarYearSelect {years} {yearFormat} value={month.year} />
|
|
59
|
+
{/snippet}
|
|
60
|
+
|
|
61
|
+
{#if captionLayout === "dropdown"}
|
|
62
|
+
{@render MonthSelect()}
|
|
63
|
+
{@render YearSelect()}
|
|
64
|
+
{:else if captionLayout === "dropdown-months"}
|
|
65
|
+
{@render MonthSelect()}
|
|
66
|
+
{#if placeholder}
|
|
67
|
+
{formatYear(placeholder)}
|
|
68
|
+
{/if}
|
|
69
|
+
{:else if captionLayout === "dropdown-years"}
|
|
70
|
+
{#if placeholder}
|
|
71
|
+
{formatMonth(placeholder)}
|
|
72
|
+
{/if}
|
|
73
|
+
{@render YearSelect()}
|
|
74
|
+
{:else}
|
|
75
|
+
{formatMonth(month)} {formatYear(month)}
|
|
76
|
+
{/if}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.CellProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.Cell
|
|
13
|
+
class={cn(
|
|
14
|
+
"[&:has([data-selected])]:bg-accent [&:has([data-selected][data-outside-month])]:bg-accent/50 relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([data-selected])]:rounded-md",
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
bind:ref
|
|
18
|
+
{...restProps}
|
|
19
|
+
/>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { buttonVariants } from "../button/index.js";
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
...restProps
|
|
10
|
+
}: CalendarPrimitive.DayProps = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<CalendarPrimitive.Day
|
|
14
|
+
class={cn(
|
|
15
|
+
buttonVariants({ variant: "ghost" }),
|
|
16
|
+
"size-8 p-0 font-normal",
|
|
17
|
+
// Today
|
|
18
|
+
"[&[data-today]:not([data-selected])]:bg-accent [&[data-today]:not([data-selected])]:text-accent-foreground",
|
|
19
|
+
// Selected
|
|
20
|
+
"data-[selected]:bg-primary data-[selected]:text-primary-foreground data-[selected]:hover:bg-primary data-[selected]:hover:text-primary-foreground data-[selected]:focus:bg-primary data-[selected]:focus:text-primary-foreground data-[selected]:opacity-100",
|
|
21
|
+
// Disabled
|
|
22
|
+
"data-[disabled]:text-muted-foreground data-[disabled]:opacity-50",
|
|
23
|
+
// Unavailable
|
|
24
|
+
"data-[unavailable]:text-destructive-foreground data-[unavailable]:line-through",
|
|
25
|
+
// Outside months
|
|
26
|
+
"data-[outside-month]:text-muted-foreground [&[data-outside-month][data-selected]]:bg-accent/50 [&[data-outside-month][data-selected]]:text-muted-foreground data-[outside-month]:pointer-events-none data-[outside-month]:opacity-50 [&[data-outside-month][data-selected]]:opacity-30",
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
bind:ref
|
|
30
|
+
{...restProps}
|
|
31
|
+
/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.GridBodyProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.GridBody bind:ref class={cn(className)} {...restProps} />
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.GridHeadProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.GridHead bind:ref class={cn(className)} {...restProps} />
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.GridRowProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.GridRow bind:ref class={cn("flex", className)} {...restProps} />
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.GridProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.Grid
|
|
13
|
+
bind:ref
|
|
14
|
+
class={cn("w-full border-collapse space-y-1", className)}
|
|
15
|
+
{...restProps}
|
|
16
|
+
/>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.HeadCellProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.HeadCell
|
|
13
|
+
bind:ref
|
|
14
|
+
class={cn("text-muted-foreground w-8 rounded-md text-[0.8rem] font-normal", className)}
|
|
15
|
+
{...restProps}
|
|
16
|
+
/>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.HeaderProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.Header
|
|
13
|
+
bind:ref
|
|
14
|
+
class={cn("relative flex w-full items-center justify-between pt-1", className)}
|
|
15
|
+
{...restProps}
|
|
16
|
+
/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.HeadingProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.Heading bind:ref class={cn("text-sm font-medium", className)} {...restProps} />
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from 'bits-ui';
|
|
3
|
+
import { cn, type WithoutChildrenOrChild } from '../utils';
|
|
4
|
+
import ChevronDownIcon from '$icons/lucide/chevron-down';
|
|
5
|
+
|
|
6
|
+
let { ref = $bindable(null), class: className, value, onchange, ...restProps }: WithoutChildrenOrChild<CalendarPrimitive.MonthSelectProps> = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<span class={cn('has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative flex rounded-md border', className)}>
|
|
10
|
+
<CalendarPrimitive.MonthSelect bind:ref class="absolute inset-0 opacity-0" {...restProps}>
|
|
11
|
+
{#snippet child({ props, monthItems, selectedMonthItem })}
|
|
12
|
+
<select {...props} {value} {onchange}>
|
|
13
|
+
{#each monthItems as monthItem (monthItem.value)}
|
|
14
|
+
<option value={monthItem.value} selected={value !== undefined ? monthItem.value === value : monthItem.value === selectedMonthItem.value}>
|
|
15
|
+
{monthItem.label}
|
|
16
|
+
</option>
|
|
17
|
+
{/each}
|
|
18
|
+
</select>
|
|
19
|
+
<span class="[&>svg]:text-muted-foreground flex h-8 select-none items-center gap-1 rounded-md pl-2 pr-1 text-sm font-medium [&>svg]:size-3.5" aria-hidden="true">
|
|
20
|
+
{monthItems.find((item) => item.value === value)?.label || selectedMonthItem.label}
|
|
21
|
+
<ChevronDownIcon class="size-4" />
|
|
22
|
+
</span>
|
|
23
|
+
{/snippet}
|
|
24
|
+
</CalendarPrimitive.MonthSelect>
|
|
25
|
+
</span>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type WithElementRef, cn } from '../utils';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
children,
|
|
9
|
+
...restProps
|
|
10
|
+
}: WithElementRef<HTMLAttributes<HTMLElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div {...restProps} bind:this={ref} class={cn('flex flex-col', className)}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { WithElementRef } from "bits-ui";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...restProps
|
|
11
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div
|
|
15
|
+
bind:this={ref}
|
|
16
|
+
class={cn("mt-4 flex flex-col space-y-4 sm:flex-row sm:space-x-4 sm:space-y-0", className)}
|
|
17
|
+
{...restProps}
|
|
18
|
+
>
|
|
19
|
+
{@render children?.()}
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn, type WithElementRef } from '../utils';
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
children,
|
|
9
|
+
...restProps
|
|
10
|
+
}: WithElementRef<HTMLAttributes<HTMLElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<nav
|
|
14
|
+
{...restProps}
|
|
15
|
+
bind:this={ref}
|
|
16
|
+
class={cn('absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1', className)}
|
|
17
|
+
>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</nav>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from 'bits-ui';
|
|
3
|
+
import ChevronRight from '$icons/lucide/chevron-right';
|
|
4
|
+
import { buttonVariants } from '../button/index.js';
|
|
5
|
+
import { cn } from '../utils.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, children, ...restProps }: CalendarPrimitive.NextButtonProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#snippet Fallback()}
|
|
11
|
+
<ChevronRight />
|
|
12
|
+
{/snippet}
|
|
13
|
+
|
|
14
|
+
<CalendarPrimitive.NextButton
|
|
15
|
+
bind:ref
|
|
16
|
+
class={cn(buttonVariants({ variant: 'outline' }), 'size-7 bg-transparent p-0 opacity-50 hover:opacity-100', className)}
|
|
17
|
+
{...restProps}
|
|
18
|
+
children={children || Fallback}
|
|
19
|
+
/>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from 'bits-ui';
|
|
3
|
+
import ChevronLeft from '$icons/lucide/chevron-left';
|
|
4
|
+
import { buttonVariants } from '../button/index.js';
|
|
5
|
+
import { cn } from '../utils.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, children, ...restProps }: CalendarPrimitive.PrevButtonProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#snippet Fallback()}
|
|
11
|
+
<ChevronLeft />
|
|
12
|
+
{/snippet}
|
|
13
|
+
|
|
14
|
+
<CalendarPrimitive.PrevButton
|
|
15
|
+
bind:ref
|
|
16
|
+
class={cn(buttonVariants({ variant: 'outline' }), 'size-7 bg-transparent p-0 opacity-50 hover:opacity-100', className)}
|
|
17
|
+
{...restProps}
|
|
18
|
+
children={children || Fallback}
|
|
19
|
+
/>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from 'bits-ui';
|
|
3
|
+
import { cn, type WithoutChildrenOrChild } from '../utils';
|
|
4
|
+
import ChevronDownIcon from '$icons/lucide/chevron-down';
|
|
5
|
+
|
|
6
|
+
let { ref = $bindable(null), class: className, value, ...restProps }: WithoutChildrenOrChild<CalendarPrimitive.YearSelectProps> = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<span class={cn('has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative flex rounded-md border', className)}>
|
|
10
|
+
<CalendarPrimitive.YearSelect bind:ref class="absolute inset-0 opacity-0" {...restProps}>
|
|
11
|
+
{#snippet child({ props, yearItems, selectedYearItem })}
|
|
12
|
+
<select {...props} {value}>
|
|
13
|
+
{#each yearItems as yearItem (yearItem.value)}
|
|
14
|
+
<option value={yearItem.value} selected={value !== undefined ? yearItem.value === value : yearItem.value === selectedYearItem.value}>
|
|
15
|
+
{yearItem.label}
|
|
16
|
+
</option>
|
|
17
|
+
{/each}
|
|
18
|
+
</select>
|
|
19
|
+
<span class="[&>svg]:text-muted-foreground flex h-8 select-none items-center gap-1 rounded-md pl-2 pr-1 text-sm font-medium [&>svg]:size-3.5" aria-hidden="true">
|
|
20
|
+
{yearItems.find((item) => item.value === value)?.label || selectedYearItem.label}
|
|
21
|
+
<ChevronDownIcon class="size-4" />
|
|
22
|
+
</span>
|
|
23
|
+
{/snippet}
|
|
24
|
+
</CalendarPrimitive.YearSelect>
|
|
25
|
+
</span>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive, type WithoutChildrenOrChild } from "bits-ui";
|
|
3
|
+
import * as Calendar from "./index.js";
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
value = $bindable(),
|
|
9
|
+
placeholder = $bindable(),
|
|
10
|
+
class: className,
|
|
11
|
+
weekdayFormat = "short",
|
|
12
|
+
...restProps
|
|
13
|
+
}: WithoutChildrenOrChild<CalendarPrimitive.RootProps> = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<!--
|
|
17
|
+
Discriminated Unions + Destructing (required for bindable) do not
|
|
18
|
+
get along, so we shut typescript up by casting `value` to `never`.
|
|
19
|
+
-->
|
|
20
|
+
<CalendarPrimitive.Root
|
|
21
|
+
bind:value={value as never}
|
|
22
|
+
bind:ref
|
|
23
|
+
bind:placeholder
|
|
24
|
+
{weekdayFormat}
|
|
25
|
+
class={cn("p-3", className)}
|
|
26
|
+
{...restProps}
|
|
27
|
+
>
|
|
28
|
+
{#snippet children({ months, weekdays })}
|
|
29
|
+
<Calendar.Header>
|
|
30
|
+
<Calendar.PrevButton />
|
|
31
|
+
<Calendar.Heading />
|
|
32
|
+
<Calendar.NextButton />
|
|
33
|
+
</Calendar.Header>
|
|
34
|
+
<Calendar.Months>
|
|
35
|
+
{#each months as month (month)}
|
|
36
|
+
<Calendar.Grid>
|
|
37
|
+
<Calendar.GridHead>
|
|
38
|
+
<Calendar.GridRow class="flex">
|
|
39
|
+
{#each weekdays as weekday (weekday)}
|
|
40
|
+
<Calendar.HeadCell>
|
|
41
|
+
{weekday.slice(0, 2)}
|
|
42
|
+
</Calendar.HeadCell>
|
|
43
|
+
{/each}
|
|
44
|
+
</Calendar.GridRow>
|
|
45
|
+
</Calendar.GridHead>
|
|
46
|
+
<Calendar.GridBody>
|
|
47
|
+
{#each month.weeks as weekDates (weekDates)}
|
|
48
|
+
<Calendar.GridRow class="mt-2 w-full">
|
|
49
|
+
{#each weekDates as date (date)}
|
|
50
|
+
<Calendar.Cell {date} month={month.value}>
|
|
51
|
+
<Calendar.Day />
|
|
52
|
+
</Calendar.Cell>
|
|
53
|
+
{/each}
|
|
54
|
+
</Calendar.GridRow>
|
|
55
|
+
{/each}
|
|
56
|
+
</Calendar.GridBody>
|
|
57
|
+
</Calendar.Grid>
|
|
58
|
+
{/each}
|
|
59
|
+
</Calendar.Months>
|
|
60
|
+
{/snippet}
|
|
61
|
+
</CalendarPrimitive.Root>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Root from "./calendar.svelte";
|
|
2
|
+
import Cell from "./calendar-cell.svelte";
|
|
3
|
+
import Day from "./calendar-day.svelte";
|
|
4
|
+
import Grid from "./calendar-grid.svelte";
|
|
5
|
+
import Header from "./calendar-header.svelte";
|
|
6
|
+
import Months from "./calendar-months.svelte";
|
|
7
|
+
import GridRow from "./calendar-grid-row.svelte";
|
|
8
|
+
import Heading from "./calendar-heading.svelte";
|
|
9
|
+
import GridBody from "./calendar-grid-body.svelte";
|
|
10
|
+
import GridHead from "./calendar-grid-head.svelte";
|
|
11
|
+
import HeadCell from "./calendar-head-cell.svelte";
|
|
12
|
+
import NextButton from "./calendar-next-button.svelte";
|
|
13
|
+
import PrevButton from "./calendar-prev-button.svelte";
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
Day,
|
|
17
|
+
Cell,
|
|
18
|
+
Grid,
|
|
19
|
+
Header,
|
|
20
|
+
Months,
|
|
21
|
+
GridRow,
|
|
22
|
+
Heading,
|
|
23
|
+
GridBody,
|
|
24
|
+
GridHead,
|
|
25
|
+
HeadCell,
|
|
26
|
+
NextButton,
|
|
27
|
+
PrevButton,
|
|
28
|
+
//
|
|
29
|
+
Root as Calendar,
|
|
30
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { WithElementRef } from "bits-ui";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...restProps
|
|
11
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div bind:this={ref} class={cn("p-6", className)} {...restProps}>
|
|
15
|
+
{@render children?.()}
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { WithElementRef } from "bits-ui";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...restProps
|
|
11
|
+
}: WithElementRef<HTMLAttributes<HTMLParagraphElement>> = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<p bind:this={ref} class={cn("text-muted-foreground text-sm", className)} {...restProps}>
|
|
15
|
+
{@render children?.()}
|
|
16
|
+
</p>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { WithElementRef } from "bits-ui";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
children,
|
|
10
|
+
...restProps
|
|
11
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div bind:this={ref} class={cn("flex items-center p-6 pt-0", className)} {...restProps}>
|
|
15
|
+
{@render children?.()}
|
|
16
|
+
</div>
|