@flightlesslabs/dodo-ui-date 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/components/Calendar/Calendar.scss +147 -0
- package/dist/components/Calendar/Calendar.stories.svelte +136 -0
- package/dist/components/Calendar/Calendar.stories.svelte.d.ts +22 -0
- package/dist/components/Calendar/Calendar.svelte +59 -0
- package/dist/components/Calendar/Calendar.svelte.d.ts +6 -0
- package/dist/components/Calendar/CalendarGrid/CalendarGrid.svelte +16 -0
- package/dist/components/Calendar/CalendarGrid/CalendarGrid.svelte.d.ts +4 -0
- package/dist/components/Calendar/CalendarGrid/TableBody.svelte +25 -0
- package/dist/components/Calendar/CalendarGrid/TableBody.svelte.d.ts +8 -0
- package/dist/components/Calendar/CalendarGrid/TableHead.svelte +19 -0
- package/dist/components/Calendar/CalendarGrid/TableHead.svelte.d.ts +6 -0
- package/dist/components/Calendar/Header.svelte +25 -0
- package/dist/components/Calendar/Header.svelte.d.ts +3 -0
- package/dist/components/DatePicker/DatePicker.scss +55 -0
- package/dist/components/DatePicker/DatePicker.stories.svelte +136 -0
- package/dist/components/DatePicker/DatePicker.stories.svelte.d.ts +22 -0
- package/dist/components/DatePicker/DatePicker.svelte +134 -0
- package/dist/components/DatePicker/DatePicker.svelte.d.ts +63 -0
- package/dist/components/DatePicker/DatePickerInput/DatePickerInput.svelte +95 -0
- package/dist/components/DatePicker/DatePickerInput/DatePickerInput.svelte.d.ts +22 -0
- package/dist/components/DatePicker/DatePickerInput/Segments.svelte +17 -0
- package/dist/components/DatePicker/DatePickerInput/Segments.svelte.d.ts +8 -0
- package/dist/components/DatePicker/DatePickerInput/utils.d.ts +10 -0
- package/dist/components/DatePicker/DatePickerInput/utils.js +26 -0
- package/dist/components/DatePicker/DatePickerPopup/CalendarGrid.svelte +35 -0
- package/dist/components/DatePicker/DatePickerPopup/CalendarGrid.svelte.d.ts +4 -0
- package/dist/components/DatePicker/DatePickerPopup/DatePickerPopup.svelte +50 -0
- package/dist/components/DatePicker/DatePickerPopup/DatePickerPopup.svelte.d.ts +6 -0
- package/dist/components/DatePicker/DatePickerPopup/Header.svelte +25 -0
- package/dist/components/DatePicker/DatePickerPopup/Header.svelte.d.ts +3 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/storybook-types.d.ts +129 -0
- package/dist/storybook-types.js +1 -0
- package/dist/styles/global/_breakpoints.scss +38 -0
- package/dist/styles/main.css +155 -0
- package/dist/styles/main.css.map +1 -0
- package/dist/styles/main.scss +2 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.js +12 -0
- package/package.json +114 -0
- package/src/lib/components/Calendar/Calendar.scss +147 -0
- package/src/lib/components/Calendar/Calendar.stories.svelte +136 -0
- package/src/lib/components/Calendar/Calendar.svelte +59 -0
- package/src/lib/components/Calendar/CalendarGrid/CalendarGrid.svelte +16 -0
- package/src/lib/components/Calendar/CalendarGrid/TableBody.svelte +25 -0
- package/src/lib/components/Calendar/CalendarGrid/TableHead.svelte +19 -0
- package/src/lib/components/Calendar/Header.svelte +25 -0
- package/src/lib/components/DatePicker/DatePicker.scss +55 -0
- package/src/lib/components/DatePicker/DatePicker.stories.svelte +136 -0
- package/src/lib/components/DatePicker/DatePicker.svelte +134 -0
- package/src/lib/components/DatePicker/DatePickerInput/DatePickerInput.svelte +95 -0
- package/src/lib/components/DatePicker/DatePickerInput/Segments.svelte +17 -0
- package/src/lib/components/DatePicker/DatePickerInput/utils.ts +55 -0
- package/src/lib/components/DatePicker/DatePickerPopup/CalendarGrid.svelte +35 -0
- package/src/lib/components/DatePicker/DatePickerPopup/DatePickerPopup.svelte +50 -0
- package/src/lib/components/DatePicker/DatePickerPopup/Header.svelte +25 -0
- package/src/lib/index.ts +16 -0
- package/src/lib/storybook-types.ts +182 -0
- package/src/lib/styles/global/_breakpoints.scss +38 -0
- package/src/lib/styles/main.scss +2 -0
- package/src/lib/test/setup.ts +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Siddhesh Mangela
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
@use '../../styles/global/breakpoints' as breakpoints;
|
|
2
|
+
|
|
3
|
+
// ----------------------------------------
|
|
4
|
+
// Theme tokens (global CSS variables)
|
|
5
|
+
// ----------------------------------------
|
|
6
|
+
:root {
|
|
7
|
+
--dodo-ui-Calendar-date-selected-bg: var(--dodo-color-primary-500);
|
|
8
|
+
--dodo-ui-Calendar-date-selected-hover-bg: var(--dodo-color-primary-600);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dodo-theme--dark {
|
|
12
|
+
--dodo-ui-Calendar-date-selected-bg: var(--dodo-color-primary-300);
|
|
13
|
+
--dodo-ui-Calendar-date-selected-hover-bg: var(--dodo-color-primary-400);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.dodo-ui-Calendar {
|
|
17
|
+
font-size: 1rem;
|
|
18
|
+
color: var(--dodo-color-neutral-900);
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
|
|
22
|
+
@include breakpoints.up('sm') {
|
|
23
|
+
padding: var(--dodo-ui-space);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[data-calendar-header] {
|
|
27
|
+
display: flex;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
align-items: center;
|
|
30
|
+
padding: 0 calc(var(--dodo-ui-space) / 2);
|
|
31
|
+
margin-bottom: calc(var(--dodo-ui-space) * 2);
|
|
32
|
+
margin-top: var(--dodo-ui-space);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[data-calendar-heading] {
|
|
36
|
+
margin: 0 calc(var(--dodo-ui-space) / 2);
|
|
37
|
+
font-weight: 500;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
button[data-calendar-next-button],
|
|
41
|
+
button[data-calendar-prev-button] {
|
|
42
|
+
font-size: 1.4em;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-calendar-grid] {
|
|
46
|
+
width: 100%;
|
|
47
|
+
user-select: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-calendar-grid-row] {
|
|
51
|
+
display: flex;
|
|
52
|
+
width: 100%;
|
|
53
|
+
justify-content: space-around;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[data-calendar-grid-head] {
|
|
57
|
+
margin-bottom: var(--dodo-ui-space);
|
|
58
|
+
display: block;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-calendar-head-cell] {
|
|
62
|
+
display: inline-flex;
|
|
63
|
+
width: var(--dodo-ui-element-height-normal);
|
|
64
|
+
justify-content: center;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
color: var(--dodo-color-neutral-600);
|
|
67
|
+
font-size: 0.9rem;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[data-calendar-cell] {
|
|
71
|
+
display: inline-flex;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[data-calendar-day] {
|
|
75
|
+
transition:
|
|
76
|
+
background-color 70ms,
|
|
77
|
+
color 70ms,
|
|
78
|
+
border-color 70ms;
|
|
79
|
+
display: inline-flex;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
align-items: center;
|
|
82
|
+
width: var(--dodo-ui-element-height-normal);
|
|
83
|
+
height: var(--dodo-ui-element-height-normal);
|
|
84
|
+
border-radius: var(--dodo-ui-element-roundness-1);
|
|
85
|
+
border: var(--dodo-ui-element-border-width) solid transparent;
|
|
86
|
+
position: relative;
|
|
87
|
+
|
|
88
|
+
&:hover {
|
|
89
|
+
background-color: var(--dodo-color-neutral-100);
|
|
90
|
+
border-color: var(--dodo-color-neutral-400);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&[data-selected] {
|
|
94
|
+
background-color: var(--dodo-ui-Calendar-date-selected-bg);
|
|
95
|
+
color: var(--dodo-color-constant-white);
|
|
96
|
+
|
|
97
|
+
&:hover {
|
|
98
|
+
background-color: var(--dodo-ui-Calendar-date-selected-hover-bg);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&[data-today] {
|
|
102
|
+
background-color: var(--dodo-ui-Calendar-date-selected-bg);
|
|
103
|
+
color: var(--dodo-color-constant-white);
|
|
104
|
+
|
|
105
|
+
&:hover {
|
|
106
|
+
background-color: var(--dodo-ui-Calendar-date-selected-hover-bg);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&::after {
|
|
110
|
+
background-color: var(--dodo-color-constant-white);
|
|
111
|
+
|
|
112
|
+
&:hover {
|
|
113
|
+
background-color: var(--dodo-color-constant-white);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&[data-today] {
|
|
120
|
+
background-color: var(--dodo-color-primary-50);
|
|
121
|
+
&::after {
|
|
122
|
+
content: '';
|
|
123
|
+
width: var(--dodo-ui-track-element-height-small);
|
|
124
|
+
height: var(--dodo-ui-track-element-height-small);
|
|
125
|
+
border-radius: 50%;
|
|
126
|
+
display: inline-flex;
|
|
127
|
+
background-color: var(--dodo-color-primary-600);
|
|
128
|
+
position: absolute;
|
|
129
|
+
bottom: 0.2em;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&[data-outside-month],
|
|
134
|
+
&[data-disabled] {
|
|
135
|
+
color: var(--dodo-color-neutral-400);
|
|
136
|
+
|
|
137
|
+
&:hover {
|
|
138
|
+
background-color: initial;
|
|
139
|
+
border-color: transparent;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&[data-today] {
|
|
143
|
+
background-color: initial;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Calendar from './Calendar.svelte';
|
|
4
|
+
import type { CalendarProps } from './Calendar.svelte';
|
|
5
|
+
import type { ArgTypes } from 'storybook/internal/csf';
|
|
6
|
+
import { CalendarDate, type DateValue } from '@internationalized/date';
|
|
7
|
+
import {
|
|
8
|
+
cardColorOptions,
|
|
9
|
+
componentRoundnessOptions,
|
|
10
|
+
ComponentShadowOptions,
|
|
11
|
+
componentThemeColorsOptions,
|
|
12
|
+
componentVariantOptions,
|
|
13
|
+
Theme,
|
|
14
|
+
} from '@flightlesslabs/dodo-ui';
|
|
15
|
+
|
|
16
|
+
const description = `
|
|
17
|
+
a plug and play Calendar component based on bits-ui [calendar](https://bits-ui.com/docs/components/calendar).
|
|
18
|
+
|
|
19
|
+
\`\`\`ts
|
|
20
|
+
import { Calendar } from '@flightlesslabs/dodo-ui-date';
|
|
21
|
+
\`\`\`
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
// ------------------------------
|
|
25
|
+
// Storybook ArgTypes
|
|
26
|
+
// ------------------------------
|
|
27
|
+
export const storyCalendarArgTypes: Partial<ArgTypes<CalendarProps>> = {
|
|
28
|
+
// ------------------------------
|
|
29
|
+
// Core
|
|
30
|
+
// ------------------------------
|
|
31
|
+
class: { table: { category: 'API', subcategory: 'Base' } },
|
|
32
|
+
value: {
|
|
33
|
+
control: { type: 'text' },
|
|
34
|
+
table: { category: 'API', subcategory: 'Base' },
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// ------------------------------
|
|
38
|
+
// State
|
|
39
|
+
// ------------------------------
|
|
40
|
+
disabled: {
|
|
41
|
+
control: { type: 'boolean' },
|
|
42
|
+
description: 'Disabled state of the input',
|
|
43
|
+
table: { category: 'API', subcategory: 'State', defaultValue: { summary: 'false' } },
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// ------------------------------
|
|
47
|
+
// Appearance
|
|
48
|
+
// ------------------------------
|
|
49
|
+
shadow: {
|
|
50
|
+
control: { type: 'select' },
|
|
51
|
+
options: ComponentShadowOptions,
|
|
52
|
+
description: 'Component Shadow',
|
|
53
|
+
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: '1' } },
|
|
54
|
+
},
|
|
55
|
+
color: {
|
|
56
|
+
control: { type: 'select' },
|
|
57
|
+
options: cardColorOptions,
|
|
58
|
+
description: 'Color theme token',
|
|
59
|
+
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'default' } },
|
|
60
|
+
},
|
|
61
|
+
variant: {
|
|
62
|
+
control: { type: 'select' },
|
|
63
|
+
options: componentVariantOptions,
|
|
64
|
+
description: 'Visual variant of the card',
|
|
65
|
+
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'text' } },
|
|
66
|
+
},
|
|
67
|
+
roundness: {
|
|
68
|
+
control: { type: 'select' },
|
|
69
|
+
options: componentRoundnessOptions,
|
|
70
|
+
description: 'Border radius token',
|
|
71
|
+
table: { category: 'API', subcategory: 'Appearance' },
|
|
72
|
+
},
|
|
73
|
+
outline: {
|
|
74
|
+
control: { type: 'boolean' },
|
|
75
|
+
description: 'Render outlined style',
|
|
76
|
+
table: { category: 'API', subcategory: 'Appearance' },
|
|
77
|
+
},
|
|
78
|
+
active: {
|
|
79
|
+
control: { type: 'boolean' },
|
|
80
|
+
description: 'Add mouse hover and active effects',
|
|
81
|
+
table: { category: 'API', subcategory: 'Appearance' },
|
|
82
|
+
},
|
|
83
|
+
theme: {
|
|
84
|
+
control: { type: 'select' },
|
|
85
|
+
options: componentThemeColorsOptions,
|
|
86
|
+
description: 'Theme color',
|
|
87
|
+
table: { category: 'API', subcategory: 'Base', defaultValue: { summary: 'undefined' } },
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// ------------------------------
|
|
92
|
+
// Storybook Meta
|
|
93
|
+
// ------------------------------
|
|
94
|
+
const { Story } = defineMeta({
|
|
95
|
+
component: Calendar,
|
|
96
|
+
tags: ['autodocs'],
|
|
97
|
+
argTypes: storyCalendarArgTypes,
|
|
98
|
+
parameters: {
|
|
99
|
+
docs: {
|
|
100
|
+
description: {
|
|
101
|
+
component: description,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
let myValue = $state<DateValue>(new CalendarDate(2026, 4, 7));
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<!-- ------------------------------ -->
|
|
111
|
+
<!-- Stories -->
|
|
112
|
+
<!-- ------------------------------ -->
|
|
113
|
+
|
|
114
|
+
<Story name="Default" />
|
|
115
|
+
|
|
116
|
+
<Story name="Controlled" asChild>
|
|
117
|
+
<Calendar bind:value={myValue} />
|
|
118
|
+
</Story>
|
|
119
|
+
|
|
120
|
+
<Story name="Starts On Sunday" args={{ weekStartsOn: 0 }} />
|
|
121
|
+
|
|
122
|
+
<Story name="Min Date" args={{ minValue: new CalendarDate(2026, 4, 7) }} />
|
|
123
|
+
|
|
124
|
+
<Story name="Max Date" args={{ maxValue: new CalendarDate(2026, 4, 7) }} />
|
|
125
|
+
|
|
126
|
+
<Story name="Light Theme" asChild>
|
|
127
|
+
<Theme type="light">
|
|
128
|
+
<Calendar />
|
|
129
|
+
</Theme>
|
|
130
|
+
</Story>
|
|
131
|
+
|
|
132
|
+
<Story name="Dark Theme" asChild globals={{ backgrounds: { value: 'dark' } }}>
|
|
133
|
+
<Theme type="dark">
|
|
134
|
+
<Calendar />
|
|
135
|
+
</Theme>
|
|
136
|
+
</Story>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Calendar from './Calendar.svelte';
|
|
2
|
+
import type { CalendarProps } from './Calendar.svelte';
|
|
3
|
+
import type { ArgTypes } from 'storybook/internal/csf';
|
|
4
|
+
export declare const storyCalendarArgTypes: Partial<ArgTypes<CalendarProps>>;
|
|
5
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
6
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
7
|
+
$$bindings?: Bindings;
|
|
8
|
+
} & Exports;
|
|
9
|
+
(internal: unknown, props: {
|
|
10
|
+
$$events?: Events;
|
|
11
|
+
$$slots?: Slots;
|
|
12
|
+
}): Exports & {
|
|
13
|
+
$set?: any;
|
|
14
|
+
$on?: any;
|
|
15
|
+
};
|
|
16
|
+
z_$$bindings?: Bindings;
|
|
17
|
+
}
|
|
18
|
+
declare const Calendar: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
}, {}, {}, string>;
|
|
21
|
+
type Calendar = InstanceType<typeof Calendar>;
|
|
22
|
+
export default Calendar;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type CalendarProps = Omit<CalendarSingleRootProps, 'type'> &
|
|
3
|
+
Omit<CardProps, 'children' | 'ref'>;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { Calendar as CalendarBitsUi, type CalendarSingleRootProps } from 'bits-ui';
|
|
8
|
+
import Header from './Header.svelte';
|
|
9
|
+
import CalendarGrid from './CalendarGrid/CalendarGrid.svelte';
|
|
10
|
+
import { useThemeContext, type CardProps } from '@flightlesslabs/dodo-ui';
|
|
11
|
+
let {
|
|
12
|
+
roundness = 1,
|
|
13
|
+
outline = true,
|
|
14
|
+
class: className = '',
|
|
15
|
+
theme: cardTheme,
|
|
16
|
+
color = 'default',
|
|
17
|
+
variant = 'text',
|
|
18
|
+
shadow = 0,
|
|
19
|
+
active = false,
|
|
20
|
+
weekStartsOn = 1,
|
|
21
|
+
weekdayFormat = 'short',
|
|
22
|
+
fixedWeeks = true,
|
|
23
|
+
value = $bindable(undefined),
|
|
24
|
+
...restProps
|
|
25
|
+
}: CalendarProps = $props();
|
|
26
|
+
|
|
27
|
+
const themeContext = useThemeContext();
|
|
28
|
+
const theme = $derived(cardTheme ? cardTheme : themeContext.theme);
|
|
29
|
+
|
|
30
|
+
const popupClasses = $derived(
|
|
31
|
+
[
|
|
32
|
+
'dodo-ui-Card',
|
|
33
|
+
'dodo-ui-Calendar',
|
|
34
|
+
`color--${color}`,
|
|
35
|
+
`variant--${variant}`,
|
|
36
|
+
`roundness--${roundness}`,
|
|
37
|
+
`dodo-shadow-${shadow}`,
|
|
38
|
+
outline && 'outline',
|
|
39
|
+
active && 'active',
|
|
40
|
+
theme ? `dodo-theme--${theme}` : '',
|
|
41
|
+
className,
|
|
42
|
+
].filter(Boolean),
|
|
43
|
+
);
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<CalendarBitsUi.Root
|
|
47
|
+
{...restProps}
|
|
48
|
+
{weekStartsOn}
|
|
49
|
+
{weekdayFormat}
|
|
50
|
+
{fixedWeeks}
|
|
51
|
+
bind:value
|
|
52
|
+
type="single"
|
|
53
|
+
class={popupClasses.join(' ')}
|
|
54
|
+
>
|
|
55
|
+
{#snippet children(calendarRootSnippetProps)}
|
|
56
|
+
<Header />
|
|
57
|
+
<CalendarGrid {...calendarRootSnippetProps} />
|
|
58
|
+
{/snippet}
|
|
59
|
+
</CalendarBitsUi.Root>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type CalendarProps = Omit<CalendarSingleRootProps, 'type'> & Omit<CardProps, 'children' | 'ref'>;
|
|
2
|
+
import { type CalendarSingleRootProps } from 'bits-ui';
|
|
3
|
+
import { type CardProps } from '@flightlesslabs/dodo-ui';
|
|
4
|
+
declare const Calendar: import("svelte").Component<CalendarProps, {}, "value">;
|
|
5
|
+
type Calendar = ReturnType<typeof Calendar>;
|
|
6
|
+
export default Calendar;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar, type CalendarRootSnippetProps } from 'bits-ui';
|
|
3
|
+
import TableHead from './TableHead.svelte';
|
|
4
|
+
import TableBody from './TableBody.svelte';
|
|
5
|
+
|
|
6
|
+
let { months, weekdays }: CalendarRootSnippetProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div class="CalendarGrid">
|
|
10
|
+
{#each months as month (month.value)}
|
|
11
|
+
<Calendar.Grid>
|
|
12
|
+
<TableHead {weekdays} />
|
|
13
|
+
<TableBody {month} />
|
|
14
|
+
</Calendar.Grid>
|
|
15
|
+
{/each}
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { DateValue } from '@internationalized/date';
|
|
3
|
+
import { Calendar, type Month } from 'bits-ui';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
month: Month<DateValue>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
let { month }: Props = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<Calendar.GridBody>
|
|
13
|
+
{#each month.weeks as weekDates (weekDates)}
|
|
14
|
+
<Calendar.GridRow>
|
|
15
|
+
{#each weekDates as date (date)}
|
|
16
|
+
<Calendar.Cell {date} month={month.value}>
|
|
17
|
+
<Calendar.Day>
|
|
18
|
+
<div></div>
|
|
19
|
+
{date.day}
|
|
20
|
+
</Calendar.Day>
|
|
21
|
+
</Calendar.Cell>
|
|
22
|
+
{/each}
|
|
23
|
+
</Calendar.GridRow>
|
|
24
|
+
{/each}
|
|
25
|
+
</Calendar.GridBody>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DateValue } from '@internationalized/date';
|
|
2
|
+
import { type Month } from 'bits-ui';
|
|
3
|
+
type Props = {
|
|
4
|
+
month: Month<DateValue>;
|
|
5
|
+
};
|
|
6
|
+
declare const TableBody: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type TableBody = ReturnType<typeof TableBody>;
|
|
8
|
+
export default TableBody;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar } from 'bits-ui';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
weekdays: string[];
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
let { weekdays }: Props = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<Calendar.GridHead>
|
|
12
|
+
<Calendar.GridRow>
|
|
13
|
+
{#each weekdays as day (day)}
|
|
14
|
+
<Calendar.HeadCell>
|
|
15
|
+
<div>{day.slice(0, 2)}</div>
|
|
16
|
+
</Calendar.HeadCell>
|
|
17
|
+
{/each}
|
|
18
|
+
</Calendar.GridRow>
|
|
19
|
+
</Calendar.GridHead>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '@iconify/svelte';
|
|
3
|
+
import { Calendar } from 'bits-ui';
|
|
4
|
+
|
|
5
|
+
const triggerClasses = $derived(
|
|
6
|
+
[
|
|
7
|
+
'dodo-ui-Button',
|
|
8
|
+
'compact',
|
|
9
|
+
'size--normal',
|
|
10
|
+
'variant--text',
|
|
11
|
+
'color--primary',
|
|
12
|
+
'roundness--1',
|
|
13
|
+
].filter(Boolean),
|
|
14
|
+
);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Calendar.Header>
|
|
18
|
+
<Calendar.PrevButton class={triggerClasses.join(' ')}>
|
|
19
|
+
<Icon icon="material-symbols:chevron-left-rounded" />
|
|
20
|
+
</Calendar.PrevButton>
|
|
21
|
+
<Calendar.Heading />
|
|
22
|
+
<Calendar.NextButton class={triggerClasses.join(' ')}>
|
|
23
|
+
<Icon icon="material-symbols:chevron-right-rounded" />
|
|
24
|
+
</Calendar.NextButton>
|
|
25
|
+
</Calendar.Header>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.dodo-ui-DatePicker {
|
|
2
|
+
button[data-popover-trigger] {
|
|
3
|
+
font-size: 1.4em;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
[data-date-field-input] {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
[data-date-field-segment] {
|
|
12
|
+
height: 80%;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-segment='literal'] {
|
|
18
|
+
color: var(--dodo-color-neutral-500);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ----------------------------------------
|
|
22
|
+
// Sizes
|
|
23
|
+
// ----------------------------------------
|
|
24
|
+
&.size {
|
|
25
|
+
&--normal {
|
|
26
|
+
button[data-popover-trigger] {
|
|
27
|
+
margin: 0 calc(var(--dodo-ui-space) / 2.5);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
[data-date-field-segment] {
|
|
31
|
+
padding: 0 calc(var(--dodo-ui-space) / 3);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&--small {
|
|
36
|
+
button[data-popover-trigger] {
|
|
37
|
+
margin: 0 calc(var(--dodo-ui-space--small) / 2.5);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
[data-date-field-segment] {
|
|
41
|
+
padding: 0 calc(var(--dodo-ui-space-small) / 3);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&--large {
|
|
46
|
+
button[data-popover-trigger] {
|
|
47
|
+
margin: 0 calc(var(--dodo-ui-space--large) / 2.5);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-date-field-segment] {
|
|
51
|
+
padding: 0 calc(var(--dodo-ui-space-large) / 3);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|