@aphexcms/ui 0.1.7 → 0.1.8

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.
Files changed (53) hide show
  1. package/dist/components/ui/calendar/calendar-caption.svelte +76 -0
  2. package/dist/components/ui/calendar/calendar-caption.svelte.d.ts +19 -0
  3. package/dist/components/ui/calendar/calendar-cell.svelte +19 -0
  4. package/dist/components/ui/calendar/calendar-cell.svelte.d.ts +4 -0
  5. package/dist/components/ui/calendar/calendar-day.svelte +35 -0
  6. package/dist/components/ui/calendar/calendar-day.svelte.d.ts +4 -0
  7. package/dist/components/ui/calendar/calendar-grid-body.svelte +12 -0
  8. package/dist/components/ui/calendar/calendar-grid-body.svelte.d.ts +4 -0
  9. package/dist/components/ui/calendar/calendar-grid-head.svelte +12 -0
  10. package/dist/components/ui/calendar/calendar-grid-head.svelte.d.ts +4 -0
  11. package/dist/components/ui/calendar/calendar-grid-row.svelte +12 -0
  12. package/dist/components/ui/calendar/calendar-grid-row.svelte.d.ts +4 -0
  13. package/dist/components/ui/calendar/calendar-grid.svelte +16 -0
  14. package/dist/components/ui/calendar/calendar-grid.svelte.d.ts +4 -0
  15. package/dist/components/ui/calendar/calendar-head-cell.svelte +19 -0
  16. package/dist/components/ui/calendar/calendar-head-cell.svelte.d.ts +4 -0
  17. package/dist/components/ui/calendar/calendar-header.svelte +19 -0
  18. package/dist/components/ui/calendar/calendar-header.svelte.d.ts +4 -0
  19. package/dist/components/ui/calendar/calendar-heading.svelte +16 -0
  20. package/dist/components/ui/calendar/calendar-heading.svelte.d.ts +4 -0
  21. package/dist/components/ui/calendar/calendar-month-select.svelte +44 -0
  22. package/dist/components/ui/calendar/calendar-month-select.svelte.d.ts +4 -0
  23. package/dist/components/ui/calendar/calendar-month.svelte +15 -0
  24. package/dist/components/ui/calendar/calendar-month.svelte.d.ts +5 -0
  25. package/dist/components/ui/calendar/calendar-months.svelte +19 -0
  26. package/dist/components/ui/calendar/calendar-months.svelte.d.ts +5 -0
  27. package/dist/components/ui/calendar/calendar-nav.svelte +19 -0
  28. package/dist/components/ui/calendar/calendar-nav.svelte.d.ts +5 -0
  29. package/dist/components/ui/calendar/calendar-next-button.svelte +31 -0
  30. package/dist/components/ui/calendar/calendar-next-button.svelte.d.ts +8 -0
  31. package/dist/components/ui/calendar/calendar-prev-button.svelte +31 -0
  32. package/dist/components/ui/calendar/calendar-prev-button.svelte.d.ts +8 -0
  33. package/dist/components/ui/calendar/calendar-year-select.svelte +43 -0
  34. package/dist/components/ui/calendar/calendar-year-select.svelte.d.ts +4 -0
  35. package/dist/components/ui/calendar/calendar.svelte +115 -0
  36. package/dist/components/ui/calendar/calendar.svelte.d.ts +21 -0
  37. package/dist/components/ui/calendar/index.d.ts +19 -0
  38. package/dist/components/ui/calendar/index.js +21 -0
  39. package/dist/components/ui/checkbox/checkbox.svelte +5 -5
  40. package/dist/components/ui/checkbox/checkbox.svelte.d.ts +1 -1
  41. package/dist/components/ui/checkbox/index.d.ts +2 -2
  42. package/dist/components/ui/checkbox/index.js +2 -2
  43. package/dist/components/ui/radio-group/index.d.ts +3 -0
  44. package/dist/components/ui/radio-group/index.js +5 -0
  45. package/dist/components/ui/radio-group/radio-group-item.svelte +31 -0
  46. package/dist/components/ui/radio-group/radio-group-item.svelte.d.ts +4 -0
  47. package/dist/components/ui/radio-group/radio-group.svelte +19 -0
  48. package/dist/components/ui/radio-group/radio-group.svelte.d.ts +4 -0
  49. package/dist/components/ui/switch/index.d.ts +2 -0
  50. package/dist/components/ui/switch/index.js +4 -0
  51. package/dist/components/ui/switch/switch.svelte +29 -0
  52. package/dist/components/ui/switch/switch.svelte.d.ts +4 -0
  53. package/package.json +16 -1
