@flightlesslabs/dodo-ui 0.22.2 → 0.24.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/README.md +1 -9
- package/dist/index.d.ts +4 -10
- package/dist/index.js +5 -10
- package/dist/styles/components.css +0 -154
- package/dist/styles/components.css.map +1 -1
- package/dist/styles/components.scss +0 -2
- package/package.json +27 -41
- package/src/lib/index.ts +6 -19
- package/src/lib/styles/components.scss +0 -2
- package/src/lib/utils/time/date-creator/createDate/createDate.test.ts +109 -0
- package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.test.ts +146 -0
- package/dist/Home.mdx +0 -69
- package/dist/components/Form/Button/Button.stories.svelte +0 -178
- package/dist/components/Form/Button/Button.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
- package/dist/components/Form/Checkbox/Checkbox.stories.svelte.d.ts +0 -25
- package/dist/components/Form/DatePicker/DatePicker.scss +0 -55
- package/dist/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
- package/dist/components/Form/DatePicker/DatePicker.stories.svelte.d.ts +0 -22
- package/dist/components/Form/DatePicker/DatePicker.svelte +0 -136
- package/dist/components/Form/DatePicker/DatePicker.svelte.d.ts +0 -64
- package/dist/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte +0 -96
- package/dist/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte.d.ts +0 -23
- package/dist/components/Form/DatePicker/DatePickerInput/Segments.svelte +0 -17
- package/dist/components/Form/DatePicker/DatePickerInput/Segments.svelte.d.ts +0 -8
- package/dist/components/Form/DatePicker/DatePickerInput/utils.d.ts +0 -10
- package/dist/components/Form/DatePicker/DatePickerInput/utils.js +0 -26
- package/dist/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte +0 -35
- package/dist/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte.d.ts +0 -4
- package/dist/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte +0 -52
- package/dist/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte.d.ts +0 -6
- package/dist/components/Form/DatePicker/DatePickerPopup/Header.svelte +0 -25
- package/dist/components/Form/DatePicker/DatePickerPopup/Header.svelte.d.ts +0 -3
- package/dist/components/Form/FormField/FormField.stories.svelte +0 -48
- package/dist/components/Form/FormField/FormField.stories.svelte.d.ts +0 -25
- package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
- package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Label/Label.stories.svelte +0 -31
- package/dist/components/Form/Label/Label.stories.svelte.d.ts +0 -25
- package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
- package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte.d.ts +0 -25
- package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
- package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte.d.ts +0 -25
- package/dist/components/Form/Select/Select.stories.svelte +0 -175
- package/dist/components/Form/Select/Select.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Switch/Switch.stories.svelte +0 -128
- package/dist/components/Form/Switch/Switch.stories.svelte.d.ts +0 -25
- package/dist/components/Form/TextInput/TextInput.stories.svelte +0 -162
- package/dist/components/Form/TextInput/TextInput.stories.svelte.d.ts +0 -22
- package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
- package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte.d.ts +0 -22
- package/dist/components/Info/Calendar/Calendar.scss +0 -147
- package/dist/components/Info/Calendar/Calendar.stories.svelte +0 -134
- package/dist/components/Info/Calendar/Calendar.stories.svelte.d.ts +0 -22
- package/dist/components/Info/Calendar/Calendar.svelte +0 -61
- package/dist/components/Info/Calendar/Calendar.svelte.d.ts +0 -6
- package/dist/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte +0 -16
- package/dist/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte.d.ts +0 -4
- package/dist/components/Info/Calendar/CalendarGrid/TableBody.svelte +0 -25
- package/dist/components/Info/Calendar/CalendarGrid/TableBody.svelte.d.ts +0 -8
- package/dist/components/Info/Calendar/CalendarGrid/TableHead.svelte +0 -19
- package/dist/components/Info/Calendar/CalendarGrid/TableHead.svelte.d.ts +0 -6
- package/dist/components/Info/Calendar/Header.svelte +0 -25
- package/dist/components/Info/Calendar/Header.svelte.d.ts +0 -3
- package/dist/components/Layout/Card/Card.stories.svelte +0 -113
- package/dist/components/Layout/Card/Card.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Column/Column.stories.svelte +0 -66
- package/dist/components/Layout/Grid/Column/Column.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Grid.stories.svelte +0 -192
- package/dist/components/Layout/Grid/Grid.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Row/Row.stories.svelte +0 -39
- package/dist/components/Layout/Grid/Row/Row.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Theme/Theme.stories.svelte +0 -54
- package/dist/components/Layout/Theme/Theme.stories.svelte.d.ts +0 -25
- package/dist/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
- package/dist/storybook-types.d.ts +0 -129
- package/dist/storybook-types.js +0 -1
- package/dist/utils/time/date-creator/createDate/createDate.mdx +0 -98
- package/dist/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
- package/dist/utils/time/timeout/timeout.mdx +0 -114
- package/src/lib/Home.mdx +0 -69
- package/src/lib/components/Form/Button/Button.stories.svelte +0 -178
- package/src/lib/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
- package/src/lib/components/Form/DatePicker/DatePicker.scss +0 -55
- package/src/lib/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
- package/src/lib/components/Form/DatePicker/DatePicker.svelte +0 -136
- package/src/lib/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte +0 -96
- package/src/lib/components/Form/DatePicker/DatePickerInput/Segments.svelte +0 -17
- package/src/lib/components/Form/DatePicker/DatePickerInput/utils.ts +0 -55
- package/src/lib/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte +0 -35
- package/src/lib/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte +0 -52
- package/src/lib/components/Form/DatePicker/DatePickerPopup/Header.svelte +0 -25
- package/src/lib/components/Form/FormField/FormField.stories.svelte +0 -48
- package/src/lib/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
- package/src/lib/components/Form/Label/Label.stories.svelte +0 -31
- package/src/lib/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
- package/src/lib/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
- package/src/lib/components/Form/Select/Select.stories.svelte +0 -175
- package/src/lib/components/Form/Switch/Switch.stories.svelte +0 -128
- package/src/lib/components/Form/TextInput/TextInput.stories.svelte +0 -162
- package/src/lib/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
- package/src/lib/components/Info/Calendar/Calendar.scss +0 -147
- package/src/lib/components/Info/Calendar/Calendar.stories.svelte +0 -134
- package/src/lib/components/Info/Calendar/Calendar.svelte +0 -61
- package/src/lib/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte +0 -16
- package/src/lib/components/Info/Calendar/CalendarGrid/TableBody.svelte +0 -25
- package/src/lib/components/Info/Calendar/CalendarGrid/TableHead.svelte +0 -19
- package/src/lib/components/Info/Calendar/Header.svelte +0 -25
- package/src/lib/components/Layout/Card/Card.stories.svelte +0 -113
- package/src/lib/components/Layout/Grid/Column/Column.stories.svelte +0 -66
- package/src/lib/components/Layout/Grid/Grid.stories.svelte +0 -192
- package/src/lib/components/Layout/Grid/Row/Row.stories.svelte +0 -39
- package/src/lib/components/Layout/Theme/Theme.stories.svelte +0 -54
- package/src/lib/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
- package/src/lib/storybook-types.ts +0 -182
- package/src/lib/utils/time/date-creator/createDate/createDate.mdx +0 -98
- package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
- package/src/lib/utils/time/timeout/timeout.mdx +0 -114
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Checkbox from './Checkbox.svelte';
|
|
4
|
-
import type { CheckboxProps } from './Checkbox.svelte';
|
|
5
|
-
import type { ArgTypes } from 'storybook/internal/csf';
|
|
6
|
-
import { componentColorOptions } from '$lib/attributes/color.js';
|
|
7
|
-
import { componentSizeOptions } from '$lib/attributes/size.js';
|
|
8
|
-
import { componenRoundnessShapeOptions } from '$lib/attributes/roundness.js';
|
|
9
|
-
import Theme from '$lib/components/Layout/Theme/Theme.svelte';
|
|
10
|
-
import { componentVariantOptions } from '$lib/attributes/variant.js';
|
|
11
|
-
|
|
12
|
-
const description = `
|
|
13
|
-
A simple Checkbox component based on bits-ui [checkbox](https://bits-ui.com/docs/components/checkbox).
|
|
14
|
-
|
|
15
|
-
\`\`\`ts
|
|
16
|
-
import { Checkbox } from '@flightlesslabs/dodo-ui';
|
|
17
|
-
\`\`\`
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Storybook controls for Checkbox
|
|
22
|
-
*/
|
|
23
|
-
export const CheckboxArgTypes: Partial<ArgTypes<CheckboxProps>> = {
|
|
24
|
-
// ------------------------------
|
|
25
|
-
// Core
|
|
26
|
-
// ------------------------------
|
|
27
|
-
children: { table: { category: 'API', subcategory: 'Base' } },
|
|
28
|
-
disabled: {
|
|
29
|
-
control: { type: 'boolean' },
|
|
30
|
-
description: 'Disable interactions',
|
|
31
|
-
table: { category: 'API', subcategory: 'Base' },
|
|
32
|
-
},
|
|
33
|
-
class: { table: { category: 'API', subcategory: 'Base' } },
|
|
34
|
-
|
|
35
|
-
// ------------------------------
|
|
36
|
-
// Appearance
|
|
37
|
-
// ------------------------------
|
|
38
|
-
color: {
|
|
39
|
-
control: { type: 'select' },
|
|
40
|
-
options: componentColorOptions,
|
|
41
|
-
description: 'Color theme token',
|
|
42
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'neutral' } },
|
|
43
|
-
},
|
|
44
|
-
variant: {
|
|
45
|
-
control: { type: 'select' },
|
|
46
|
-
options: componentVariantOptions,
|
|
47
|
-
description: 'Visual variant of the Checkbox',
|
|
48
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'text' } },
|
|
49
|
-
},
|
|
50
|
-
size: {
|
|
51
|
-
control: { type: 'select' },
|
|
52
|
-
options: componentSizeOptions,
|
|
53
|
-
description: 'Visual size token',
|
|
54
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'normal' } },
|
|
55
|
-
},
|
|
56
|
-
roundness: {
|
|
57
|
-
control: { type: 'select' },
|
|
58
|
-
options: componenRoundnessShapeOptions,
|
|
59
|
-
description: 'Border radius token',
|
|
60
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
61
|
-
},
|
|
62
|
-
outline: {
|
|
63
|
-
control: { type: 'boolean' },
|
|
64
|
-
description: 'Render outlined style',
|
|
65
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'true' } },
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const { Story } = defineMeta({
|
|
70
|
-
component: Checkbox,
|
|
71
|
-
tags: ['autodocs'],
|
|
72
|
-
argTypes: CheckboxArgTypes,
|
|
73
|
-
parameters: {
|
|
74
|
-
docs: {
|
|
75
|
-
description: {
|
|
76
|
-
component: description,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
let myValue = $state<boolean>(true);
|
|
83
|
-
</script>
|
|
84
|
-
|
|
85
|
-
<!-- ------------------------------ -->
|
|
86
|
-
<!-- Stories -->
|
|
87
|
-
<!-- ------------------------------ -->
|
|
88
|
-
|
|
89
|
-
<Story name="Default" args={{ id: 'Default' }}>Check this text</Story>
|
|
90
|
-
|
|
91
|
-
<Story name="Controlled" asChild>
|
|
92
|
-
<Checkbox id="Checked" bind:checked={myValue}>Check this text</Checkbox>
|
|
93
|
-
</Story>
|
|
94
|
-
|
|
95
|
-
<Story
|
|
96
|
-
name="OnChange (Actions)"
|
|
97
|
-
args={{
|
|
98
|
-
id: 'OnChange_Action',
|
|
99
|
-
onCheckedChange: (checked: boolean) => {
|
|
100
|
-
alert('OnChange');
|
|
101
|
-
console.log('OnChange', checked);
|
|
102
|
-
},
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
Check this text
|
|
106
|
-
</Story>
|
|
107
|
-
|
|
108
|
-
<Story name="Indeterminate" args={{ id: 'indeterminate', indeterminate: true }}>
|
|
109
|
-
Check this text
|
|
110
|
-
</Story>
|
|
111
|
-
|
|
112
|
-
<Story name="Color" args={{ id: 'Safe', color: 'safe' }}>Check this text</Story>
|
|
113
|
-
|
|
114
|
-
<Story name="Solid" args={{ id: 'Solid', variant: 'solid', checked: true }}>Check this text</Story>
|
|
115
|
-
|
|
116
|
-
<Story name="NoOutline" args={{ id: 'Outline', outline: false }}>Check this text</Story>
|
|
117
|
-
|
|
118
|
-
<Story name="Size" args={{ id: 'Size', size: 'large' }}>Check this text</Story>
|
|
119
|
-
|
|
120
|
-
<Story name="Disabled" args={{ disabled: true }}>Check this text</Story>
|
|
121
|
-
|
|
122
|
-
<Story name="Light Theme" asChild>
|
|
123
|
-
<Theme type="light">
|
|
124
|
-
<Checkbox id="Light_Theme">Check this text</Checkbox>
|
|
125
|
-
</Theme>
|
|
126
|
-
</Story>
|
|
127
|
-
|
|
128
|
-
<Story name="Dark Theme" asChild globals={{ backgrounds: { value: 'dark' } }}>
|
|
129
|
-
<Theme type="dark">
|
|
130
|
-
<Checkbox id="Dark_Theme">Check this text</Checkbox>
|
|
131
|
-
</Theme>
|
|
132
|
-
</Story>
|
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import DatePicker from './DatePicker.svelte';
|
|
4
|
-
import type { DatePickerProps } from './DatePicker.svelte';
|
|
5
|
-
import type { ArgTypes } from 'storybook/internal/csf';
|
|
6
|
-
|
|
7
|
-
import { componentSizeOptions } from '$lib/attributes/size.js';
|
|
8
|
-
import { componentRoundnessOptions } from '$lib/attributes/roundness.js';
|
|
9
|
-
import { CalendarDate, type DateValue } from '@internationalized/date';
|
|
10
|
-
import Theme from '$lib/components/Layout/Theme/Theme.svelte';
|
|
11
|
-
|
|
12
|
-
const description = `
|
|
13
|
-
A sleek, plug and play Date Picker based on bits-ui [date-picker](https://bits-ui.com/docs/components/date-picker).
|
|
14
|
-
\`\`\`ts
|
|
15
|
-
import { DatePicker } from '@flightlesslabs/dodo-ui';
|
|
16
|
-
|
|
17
|
-
import { CalendarDate, type DateValue } from '@internationalized/date';
|
|
18
|
-
\`\`\`
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
// ------------------------------
|
|
22
|
-
// Storybook ArgTypes
|
|
23
|
-
// ------------------------------
|
|
24
|
-
export const storyDatePickerArgTypes: Partial<ArgTypes<DatePickerProps>> = {
|
|
25
|
-
// ------------------------------
|
|
26
|
-
// Core
|
|
27
|
-
// ------------------------------
|
|
28
|
-
class: { table: { category: 'API', subcategory: 'Base' } },
|
|
29
|
-
value: {
|
|
30
|
-
control: { type: 'text' },
|
|
31
|
-
table: { category: 'API', subcategory: 'Base' },
|
|
32
|
-
},
|
|
33
|
-
dateFormat: {
|
|
34
|
-
control: { type: 'text' },
|
|
35
|
-
table: { category: 'API', subcategory: 'Base', defaultValue: { summary: 'dd/mm/yyyy' } },
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
// ------------------------------
|
|
39
|
-
// State
|
|
40
|
-
// ------------------------------
|
|
41
|
-
disabled: {
|
|
42
|
-
control: { type: 'boolean' },
|
|
43
|
-
description: 'Disabled state of the input',
|
|
44
|
-
table: { category: 'API', subcategory: 'State', defaultValue: { summary: 'false' } },
|
|
45
|
-
},
|
|
46
|
-
focused: {
|
|
47
|
-
control: { type: 'boolean' },
|
|
48
|
-
description: 'Force focused visual state',
|
|
49
|
-
table: { category: 'API', subcategory: 'State', defaultValue: { summary: 'false' } },
|
|
50
|
-
},
|
|
51
|
-
error: {
|
|
52
|
-
control: { type: 'boolean' },
|
|
53
|
-
description: 'Error visual state',
|
|
54
|
-
table: { category: 'API', subcategory: 'State', defaultValue: { summary: 'false' } },
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
// ------------------------------
|
|
58
|
-
// Appearance
|
|
59
|
-
// ------------------------------
|
|
60
|
-
size: {
|
|
61
|
-
control: { type: 'select' },
|
|
62
|
-
options: componentSizeOptions,
|
|
63
|
-
description: 'Visual size token',
|
|
64
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'normal' } },
|
|
65
|
-
},
|
|
66
|
-
roundness: {
|
|
67
|
-
control: { type: 'select' },
|
|
68
|
-
options: componentRoundnessOptions,
|
|
69
|
-
description: 'Border radius token',
|
|
70
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: '1' } },
|
|
71
|
-
},
|
|
72
|
-
outline: {
|
|
73
|
-
control: { type: 'boolean' },
|
|
74
|
-
description: 'Render outlined enclosure',
|
|
75
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'true' } },
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
// ------------------------------
|
|
79
|
-
// Slots (Snippets)
|
|
80
|
-
// ------------------------------
|
|
81
|
-
before: {
|
|
82
|
-
table: { category: 'API', subcategory: 'Slots' },
|
|
83
|
-
description: 'Content rendered before the input',
|
|
84
|
-
},
|
|
85
|
-
after: {
|
|
86
|
-
table: { category: 'API', subcategory: 'Slots' },
|
|
87
|
-
description: 'Content rendered after the input',
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// ------------------------------
|
|
92
|
-
// Storybook Meta
|
|
93
|
-
// ------------------------------
|
|
94
|
-
const { Story } = defineMeta({
|
|
95
|
-
component: DatePicker,
|
|
96
|
-
tags: ['autodocs'],
|
|
97
|
-
argTypes: storyDatePickerArgTypes,
|
|
98
|
-
parameters: {
|
|
99
|
-
docs: {
|
|
100
|
-
description: {
|
|
101
|
-
component: description,
|
|
102
|
-
},
|
|
103
|
-
story: { height: '420px' },
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
let myValue = $state<DateValue>(new CalendarDate(2026, 4, 7));
|
|
109
|
-
</script>
|
|
110
|
-
|
|
111
|
-
<!-- ------------------------------ -->
|
|
112
|
-
<!-- Stories -->
|
|
113
|
-
<!-- ------------------------------ -->
|
|
114
|
-
|
|
115
|
-
<Story name="Default" />
|
|
116
|
-
|
|
117
|
-
<Story name="Controlled" asChild>
|
|
118
|
-
<DatePicker bind:value={myValue} />
|
|
119
|
-
</Story>
|
|
120
|
-
|
|
121
|
-
<Story name="Starts On Sunday" args={{ weekStartsOn: 0 }} />
|
|
122
|
-
|
|
123
|
-
<Story name="Date Format" args={{ dateFormat: 'mm/dd/yyyy' }} />
|
|
124
|
-
|
|
125
|
-
<Story name="Min Date" args={{ minValue: new CalendarDate(2026, 4, 7) }} />
|
|
126
|
-
|
|
127
|
-
<Story name="Max Date" args={{ maxValue: new CalendarDate(2026, 4, 7) }} />
|
|
128
|
-
|
|
129
|
-
<Story name="Light Theme" asChild>
|
|
130
|
-
<Theme type="light">
|
|
131
|
-
<DatePicker />
|
|
132
|
-
</Theme>
|
|
133
|
-
</Story>
|
|
134
|
-
|
|
135
|
-
<Story name="Dark Theme" asChild globals={{ backgrounds: { value: 'dark' } }}>
|
|
136
|
-
<Theme type="dark">
|
|
137
|
-
<DatePicker />
|
|
138
|
-
</Theme>
|
|
139
|
-
</Story>
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { ComponentRoundnessShape } from '$lib/attributes/roundness.js';
|
|
3
|
-
import type { ComponentSize } from '$lib/attributes/size.js';
|
|
4
|
-
|
|
5
|
-
export type DatePickerProps = DatePickerRootPropsWithoutHTML & {
|
|
6
|
-
/** Visual size token (e.g. small, normal, large) */
|
|
7
|
-
size?: ComponentSize;
|
|
8
|
-
|
|
9
|
-
/** Border radius token (e.g. 1–3, "pill") */
|
|
10
|
-
roundness?: ComponentRoundnessShape;
|
|
11
|
-
|
|
12
|
-
/** Render an outlined enclosure (shows border) */
|
|
13
|
-
outline?: boolean;
|
|
14
|
-
|
|
15
|
-
/** Custom CSS class names applied to the InputEnclosure */
|
|
16
|
-
class?: string;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Error visual state.
|
|
20
|
-
*
|
|
21
|
-
* When true, applies error styling to the enclosure.
|
|
22
|
-
* Intended for validation errors.
|
|
23
|
-
*/
|
|
24
|
-
error?: boolean;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Focused visual state.
|
|
28
|
-
*
|
|
29
|
-
* When true, forces focused styling on the enclosure.
|
|
30
|
-
* Usually controlled automatically via focus/blur.
|
|
31
|
-
*/
|
|
32
|
-
focused?: boolean;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Content rendered before the input (prefix).
|
|
36
|
-
*
|
|
37
|
-
* Use {#snippet before} in Svelte.
|
|
38
|
-
*/
|
|
39
|
-
before?: Snippet;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Content rendered after the input (suffix).
|
|
43
|
-
*
|
|
44
|
-
* Use {#snippet after} in Svelte.
|
|
45
|
-
*/
|
|
46
|
-
after?: Snippet;
|
|
47
|
-
|
|
48
|
-
/** Select placeholder */
|
|
49
|
-
placeholder?: string;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Date display format for the input segments.
|
|
53
|
-
*
|
|
54
|
-
* Controls the visual order and separators of the date parts
|
|
55
|
-
* (e.g. "dd/mm/yyyy", "mm-dd-yyyy", "yyyy.mm.dd").
|
|
56
|
-
*
|
|
57
|
-
* This only affects how the date is rendered in the input,
|
|
58
|
-
* not the internal parsing or keyboard interaction behavior
|
|
59
|
-
* of the DatePicker.
|
|
60
|
-
*/
|
|
61
|
-
dateFormat?: DatePickerFormat;
|
|
62
|
-
|
|
63
|
-
/** bits ui dateFieldInputProps */
|
|
64
|
-
dateFieldInputProps?: DateFieldInputProps;
|
|
65
|
-
|
|
66
|
-
/** bits ui datePickerTriggerProps */
|
|
67
|
-
datePickerTriggerProps?: DatePickerTriggerProps;
|
|
68
|
-
|
|
69
|
-
/** Props for Popup */
|
|
70
|
-
popupProps?: DatePickerPopupProps;
|
|
71
|
-
};
|
|
72
|
-
</script>
|
|
73
|
-
|
|
74
|
-
<script lang="ts">
|
|
75
|
-
import {
|
|
76
|
-
DatePicker as DatePickerBitsUi,
|
|
77
|
-
type DateFieldInputProps,
|
|
78
|
-
type DatePickerRootPropsWithoutHTML,
|
|
79
|
-
type DatePickerTriggerProps,
|
|
80
|
-
} from 'bits-ui';
|
|
81
|
-
import type { Snippet } from 'svelte';
|
|
82
|
-
import DatepickerInput from './DatePickerInput/DatePickerInput.svelte';
|
|
83
|
-
import type { DatePickerFormat } from './DatePickerInput/utils.js';
|
|
84
|
-
import DatePickerPopup, {
|
|
85
|
-
type DatePickerPopupProps,
|
|
86
|
-
} from './DatePickerPopup/DatePickerPopup.svelte';
|
|
87
|
-
|
|
88
|
-
let {
|
|
89
|
-
size = 'normal',
|
|
90
|
-
roundness = 1,
|
|
91
|
-
outline = true,
|
|
92
|
-
class: className = '',
|
|
93
|
-
disabled = false,
|
|
94
|
-
error = false,
|
|
95
|
-
focused: forcedFocused = false,
|
|
96
|
-
before,
|
|
97
|
-
after,
|
|
98
|
-
open = $bindable(false),
|
|
99
|
-
value = $bindable(undefined),
|
|
100
|
-
placeholder,
|
|
101
|
-
weekdayFormat = 'short',
|
|
102
|
-
fixedWeeks = true,
|
|
103
|
-
dateFieldInputProps,
|
|
104
|
-
datePickerTriggerProps,
|
|
105
|
-
weekStartsOn = 1,
|
|
106
|
-
dateFormat = 'dd/mm/yyyy',
|
|
107
|
-
popupProps,
|
|
108
|
-
...restProps
|
|
109
|
-
}: DatePickerProps = $props();
|
|
110
|
-
</script>
|
|
111
|
-
|
|
112
|
-
<DatePickerBitsUi.Root
|
|
113
|
-
{...restProps}
|
|
114
|
-
bind:value
|
|
115
|
-
bind:open
|
|
116
|
-
{weekdayFormat}
|
|
117
|
-
{weekStartsOn}
|
|
118
|
-
{fixedWeeks}
|
|
119
|
-
>
|
|
120
|
-
<DatepickerInput
|
|
121
|
-
{size}
|
|
122
|
-
{roundness}
|
|
123
|
-
{outline}
|
|
124
|
-
class={className}
|
|
125
|
-
{disabled}
|
|
126
|
-
{error}
|
|
127
|
-
{dateFieldInputProps}
|
|
128
|
-
{datePickerTriggerProps}
|
|
129
|
-
focused={forcedFocused}
|
|
130
|
-
{before}
|
|
131
|
-
{after}
|
|
132
|
-
{placeholder}
|
|
133
|
-
{dateFormat}
|
|
134
|
-
/>
|
|
135
|
-
<DatePickerPopup {...popupProps} />
|
|
136
|
-
</DatePickerBitsUi.Root>
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
|
|
4
|
-
export type DatePickerInputProps = {
|
|
5
|
-
size?: ComponentSize;
|
|
6
|
-
roundness?: ComponentRoundnessShape;
|
|
7
|
-
outline?: boolean;
|
|
8
|
-
class?: string;
|
|
9
|
-
error?: boolean;
|
|
10
|
-
focused?: boolean;
|
|
11
|
-
before?: Snippet;
|
|
12
|
-
after?: Snippet;
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
dateFieldInputProps?: DateFieldInputProps;
|
|
15
|
-
datePickerTriggerProps?: DatePickerTriggerProps;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
dateFormat?: DatePickerFormat;
|
|
18
|
-
};
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<script lang="ts">
|
|
22
|
-
import { DatePicker, type DateFieldInputProps, type DatePickerTriggerProps } from 'bits-ui';
|
|
23
|
-
import type { ComponentSize } from '$lib/attributes/size.js';
|
|
24
|
-
import type { ComponentRoundnessShape } from '$lib/attributes/roundness.js';
|
|
25
|
-
import Icon from '@iconify/svelte';
|
|
26
|
-
import Segments from './Segments.svelte';
|
|
27
|
-
import InputEnclosure from '../../InputEnclosure/InputEnclosure.svelte';
|
|
28
|
-
import type { DatePickerFormat } from './utils.js';
|
|
29
|
-
|
|
30
|
-
let {
|
|
31
|
-
size = 'normal',
|
|
32
|
-
class: className = '',
|
|
33
|
-
disabled = false,
|
|
34
|
-
error = false,
|
|
35
|
-
focused: forcedFocused = false,
|
|
36
|
-
placeholder,
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
|
-
after,
|
|
39
|
-
dateFieldInputProps,
|
|
40
|
-
datePickerTriggerProps,
|
|
41
|
-
dateFormat = 'dd/mm/yyyy',
|
|
42
|
-
...restProps
|
|
43
|
-
}: DatePickerInputProps = $props();
|
|
44
|
-
|
|
45
|
-
let isFocused = $state(false);
|
|
46
|
-
|
|
47
|
-
function handleFocus() {
|
|
48
|
-
isFocused = true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function handleBlur() {
|
|
52
|
-
isFocused = false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const classes = $derived(['dodo-ui-DatePicker', className].filter(Boolean));
|
|
56
|
-
|
|
57
|
-
const triggerClasses = $derived(
|
|
58
|
-
[
|
|
59
|
-
'dodo-ui-UtilityButton',
|
|
60
|
-
`size--${size}`,
|
|
61
|
-
'compact',
|
|
62
|
-
'color--primary',
|
|
63
|
-
'roundness--full',
|
|
64
|
-
error && 'error',
|
|
65
|
-
disabled && 'disabled',
|
|
66
|
-
].filter(Boolean),
|
|
67
|
-
);
|
|
68
|
-
</script>
|
|
69
|
-
|
|
70
|
-
<InputEnclosure
|
|
71
|
-
{size}
|
|
72
|
-
{disabled}
|
|
73
|
-
{error}
|
|
74
|
-
class={classes.join(' ')}
|
|
75
|
-
focused={forcedFocused || isFocused}
|
|
76
|
-
{...restProps}
|
|
77
|
-
>
|
|
78
|
-
<DatePicker.Input
|
|
79
|
-
onfocus={handleFocus}
|
|
80
|
-
onblur={handleBlur}
|
|
81
|
-
{placeholder}
|
|
82
|
-
class="InputBox"
|
|
83
|
-
{...dateFieldInputProps}
|
|
84
|
-
>
|
|
85
|
-
{#snippet children({ segments })}
|
|
86
|
-
<Segments {segments} {dateFormat} />
|
|
87
|
-
{/snippet}
|
|
88
|
-
</DatePicker.Input>
|
|
89
|
-
|
|
90
|
-
{#snippet after()}
|
|
91
|
-
<DatePicker.Trigger class={triggerClasses.join(' ')} {...datePickerTriggerProps}>
|
|
92
|
-
<Icon icon="material-symbols:calendar-month-sharp" />
|
|
93
|
-
</DatePicker.Trigger>
|
|
94
|
-
{@render after?.()}
|
|
95
|
-
{/snippet}
|
|
96
|
-
</InputEnclosure>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { DatePicker } from 'bits-ui';
|
|
3
|
-
import { formatSegments, type DatePickerFormat, type DateSegment } from './utils.js';
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
segments: DateSegment[];
|
|
7
|
-
dateFormat: DatePickerFormat;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
let { segments, dateFormat }: Props = $props();
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
{#each formatSegments(segments, dateFormat) as { part, value }, i (part + i)}
|
|
14
|
-
<DatePicker.Segment {part}>
|
|
15
|
-
{value}
|
|
16
|
-
</DatePicker.Segment>
|
|
17
|
-
{/each}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { SegmentPart } from 'bits-ui';
|
|
2
|
-
|
|
3
|
-
// ---- Segment Types ----
|
|
4
|
-
export type DateSegment = {
|
|
5
|
-
part: SegmentPart;
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
// ---- Supported format tokens ----
|
|
10
|
-
export type FormatToken = 'dd' | 'mm' | 'yyyy' | 'hh' | 'min' | 'ss';
|
|
11
|
-
|
|
12
|
-
// ---- Optional: stricter format typing ----
|
|
13
|
-
type Separator = '/' | '-' | '.' | ' ';
|
|
14
|
-
|
|
15
|
-
export type DatePickerFormat =
|
|
16
|
-
| `${FormatToken}${Separator}${FormatToken}${Separator}${FormatToken}`
|
|
17
|
-
| `${FormatToken}${Separator}${FormatToken}`
|
|
18
|
-
| `${FormatToken}`;
|
|
19
|
-
|
|
20
|
-
// ---- Formatter ----
|
|
21
|
-
export function formatSegments(segments: DateSegment[], format: DatePickerFormat): DateSegment[] {
|
|
22
|
-
const segmentMap: Partial<Record<SegmentPart, DateSegment>> = Object.fromEntries(
|
|
23
|
-
segments.map((s) => [s.part, s]),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const tokens = format.match(/dd|mm|yyyy|hh|min|ss|./g) ?? [];
|
|
27
|
-
|
|
28
|
-
return tokens.map((token): DateSegment => {
|
|
29
|
-
switch (token) {
|
|
30
|
-
case 'dd':
|
|
31
|
-
return segmentMap.day ?? { part: 'day', value: '' };
|
|
32
|
-
|
|
33
|
-
case 'mm':
|
|
34
|
-
return segmentMap.month ?? { part: 'month', value: '' };
|
|
35
|
-
|
|
36
|
-
case 'yyyy':
|
|
37
|
-
return segmentMap.year ?? { part: 'year', value: '' };
|
|
38
|
-
|
|
39
|
-
case 'hh':
|
|
40
|
-
return segmentMap.hour ?? { part: 'hour', value: '' };
|
|
41
|
-
|
|
42
|
-
case 'min':
|
|
43
|
-
return segmentMap.minute ?? { part: 'minute', value: '' };
|
|
44
|
-
|
|
45
|
-
case 'ss':
|
|
46
|
-
return segmentMap.second ?? { part: 'second', value: '' };
|
|
47
|
-
|
|
48
|
-
default:
|
|
49
|
-
return {
|
|
50
|
-
part: 'literal',
|
|
51
|
-
value: token,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { DatePicker, type CalendarRootSnippetProps } from 'bits-ui';
|
|
3
|
-
|
|
4
|
-
let { months, weekdays }: CalendarRootSnippetProps = $props();
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
<div class="CalendarGrid">
|
|
8
|
-
{#each months as month (month.value)}
|
|
9
|
-
<DatePicker.Grid>
|
|
10
|
-
<DatePicker.GridHead>
|
|
11
|
-
<DatePicker.GridRow>
|
|
12
|
-
{#each weekdays as day (day)}
|
|
13
|
-
<DatePicker.HeadCell>
|
|
14
|
-
<div>{day.slice(0, 2)}</div>
|
|
15
|
-
</DatePicker.HeadCell>
|
|
16
|
-
{/each}
|
|
17
|
-
</DatePicker.GridRow>
|
|
18
|
-
</DatePicker.GridHead>
|
|
19
|
-
<DatePicker.GridBody>
|
|
20
|
-
{#each month.weeks as weekDates (weekDates)}
|
|
21
|
-
<DatePicker.GridRow>
|
|
22
|
-
{#each weekDates as date (date)}
|
|
23
|
-
<DatePicker.Cell {date} month={month.value}>
|
|
24
|
-
<DatePicker.Day>
|
|
25
|
-
<div></div>
|
|
26
|
-
{date.day}
|
|
27
|
-
</DatePicker.Day>
|
|
28
|
-
</DatePicker.Cell>
|
|
29
|
-
{/each}
|
|
30
|
-
</DatePicker.GridRow>
|
|
31
|
-
{/each}
|
|
32
|
-
</DatePicker.GridBody>
|
|
33
|
-
</DatePicker.Grid>
|
|
34
|
-
{/each}
|
|
35
|
-
</div>
|