@casinogate/ui 2.0.2 → 2.0.3
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/dist/assets/css/root.css +330 -0
- package/dist/atomic/icons/calendar.svelte +13 -0
- package/dist/atomic/icons/calendar.svelte.d.ts +3 -0
- package/dist/atomic/icons/exports.d.ts +1 -0
- package/dist/atomic/icons/exports.js +1 -0
- package/dist/composed/calendar/api/format-caption.d.ts +5 -0
- package/dist/composed/calendar/api/format-caption.js +13 -0
- package/dist/composed/calendar/api/index.d.ts +1 -0
- package/dist/composed/calendar/api/index.js +1 -0
- package/dist/composed/calendar/index.d.ts +2 -0
- package/dist/composed/calendar/index.js +1 -0
- package/dist/composed/calendar/root/calendar.root.svelte +91 -0
- package/dist/composed/calendar/root/calendar.root.svelte.d.ts +4 -0
- package/dist/composed/calendar/root/index.d.ts +1 -0
- package/dist/composed/calendar/root/index.js +1 -0
- package/dist/composed/calendar/types.d.ts +32 -0
- package/dist/composed/calendar/types.js +1 -0
- package/dist/composed/date-picker/index.d.ts +2 -0
- package/dist/composed/date-picker/index.js +1 -0
- package/dist/composed/date-picker/root/date-picker.root.svelte +144 -0
- package/dist/composed/date-picker/root/date-picker.root.svelte.d.ts +4 -0
- package/dist/composed/date-picker/root/index.d.ts +1 -0
- package/dist/composed/date-picker/root/index.js +1 -0
- package/dist/composed/date-picker/types.d.ts +45 -0
- package/dist/composed/date-picker/types.js +1 -0
- package/dist/composed/index.d.ts +2 -0
- package/dist/composed/index.js +2 -0
- package/dist/internal/utils/tailwindcss.d.ts +1 -1
- package/dist/primitives/calendar/components/calendar.body.svelte +20 -0
- package/dist/primitives/calendar/components/calendar.body.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.cell.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.cell.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.day.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.day.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.grid-body.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.grid-body.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.grid-head.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.grid-head.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.grid-row.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.grid-row.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.grid.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.grid.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.head-cell.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.head-cell.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.header.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.header.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.heading.svelte +10 -0
- package/dist/primitives/calendar/components/calendar.heading.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.month-select.svelte +37 -0
- package/dist/primitives/calendar/components/calendar.month-select.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.next-button.svelte +26 -0
- package/dist/primitives/calendar/components/calendar.next-button.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.prev-button.svelte +26 -0
- package/dist/primitives/calendar/components/calendar.prev-button.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.root.svelte +35 -0
- package/dist/primitives/calendar/components/calendar.root.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/calendar.year-select.svelte +37 -0
- package/dist/primitives/calendar/components/calendar.year-select.svelte.d.ts +4 -0
- package/dist/primitives/calendar/components/index.d.ts +15 -0
- package/dist/primitives/calendar/components/index.js +15 -0
- package/dist/primitives/calendar/index.d.ts +2 -0
- package/dist/primitives/calendar/index.js +2 -0
- package/dist/primitives/calendar/styles.d.ts +59 -0
- package/dist/primitives/calendar/styles.js +72 -0
- package/dist/primitives/calendar/types.d.ts +30 -0
- package/dist/primitives/calendar/types.js +1 -0
- package/dist/primitives/date-picker/components/date-picker.calendar.svelte +10 -0
- package/dist/primitives/date-picker/components/date-picker.calendar.svelte.d.ts +4 -0
- package/dist/primitives/date-picker/components/date-picker.content.svelte +28 -0
- package/dist/primitives/date-picker/components/date-picker.content.svelte.d.ts +4 -0
- package/dist/primitives/date-picker/components/date-picker.input.svelte +28 -0
- package/dist/primitives/date-picker/components/date-picker.input.svelte.d.ts +4 -0
- package/dist/primitives/date-picker/components/date-picker.portal.svelte +10 -0
- package/dist/primitives/date-picker/components/date-picker.portal.svelte.d.ts +3 -0
- package/dist/primitives/date-picker/components/date-picker.root.svelte +21 -0
- package/dist/primitives/date-picker/components/date-picker.root.svelte.d.ts +4 -0
- package/dist/primitives/date-picker/components/date-picker.segment.svelte +10 -0
- package/dist/primitives/date-picker/components/date-picker.segment.svelte.d.ts +4 -0
- package/dist/primitives/date-picker/components/date-picker.trigger.svelte +61 -0
- package/dist/primitives/date-picker/components/date-picker.trigger.svelte.d.ts +4 -0
- package/dist/primitives/date-picker/components/index.d.ts +7 -0
- package/dist/primitives/date-picker/components/index.js +7 -0
- package/dist/primitives/date-picker/index.d.ts +2 -0
- package/dist/primitives/date-picker/index.js +2 -0
- package/dist/primitives/date-picker/styles.d.ts +171 -0
- package/dist/primitives/date-picker/styles.js +143 -0
- package/dist/primitives/date-picker/types.d.ts +14 -0
- package/dist/primitives/date-picker/types.js +1 -0
- package/dist/primitives/select/styles.js +3 -0
- package/package.json +2 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CalendarMultipleRootProps, CalendarSingleRootProps } from '../../primitives/calendar/types.js';
|
|
2
|
+
import type { DateValue } from '@internationalized/date';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
export type CalendarCaptionLayout = 'label' | 'dropdown' | 'dropdown-months' | 'dropdown-years';
|
|
5
|
+
type CalendarDaySnippetArgs = {
|
|
6
|
+
date: DateValue;
|
|
7
|
+
month: DateValue;
|
|
8
|
+
};
|
|
9
|
+
type CalendarSharedProps = {
|
|
10
|
+
/**
|
|
11
|
+
* How the calendar caption is rendered.
|
|
12
|
+
* - `'label'` – formatted month + year heading (default)
|
|
13
|
+
* - `'dropdown'` – month and year selects
|
|
14
|
+
* - `'dropdown-months'` – month select + formatted year
|
|
15
|
+
* - `'dropdown-years'` – formatted month + year select
|
|
16
|
+
*/
|
|
17
|
+
captionLayout?: CalendarCaptionLayout;
|
|
18
|
+
/** Custom render for each day cell. Receives the date and the month it belongs to. */
|
|
19
|
+
day?: Snippet<[CalendarDaySnippetArgs]>;
|
|
20
|
+
/** Forwarded to the wrapping container. */
|
|
21
|
+
class?: string;
|
|
22
|
+
};
|
|
23
|
+
export type CalendarSingleProps = Omit<CalendarSingleRootProps, 'children' | 'child' | 'value' | 'onValueChange'> & CalendarSharedProps & {
|
|
24
|
+
value?: DateValue;
|
|
25
|
+
onValueChange?: (value: DateValue | undefined) => void;
|
|
26
|
+
};
|
|
27
|
+
export type CalendarMultipleProps = Omit<CalendarMultipleRootProps, 'children' | 'child' | 'value' | 'onValueChange'> & CalendarSharedProps & {
|
|
28
|
+
value?: DateValue[];
|
|
29
|
+
onValueChange?: (value: DateValue[]) => void;
|
|
30
|
+
};
|
|
31
|
+
export type CalendarProps = CalendarSingleProps | CalendarMultipleProps;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './root/index.js';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { DateFormatter, getLocalTimeZone, type DateValue } from '@internationalized/date';
|
|
3
|
+
|
|
4
|
+
const defaultFormatter = new DateFormatter('en-US', { dateStyle: 'medium' });
|
|
5
|
+
|
|
6
|
+
const defaultFormatValue = (value: DateValue | undefined): string => {
|
|
7
|
+
if (!value) return '';
|
|
8
|
+
return defaultFormatter.format(value.toDate(getLocalTimeZone()));
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { Icon } from '../../../atomic/icons/index.js';
|
|
14
|
+
import { formatMonthCaption, formatYearCaption } from '../../calendar/api/index.js';
|
|
15
|
+
import { Calendar } from '../../../primitives/calendar/index.js';
|
|
16
|
+
import { DatePicker as Primitive } from '../../../primitives/date-picker/index.js';
|
|
17
|
+
import type { DatePickerProps } from '../types.js';
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
value = $bindable(),
|
|
21
|
+
open = $bindable(false),
|
|
22
|
+
placeholder = 'Pick a date',
|
|
23
|
+
formatValue = defaultFormatValue,
|
|
24
|
+
enableSegments = false,
|
|
25
|
+
captionLayout = 'label',
|
|
26
|
+
locale = 'en-US',
|
|
27
|
+
monthFormat = 'long',
|
|
28
|
+
yearFormat = 'numeric',
|
|
29
|
+
name,
|
|
30
|
+
disabledPortal = false,
|
|
31
|
+
triggerVariant = 'primary',
|
|
32
|
+
triggerSize = 'md',
|
|
33
|
+
triggerRounded = 'sm',
|
|
34
|
+
triggerFullWidth = true,
|
|
35
|
+
triggerClass,
|
|
36
|
+
triggerProps,
|
|
37
|
+
inputClass,
|
|
38
|
+
inputProps,
|
|
39
|
+
contentClass,
|
|
40
|
+
contentProps,
|
|
41
|
+
...restProps
|
|
42
|
+
}: DatePickerProps = $props();
|
|
43
|
+
|
|
44
|
+
const displayLabel = $derived(formatValue(value) || placeholder);
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<Primitive.Root bind:value bind:open {locale} {monthFormat} {yearFormat} {...restProps}>
|
|
48
|
+
{#if enableSegments}
|
|
49
|
+
<Primitive.Input {name} class={inputClass} {...inputProps}>
|
|
50
|
+
{#snippet children({ segments })}
|
|
51
|
+
{#each segments as { part, value: segmentValue }, i (i)}
|
|
52
|
+
<Primitive.Segment {part}>{segmentValue}</Primitive.Segment>
|
|
53
|
+
{/each}
|
|
54
|
+
|
|
55
|
+
<Primitive.Trigger
|
|
56
|
+
variant={triggerVariant}
|
|
57
|
+
size={triggerSize}
|
|
58
|
+
rounded={triggerRounded}
|
|
59
|
+
fullWidth={triggerFullWidth}
|
|
60
|
+
class={triggerClass}
|
|
61
|
+
hasChevron={false}
|
|
62
|
+
{...triggerProps}
|
|
63
|
+
>
|
|
64
|
+
<Icon.Calendar width={18} height={18} />
|
|
65
|
+
</Primitive.Trigger>
|
|
66
|
+
{/snippet}
|
|
67
|
+
</Primitive.Input>
|
|
68
|
+
{:else}
|
|
69
|
+
<Primitive.Trigger
|
|
70
|
+
variant={triggerVariant}
|
|
71
|
+
size={triggerSize}
|
|
72
|
+
rounded={triggerRounded}
|
|
73
|
+
fullWidth={triggerFullWidth}
|
|
74
|
+
class={triggerClass}
|
|
75
|
+
{...triggerProps}
|
|
76
|
+
>
|
|
77
|
+
{displayLabel}
|
|
78
|
+
</Primitive.Trigger>
|
|
79
|
+
{/if}
|
|
80
|
+
|
|
81
|
+
<Primitive.Portal disabled={disabledPortal}>
|
|
82
|
+
<Primitive.Content class={contentClass} {...contentProps}>
|
|
83
|
+
<Primitive.Calendar>
|
|
84
|
+
{#snippet children({ months, weekdays })}
|
|
85
|
+
{@const currentMonth = months[0]?.value}
|
|
86
|
+
<Calendar.Header>
|
|
87
|
+
<Calendar.PrevButton />
|
|
88
|
+
|
|
89
|
+
{#if captionLayout === 'dropdown'}
|
|
90
|
+
<div class="cgui:flex cgui:items-center cgui:gap-2">
|
|
91
|
+
<Calendar.MonthSelect />
|
|
92
|
+
<Calendar.YearSelect />
|
|
93
|
+
</div>
|
|
94
|
+
{:else if captionLayout === 'dropdown-months' && currentMonth}
|
|
95
|
+
<div class="cgui:flex cgui:items-center cgui:gap-2">
|
|
96
|
+
<Calendar.MonthSelect />
|
|
97
|
+
<span class="cgui:text-body cgui:text-fg-darkest cgui:font-medium">
|
|
98
|
+
{formatYearCaption(currentMonth, locale, yearFormat)}
|
|
99
|
+
</span>
|
|
100
|
+
</div>
|
|
101
|
+
{:else if captionLayout === 'dropdown-years' && currentMonth}
|
|
102
|
+
<div class="cgui:flex cgui:items-center cgui:gap-2">
|
|
103
|
+
<span class="cgui:text-body cgui:text-fg-darkest cgui:font-medium">
|
|
104
|
+
{formatMonthCaption(currentMonth, locale, monthFormat)}
|
|
105
|
+
</span>
|
|
106
|
+
<Calendar.YearSelect />
|
|
107
|
+
</div>
|
|
108
|
+
{:else}
|
|
109
|
+
<Calendar.Heading />
|
|
110
|
+
{/if}
|
|
111
|
+
|
|
112
|
+
<Calendar.NextButton />
|
|
113
|
+
</Calendar.Header>
|
|
114
|
+
|
|
115
|
+
<Calendar.Body>
|
|
116
|
+
{#each months as month, i (i)}
|
|
117
|
+
<Calendar.Grid>
|
|
118
|
+
<Calendar.GridHead>
|
|
119
|
+
<Calendar.GridRow>
|
|
120
|
+
{#each weekdays as weekday, j (j)}
|
|
121
|
+
<Calendar.HeadCell>{weekday}</Calendar.HeadCell>
|
|
122
|
+
{/each}
|
|
123
|
+
</Calendar.GridRow>
|
|
124
|
+
</Calendar.GridHead>
|
|
125
|
+
|
|
126
|
+
<Calendar.GridBody>
|
|
127
|
+
{#each month.weeks as weekDates, w (w)}
|
|
128
|
+
<Calendar.GridRow>
|
|
129
|
+
{#each weekDates as date, d (d)}
|
|
130
|
+
<Calendar.Cell {date} month={month.value}>
|
|
131
|
+
<Calendar.Day>{date.day}</Calendar.Day>
|
|
132
|
+
</Calendar.Cell>
|
|
133
|
+
{/each}
|
|
134
|
+
</Calendar.GridRow>
|
|
135
|
+
{/each}
|
|
136
|
+
</Calendar.GridBody>
|
|
137
|
+
</Calendar.Grid>
|
|
138
|
+
{/each}
|
|
139
|
+
</Calendar.Body>
|
|
140
|
+
{/snippet}
|
|
141
|
+
</Primitive.Calendar>
|
|
142
|
+
</Primitive.Content>
|
|
143
|
+
</Primitive.Portal>
|
|
144
|
+
</Primitive.Root>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DatePicker } from './date-picker.root.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DatePicker } from './date-picker.root.svelte';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DatePickerContentProps, DatePickerInputProps, DatePickerRootProps, DatePickerTriggerProps } from '../../primitives/date-picker/types.js';
|
|
2
|
+
import type { DateValue } from '@internationalized/date';
|
|
3
|
+
import type { CalendarCaptionLayout } from '../calendar/types.js';
|
|
4
|
+
export type DatePickerFormatValue = (value: DateValue | undefined) => string;
|
|
5
|
+
export type DatePickerProps = Omit<DatePickerRootProps, 'children' | 'child' | 'placeholder'> & {
|
|
6
|
+
/**
|
|
7
|
+
* Formatter used to render the selected date in the trigger label.
|
|
8
|
+
* Receives the current value and returns the string shown to the user.
|
|
9
|
+
* Defaults to a medium-style locale formatter.
|
|
10
|
+
*/
|
|
11
|
+
formatValue?: DatePickerFormatValue;
|
|
12
|
+
/**
|
|
13
|
+
* When true, renders a segmented date input (day/month/year) alongside a
|
|
14
|
+
* calendar icon button trigger. When false (default), renders a single
|
|
15
|
+
* Select-style trigger button that shows the formatted value.
|
|
16
|
+
*/
|
|
17
|
+
enableSegments?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* How the calendar caption is rendered inside the popover.
|
|
20
|
+
* - `'label'` – formatted month + year heading (default)
|
|
21
|
+
* - `'dropdown'` – month and year selects
|
|
22
|
+
* - `'dropdown-months'` – month select + formatted year
|
|
23
|
+
* - `'dropdown-years'` – formatted month + year select
|
|
24
|
+
*/
|
|
25
|
+
captionLayout?: CalendarCaptionLayout;
|
|
26
|
+
/** Placeholder shown in the trigger when no value is selected. */
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
/** Form field name. Only emitted when `enableSegments` is true. */
|
|
29
|
+
name?: string;
|
|
30
|
+
/** Disable rendering the popover into a portal. */
|
|
31
|
+
disabledPortal?: boolean;
|
|
32
|
+
/** Style overrides forwarded to the trigger primitive. */
|
|
33
|
+
triggerVariant?: DatePickerTriggerProps['variant'];
|
|
34
|
+
triggerSize?: DatePickerTriggerProps['size'];
|
|
35
|
+
triggerRounded?: DatePickerTriggerProps['rounded'];
|
|
36
|
+
triggerFullWidth?: DatePickerTriggerProps['fullWidth'];
|
|
37
|
+
triggerClass?: string;
|
|
38
|
+
triggerProps?: Omit<DatePickerTriggerProps, 'class' | 'children' | 'child' | 'ref' | 'variant' | 'size' | 'rounded' | 'fullWidth'>;
|
|
39
|
+
/** Style overrides forwarded to the segmented input wrapper. */
|
|
40
|
+
inputClass?: string;
|
|
41
|
+
inputProps?: Omit<DatePickerInputProps, 'class' | 'children' | 'child' | 'ref' | 'name'>;
|
|
42
|
+
/** Style overrides forwarded to the popover content. */
|
|
43
|
+
contentClass?: string;
|
|
44
|
+
contentProps?: Omit<DatePickerContentProps, 'class' | 'children' | 'child' | 'ref'>;
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/composed/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './breadcrumb/index.js';
|
|
2
|
+
export * from './calendar/index.js';
|
|
2
3
|
export * from './collapsible/index.js';
|
|
3
4
|
export * from './combobox/index.js';
|
|
4
5
|
export * from './command/index.js';
|
|
5
6
|
export * from './data-table/index.js';
|
|
7
|
+
export * from './date-picker/index.js';
|
|
6
8
|
export * from './dialog/index.js';
|
|
7
9
|
export * from './drawer/index.js';
|
|
8
10
|
export * from './dropdown/index.js';
|
package/dist/composed/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './breadcrumb/index.js';
|
|
2
|
+
export * from './calendar/index.js';
|
|
2
3
|
export * from './collapsible/index.js';
|
|
3
4
|
export * from './combobox/index.js';
|
|
4
5
|
export * from './command/index.js';
|
|
5
6
|
export * from './data-table/index.js';
|
|
7
|
+
export * from './date-picker/index.js';
|
|
6
8
|
export * from './dialog/index.js';
|
|
7
9
|
export * from './drawer/index.js';
|
|
8
10
|
export * from './dropdown/index.js';
|
|
@@ -5,5 +5,5 @@ export declare function cn(...inputs: CnOptions): string;
|
|
|
5
5
|
export declare const tv: TV;
|
|
6
6
|
export declare const numberToPx: (value: number) => string;
|
|
7
7
|
export declare const numberToRem: (value: number, base?: number) => string;
|
|
8
|
-
export type WithVariants<TSource extends Record<string,
|
|
8
|
+
export type WithVariants<TSource extends Record<string, unknown>, TStyles extends VariantProps<any>> = TSource & Without<TStyles, TSource>;
|
|
9
9
|
export type { VariantProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { calendarBodyVariants } from '../styles.js';
|
|
4
|
+
import type { CalendarBodyProps } from '../types.js';
|
|
5
|
+
|
|
6
|
+
let { ref = $bindable(null), class: className, child, children, ...restProps }: CalendarBodyProps = $props();
|
|
7
|
+
|
|
8
|
+
const sharedProps = $derived({
|
|
9
|
+
class: cn(calendarBodyVariants(), className),
|
|
10
|
+
...restProps,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
{#if child}
|
|
15
|
+
{@render child?.({ props: sharedProps })}
|
|
16
|
+
{:else}
|
|
17
|
+
<div bind:this={ref} {...sharedProps}>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</div>
|
|
20
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarCellVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarCellProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarCellProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.Cell bind:ref class={cn(calendarCellVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarDayVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarDayProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarDayProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.Day bind:ref class={cn(calendarDayVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarGridBodyVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarGridBodyProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarGridBodyProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.GridBody bind:ref class={cn(calendarGridBodyVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarGridHeadVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarGridHeadProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarGridHeadProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.GridHead bind:ref class={cn(calendarGridHeadVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarGridRowVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarGridRowProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarGridRowProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.GridRow bind:ref class={cn(calendarGridRowVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarGridVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarGridProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarGridProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.Grid bind:ref class={cn(calendarGridVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarHeadCellVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarHeadCellProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarHeadCellProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.HeadCell bind:ref class={cn(calendarHeadCellVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarHeaderVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarHeaderProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarHeaderProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.Header bind:ref class={cn(calendarHeaderVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
import { calendarHeadingVariants } from '../styles.js';
|
|
5
|
+
import type { CalendarHeadingProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarHeadingProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Primitive.Heading bind:ref class={cn(calendarHeadingVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
3
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
4
|
+
// import { calendarMonthSelectStyles } from '../styles.js';
|
|
5
|
+
import { Select } from '../../select/index.js';
|
|
6
|
+
import type { CalendarMonthSelectProps } from '../types.js';
|
|
7
|
+
|
|
8
|
+
let { ref = $bindable(null), class: className, ...restProps }: CalendarMonthSelectProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<Primitive.MonthSelect bind:ref class={cn(className)} {...restProps}>
|
|
12
|
+
{#snippet child({ monthItems, selectedMonthItem, props })}
|
|
13
|
+
<Select.Root
|
|
14
|
+
type="single"
|
|
15
|
+
value={String(selectedMonthItem.value)}
|
|
16
|
+
onValueChange={(v) => {
|
|
17
|
+
if ('onchange' in props && typeof props.onchange === 'function') {
|
|
18
|
+
props.onchange?.({ target: { value: String(v) } } as unknown as Event);
|
|
19
|
+
}
|
|
20
|
+
}}
|
|
21
|
+
disabled={props?.disabled as boolean}
|
|
22
|
+
>
|
|
23
|
+
<Select.Trigger class="cgui:min-w-28 cgui:shrink">
|
|
24
|
+
{selectedMonthItem.label}
|
|
25
|
+
</Select.Trigger>
|
|
26
|
+
<Select.Content class="cgui:max-h-40">
|
|
27
|
+
<Select.Viewport>
|
|
28
|
+
{#each monthItems as monthItem, i (i)}
|
|
29
|
+
<Select.Item value={monthItem.value.toString()}>
|
|
30
|
+
{monthItem.label}
|
|
31
|
+
</Select.Item>
|
|
32
|
+
{/each}
|
|
33
|
+
</Select.Viewport>
|
|
34
|
+
</Select.Content>
|
|
35
|
+
</Select.Root>
|
|
36
|
+
{/snippet}
|
|
37
|
+
</Primitive.MonthSelect>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Icon } from '../../../atomic/icons/index.js';
|
|
3
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
4
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
5
|
+
import { mergeProps } from 'svelte-toolbelt';
|
|
6
|
+
import { calendarHeaderButtonVariants } from '../styles.js';
|
|
7
|
+
import type { CalendarNextButtonProps } from '../types.js';
|
|
8
|
+
|
|
9
|
+
let { class: className, children, ref = $bindable(null), child, ...restProps }: CalendarNextButtonProps = $props();
|
|
10
|
+
|
|
11
|
+
const classNames = $derived(cn(calendarHeaderButtonVariants(), className));
|
|
12
|
+
|
|
13
|
+
const mergedProps = $derived(mergeProps(restProps, { class: classNames }));
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#if child}
|
|
17
|
+
{@render child?.({ props: mergedProps })}
|
|
18
|
+
{:else}
|
|
19
|
+
<Primitive.NextButton bind:ref {...mergedProps}>
|
|
20
|
+
{#if children}
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
{:else}
|
|
23
|
+
<Icon.ChevronRight />
|
|
24
|
+
{/if}
|
|
25
|
+
</Primitive.NextButton>
|
|
26
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Icon } from '../../../atomic/icons/index.js';
|
|
3
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
4
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
5
|
+
import { mergeProps } from 'svelte-toolbelt';
|
|
6
|
+
import { calendarHeaderButtonVariants } from '../styles.js';
|
|
7
|
+
import type { CalendarPrevButtonProps } from '../types.js';
|
|
8
|
+
|
|
9
|
+
let { class: className, children, ref = $bindable(null), child, ...restProps }: CalendarPrevButtonProps = $props();
|
|
10
|
+
|
|
11
|
+
const classNames = $derived(cn(calendarHeaderButtonVariants(), className));
|
|
12
|
+
|
|
13
|
+
const mergedProps = $derived(mergeProps(restProps, { class: classNames }));
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#if child}
|
|
17
|
+
{@render child?.({ props: mergedProps })}
|
|
18
|
+
{:else}
|
|
19
|
+
<Primitive.PrevButton bind:ref {...mergedProps}>
|
|
20
|
+
{#if children}
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
{:else}
|
|
23
|
+
<Icon.ChevronLeft />
|
|
24
|
+
{/if}
|
|
25
|
+
</Primitive.PrevButton>
|
|
26
|
+
{/if}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as Primitive } from 'bits-ui';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../../../internal/utils/tailwindcss.js';
|
|
5
|
+
import { boxWith } from 'svelte-toolbelt';
|
|
6
|
+
import { CalendarRootStylesContext, calendarRootVariants } from '../styles.js';
|
|
7
|
+
import type { CalendarRootProps } from '../types.js';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
ref = $bindable(null),
|
|
12
|
+
placeholder = $bindable(),
|
|
13
|
+
class: className,
|
|
14
|
+
//
|
|
15
|
+
rounded = 'md',
|
|
16
|
+
...restProps
|
|
17
|
+
}: CalendarRootProps = $props();
|
|
18
|
+
|
|
19
|
+
CalendarRootStylesContext.set({
|
|
20
|
+
rounded: boxWith(() => rounded),
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<Primitive.Root
|
|
25
|
+
bind:value={value as never}
|
|
26
|
+
bind:placeholder
|
|
27
|
+
bind:ref
|
|
28
|
+
class={cn(
|
|
29
|
+
calendarRootVariants({
|
|
30
|
+
rounded,
|
|
31
|
+
}),
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...restProps}
|
|
35
|
+
/>
|