@@ -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
+ import type { ComponentProps } from 'svelte';
2
+ import type Calendar from './calendar.svelte';
3
+ import CalendarMonthSelect from './calendar-month-select.svelte';
4
+ import CalendarYearSelect from './calendar-year-select.svelte';
5
+ import { type DateValue } from '@internationalized/date';
6
+ type $$ComponentProps = {
7
+ captionLayout: ComponentProps<typeof Calendar>['captionLayout'];
8
+ months: ComponentProps<typeof CalendarMonthSelect>['months'];
9
+ monthFormat: ComponentProps<typeof CalendarMonthSelect>['monthFormat'];
10
+ years: ComponentProps<typeof CalendarYearSelect>['years'];
11
+ yearFormat: ComponentProps<typeof CalendarYearSelect>['yearFormat'];
12
+ month: DateValue;
13
+ placeholder: DateValue | undefined;
14
+ locale: string;
15
+ monthIndex: number;
16
+ };
17
+ declare const CalendarCaption: import("svelte").Component<$$ComponentProps, {}, "placeholder">;
18
+ type CalendarCaption = ReturnType<typeof CalendarCaption>;
19
+ export default CalendarCaption;
@@ -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
+ bind:ref
14
+ class={cn(
15
+ 'size-(--cell-size) relative p-0 text-center text-sm focus-within:z-20 [&:first-child[data-selected]_[data-bits-day]]:rounded-l-md [&:last-child[data-selected]_[data-bits-day]]:rounded-r-md',
16
+ className
17
+ )}
18
+ {...restProps}
19
+ />
@@ -0,0 +1,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarCell: import("svelte").Component<CalendarPrimitive.CellProps, {}, "ref">;
3
+ type CalendarCell = ReturnType<typeof CalendarCell>;
4
+ export default CalendarCell;
@@ -0,0 +1,35 @@
1
+ <script lang="ts">
2
+ import { buttonVariants } from '../button/index.js';
3
+ import { cn } from '../../../utils.js';
4
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ ...restProps
10
+ }: CalendarPrimitive.DayProps = $props();
11
+ </script>
12
+
13
+ <CalendarPrimitive.Day
14
+ bind:ref
15
+ class={cn(
16
+ buttonVariants({ variant: 'ghost' }),
17
+ 'size-(--cell-size) flex select-none flex-col items-center justify-center gap-1 whitespace-nowrap p-0 font-normal leading-none',
18
+ '[&[data-today]:not([data-selected])]:bg-accent [&[data-today]:not([data-selected])]:text-accent-foreground [&[data-today][data-disabled]]:text-muted-foreground',
19
+ 'data-[selected]:bg-primary dark:data-[selected]:hover:bg-accent/50 data-[selected]:text-primary-foreground',
20
+ // Outside months
21
+ '[&[data-outside-month]:not([data-selected])]:text-muted-foreground [&[data-outside-month]:not([data-selected])]:hover:text-accent-foreground',
22
+ // Disabled
23
+ 'data-[disabled]:text-muted-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
24
+ // Unavailable
25
+ 'data-[unavailable]:text-muted-foreground data-[unavailable]:line-through',
26
+ // hover
27
+ 'dark:hover:text-accent-foreground',
28
+ // focus
29
+ 'focus:border-ring focus:ring-ring/50 focus:relative',
30
+ // inner spans
31
+ '[&>span]:text-xs [&>span]:opacity-70',
32
+ className
33
+ )}
34
+ {...restProps}
35
+ />
@@ -0,0 +1,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarDay: import("svelte").Component<CalendarPrimitive.DayProps, {}, "ref">;
3
+ type CalendarDay = ReturnType<typeof CalendarDay>;
4
+ export default CalendarDay;
@@ -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,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarGridBody: import("svelte").Component<CalendarPrimitive.GridBodyProps, {}, "ref">;
3
+ type CalendarGridBody = ReturnType<typeof CalendarGridBody>;
4
+ export default CalendarGridBody;
@@ -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,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarGridHead: import("svelte").Component<CalendarPrimitive.GridHeadProps, {}, "ref">;
3
+ type CalendarGridHead = ReturnType<typeof CalendarGridHead>;
4
+ export default CalendarGridHead;
@@ -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,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarGridRow: import("svelte").Component<CalendarPrimitive.GridRowProps, {}, "ref">;
3
+ type CalendarGridRow = ReturnType<typeof CalendarGridRow>;
4
+ export default CalendarGridRow;
@@ -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('mt-4 flex w-full border-collapse flex-col gap-1', className)}
15
+ {...restProps}
16
+ />
@@ -0,0 +1,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarGrid: import("svelte").Component<CalendarPrimitive.GridProps, {}, "ref">;
3
+ type CalendarGrid = ReturnType<typeof CalendarGrid>;
4
+ export default CalendarGrid;
@@ -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.HeadCellProps = $props();
10
+ </script>
11
+
12
+ <CalendarPrimitive.HeadCell
13
+ bind:ref
14
+ class={cn(
15
+ 'text-muted-foreground w-(--cell-size) rounded-md text-[0.8rem] font-normal',
16
+ className
17
+ )}
18
+ {...restProps}
19
+ />
@@ -0,0 +1,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarHeadCell: import("svelte").Component<CalendarPrimitive.HeadCellProps, {}, "ref">;
3
+ type CalendarHeadCell = ReturnType<typeof CalendarHeadCell>;
4
+ export default CalendarHeadCell;
@@ -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.HeaderProps = $props();
10
+ </script>
11
+
12
+ <CalendarPrimitive.Header
13
+ bind:ref
14
+ class={cn(
15
+ 'h-(--cell-size) flex w-full items-center justify-center gap-1.5 text-sm font-medium',
16
+ className
17
+ )}
18
+ {...restProps}
19
+ />
@@ -0,0 +1,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarHeader: import("svelte").Component<CalendarPrimitive.HeaderProps, {}, "ref">;
3
+ type CalendarHeader = ReturnType<typeof CalendarHeader>;
4
+ export default CalendarHeader;
@@ -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.HeadingProps = $props();
10
+ </script>
11
+
12
+ <CalendarPrimitive.Heading
13
+ bind:ref
14
+ class={cn('px-(--cell-size) text-sm font-medium', className)}
15
+ {...restProps}
16
+ />
@@ -0,0 +1,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarHeading: import("svelte").Component<CalendarPrimitive.HeadingProps, {}, "ref">;
3
+ type CalendarHeading = ReturnType<typeof CalendarHeading>;
4
+ export default CalendarHeading;
@@ -0,0 +1,44 @@
1
+ <script lang="ts">
2
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
3
+ import { cn, type WithoutChildrenOrChild } from '../../../utils.js';
4
+ import ChevronDownIcon from '@lucide/svelte/icons/chevron-down';
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ value,
10
+ onchange,
11
+ ...restProps
12
+ }: WithoutChildrenOrChild<CalendarPrimitive.MonthSelectProps> = $props();
13
+ </script>
14
+
15
+ <span
16
+ class={cn(
17
+ 'has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative flex rounded-md border',
18
+ className
19
+ )}
20
+ >
21
+ <CalendarPrimitive.MonthSelect bind:ref class="absolute inset-0 opacity-0" {...restProps}>
22
+ {#snippet child({ props, monthItems, selectedMonthItem })}
23
+ <select {...props} {value} {onchange}>
24
+ {#each monthItems as monthItem (monthItem.value)}
25
+ <option
26
+ value={monthItem.value}
27
+ selected={value !== undefined
28
+ ? monthItem.value === value
29
+ : monthItem.value === selectedMonthItem.value}
30
+ >
31
+ {monthItem.label}
32
+ </option>
33
+ {/each}
34
+ </select>
35
+ <span
36
+ 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"
37
+ aria-hidden="true"
38
+ >
39
+ {monthItems.find((item) => item.value === value)?.label || selectedMonthItem.label}
40
+ <ChevronDownIcon class="size-4" />
41
+ </span>
42
+ {/snippet}
43
+ </CalendarPrimitive.MonthSelect>
44
+ </span>
@@ -0,0 +1,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarMonthSelect: import("svelte").Component<Omit<Omit<CalendarPrimitive.MonthSelectProps, "child">, "children">, {}, "ref">;
3
+ type CalendarMonthSelect = ReturnType<typeof CalendarMonthSelect>;
4
+ export default CalendarMonthSelect;
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { type WithElementRef, cn } from '../../../utils.js';
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,5 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ declare const CalendarMonth: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLElement>>, {}, "ref">;
4
+ type CalendarMonth = ReturnType<typeof CalendarMonth>;
5
+ export default CalendarMonth;
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cn, type WithElementRef } from '../../../utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div
14
+ bind:this={ref}
15
+ class={cn('relative flex flex-col gap-4 md:flex-row', className)}
16
+ {...restProps}
17
+ >
18
+ {@render children?.()}
19
+ </div>
@@ -0,0 +1,5 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import { type WithElementRef } from '../../../utils.js';
3
+ declare const CalendarMonths: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type CalendarMonths = ReturnType<typeof CalendarMonths>;
5
+ export default CalendarMonths;
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import { cn, type WithElementRef } from '../../../utils.js';
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,5 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ declare const CalendarNav: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLElement>>, {}, "ref">;
4
+ type CalendarNav = ReturnType<typeof CalendarNav>;
5
+ export default CalendarNav;
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
3
+ import ChevronRightIcon from '@lucide/svelte/icons/chevron-right';
4
+ import { buttonVariants, type ButtonVariant } from '../button/index.js';
5
+ import { cn } from '../../../utils.js';
6
+
7
+ let {
8
+ ref = $bindable(null),
9
+ class: className,
10
+ children,
11
+ variant = 'ghost',
12
+ ...restProps
13
+ }: CalendarPrimitive.NextButtonProps & {
14
+ variant?: ButtonVariant;
15
+ } = $props();
16
+ </script>
17
+
18
+ {#snippet Fallback()}
19
+ <ChevronRightIcon class="size-4" />
20
+ {/snippet}
21
+
22
+ <CalendarPrimitive.NextButton
23
+ bind:ref
24
+ class={cn(
25
+ buttonVariants({ variant }),
26
+ 'size-(--cell-size) select-none bg-transparent p-0 disabled:opacity-50 rtl:rotate-180',
27
+ className
28
+ )}
29
+ children={children || Fallback}
30
+ {...restProps}
31
+ />
@@ -0,0 +1,8 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ import { type ButtonVariant } from '../button/index.js';
3
+ type $$ComponentProps = CalendarPrimitive.NextButtonProps & {
4
+ variant?: ButtonVariant;
5
+ };
6
+ declare const CalendarNextButton: import("svelte").Component<$$ComponentProps, {}, "ref">;
7
+ type CalendarNextButton = ReturnType<typeof CalendarNextButton>;
8
+ export default CalendarNextButton;
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
3
+ import ChevronLeftIcon from '@lucide/svelte/icons/chevron-left';
4
+ import { buttonVariants, type ButtonVariant } from '../button/index.js';
5
+ import { cn } from '../../../utils.js';
6
+
7
+ let {
8
+ ref = $bindable(null),
9
+ class: className,
10
+ children,
11
+ variant = 'ghost',
12
+ ...restProps
13
+ }: CalendarPrimitive.PrevButtonProps & {
14
+ variant?: ButtonVariant;
15
+ } = $props();
16
+ </script>
17
+
18
+ {#snippet Fallback()}
19
+ <ChevronLeftIcon class="size-4" />
20
+ {/snippet}
21
+
22
+ <CalendarPrimitive.PrevButton
23
+ bind:ref
24
+ class={cn(
25
+ buttonVariants({ variant }),
26
+ 'size-(--cell-size) select-none bg-transparent p-0 disabled:opacity-50 rtl:rotate-180',
27
+ className
28
+ )}
29
+ children={children || Fallback}
30
+ {...restProps}
31
+ />
@@ -0,0 +1,8 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ import { type ButtonVariant } from '../button/index.js';
3
+ type $$ComponentProps = CalendarPrimitive.PrevButtonProps & {
4
+ variant?: ButtonVariant;
5
+ };
6
+ declare const CalendarPrevButton: import("svelte").Component<$$ComponentProps, {}, "ref">;
7
+ type CalendarPrevButton = ReturnType<typeof CalendarPrevButton>;
8
+ export default CalendarPrevButton;
@@ -0,0 +1,43 @@
1
+ <script lang="ts">
2
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
3
+ import { cn, type WithoutChildrenOrChild } from '../../../utils.js';
4
+ import ChevronDownIcon from '@lucide/svelte/icons/chevron-down';
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ value,
10
+ ...restProps
11
+ }: WithoutChildrenOrChild<CalendarPrimitive.YearSelectProps> = $props();
12
+ </script>
13
+
14
+ <span
15
+ class={cn(
16
+ 'has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative flex rounded-md border',
17
+ className
18
+ )}
19
+ >
20
+ <CalendarPrimitive.YearSelect bind:ref class="absolute inset-0 opacity-0" {...restProps}>
21
+ {#snippet child({ props, yearItems, selectedYearItem })}
22
+ <select {...props} {value}>
23
+ {#each yearItems as yearItem (yearItem.value)}
24
+ <option
25
+ value={yearItem.value}
26
+ selected={value !== undefined
27
+ ? yearItem.value === value
28
+ : yearItem.value === selectedYearItem.value}
29
+ >
30
+ {yearItem.label}
31
+ </option>
32
+ {/each}
33
+ </select>
34
+ <span
35
+ 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"
36
+ aria-hidden="true"
37
+ >
38
+ {yearItems.find((item) => item.value === value)?.label || selectedYearItem.label}
39
+ <ChevronDownIcon class="size-4" />
40
+ </span>
41
+ {/snippet}
42
+ </CalendarPrimitive.YearSelect>
43
+ </span>
@@ -0,0 +1,4 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ declare const CalendarYearSelect: import("svelte").Component<Omit<Omit<CalendarPrimitive.YearSelectProps, "child">, "children">, {}, "ref">;
3
+ type CalendarYearSelect = ReturnType<typeof CalendarYearSelect>;
4
+ export default CalendarYearSelect;
@@ -0,0 +1,115 @@
1
+ <script lang="ts">
2
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
3
+ import * as Calendar from './index.js';
4
+ import { cn, type WithoutChildrenOrChild } from '../../../utils.js';
5
+ import type { ButtonVariant } from '../button/button.svelte';
6
+ import { isEqualMonth, type DateValue } from '@internationalized/date';
7
+ import type { Snippet } from 'svelte';
8
+
9
+ let {
10
+ ref = $bindable(null),
11
+ value = $bindable(),
12
+ placeholder = $bindable(),
13
+ class: className,
14
+ weekdayFormat = 'short',
15
+ buttonVariant = 'ghost',
16
+ captionLayout = 'label',
17
+ locale = 'en-US',
18
+ months: monthsProp,
19
+ years,
20
+ monthFormat: monthFormatProp,
21
+ yearFormat = 'numeric',
22
+ day,
23
+ disableDaysOutsideMonth = false,
24
+ ...restProps
25
+ }: WithoutChildrenOrChild<CalendarPrimitive.RootProps> & {
26
+ buttonVariant?: ButtonVariant;
27
+ captionLayout?: 'dropdown' | 'dropdown-months' | 'dropdown-years' | 'label';
28
+ months?: CalendarPrimitive.MonthSelectProps['months'];
29
+ years?: CalendarPrimitive.YearSelectProps['years'];
30
+ monthFormat?: CalendarPrimitive.MonthSelectProps['monthFormat'];
31
+ yearFormat?: CalendarPrimitive.YearSelectProps['yearFormat'];
32
+ day?: Snippet<[{ day: DateValue; outsideMonth: boolean }]>;
33
+ } = $props();
34
+
35
+ const monthFormat = $derived.by(() => {
36
+ if (monthFormatProp) return monthFormatProp;
37
+ if (captionLayout.startsWith('dropdown')) return 'short';
38
+ return 'long';
39
+ });
40
+ </script>
41
+
42
+ <!--
43
+ Discriminated Unions + Destructing (required for bindable) do not
44
+ get along, so we shut typescript up by casting `value` to `never`.
45
+ -->
46
+ <CalendarPrimitive.Root
47
+ bind:value={value as never}
48
+ bind:ref
49
+ bind:placeholder
50
+ {weekdayFormat}
51
+ {disableDaysOutsideMonth}
52
+ class={cn(
53
+ 'bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent',
54
+ className
55
+ )}
56
+ {locale}
57
+ {monthFormat}
58
+ {yearFormat}
59
+ {...restProps}
60
+ >
61
+ {#snippet children({ months, weekdays })}
62
+ <Calendar.Months>
63
+ <Calendar.Nav>
64
+ <Calendar.PrevButton variant={buttonVariant} />
65
+ <Calendar.NextButton variant={buttonVariant} />
66
+ </Calendar.Nav>
67
+ {#each months as month, monthIndex (month)}
68
+ <Calendar.Month>
69
+ <Calendar.Header>
70
+ <Calendar.Caption
71
+ {captionLayout}
72
+ months={monthsProp}
73
+ {monthFormat}
74
+ {years}
75
+ {yearFormat}
76
+ month={month.value}
77
+ bind:placeholder
78
+ {locale}
79
+ {monthIndex}
80
+ />
81
+ </Calendar.Header>
82
+ <Calendar.Grid>
83
+ <Calendar.GridHead>
84
+ <Calendar.GridRow class="select-none">
85
+ {#each weekdays as weekday (weekday)}
86
+ <Calendar.HeadCell>
87
+ {weekday.slice(0, 2)}
88
+ </Calendar.HeadCell>
89
+ {/each}
90
+ </Calendar.GridRow>
91
+ </Calendar.GridHead>
92
+ <Calendar.GridBody>
93
+ {#each month.weeks as weekDates (weekDates)}
94
+ <Calendar.GridRow class="mt-2 w-full">
95
+ {#each weekDates as date (date)}
96
+ <Calendar.Cell {date} month={month.value}>
97
+ {#if day}
98
+ {@render day({
99
+ day: date,
100
+ outsideMonth: !isEqualMonth(date, month.value)
101
+ })}
102
+ {:else}
103
+ <Calendar.Day />
104
+ {/if}
105
+ </Calendar.Cell>
106
+ {/each}
107
+ </Calendar.GridRow>
108
+ {/each}
109
+ </Calendar.GridBody>
110
+ </Calendar.Grid>
111
+ </Calendar.Month>
112
+ {/each}
113
+ </Calendar.Months>
114
+ {/snippet}
115
+ </CalendarPrimitive.Root>
@@ -0,0 +1,21 @@
1
+ import { Calendar as CalendarPrimitive } from 'bits-ui';
2
+ import * as Calendar from './index.js';
3
+ import { type WithoutChildrenOrChild } from '../../../utils.js';
4
+ import type { ButtonVariant } from '../button/button.svelte';
5
+ import { type DateValue } from '@internationalized/date';
6
+ import type { Snippet } from 'svelte';
7
+ type $$ComponentProps = WithoutChildrenOrChild<CalendarPrimitive.RootProps> & {
8
+ buttonVariant?: ButtonVariant;
9
+ captionLayout?: 'dropdown' | 'dropdown-months' | 'dropdown-years' | 'label';
10
+ months?: CalendarPrimitive.MonthSelectProps['months'];
11
+ years?: CalendarPrimitive.YearSelectProps['years'];
12
+ monthFormat?: CalendarPrimitive.MonthSelectProps['monthFormat'];
13
+ yearFormat?: CalendarPrimitive.YearSelectProps['yearFormat'];
14
+ day?: Snippet<[{
15
+ day: DateValue;
16
+ outsideMonth: boolean;
17
+ }]>;
18
+ };
19
+ declare const Calendar: import("svelte").Component<$$ComponentProps, {}, "placeholder" | "ref" | "value">;
20
+ type Calendar = ReturnType<typeof Calendar>;
21
+ export default Calendar;
@@ -0,0 +1,19 @@
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
+ import MonthSelect from './calendar-month-select.svelte';
15
+ import YearSelect from './calendar-year-select.svelte';
16
+ import Month from './calendar-month.svelte';
17
+ import Nav from './calendar-nav.svelte';
18
+ import Caption from './calendar-caption.svelte';
19
+ export { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton, Nav, Month, YearSelect, MonthSelect, Caption, Root as Calendar };
@@ -0,0 +1,21 @@
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
+ import MonthSelect from './calendar-month-select.svelte';
15
+ import YearSelect from './calendar-year-select.svelte';
16
+ import Month from './calendar-month.svelte';
17
+ import Nav from './calendar-nav.svelte';
18
+ import Caption from './calendar-caption.svelte';
19
+ export { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton, Nav, Month, YearSelect, MonthSelect, Caption,
20
+ //
21
+ Root as Calendar };
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
- import { Checkbox as CheckboxPrimitive } from "bits-ui";
3
- import CheckIcon from "@lucide/svelte/icons/check";
4
- import MinusIcon from "@lucide/svelte/icons/minus";
5
- import { cn, type WithoutChildrenOrChild } from "../../../utils.js";
2
+ import { Checkbox as CheckboxPrimitive } from 'bits-ui';
3
+ import CheckIcon from '@lucide/svelte/icons/check';
4
+ import MinusIcon from '@lucide/svelte/icons/minus';
5
+ import { cn, type WithoutChildrenOrChild } from '../../../utils.js';
6
6
 
7
7
  let {
8
8
  ref = $bindable(null),
@@ -17,7 +17,7 @@
17
17
  bind:ref
18
18
  data-slot="checkbox"
19
19
  class={cn(
20
- "border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive shadow-xs peer flex size-4 shrink-0 items-center justify-center rounded-[4px] border outline-none transition-shadow focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
20
+ 'border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive shadow-xs peer flex size-4 shrink-0 items-center justify-center rounded-[4px] border outline-none transition-shadow focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
21
21
  className
22
22
  )}
23
23
  bind:checked
@@ -1,4 +1,4 @@
1
- import { Checkbox as CheckboxPrimitive } from "bits-ui";
1
+ import { Checkbox as CheckboxPrimitive } from 'bits-ui';
2
2
  declare const Checkbox: import("svelte").Component<Omit<Omit<CheckboxPrimitive.RootProps, "child">, "children">, {}, "ref" | "checked" | "indeterminate">;
3
3
  type Checkbox = ReturnType<typeof Checkbox>;
4
4
  export default Checkbox;
@@ -1,2 +1,2 @@
1
- import Root from "./checkbox.svelte";
2
- export { Root, Root as Checkbox, };
1
+ import Root from './checkbox.svelte';
2
+ export { Root, Root as Checkbox };
@@ -1,4 +1,4 @@
1
- import Root from "./checkbox.svelte";
1
+ import Root from './checkbox.svelte';
2
2
  export { Root,
3
3
  //
4
- Root as Checkbox, };
4
+ Root as Checkbox };
@@ -0,0 +1,3 @@
1
+ import Root from './radio-group.svelte';
2
+ import Item from './radio-group-item.svelte';
3
+ export { Root, Item, Root as RadioGroup, Item as RadioGroupItem };
@@ -0,0 +1,5 @@
1
+ import Root from './radio-group.svelte';
2
+ import Item from './radio-group-item.svelte';
3
+ export { Root, Item,
4
+ //
5
+ Root as RadioGroup, Item as RadioGroupItem };
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import { RadioGroup as RadioGroupPrimitive } from 'bits-ui';
3
+ import CircleIcon from '@lucide/svelte/icons/circle';
4
+ import { cn, type WithoutChildrenOrChild } from '../../../utils.js';
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ ...restProps
10
+ }: WithoutChildrenOrChild<RadioGroupPrimitive.ItemProps> = $props();
11
+ </script>
12
+
13
+ <RadioGroupPrimitive.Item
14
+ bind:ref
15
+ data-slot="radio-group-item"
16
+ class={cn(
17
+ 'border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 shadow-xs aspect-square size-4 shrink-0 rounded-full border outline-none transition-[color,box-shadow] focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
18
+ className
19
+ )}
20
+ {...restProps}
21
+ >
22
+ {#snippet children({ checked })}
23
+ <div data-slot="radio-group-indicator" class="relative flex items-center justify-center">
24
+ {#if checked}
25
+ <CircleIcon
26
+ class="fill-primary absolute left-1/2 top-1/2 size-2 -translate-x-1/2 -translate-y-1/2"
27
+ />
28
+ {/if}
29
+ </div>
30
+ {/snippet}
31
+ </RadioGroupPrimitive.Item>
@@ -0,0 +1,4 @@
1
+ import { RadioGroup as RadioGroupPrimitive } from 'bits-ui';
2
+ declare const RadioGroupItem: import("svelte").Component<Omit<Omit<RadioGroupPrimitive.ItemProps, "child">, "children">, {}, "ref">;
3
+ type RadioGroupItem = ReturnType<typeof RadioGroupItem>;
4
+ export default RadioGroupItem;
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import { RadioGroup as RadioGroupPrimitive } from 'bits-ui';
3
+ import { cn } from '../../../utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ value = $bindable(''),
9
+ ...restProps
10
+ }: RadioGroupPrimitive.RootProps = $props();
11
+ </script>
12
+
13
+ <RadioGroupPrimitive.Root
14
+ bind:ref
15
+ bind:value
16
+ data-slot="radio-group"
17
+ class={cn('grid gap-3', className)}
18
+ {...restProps}
19
+ />
@@ -0,0 +1,4 @@
1
+ import { RadioGroup as RadioGroupPrimitive } from 'bits-ui';
2
+ declare const RadioGroup: import("svelte").Component<RadioGroupPrimitive.RootProps, {}, "ref" | "value">;
3
+ type RadioGroup = ReturnType<typeof RadioGroup>;
4
+ export default RadioGroup;
@@ -0,0 +1,2 @@
1
+ import Root from './switch.svelte';
2
+ export { Root, Root as Switch };
@@ -0,0 +1,4 @@
1
+ import Root from './switch.svelte';
2
+ export { Root,
3
+ //
4
+ Root as Switch };
@@ -0,0 +1,29 @@
1
+ <script lang="ts">
2
+ import { Switch as SwitchPrimitive } from 'bits-ui';
3
+ import { cn, type WithoutChildrenOrChild } from '../../../utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ checked = $bindable(false),
9
+ ...restProps
10
+ }: WithoutChildrenOrChild<SwitchPrimitive.RootProps> = $props();
11
+ </script>
12
+
13
+ <SwitchPrimitive.Root
14
+ bind:ref
15
+ bind:checked
16
+ data-slot="switch"
17
+ class={cn(
18
+ 'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 shadow-xs peer inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent outline-none transition-all focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
19
+ className
20
+ )}
21
+ {...restProps}
22
+ >
23
+ <SwitchPrimitive.Thumb
24
+ data-slot="switch-thumb"
25
+ class={cn(
26
+ 'bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0'
27
+ )}
28
+ />
29
+ </SwitchPrimitive.Root>
@@ -0,0 +1,4 @@
1
+ import { Switch as SwitchPrimitive } from 'bits-ui';
2
+ declare const Switch: import("svelte").Component<Omit<Omit<SwitchPrimitive.RootProps, "child">, "children">, {}, "ref" | "checked">;
3
+ type Switch = ReturnType<typeof Switch>;
4
+ export default Switch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aphexcms/ui",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Shared UI components for Aphex CMS (shadcn-svelte)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -35,6 +35,11 @@
35
35
  "svelte": "./dist/components/ui/button/index.js",
36
36
  "default": "./dist/components/ui/button/index.js"
37
37
  },
38
+ "./shadcn/calendar": {
39
+ "types": "./dist/components/ui/calendar/index.d.ts",
40
+ "svelte": "./dist/components/ui/calendar/index.js",
41
+ "default": "./dist/components/ui/calendar/index.js"
42
+ },
38
43
  "./shadcn/card": {
39
44
  "types": "./dist/components/ui/card/index.d.ts",
40
45
  "svelte": "./dist/components/ui/card/index.js",
@@ -80,6 +85,11 @@
80
85
  "svelte": "./dist/components/ui/popover/index.js",
81
86
  "default": "./dist/components/ui/popover/index.js"
82
87
  },
88
+ "./shadcn/radio-group": {
89
+ "types": "./dist/components/ui/radio-group/index.d.ts",
90
+ "svelte": "./dist/components/ui/radio-group/index.js",
91
+ "default": "./dist/components/ui/radio-group/index.js"
92
+ },
83
93
  "./shadcn/select": {
84
94
  "types": "./dist/components/ui/select/index.d.ts",
85
95
  "svelte": "./dist/components/ui/select/index.js",
@@ -105,6 +115,11 @@
105
115
  "svelte": "./dist/components/ui/skeleton/index.js",
106
116
  "default": "./dist/components/ui/skeleton/index.js"
107
117
  },
118
+ "./shadcn/switch": {
119
+ "types": "./dist/components/ui/switch/index.d.ts",
120
+ "svelte": "./dist/components/ui/switch/index.js",
121
+ "default": "./dist/components/ui/switch/index.js"
122
+ },
108
123
  "./shadcn/tabs": {
109
124
  "types": "./dist/components/ui/tabs/index.d.ts",
110
125
  "svelte": "./dist/components/ui/tabs/index.js",