@youcan/celeste 0.7.2 → 0.8.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/dist/celeste.css +495 -30
- package/dist/cjs/calendar.cjs +2 -0
- package/dist/cjs/chunks/ComboboxContent.cjs +1 -1
- package/dist/cjs/chunks/DialogPortal.cjs +1 -1
- package/dist/cjs/chunks/DismissableLayer.cjs +0 -34
- package/dist/cjs/chunks/FocusScope.cjs +2 -2
- package/dist/cjs/chunks/MenuContentImpl.cjs +1 -1
- package/dist/cjs/chunks/SelectItemAlignedPosition.cjs +1 -1
- package/dist/cjs/chunks/calendar.cjs +923 -0
- package/dist/cjs/chunks/components.cjs +9 -1
- package/dist/cjs/chunks/counter-input.cjs +2 -13
- package/dist/cjs/chunks/date-picker.cjs +99 -0
- package/dist/cjs/chunks/defu.cjs +34 -0
- package/dist/cjs/chunks/popover-content.cjs +1 -1
- package/dist/cjs/chunks/range-calendar.cjs +1170 -0
- package/dist/cjs/chunks/range-picker.cjs +231 -0
- package/dist/cjs/chunks/text-input.cjs +1 -1
- package/dist/cjs/chunks/tooltip-content.cjs +3 -2
- package/dist/cjs/chunks/useCalendar.cjs +2439 -0
- package/dist/cjs/chunks/useLocale.cjs +20 -0
- package/dist/cjs/date-picker.cjs +2 -0
- package/dist/cjs/index.cjs +9 -1
- package/dist/cjs/range-calendar.cjs +2 -0
- package/dist/cjs/range-picker.cjs +2 -0
- package/dist/components/calendar/calendar.d.ts +19 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/date-picker/date-picker.d.ts +27 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/range-calendar/index.d.ts +2 -0
- package/dist/components/range-calendar/range-calendar.d.ts +24 -0
- package/dist/components/range-picker/index.d.ts +2 -0
- package/dist/components/range-picker/range-picker.d.ts +38 -0
- package/dist/components/rich-editor/rich-editor.d.ts +1 -1
- package/dist/components/text-input/text-input.d.ts +2 -2
- package/dist/es/calendar.js +2 -0
- package/dist/es/chunks/ComboboxContent.js +1 -1
- package/dist/es/chunks/DialogPortal.js +1 -1
- package/dist/es/chunks/DismissableLayer.js +1 -29
- package/dist/es/chunks/FocusScope.js +1 -1
- package/dist/es/chunks/MenuContentImpl.js +1 -1
- package/dist/es/chunks/SelectItemAlignedPosition.js +1 -1
- package/dist/es/chunks/calendar.js +916 -0
- package/dist/es/chunks/components.js +9 -1
- package/dist/es/chunks/counter-input.js +1 -12
- package/dist/es/chunks/date-picker.js +92 -0
- package/dist/es/chunks/defu.js +29 -0
- package/dist/es/chunks/popover-content.js +1 -1
- package/dist/es/chunks/range-calendar.js +1163 -0
- package/dist/es/chunks/range-picker.js +224 -0
- package/dist/es/chunks/text-input.js +1 -1
- package/dist/es/chunks/tooltip-content.js +2 -1
- package/dist/es/chunks/useCalendar.js +2331 -0
- package/dist/es/chunks/useLocale.js +14 -0
- package/dist/es/date-picker.js +2 -0
- package/dist/es/index.js +6 -2
- package/dist/es/range-calendar.js +2 -0
- package/dist/es/range-picker.js +2 -0
- package/package.json +4 -3
- package/src/components/calendar/calendar.vue +305 -0
- package/src/components/calendar/index.ts +2 -0
- package/src/components/calendar/stories/calendar.stories.ts +76 -0
- package/src/components/date-picker/date-picker.vue +91 -0
- package/src/components/date-picker/index.ts +2 -0
- package/src/components/date-picker/stories/date-picker.stories.ts +92 -0
- package/src/components/index.ts +4 -0
- package/src/components/range-calendar/index.ts +2 -0
- package/src/components/range-calendar/range-calendar.vue +363 -0
- package/src/components/range-calendar/stories/range-calendar.stories.ts +46 -0
- package/src/components/range-picker/index.ts +2 -0
- package/src/components/range-picker/range-picker.vue +237 -0
- package/src/components/range-picker/stories/range-picker.stories.ts +97 -0
- package/src/components/text-input/text-input.vue +2 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { CalendarDate } from '@internationalized/date';
|
|
3
|
+
import { ref } from 'vue';
|
|
4
|
+
import Button from '@/components/button/button.vue';
|
|
5
|
+
import PopoverContent from '@/components/popover/popover-content.vue';
|
|
6
|
+
import PopoverTrigger from '@/components/popover/popover-trigger.vue';
|
|
7
|
+
import Popover from '@/components/popover/popover.vue';
|
|
8
|
+
import DatePicker from '../date-picker.vue';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof DatePicker> = {
|
|
11
|
+
title: 'Components/Date Picker',
|
|
12
|
+
component: DatePicker,
|
|
13
|
+
parameters: { layout: 'centered' },
|
|
14
|
+
argTypes: {
|
|
15
|
+
footer: {
|
|
16
|
+
control: { type: 'boolean' },
|
|
17
|
+
description: 'Toggles the Cancel / Apply footer.',
|
|
18
|
+
},
|
|
19
|
+
weekStartsOn: {
|
|
20
|
+
control: { type: 'select' },
|
|
21
|
+
options: [0, 1, 2, 3, 4, 5, 6],
|
|
22
|
+
description: 'First day of the week (0 = Sunday, 1 = Monday).',
|
|
23
|
+
},
|
|
24
|
+
locale: {
|
|
25
|
+
control: { type: 'text' },
|
|
26
|
+
description: 'BCP-47 locale used for the heading and weekday labels.',
|
|
27
|
+
},
|
|
28
|
+
cancelLabel: { control: { type: 'text' } },
|
|
29
|
+
applyLabel: { control: { type: 'text' } },
|
|
30
|
+
},
|
|
31
|
+
args: {
|
|
32
|
+
footer: true,
|
|
33
|
+
weekStartsOn: 1,
|
|
34
|
+
locale: 'en-US',
|
|
35
|
+
cancelLabel: 'Cancel',
|
|
36
|
+
applyLabel: 'Apply',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default meta;
|
|
41
|
+
type Story = StoryObj<typeof DatePicker>;
|
|
42
|
+
|
|
43
|
+
export const Default: Story = {
|
|
44
|
+
render: args => ({
|
|
45
|
+
components: { DatePicker },
|
|
46
|
+
setup() {
|
|
47
|
+
const value = ref(new CalendarDate(2024, 1, 11));
|
|
48
|
+
const markedDates = [new CalendarDate(2024, 1, 16)];
|
|
49
|
+
return { args, value, markedDates };
|
|
50
|
+
},
|
|
51
|
+
template: `<DatePicker v-model="value" v-bind="args" :marked-dates="markedDates" />`,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const NoFooter: Story = {
|
|
56
|
+
args: { footer: false },
|
|
57
|
+
render: args => ({
|
|
58
|
+
components: { DatePicker },
|
|
59
|
+
setup() {
|
|
60
|
+
const value = ref(new CalendarDate(2024, 1, 11));
|
|
61
|
+
return { args, value };
|
|
62
|
+
},
|
|
63
|
+
template: `<DatePicker v-model="value" v-bind="args" />`,
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const InPopover: Story = {
|
|
68
|
+
render: args => ({
|
|
69
|
+
components: { DatePicker, Popover, PopoverContent, PopoverTrigger, Button },
|
|
70
|
+
setup() {
|
|
71
|
+
const value = ref<CalendarDate>();
|
|
72
|
+
const open = ref(false);
|
|
73
|
+
function onApply(): void {
|
|
74
|
+
open.value = false;
|
|
75
|
+
}
|
|
76
|
+
return { args, value, open, onApply };
|
|
77
|
+
},
|
|
78
|
+
template: `
|
|
79
|
+
<Popover v-model:open="open">
|
|
80
|
+
<PopoverTrigger as-child>
|
|
81
|
+
<Button variant="stroke" intent="neutral">
|
|
82
|
+
<i class="i-celeste-calendar-line" />
|
|
83
|
+
{{ value ? value.toString() : 'Pick a date' }}
|
|
84
|
+
</Button>
|
|
85
|
+
</PopoverTrigger>
|
|
86
|
+
<PopoverContent :show-tail="false" :dismissible="false" style="padding: 0; border: none; box-shadow: none;">
|
|
87
|
+
<DatePicker v-model="value" v-bind="args" @apply="onApply" @cancel="open = false" />
|
|
88
|
+
</PopoverContent>
|
|
89
|
+
</Popover>
|
|
90
|
+
`,
|
|
91
|
+
}),
|
|
92
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export * from './alert';
|
|
2
2
|
export * from './badge';
|
|
3
3
|
export * from './button';
|
|
4
|
+
export * from './calendar';
|
|
4
5
|
export * from './checkbox';
|
|
5
6
|
export * from './collapsible';
|
|
6
7
|
export * from './color-picker';
|
|
7
8
|
export * from './combobox';
|
|
8
9
|
export * from './content-divider';
|
|
9
10
|
export * from './counter-input';
|
|
11
|
+
export * from './date-picker';
|
|
10
12
|
export * from './digit-input';
|
|
11
13
|
export * from './dropdown-menu';
|
|
12
14
|
export * from './file-upload';
|
|
@@ -17,6 +19,8 @@ export * from './pagination';
|
|
|
17
19
|
export * from './popover';
|
|
18
20
|
export * from './progress';
|
|
19
21
|
export * from './radio-group';
|
|
22
|
+
export * from './range-calendar';
|
|
23
|
+
export * from './range-picker';
|
|
20
24
|
export * from './rich-editor';
|
|
21
25
|
export * from './scroll-area';
|
|
22
26
|
export * from './segmented-control';
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { DateValue, RangeCalendarRootEmits, RangeCalendarRootProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { DateFormatter, getLocalTimeZone, isEqualDay } from '@internationalized/date';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import {
|
|
7
|
+
RangeCalendarCell,
|
|
8
|
+
RangeCalendarCellTrigger,
|
|
9
|
+
RangeCalendarGrid,
|
|
10
|
+
RangeCalendarGridBody,
|
|
11
|
+
RangeCalendarGridHead,
|
|
12
|
+
RangeCalendarGridRow,
|
|
13
|
+
RangeCalendarHeadCell,
|
|
14
|
+
RangeCalendarNext,
|
|
15
|
+
RangeCalendarPrev,
|
|
16
|
+
RangeCalendarRoot,
|
|
17
|
+
useForwardPropsEmits,
|
|
18
|
+
} from 'reka-ui';
|
|
19
|
+
import { computed } from 'vue';
|
|
20
|
+
import { useDelegatedProps } from '@/composables/use-delegated-props';
|
|
21
|
+
|
|
22
|
+
export interface RangeCalendarProps extends RangeCalendarRootProps {
|
|
23
|
+
class?: HTMLAttributes['class'];
|
|
24
|
+
markedDates?: DateValue[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(defineProps<RangeCalendarProps>(), {
|
|
28
|
+
weekStartsOn: 1,
|
|
29
|
+
weekdayFormat: 'short',
|
|
30
|
+
fixedWeeks: true,
|
|
31
|
+
numberOfMonths: 2,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const emits = defineEmits<RangeCalendarRootEmits>();
|
|
35
|
+
|
|
36
|
+
const delegatedProps = useDelegatedProps(props, ['class', 'markedDates']);
|
|
37
|
+
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
38
|
+
|
|
39
|
+
const monthFormatter = computed(
|
|
40
|
+
() => new DateFormatter(props.locale ?? 'en-US', { month: 'long', year: 'numeric' }),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
function formatMonth(date: DateValue): string {
|
|
44
|
+
return monthFormatter.value.format(date.toDate(getLocalTimeZone()));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function isMarked(date: DateValue): boolean {
|
|
48
|
+
return props.markedDates?.some(marked => isEqualDay(marked, date)) ?? false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function weekdayLabel(day: string): string {
|
|
52
|
+
return /^[a-z]/i.test(day.trim()) ? day.slice(0, 2) : day;
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<RangeCalendarRoot
|
|
58
|
+
v-slot="{ weekDays, grid }"
|
|
59
|
+
v-bind="forwarded"
|
|
60
|
+
:class="clsx('celeste-range-calendar', props.class)"
|
|
61
|
+
>
|
|
62
|
+
<div class="celeste-range-calendar-months">
|
|
63
|
+
<div
|
|
64
|
+
v-for="month in grid"
|
|
65
|
+
:key="month.value.toString()"
|
|
66
|
+
class="celeste-range-calendar-month"
|
|
67
|
+
>
|
|
68
|
+
<div class="celeste-range-calendar-header">
|
|
69
|
+
<RangeCalendarPrev as-child>
|
|
70
|
+
<button type="button" class="celeste-range-calendar-nav">
|
|
71
|
+
<i class="i-celeste-arrow-left-s-line" />
|
|
72
|
+
</button>
|
|
73
|
+
</RangeCalendarPrev>
|
|
74
|
+
<span class="celeste-range-calendar-heading">{{ formatMonth(month.value) }}</span>
|
|
75
|
+
<RangeCalendarNext as-child>
|
|
76
|
+
<button type="button" class="celeste-range-calendar-nav">
|
|
77
|
+
<i class="i-celeste-arrow-right-s-line" />
|
|
78
|
+
</button>
|
|
79
|
+
</RangeCalendarNext>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<RangeCalendarGrid class="celeste-range-calendar-grid">
|
|
83
|
+
<RangeCalendarGridHead>
|
|
84
|
+
<RangeCalendarGridRow class="celeste-range-calendar-week">
|
|
85
|
+
<RangeCalendarHeadCell
|
|
86
|
+
v-for="day in weekDays"
|
|
87
|
+
:key="day"
|
|
88
|
+
class="celeste-range-calendar-weekday"
|
|
89
|
+
>
|
|
90
|
+
{{ weekdayLabel(day) }}
|
|
91
|
+
</RangeCalendarHeadCell>
|
|
92
|
+
</RangeCalendarGridRow>
|
|
93
|
+
</RangeCalendarGridHead>
|
|
94
|
+
<RangeCalendarGridBody class="celeste-range-calendar-body">
|
|
95
|
+
<RangeCalendarGridRow
|
|
96
|
+
v-for="(weekDates, index) in month.rows"
|
|
97
|
+
:key="`week-${index}`"
|
|
98
|
+
class="celeste-range-calendar-week"
|
|
99
|
+
>
|
|
100
|
+
<RangeCalendarCell
|
|
101
|
+
v-for="weekDate in weekDates"
|
|
102
|
+
:key="weekDate.toString()"
|
|
103
|
+
:date="weekDate"
|
|
104
|
+
class="celeste-range-calendar-cell"
|
|
105
|
+
>
|
|
106
|
+
<RangeCalendarCellTrigger
|
|
107
|
+
:day="weekDate"
|
|
108
|
+
:month="month.value"
|
|
109
|
+
class="celeste-range-calendar-day"
|
|
110
|
+
:data-marked="isMarked(weekDate) ? '' : undefined"
|
|
111
|
+
>
|
|
112
|
+
<span class="celeste-range-calendar-day-number">{{ weekDate.day }}</span>
|
|
113
|
+
</RangeCalendarCellTrigger>
|
|
114
|
+
</RangeCalendarCell>
|
|
115
|
+
</RangeCalendarGridRow>
|
|
116
|
+
</RangeCalendarGridBody>
|
|
117
|
+
</RangeCalendarGrid>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
</RangeCalendarRoot>
|
|
121
|
+
</template>
|
|
122
|
+
|
|
123
|
+
<style scoped lang="scss">
|
|
124
|
+
.celeste-range-calendar {
|
|
125
|
+
display: flex;
|
|
126
|
+
box-sizing: border-box;
|
|
127
|
+
color: var(--color-text-sub-600);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.celeste-range-calendar-months {
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: stretch;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.celeste-range-calendar-month {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex: 1;
|
|
138
|
+
flex-direction: column;
|
|
139
|
+
gap: var(--spacing-8);
|
|
140
|
+
min-width: 0;
|
|
141
|
+
padding: 20px;
|
|
142
|
+
|
|
143
|
+
&:not(:last-child) {
|
|
144
|
+
border-inline-end: 1px solid var(--color-stroke-soft-200);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.celeste-range-calendar-header {
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
justify-content: center;
|
|
152
|
+
padding: var(--spacing-6);
|
|
153
|
+
gap: var(--spacing-6);
|
|
154
|
+
border-radius: var(--radius-8);
|
|
155
|
+
background-color: var(--color-bg-weak-50);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.celeste-range-calendar-heading {
|
|
159
|
+
flex: 1;
|
|
160
|
+
color: var(--color-text-sub-600);
|
|
161
|
+
font: var(--label-sm);
|
|
162
|
+
text-align: center;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.celeste-range-calendar-nav {
|
|
166
|
+
display: inline-flex;
|
|
167
|
+
box-sizing: border-box;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: center;
|
|
170
|
+
width: 24px;
|
|
171
|
+
height: 24px;
|
|
172
|
+
padding: 2px;
|
|
173
|
+
transition-property: background-color, color, box-shadow;
|
|
174
|
+
transition-duration: var(--animation-fast);
|
|
175
|
+
transition-timing-function: ease-out;
|
|
176
|
+
border: none;
|
|
177
|
+
border-radius: var(--radius-6);
|
|
178
|
+
background-color: var(--color-bg-white-0);
|
|
179
|
+
box-shadow: var(--shadow-regular-xs);
|
|
180
|
+
color: var(--color-icon-sub-600);
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
|
|
183
|
+
i {
|
|
184
|
+
width: 20px;
|
|
185
|
+
height: 20px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&:dir(rtl) i {
|
|
189
|
+
transform: scaleX(-1);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
&:hover {
|
|
193
|
+
color: var(--color-icon-strong-950);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&:focus-visible {
|
|
197
|
+
outline: none;
|
|
198
|
+
box-shadow: var(--shadow-buttons-important-focus);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&[data-disabled] {
|
|
202
|
+
background-color: transparent;
|
|
203
|
+
box-shadow: none;
|
|
204
|
+
color: var(--color-icon-disabled-300);
|
|
205
|
+
cursor: default;
|
|
206
|
+
pointer-events: none;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.celeste-range-calendar-grid {
|
|
211
|
+
display: flex;
|
|
212
|
+
flex-direction: column;
|
|
213
|
+
gap: var(--spacing-8);
|
|
214
|
+
width: 100%;
|
|
215
|
+
border-collapse: collapse;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.celeste-range-calendar-body {
|
|
219
|
+
display: flex;
|
|
220
|
+
flex-direction: column;
|
|
221
|
+
gap: var(--spacing-8);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.celeste-range-calendar-week {
|
|
225
|
+
display: grid;
|
|
226
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
227
|
+
align-items: center;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.celeste-range-calendar-weekday {
|
|
231
|
+
padding-block: var(--spacing-10);
|
|
232
|
+
color: var(--color-text-soft-400);
|
|
233
|
+
font: var(--label-sm);
|
|
234
|
+
text-align: center;
|
|
235
|
+
text-transform: uppercase;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.celeste-range-calendar-cell {
|
|
239
|
+
position: relative;
|
|
240
|
+
min-width: 0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.celeste-range-calendar-cell:has(.celeste-range-calendar-day[data-selected]),
|
|
244
|
+
.celeste-range-calendar-cell:has(.celeste-range-calendar-day[data-highlighted]) {
|
|
245
|
+
background-color: var(--color-primary-alpha-10);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.celeste-range-calendar-cell:has(.celeste-range-calendar-day[data-selection-start]),
|
|
249
|
+
.celeste-range-calendar-cell:has(.celeste-range-calendar-day[data-highlighted-start]),
|
|
250
|
+
.celeste-range-calendar-week > .celeste-range-calendar-cell:first-child:has(.celeste-range-calendar-day[data-selected]),
|
|
251
|
+
.celeste-range-calendar-week
|
|
252
|
+
> .celeste-range-calendar-cell:first-child:has(.celeste-range-calendar-day[data-highlighted]) {
|
|
253
|
+
border-start-start-radius: var(--radius-8);
|
|
254
|
+
border-end-start-radius: var(--radius-8);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.celeste-range-calendar-cell:has(.celeste-range-calendar-day[data-selection-end]),
|
|
258
|
+
.celeste-range-calendar-cell:has(.celeste-range-calendar-day[data-highlighted-end]),
|
|
259
|
+
.celeste-range-calendar-week > .celeste-range-calendar-cell:last-child:has(.celeste-range-calendar-day[data-selected]),
|
|
260
|
+
.celeste-range-calendar-week
|
|
261
|
+
> .celeste-range-calendar-cell:last-child:has(.celeste-range-calendar-day[data-highlighted]) {
|
|
262
|
+
border-start-end-radius: var(--radius-8);
|
|
263
|
+
border-end-end-radius: var(--radius-8);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.celeste-range-calendar-day {
|
|
267
|
+
display: flex;
|
|
268
|
+
position: relative;
|
|
269
|
+
box-sizing: border-box;
|
|
270
|
+
align-items: center;
|
|
271
|
+
justify-content: center;
|
|
272
|
+
width: 40px;
|
|
273
|
+
max-width: 100%;
|
|
274
|
+
margin-inline: auto;
|
|
275
|
+
padding-block: var(--spacing-10);
|
|
276
|
+
transition-property: background-color, color;
|
|
277
|
+
transition-duration: var(--animation-fast);
|
|
278
|
+
transition-timing-function: ease-out;
|
|
279
|
+
border-radius: var(--radius-8);
|
|
280
|
+
background-color: transparent;
|
|
281
|
+
color: var(--color-text-sub-600);
|
|
282
|
+
font: var(--label-sm);
|
|
283
|
+
cursor: pointer;
|
|
284
|
+
user-select: none;
|
|
285
|
+
|
|
286
|
+
&:hover {
|
|
287
|
+
background-color: var(--color-bg-weak-50);
|
|
288
|
+
color: var(--color-text-strong-950);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
&:focus-visible {
|
|
292
|
+
outline: none;
|
|
293
|
+
box-shadow: var(--shadow-buttons-important-focus);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
&[data-outside-view],
|
|
297
|
+
&[data-outside-visible-view] {
|
|
298
|
+
color: var(--color-text-disabled-300);
|
|
299
|
+
|
|
300
|
+
&:hover {
|
|
301
|
+
background-color: transparent;
|
|
302
|
+
color: var(--color-text-disabled-300);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
&[data-disabled] {
|
|
307
|
+
color: var(--color-text-disabled-300);
|
|
308
|
+
cursor: default;
|
|
309
|
+
pointer-events: none;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
&[data-unavailable] {
|
|
313
|
+
color: var(--color-text-disabled-300);
|
|
314
|
+
text-decoration: line-through;
|
|
315
|
+
pointer-events: none;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
&[data-selected],
|
|
319
|
+
&[data-highlighted] {
|
|
320
|
+
color: var(--color-primary-base);
|
|
321
|
+
|
|
322
|
+
&:hover {
|
|
323
|
+
background-color: transparent;
|
|
324
|
+
color: var(--color-primary-base);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
&[data-selection-start],
|
|
329
|
+
&[data-selection-end] {
|
|
330
|
+
background-color: var(--color-primary-base);
|
|
331
|
+
color: var(--color-text-white-0);
|
|
332
|
+
|
|
333
|
+
&:hover {
|
|
334
|
+
background-color: var(--color-primary-base);
|
|
335
|
+
color: var(--color-text-white-0);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.celeste-range-calendar-day-number {
|
|
341
|
+
position: relative;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.celeste-range-calendar-day[data-today]::after,
|
|
345
|
+
.celeste-range-calendar-day[data-marked]::after {
|
|
346
|
+
content: '';
|
|
347
|
+
position: absolute;
|
|
348
|
+
bottom: 6px;
|
|
349
|
+
left: 50%;
|
|
350
|
+
width: 3px;
|
|
351
|
+
height: 3px;
|
|
352
|
+
transform: translateX(-50%);
|
|
353
|
+
border-radius: var(--radius-full);
|
|
354
|
+
background-color: var(--color-primary-base);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.celeste-range-calendar-day[data-selection-start][data-today]::after,
|
|
358
|
+
.celeste-range-calendar-day[data-selection-end][data-today]::after,
|
|
359
|
+
.celeste-range-calendar-day[data-selection-start][data-marked]::after,
|
|
360
|
+
.celeste-range-calendar-day[data-selection-end][data-marked]::after {
|
|
361
|
+
background-color: var(--color-text-white-0);
|
|
362
|
+
}
|
|
363
|
+
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import type { DateRange } from 'reka-ui';
|
|
3
|
+
import { CalendarDate } from '@internationalized/date';
|
|
4
|
+
import { ref } from 'vue';
|
|
5
|
+
import RangeCalendar from '../range-calendar.vue';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof RangeCalendar> = {
|
|
8
|
+
title: 'Components/Range Calendar',
|
|
9
|
+
component: RangeCalendar,
|
|
10
|
+
parameters: { layout: 'centered' },
|
|
11
|
+
argTypes: {
|
|
12
|
+
numberOfMonths: {
|
|
13
|
+
control: { type: 'number' },
|
|
14
|
+
description: 'How many months to render side by side.',
|
|
15
|
+
},
|
|
16
|
+
weekStartsOn: {
|
|
17
|
+
control: { type: 'select' },
|
|
18
|
+
options: [0, 1, 2, 3, 4, 5, 6],
|
|
19
|
+
description: 'First day of the week (0 = Sunday, 1 = Monday).',
|
|
20
|
+
},
|
|
21
|
+
locale: { control: { type: 'text' } },
|
|
22
|
+
},
|
|
23
|
+
args: {
|
|
24
|
+
numberOfMonths: 2,
|
|
25
|
+
weekStartsOn: 1,
|
|
26
|
+
locale: 'en-US',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default meta;
|
|
31
|
+
type Story = StoryObj<typeof RangeCalendar>;
|
|
32
|
+
|
|
33
|
+
export const Default: Story = {
|
|
34
|
+
render: args => ({
|
|
35
|
+
components: { RangeCalendar },
|
|
36
|
+
setup() {
|
|
37
|
+
const value = ref<DateRange>({
|
|
38
|
+
start: new CalendarDate(2023, 12, 18),
|
|
39
|
+
end: new CalendarDate(2024, 1, 7),
|
|
40
|
+
});
|
|
41
|
+
const markedDates = [new CalendarDate(2023, 12, 8), new CalendarDate(2024, 1, 11)];
|
|
42
|
+
return { args, value, markedDates };
|
|
43
|
+
},
|
|
44
|
+
template: `<RangeCalendar v-model="value" v-bind="args" :marked-dates="markedDates" />`,
|
|
45
|
+
}),
|
|
46
|
+
};
|