@noxlovette/material 0.4.7 → 0.5.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/animation/TransitionPatterns.stories.svelte +357 -0
- package/dist/animation/TransitionPatterns.stories.svelte.d.ts +3 -0
- package/dist/animation/containerTransform.d.ts +26 -12
- package/dist/animation/containerTransform.js +22 -138
- package/dist/animation/enterExit.d.ts +21 -3
- package/dist/animation/enterExit.js +69 -22
- package/dist/animation/index.d.ts +1 -1
- package/dist/animation/index.js +1 -1
- package/dist/animation/presence.svelte.d.ts +47 -0
- package/dist/animation/presence.svelte.js +84 -0
- package/dist/animation/sharedAxisTransition.d.ts +35 -37
- package/dist/animation/sharedAxisTransition.js +50 -22
- package/dist/animation/skeleton.d.ts +11 -0
- package/dist/animation/skeleton.js +23 -0
- package/dist/animation/spring.d.ts +61 -0
- package/dist/animation/spring.js +53 -0
- package/dist/animation/springValue.svelte.d.ts +22 -0
- package/dist/animation/springValue.svelte.js +42 -0
- package/dist/animation/transition.d.ts +3 -1
- package/dist/animation/transition.js +3 -1
- package/dist/attachments/clickOutside.d.ts +13 -0
- package/dist/attachments/clickOutside.js +18 -0
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.js +1 -0
- package/dist/components/buttons/FAB.svelte +23 -16
- package/dist/components/buttons/FABMenu.svelte +24 -29
- package/dist/components/buttons/FABMenu.svelte.d.ts +2 -1
- package/dist/components/buttons/FABMenuItem.svelte +23 -20
- package/dist/components/buttons/FABMenuItem.svelte.d.ts +5 -1
- package/dist/components/buttons/split-button/SplitButton.svelte +10 -17
- package/dist/components/buttons/split-button/theme.js +1 -1
- package/dist/components/buttons/types.d.ts +3 -3
- package/dist/components/cards/theme.js +1 -1
- package/dist/components/containers/bottom-sheet/BottomSheet.stories.svelte +8 -12
- package/dist/components/containers/bottom-sheet/BottomSheet.svelte +67 -55
- package/dist/components/containers/bottom-sheet/BottomSheet.svelte.d.ts +1 -1
- package/dist/components/containers/bottom-sheet/types.d.ts +8 -2
- package/dist/components/containers/context-menu/ContextMenu.svelte +23 -36
- package/dist/components/containers/context-menu/theme.js +2 -2
- package/dist/components/containers/dialogue/Dialogue.svelte +49 -65
- package/dist/components/containers/link-preview/LinkPreview.svelte +12 -23
- package/dist/components/containers/link-preview/theme.d.ts +3 -3
- package/dist/components/containers/menu/Menu.svelte +14 -21
- package/dist/components/containers/menu/MenuSub.svelte +10 -17
- package/dist/components/containers/pane/DraggablePane.svelte +90 -5
- package/dist/components/containers/pane/DraggablePane.svelte.d.ts +1 -1
- package/dist/components/containers/pane/theme.js +2 -2
- package/dist/components/containers/popover/Popover.svelte +31 -42
- package/dist/components/containers/popover/theme.d.ts +3 -3
- package/dist/components/containers/scroll-area/theme.js +2 -2
- package/dist/components/containers/side-sheet/SideSheet.stories.svelte +10 -15
- package/dist/components/containers/side-sheet/SideSheet.svelte +44 -44
- package/dist/components/containers/side-sheet/SideSheet.svelte.d.ts +4 -3
- package/dist/components/containers/side-sheet/types.d.ts +8 -2
- package/dist/components/date/DateField.svelte +85 -92
- package/dist/components/date/DateField.svelte.d.ts +2 -5
- package/dist/components/date/DateRangeField.svelte +113 -155
- package/dist/components/date/DateRangeField.svelte.d.ts +2 -5
- package/dist/components/date/theme.d.ts +95 -0
- package/dist/components/date/theme.js +99 -14
- package/dist/components/date/types.d.ts +13 -0
- package/dist/components/forms/checkbox/theme.js +2 -2
- package/dist/components/forms/command/theme.d.ts +3 -3
- package/dist/components/forms/command/theme.js +1 -1
- package/dist/components/forms/pin/theme.js +2 -2
- package/dist/components/forms/radio-group/theme.js +2 -2
- package/dist/components/forms/select/Select.svelte +42 -54
- package/dist/components/forms/select/theme.js +4 -4
- package/dist/components/forms/slider/Slider.svelte +144 -126
- package/dist/components/forms/slider/Slider.svelte.d.ts +3 -0
- package/dist/components/forms/slider/theme.d.ts +154 -48
- package/dist/components/forms/slider/theme.js +60 -20
- package/dist/components/forms/slider/types.d.ts +1 -1
- package/dist/components/forms/switch/theme.js +4 -4
- package/dist/components/forms/textfield/Textfield.svelte +1 -1
- package/dist/components/forms/textfield/theme.d.ts +9 -0
- package/dist/components/forms/textfield/theme.js +26 -9
- package/dist/components/forms/toggle-group/theme.js +1 -1
- package/dist/components/forms/tooltip/Tooltip.svelte +24 -35
- package/dist/components/nav/breadcrumb/theme.js +1 -1
- package/dist/components/nav/navbar/theme.js +2 -2
- package/dist/components/nav/rail/Rail.svelte +4 -5
- package/dist/components/nav/rail/theme.js +7 -7
- package/dist/components/nav/tabs/theme.js +1 -1
- package/dist/components/pill/theme.d.ts +1 -1
- package/dist/components/pill/theme.js +1 -1
- package/dist/components/progress/CircularProgress.svelte +78 -4
- package/dist/components/progress/CircularProgress.svelte.d.ts +5 -0
- package/dist/components/progress/LinearProgress.svelte +70 -7
- package/dist/components/progress/LinearProgress.svelte.d.ts +5 -0
- package/dist/components/progress/WavyLinearProgress.svelte +27 -3
- package/dist/components/progress/WavyLinearProgress.svelte.d.ts +3 -0
- package/dist/components/progress/_wavy.d.ts +2 -0
- package/dist/components/progress/_wavy.js +3 -1
- package/dist/components/snackbar/Snackbar.svelte +13 -17
- package/dist/components/table/Table.stories.svelte +24 -0
- package/dist/components/table/TableBody.svelte +3 -16
- package/dist/components/table/TableBody.svelte.d.ts +1 -5
- package/dist/components/table/TableHeader.svelte +1 -1
- package/dist/components/table/theme.js +2 -2
- package/dist/components/table/types.d.ts +0 -7
- package/dist/components/time/TimeField.stories.svelte +41 -0
- package/dist/components/time/TimeField.stories.svelte.d.ts +19 -0
- package/dist/components/time/TimeField.svelte +62 -61
- package/dist/components/toolbar/theme.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styles/component.css +21 -22
- package/dist/styles/motion.css +317 -38
- package/dist/utils/Layer.svelte +16 -29
- package/dist/utils/icon/LoadingIndicator.svelte +61 -22
- package/dist/utils/icon/loadingShapes.d.ts +1 -0
- package/dist/utils/icon/loadingShapes.js +15 -0
- package/package.json +5 -2
- package/dist/actions/clickOutside.d.ts +0 -3
- package/dist/actions/clickOutside.js +0 -13
- package/dist/actions/floating.d.ts +0 -20
- package/dist/actions/floating.js +0 -87
- package/dist/actions/index.d.ts +0 -6
- package/dist/actions/index.js +0 -6
- package/dist/actions/keyboard.d.ts +0 -3
- package/dist/actions/keyboard.js +0 -14
- package/dist/actions/portal.d.ts +0 -3
- package/dist/actions/portal.js +0 -8
- package/dist/actions/positionFloating.d.ts +0 -10
- package/dist/actions/positionFloating.js +0 -59
- package/dist/actions/rovingFocusGroup.d.ts +0 -20
- package/dist/actions/rovingFocusGroup.js +0 -82
- package/dist/animation/easing.d.ts +0 -6
- package/dist/animation/easing.js +0 -78
- package/dist/animation/outroClass.d.ts +0 -3
- package/dist/animation/outroClass.js +0 -20
- package/dist/animation/transitionTypes.d.ts +0 -8
- package/dist/animation/transitionTypes.js +0 -1
|
@@ -1,140 +1,101 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
DateRangeField lets users enter or pick a date range (start + end) via two
|
|
4
|
-
segment inputs and a shared calendar
|
|
4
|
+
segment inputs and a shared docked calendar.
|
|
5
5
|
|
|
6
6
|
@see https://m3.material.io/components/date-pickers/guidelines
|
|
7
7
|
-->
|
|
8
8
|
<script lang="ts">
|
|
9
|
-
import { DateRangePicker } from 'bits-ui';
|
|
9
|
+
import { DateRangePicker, Portal, useId } from 'bits-ui';
|
|
10
|
+
import { enterExit, presence } from '../../animation/index.js';
|
|
10
11
|
import ButtonIcon from '../buttons/ButtonIcon.svelte';
|
|
11
12
|
import Icon from '../../utils/icon/Icon.svelte';
|
|
12
13
|
import Layer from '../../utils/Layer.svelte';
|
|
13
14
|
import type { DateRangeFieldProps } from './types';
|
|
14
|
-
import { dateRangeField } from './theme';
|
|
15
|
+
import { dateCalendar, dateRangeField, dateSegment } from './theme';
|
|
15
16
|
|
|
16
17
|
let {
|
|
17
18
|
value = $bindable(),
|
|
18
19
|
label,
|
|
19
20
|
startLabel = 'Start',
|
|
20
21
|
endLabel = 'End',
|
|
21
|
-
id,
|
|
22
|
+
id = useId(),
|
|
22
23
|
required = false,
|
|
23
24
|
disabled = false,
|
|
24
25
|
error = false,
|
|
25
26
|
variant = 'outlined',
|
|
26
27
|
supportingText,
|
|
27
28
|
name,
|
|
29
|
+
locale,
|
|
30
|
+
weekStartsOn,
|
|
28
31
|
leadingIconProps
|
|
29
|
-
}: DateRangeFieldProps
|
|
32
|
+
}: DateRangeFieldProps = $props();
|
|
30
33
|
|
|
31
34
|
const cls = $derived(dateRangeField({ disabled, error, variant }));
|
|
35
|
+
const calendar = dateCalendar();
|
|
32
36
|
</script>
|
|
33
37
|
|
|
38
|
+
{#snippet rangeInput(type: 'start' | 'end', fieldLabel: string)}
|
|
39
|
+
<div class={cls.inputWrapper()}>
|
|
40
|
+
<DateRangePicker.Input
|
|
41
|
+
{type}
|
|
42
|
+
class={cls.input()}
|
|
43
|
+
name={type === 'start' ? name : undefined}
|
|
44
|
+
id={`${id}-${type}`}
|
|
45
|
+
>
|
|
46
|
+
{#snippet children({ segments })}
|
|
47
|
+
<div class="flex w-full pt-4 tabular-nums">
|
|
48
|
+
{#each segments as { part, value: segment }}
|
|
49
|
+
<DateRangePicker.Segment
|
|
50
|
+
{part}
|
|
51
|
+
class={dateSegment({ part: part === 'literal' ? 'literal' : 'value' })}
|
|
52
|
+
>
|
|
53
|
+
{segment}
|
|
54
|
+
</DateRangePicker.Segment>
|
|
55
|
+
{/each}
|
|
56
|
+
</div>
|
|
57
|
+
{/snippet}
|
|
58
|
+
</DateRangePicker.Input>
|
|
59
|
+
|
|
60
|
+
<span class={cls.label()}>
|
|
61
|
+
{fieldLabel}{#if required}<span class={cls.requiredAsterisk()} aria-hidden="true">*</span
|
|
62
|
+
>{/if}
|
|
63
|
+
</span>
|
|
64
|
+
</div>
|
|
65
|
+
{/snippet}
|
|
66
|
+
|
|
34
67
|
<DateRangePicker.Root
|
|
35
68
|
bind:value
|
|
36
|
-
weekStartsOn
|
|
69
|
+
{weekStartsOn}
|
|
37
70
|
{required}
|
|
38
71
|
{disabled}
|
|
39
|
-
locale
|
|
40
|
-
weekdayFormat="
|
|
72
|
+
{locale}
|
|
73
|
+
weekdayFormat="narrow"
|
|
41
74
|
fixedWeeks
|
|
42
75
|
closeOnRangeSelect
|
|
43
76
|
>
|
|
44
77
|
<div class="relative w-full">
|
|
78
|
+
{#if label}
|
|
79
|
+
<DateRangePicker.Label class="sr-only">{label}</DateRangePicker.Label>
|
|
80
|
+
{/if}
|
|
45
81
|
<div class={cls.base()} data-invalid={error || undefined}>
|
|
46
82
|
{#if leadingIconProps}
|
|
47
83
|
<Icon class={cls.leadingIcon()} {...leadingIconProps} />
|
|
48
84
|
{/if}
|
|
49
85
|
|
|
50
|
-
|
|
51
|
-
<!-- Start date input -->
|
|
52
|
-
<DateRangePicker.Input type="start" class={cls.input()} {name} id={id ?? undefined}>
|
|
53
|
-
{#snippet children({ segments })}
|
|
54
|
-
<div class="flex w-full flex-col pt-4 tabular-nums">
|
|
55
|
-
<div class="flex">
|
|
56
|
-
{#each segments as { part, value: segVal }}
|
|
57
|
-
{#if part === 'literal'}
|
|
58
|
-
<DateRangePicker.Segment
|
|
59
|
-
{part}
|
|
60
|
-
class="text-md-sys-color-on-surface-variant px-0.5 select-none first:pl-0"
|
|
61
|
-
>
|
|
62
|
-
{segVal}
|
|
63
|
-
</DateRangePicker.Segment>
|
|
64
|
-
{:else}
|
|
65
|
-
<DateRangePicker.Segment
|
|
66
|
-
{part}
|
|
67
|
-
class="text-md-sys-color-on-surface hover:bg-md-sys-color-on-surface/8 focus:bg-md-sys-color-primary-container focus:text-md-sys-color-on-primary-container focus:outline-md-sys-color-primary
|
|
68
|
-
aria-[valuetext=Empty]:text-md-sys-color-on-surface-variant cursor-default rounded-xs
|
|
69
|
-
px-1
|
|
70
|
-
py-0.5
|
|
71
|
-
transition-colors
|
|
72
|
-
duration-100 select-none focus:outline-2
|
|
73
|
-
focus-visible:ring-0! focus-visible:ring-offset-0!"
|
|
74
|
-
>
|
|
75
|
-
{segVal}
|
|
76
|
-
</DateRangePicker.Segment>
|
|
77
|
-
{/if}
|
|
78
|
-
{/each}
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
{/snippet}
|
|
82
|
-
</DateRangePicker.Input>
|
|
83
|
-
|
|
84
|
-
<label class={cls.label()} for={id}>
|
|
85
|
-
{startLabel ?? label}{#if required}<span class={cls.requiredAsterisk()} aria-hidden="true"
|
|
86
|
-
>*</span
|
|
87
|
-
>{/if}
|
|
88
|
-
</label>
|
|
89
|
-
</div>
|
|
90
|
-
|
|
86
|
+
{@render rangeInput('start', startLabel)}
|
|
91
87
|
<span class={cls.separator()}>–</span>
|
|
88
|
+
{@render rangeInput('end', endLabel)}
|
|
92
89
|
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
{part}
|
|
103
|
-
class="text-md-sys-color-on-surface-variant px-0.5 select-none first:pl-0"
|
|
104
|
-
>
|
|
105
|
-
{segVal}
|
|
106
|
-
</DateRangePicker.Segment>
|
|
107
|
-
{:else}
|
|
108
|
-
<DateRangePicker.Segment
|
|
109
|
-
{part}
|
|
110
|
-
class="text-md-sys-color-on-surface hover:bg-md-sys-color-on-surface/8 focus:bg-md-sys-color-primary-container focus:text-md-sys-color-on-primary-container focus:outline-md-sys-color-primary
|
|
111
|
-
aria-[valuetext=Empty]:text-md-sys-color-on-surface-variant cursor-default rounded-xs
|
|
112
|
-
px-1
|
|
113
|
-
py-0.5
|
|
114
|
-
transition-colors
|
|
115
|
-
duration-100 select-none focus:outline-2
|
|
116
|
-
focus-visible:ring-0! focus-visible:ring-offset-0!"
|
|
117
|
-
>
|
|
118
|
-
{segVal}
|
|
119
|
-
</DateRangePicker.Segment>
|
|
120
|
-
{/if}
|
|
121
|
-
{/each}
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
{/snippet}
|
|
125
|
-
</DateRangePicker.Input>
|
|
126
|
-
|
|
127
|
-
<label class={cls.label()} for={id ? `${id}-end` : undefined}>
|
|
128
|
-
{endLabel ?? label}{#if required}<span class={cls.requiredAsterisk()} aria-hidden="true"
|
|
129
|
-
>*</span
|
|
130
|
-
>{/if}
|
|
131
|
-
</label>
|
|
132
|
-
</div>
|
|
133
|
-
|
|
134
|
-
<DateRangePicker.Trigger
|
|
135
|
-
class={cls.trailingIcon({ class: 'flex items-center justify-center' })}
|
|
136
|
-
>
|
|
137
|
-
<Icon name="calendar_month" />
|
|
90
|
+
<DateRangePicker.Trigger>
|
|
91
|
+
{#snippet child({ props })}
|
|
92
|
+
<ButtonIcon
|
|
93
|
+
{...props}
|
|
94
|
+
{disabled}
|
|
95
|
+
class={cls.trailingIcon()}
|
|
96
|
+
iconProps={{ name: 'date_range' }}
|
|
97
|
+
/>
|
|
98
|
+
{/snippet}
|
|
138
99
|
</DateRangePicker.Trigger>
|
|
139
100
|
</div>
|
|
140
101
|
|
|
@@ -145,68 +106,65 @@ segment inputs and a shared calendar popover.
|
|
|
145
106
|
{/if}
|
|
146
107
|
</div>
|
|
147
108
|
|
|
148
|
-
<
|
|
149
|
-
<DateRangePicker.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
109
|
+
<Portal>
|
|
110
|
+
<DateRangePicker.Content sideOffset={4} align="start">
|
|
111
|
+
{#snippet child({ wrapperProps, props, open })}
|
|
112
|
+
<div {...wrapperProps}>
|
|
113
|
+
<div {...props} {@attach presence(() => open, enterExit.scale)}>
|
|
114
|
+
<DateRangePicker.Calendar class={calendar.surface()}>
|
|
115
|
+
{#snippet children({ months, weekdays })}
|
|
116
|
+
<DateRangePicker.Header class={calendar.header()}>
|
|
117
|
+
<DateRangePicker.Heading class={calendar.heading()} />
|
|
118
|
+
<div class={calendar.nav()}>
|
|
119
|
+
<DateRangePicker.PrevButton>
|
|
120
|
+
{#snippet child({ props })}
|
|
121
|
+
<ButtonIcon {...props} iconProps={{ name: 'chevron_left' }} />
|
|
122
|
+
{/snippet}
|
|
123
|
+
</DateRangePicker.PrevButton>
|
|
124
|
+
<DateRangePicker.NextButton>
|
|
125
|
+
{#snippet child({ props })}
|
|
126
|
+
<ButtonIcon {...props} iconProps={{ name: 'chevron_right' }} />
|
|
127
|
+
{/snippet}
|
|
128
|
+
</DateRangePicker.NextButton>
|
|
129
|
+
</div>
|
|
130
|
+
</DateRangePicker.Header>
|
|
164
131
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
132
|
+
{#each months as month (month.value.toString())}
|
|
133
|
+
<DateRangePicker.Grid class={calendar.grid()}>
|
|
134
|
+
<DateRangePicker.GridHead>
|
|
135
|
+
<DateRangePicker.GridRow class={calendar.row()}>
|
|
136
|
+
{#each weekdays as day, i (i)}
|
|
137
|
+
<DateRangePicker.HeadCell class={calendar.weekday()}>
|
|
138
|
+
{day}
|
|
139
|
+
</DateRangePicker.HeadCell>
|
|
140
|
+
{/each}
|
|
141
|
+
</DateRangePicker.GridRow>
|
|
142
|
+
</DateRangePicker.GridHead>
|
|
143
|
+
<DateRangePicker.GridBody>
|
|
144
|
+
{#each month.weeks as weekDates, i (i)}
|
|
145
|
+
<DateRangePicker.GridRow class={calendar.row()}>
|
|
146
|
+
{#each weekDates as date (date.toString())}
|
|
147
|
+
<DateRangePicker.Cell
|
|
148
|
+
{date}
|
|
149
|
+
month={month.value}
|
|
150
|
+
class={calendar.cell()}
|
|
151
|
+
>
|
|
152
|
+
<DateRangePicker.Day class={calendar.day()}>
|
|
153
|
+
<Layer />
|
|
154
|
+
{date.day}
|
|
155
|
+
</DateRangePicker.Day>
|
|
156
|
+
</DateRangePicker.Cell>
|
|
157
|
+
{/each}
|
|
158
|
+
</DateRangePicker.GridRow>
|
|
159
|
+
{/each}
|
|
160
|
+
</DateRangePicker.GridBody>
|
|
161
|
+
</DateRangePicker.Grid>
|
|
175
162
|
{/each}
|
|
176
|
-
|
|
177
|
-
</DateRangePicker.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
<DateRangePicker.GridRow class="flex w-full justify-between">
|
|
181
|
-
{#each weekDates as date}
|
|
182
|
-
<DateRangePicker.Cell
|
|
183
|
-
{date}
|
|
184
|
-
month={month.value}
|
|
185
|
-
class="md-sys-typescale-body-large text-center"
|
|
186
|
-
>
|
|
187
|
-
<DateRangePicker.Day
|
|
188
|
-
class="group data-disabled:text-md-sys-color-on-surface/38 data-highlighted:bg-md-sys-color-primary-container/20 data-range-end:bg-md-sys-color-primary data-range-end:text-md-sys-color-on-primary data-range-middle:bg-md-sys-color-primary-container/40 data-range-start:bg-md-sys-color-primary
|
|
189
|
-
data-range-start:text-md-sys-color-on-primary data-selected:bg-md-sys-color-primary data-selected:text-md-sys-color-on-primary data-unavailable:text-md-sys-color-on-surface/38
|
|
190
|
-
relative flex
|
|
191
|
-
size-10 items-center
|
|
192
|
-
justify-center rounded-full
|
|
193
|
-
bg-transparent p-0
|
|
194
|
-
transition-colors
|
|
195
|
-
duration-100 data-disabled:cursor-not-allowed
|
|
196
|
-
data-outside-month:pointer-events-none data-outside-month:opacity-0
|
|
197
|
-
data-range-middle:rounded-none data-unavailable:line-through"
|
|
198
|
-
>
|
|
199
|
-
<Layer />
|
|
200
|
-
{date.day}
|
|
201
|
-
</DateRangePicker.Day>
|
|
202
|
-
</DateRangePicker.Cell>
|
|
203
|
-
{/each}
|
|
204
|
-
</DateRangePicker.GridRow>
|
|
205
|
-
{/each}
|
|
206
|
-
</DateRangePicker.GridBody>
|
|
207
|
-
</DateRangePicker.Grid>
|
|
208
|
-
{/each}
|
|
163
|
+
{/snippet}
|
|
164
|
+
</DateRangePicker.Calendar>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
209
167
|
{/snippet}
|
|
210
|
-
</DateRangePicker.
|
|
211
|
-
</
|
|
168
|
+
</DateRangePicker.Content>
|
|
169
|
+
</Portal>
|
|
212
170
|
</DateRangePicker.Root>
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { DateRangeFieldProps } from './types';
|
|
2
|
-
type $$ComponentProps = DateRangeFieldProps & {
|
|
3
|
-
leadingIconProps?: any;
|
|
4
|
-
};
|
|
5
2
|
/**
|
|
6
3
|
* DateRangeField lets users enter or pick a date range (start + end) via two
|
|
7
|
-
* segment inputs and a shared calendar
|
|
4
|
+
* segment inputs and a shared docked calendar.
|
|
8
5
|
*
|
|
9
6
|
* @see https://m3.material.io/components/date-pickers/guidelines
|
|
10
7
|
*/
|
|
11
|
-
declare const DateRangeField: import("svelte").Component
|
|
8
|
+
declare const DateRangeField: import("svelte").Component<DateRangeFieldProps, {}, "value">;
|
|
12
9
|
type DateRangeField = ReturnType<typeof DateRangeField>;
|
|
13
10
|
export default DateRangeField;
|
|
@@ -225,3 +225,98 @@ export declare const dateField: import("tailwind-variants").TVReturnType<{
|
|
|
225
225
|
legend: string;
|
|
226
226
|
legendLabel: string;
|
|
227
227
|
}>>;
|
|
228
|
+
/** Segments of the typed date (`DatePicker.Segment` / `DateRangePicker.Segment`). */
|
|
229
|
+
export declare const dateSegment: import("tailwind-variants").TVReturnType<{
|
|
230
|
+
part: {
|
|
231
|
+
literal: "text-md-sys-color-on-surface-variant px-0";
|
|
232
|
+
value: "\n text-md-sys-color-on-surface\n aria-[valuetext=Empty]:text-md-sys-color-on-surface-variant\n hover:bg-md-sys-color-on-surface/8\n focus:bg-md-sys-color-primary-container focus:text-md-sys-color-on-primary-container\n ";
|
|
233
|
+
};
|
|
234
|
+
}, undefined, "\n rounded-xs px-0.5 py-0.5 select-none cursor-default outline-none\n transition-colors md-sys-motion-fast-effects\n ", {
|
|
235
|
+
part: {
|
|
236
|
+
literal: "text-md-sys-color-on-surface-variant px-0";
|
|
237
|
+
value: "\n text-md-sys-color-on-surface\n aria-[valuetext=Empty]:text-md-sys-color-on-surface-variant\n hover:bg-md-sys-color-on-surface/8\n focus:bg-md-sys-color-primary-container focus:text-md-sys-color-on-primary-container\n ";
|
|
238
|
+
};
|
|
239
|
+
}, undefined, import("tailwind-variants").TVReturnTypeLike<{
|
|
240
|
+
part: {
|
|
241
|
+
literal: "text-md-sys-color-on-surface-variant px-0";
|
|
242
|
+
value: "\n text-md-sys-color-on-surface\n aria-[valuetext=Empty]:text-md-sys-color-on-surface-variant\n hover:bg-md-sys-color-on-surface/8\n focus:bg-md-sys-color-primary-container focus:text-md-sys-color-on-primary-container\n ";
|
|
243
|
+
};
|
|
244
|
+
}, undefined>>;
|
|
245
|
+
/**
|
|
246
|
+
* Docked date picker surface, shared by DateField and DateRangeField.
|
|
247
|
+
* @see https://m3.material.io/components/date-pickers/specs#docked-date-picker
|
|
248
|
+
* 360dp wide = 12dp padding + 7 × 48dp targets; each day is a 40dp circle inside its target.
|
|
249
|
+
*/
|
|
250
|
+
export declare const dateCalendar: import("tailwind-variants").TVReturnType<{
|
|
251
|
+
[key: string]: {
|
|
252
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
253
|
+
grid?: import("tailwind-variants").ClassValue;
|
|
254
|
+
surface?: import("tailwind-variants").ClassValue;
|
|
255
|
+
header?: import("tailwind-variants").ClassValue;
|
|
256
|
+
nav?: import("tailwind-variants").ClassValue;
|
|
257
|
+
cell?: import("tailwind-variants").ClassValue;
|
|
258
|
+
heading?: import("tailwind-variants").ClassValue;
|
|
259
|
+
row?: import("tailwind-variants").ClassValue;
|
|
260
|
+
weekday?: import("tailwind-variants").ClassValue;
|
|
261
|
+
day?: import("tailwind-variants").ClassValue;
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
} | {
|
|
265
|
+
[x: string]: {
|
|
266
|
+
[x: string]: import("tailwind-variants").ClassValue | {
|
|
267
|
+
grid?: import("tailwind-variants").ClassValue;
|
|
268
|
+
surface?: import("tailwind-variants").ClassValue;
|
|
269
|
+
header?: import("tailwind-variants").ClassValue;
|
|
270
|
+
nav?: import("tailwind-variants").ClassValue;
|
|
271
|
+
cell?: import("tailwind-variants").ClassValue;
|
|
272
|
+
heading?: import("tailwind-variants").ClassValue;
|
|
273
|
+
row?: import("tailwind-variants").ClassValue;
|
|
274
|
+
weekday?: import("tailwind-variants").ClassValue;
|
|
275
|
+
day?: import("tailwind-variants").ClassValue;
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
} | {}, {
|
|
279
|
+
surface: string;
|
|
280
|
+
header: string;
|
|
281
|
+
heading: string;
|
|
282
|
+
nav: string;
|
|
283
|
+
grid: string;
|
|
284
|
+
row: string;
|
|
285
|
+
weekday: string;
|
|
286
|
+
cell: string;
|
|
287
|
+
day: string;
|
|
288
|
+
}, undefined, {
|
|
289
|
+
[key: string]: {
|
|
290
|
+
[key: string]: import("tailwind-variants").ClassValue | {
|
|
291
|
+
grid?: import("tailwind-variants").ClassValue;
|
|
292
|
+
surface?: import("tailwind-variants").ClassValue;
|
|
293
|
+
header?: import("tailwind-variants").ClassValue;
|
|
294
|
+
nav?: import("tailwind-variants").ClassValue;
|
|
295
|
+
cell?: import("tailwind-variants").ClassValue;
|
|
296
|
+
heading?: import("tailwind-variants").ClassValue;
|
|
297
|
+
row?: import("tailwind-variants").ClassValue;
|
|
298
|
+
weekday?: import("tailwind-variants").ClassValue;
|
|
299
|
+
day?: import("tailwind-variants").ClassValue;
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
} | {}, {
|
|
303
|
+
surface: string;
|
|
304
|
+
header: string;
|
|
305
|
+
heading: string;
|
|
306
|
+
nav: string;
|
|
307
|
+
grid: string;
|
|
308
|
+
row: string;
|
|
309
|
+
weekday: string;
|
|
310
|
+
cell: string;
|
|
311
|
+
day: string;
|
|
312
|
+
}, import("tailwind-variants").TVReturnTypeLike<unknown, {
|
|
313
|
+
surface: string;
|
|
314
|
+
header: string;
|
|
315
|
+
heading: string;
|
|
316
|
+
nav: string;
|
|
317
|
+
grid: string;
|
|
318
|
+
row: string;
|
|
319
|
+
weekday: string;
|
|
320
|
+
cell: string;
|
|
321
|
+
day: string;
|
|
322
|
+
}>>;
|
|
@@ -18,9 +18,8 @@ export const dateRangeField = tv({
|
|
|
18
18
|
group-data-[invalid]:text-md-sys-color-error ml-3 text-[24px]
|
|
19
19
|
`,
|
|
20
20
|
trailingIcon: `
|
|
21
|
-
text-md-sys-color-on-surface-variant
|
|
22
|
-
group-
|
|
23
|
-
group-data-[invalid]:text-md-sys-color-error mr-3 text-[24px]
|
|
21
|
+
mr-1 shrink-0 text-md-sys-color-on-surface-variant
|
|
22
|
+
group-data-[invalid]:text-md-sys-color-error
|
|
24
23
|
`,
|
|
25
24
|
separator: `
|
|
26
25
|
text-md-sys-color-on-surface-variant select-none shrink-0
|
|
@@ -30,7 +29,7 @@ export const dateRangeField = tv({
|
|
|
30
29
|
md-sys-typescale-body-small
|
|
31
30
|
text-md-sys-color-on-surface-variant
|
|
32
31
|
pointer-events-none
|
|
33
|
-
transition-[top,font-size,line-height,color,transform]
|
|
32
|
+
transition-[top,font-size,line-height,color,transform] md-sys-motion-fast-spatial
|
|
34
33
|
group-focus-within:text-md-sys-color-primary
|
|
35
34
|
z-20
|
|
36
35
|
`,
|
|
@@ -38,7 +37,7 @@ export const dateRangeField = tv({
|
|
|
38
37
|
ml-0.5
|
|
39
38
|
text-md-sys-color-error
|
|
40
39
|
group-focus-within:text-md-sys-color-primary
|
|
41
|
-
transition-colors
|
|
40
|
+
transition-colors md-sys-motion-effects
|
|
42
41
|
`,
|
|
43
42
|
supportingText: `
|
|
44
43
|
px-4 pt-1 flex justify-between
|
|
@@ -54,7 +53,7 @@ export const dateRangeField = tv({
|
|
|
54
53
|
after:absolute after:bottom-0 after:left-0 after:right-0
|
|
55
54
|
state-layer before:rounded-xs hover:before:bg-md-sys-color-on-surface/8
|
|
56
55
|
after:h-px after:bg-md-sys-color-on-surface-variant
|
|
57
|
-
after:transition-[height,background-color] after:
|
|
56
|
+
after:transition-[height,background-color] after:md-sys-motion-fast-spatial
|
|
58
57
|
hover:after:bg-md-sys-color-on-surface
|
|
59
58
|
focus-within:after:bg-md-sys-color-primary focus-within:after:h-[2px]
|
|
60
59
|
disabled:bg-md-sys-color-on-surface/4
|
|
@@ -64,7 +63,7 @@ export const dateRangeField = tv({
|
|
|
64
63
|
outlined: {
|
|
65
64
|
base: `
|
|
66
65
|
rounded-xs border border-md-sys-color-outline
|
|
67
|
-
transition-colors
|
|
66
|
+
transition-colors md-sys-motion-fast-effects
|
|
68
67
|
hover:border-md-sys-color-on-surface
|
|
69
68
|
focus-within:border-2 focus-within:border-md-sys-color-primary
|
|
70
69
|
`
|
|
@@ -128,16 +127,15 @@ export const dateField = tv({
|
|
|
128
127
|
group-data-[invalid]:text-md-sys-color-error ml-3 text-[24px]
|
|
129
128
|
`,
|
|
130
129
|
trailingIcon: `
|
|
131
|
-
text-md-sys-color-on-surface-variant
|
|
132
|
-
group-
|
|
133
|
-
group-data-[invalid]:text-md-sys-color-error mr-3 text-[24px]
|
|
130
|
+
mr-1 shrink-0 text-md-sys-color-on-surface-variant
|
|
131
|
+
group-data-[invalid]:text-md-sys-color-error
|
|
134
132
|
`,
|
|
135
133
|
label: `
|
|
136
134
|
absolute left-4 top-1.5
|
|
137
135
|
md-sys-typescale-body-small
|
|
138
136
|
text-md-sys-color-on-surface-variant
|
|
139
137
|
pointer-events-none
|
|
140
|
-
transition-[top,font-size,line-height,color,transform]
|
|
138
|
+
transition-[top,font-size,line-height,color,transform] md-sys-motion-fast-spatial
|
|
141
139
|
group-focus-within:text-md-sys-color-primary
|
|
142
140
|
z-20
|
|
143
141
|
`,
|
|
@@ -145,7 +143,7 @@ export const dateField = tv({
|
|
|
145
143
|
ml-0.5
|
|
146
144
|
text-md-sys-color-error
|
|
147
145
|
group-focus-within:text-md-sys-color-primary
|
|
148
|
-
transition-colors
|
|
146
|
+
transition-colors md-sys-motion-effects
|
|
149
147
|
`,
|
|
150
148
|
supportingText: `
|
|
151
149
|
px-4 pt-1 flex justify-between
|
|
@@ -155,7 +153,7 @@ export const dateField = tv({
|
|
|
155
153
|
fieldset: `
|
|
156
154
|
absolute -top-[5px] left-0 right-0 bottom-0 m-0 px-2
|
|
157
155
|
pointer-events-none rounded-xs border border-md-sys-color-outline
|
|
158
|
-
transition-colors
|
|
156
|
+
transition-colors md-sys-motion-fast-effects
|
|
159
157
|
|
|
160
158
|
group-hover:border-md-sys-color-on-surface
|
|
161
159
|
group-focus-within:border-2 group-focus-within:border-md-sys-color-primary
|
|
@@ -176,7 +174,7 @@ export const dateField = tv({
|
|
|
176
174
|
after:absolute after:bottom-0 after:left-0 after:right-0
|
|
177
175
|
state-layer before:rounded-xs hover:before:bg-md-sys-color-on-surface/8
|
|
178
176
|
after:h-px after:bg-md-sys-color-on-surface-variant
|
|
179
|
-
after:transition-[height,background-color] after:
|
|
177
|
+
after:transition-[height,background-color] after:md-sys-motion-fast-spatial
|
|
180
178
|
hover:after:bg-md-sys-color-on-surface
|
|
181
179
|
focus-within:after:bg-md-sys-color-primary focus-within:after:h-[2px]
|
|
182
180
|
disabled:bg-md-sys-color-on-surface/4
|
|
@@ -216,3 +214,90 @@ export const dateField = tv({
|
|
|
216
214
|
variant: 'outlined'
|
|
217
215
|
}
|
|
218
216
|
});
|
|
217
|
+
/** Segments of the typed date (`DatePicker.Segment` / `DateRangePicker.Segment`). */
|
|
218
|
+
export const dateSegment = tv({
|
|
219
|
+
base: `
|
|
220
|
+
rounded-xs px-0.5 py-0.5 select-none cursor-default outline-none
|
|
221
|
+
transition-colors md-sys-motion-fast-effects
|
|
222
|
+
`,
|
|
223
|
+
variants: {
|
|
224
|
+
part: {
|
|
225
|
+
literal: 'text-md-sys-color-on-surface-variant px-0',
|
|
226
|
+
value: `
|
|
227
|
+
text-md-sys-color-on-surface
|
|
228
|
+
aria-[valuetext=Empty]:text-md-sys-color-on-surface-variant
|
|
229
|
+
hover:bg-md-sys-color-on-surface/8
|
|
230
|
+
focus:bg-md-sys-color-primary-container focus:text-md-sys-color-on-primary-container
|
|
231
|
+
`
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
defaultVariants: {
|
|
235
|
+
part: 'value'
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
/**
|
|
239
|
+
* Docked date picker surface, shared by DateField and DateRangeField.
|
|
240
|
+
* @see https://m3.material.io/components/date-pickers/specs#docked-date-picker
|
|
241
|
+
* 360dp wide = 12dp padding + 7 × 48dp targets; each day is a 40dp circle inside its target.
|
|
242
|
+
*/
|
|
243
|
+
export const dateCalendar = tv({
|
|
244
|
+
slots: {
|
|
245
|
+
surface: `
|
|
246
|
+
w-90 rounded-lg px-3 pb-3
|
|
247
|
+
bg-md-sys-color-surface-container-high shadow-elevation-3
|
|
248
|
+
text-md-sys-color-on-surface
|
|
249
|
+
`,
|
|
250
|
+
header: `
|
|
251
|
+
flex h-14 items-center justify-between pl-4 pr-1
|
|
252
|
+
`,
|
|
253
|
+
heading: `
|
|
254
|
+
md-sys-typescale-label-large text-md-sys-color-on-surface-variant
|
|
255
|
+
`,
|
|
256
|
+
nav: `
|
|
257
|
+
flex items-center text-md-sys-color-on-surface-variant
|
|
258
|
+
`,
|
|
259
|
+
grid: `
|
|
260
|
+
w-full border-collapse select-none
|
|
261
|
+
`,
|
|
262
|
+
row: `
|
|
263
|
+
flex w-full
|
|
264
|
+
`,
|
|
265
|
+
weekday: `
|
|
266
|
+
flex size-12 items-center justify-center
|
|
267
|
+
md-sys-typescale-body-large text-md-sys-color-on-surface
|
|
268
|
+
`,
|
|
269
|
+
cell: `
|
|
270
|
+
relative flex size-12 items-center justify-center p-0
|
|
271
|
+
before:absolute before:inset-x-0 before:h-10 before:bg-md-sys-color-secondary-container
|
|
272
|
+
before:opacity-0 before:transition-opacity before:md-sys-motion-fast-effects
|
|
273
|
+
data-range-middle:before:opacity-100
|
|
274
|
+
data-highlighted:before:opacity-100
|
|
275
|
+
data-range-start:before:left-1/2 data-range-end:before:right-1/2
|
|
276
|
+
data-range-start:data-range-end:before:opacity-0
|
|
277
|
+
data-outside-month:before:opacity-0
|
|
278
|
+
`,
|
|
279
|
+
day: `
|
|
280
|
+
relative flex size-10 items-center justify-center rounded-full
|
|
281
|
+
md-sys-typescale-body-large text-md-sys-color-on-surface
|
|
282
|
+
cursor-pointer outline-none
|
|
283
|
+
transition-colors md-sys-motion-fast-effects
|
|
284
|
+
|
|
285
|
+
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-md-sys-color-secondary
|
|
286
|
+
|
|
287
|
+
data-today:border data-today:border-md-sys-color-primary data-today:text-md-sys-color-primary
|
|
288
|
+
|
|
289
|
+
data-range-middle:text-md-sys-color-on-secondary-container
|
|
290
|
+
data-highlighted:text-md-sys-color-on-secondary-container
|
|
291
|
+
|
|
292
|
+
data-selected:not-data-range-middle:border-transparent
|
|
293
|
+
data-selected:not-data-range-middle:bg-md-sys-color-primary
|
|
294
|
+
data-selected:not-data-range-middle:text-md-sys-color-on-primary
|
|
295
|
+
|
|
296
|
+
data-disabled:cursor-not-allowed data-disabled:text-md-sys-color-on-surface/38
|
|
297
|
+
data-unavailable:cursor-not-allowed data-unavailable:text-md-sys-color-on-surface/38
|
|
298
|
+
data-unavailable:line-through
|
|
299
|
+
|
|
300
|
+
data-outside-month:invisible
|
|
301
|
+
`
|
|
302
|
+
}
|
|
303
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IconProps } from '../../utils/index.js';
|
|
1
2
|
import type { DateValue } from '@internationalized/date';
|
|
2
3
|
import type { Snippet } from 'svelte';
|
|
3
4
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
@@ -37,6 +38,18 @@ export interface BaseDateProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
37
38
|
* @default 'outlined'
|
|
38
39
|
*/
|
|
39
40
|
variant?: 'filled' | 'outlined';
|
|
41
|
+
/**
|
|
42
|
+
* BCP 47 locale for segment order, month names and weekday labels.
|
|
43
|
+
* @default 'en'
|
|
44
|
+
*/
|
|
45
|
+
locale?: string;
|
|
46
|
+
/**
|
|
47
|
+
* First day of the week in the calendar, 0 = Sunday.
|
|
48
|
+
* @default 0
|
|
49
|
+
*/
|
|
50
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
51
|
+
/** Optional icon before the date segments. */
|
|
52
|
+
leadingIconProps?: IconProps;
|
|
40
53
|
}
|
|
41
54
|
export interface DateFieldProps extends BaseDateProps {
|
|
42
55
|
/**
|
|
@@ -3,8 +3,8 @@ export const checkbox = tv({
|
|
|
3
3
|
slots: {
|
|
4
4
|
root: 'group inline-flex min-h-10 select-none items-start gap-3 text-md-sys-color-on-surface min-h-4.5 cursor-pointer',
|
|
5
5
|
container: 'relative inline-flex size-[18px] shrink-0',
|
|
6
|
-
control: 'layer-container absolute -inset-[11px] rounded-full text-md-sys-color-on-surface-variant state-layer before:rounded-full group-focus-visible:outline group-focus-visible:outline-3 group-focus-visible:outline-offset-2 group-focus-visible:outline-md-sys-color-secondary transition-colors
|
|
7
|
-
box: 'absolute inset-[11px] rounded-[4px] border-2 border-current bg-md-sys-color-surface transition-colors
|
|
6
|
+
control: 'layer-container absolute -inset-[11px] rounded-full text-md-sys-color-on-surface-variant state-layer before:rounded-full group-focus-visible:outline group-focus-visible:outline-3 group-focus-visible:outline-offset-2 group-focus-visible:outline-md-sys-color-secondary transition-colors md-sys-motion-fast-effects',
|
|
7
|
+
box: 'absolute inset-[11px] rounded-[4px] border-2 border-current bg-md-sys-color-surface transition-colors md-sys-motion-fast-effects',
|
|
8
8
|
checkIcon: 'pointer-events-none absolute inset-0 m-auto size-3.5 text-md-sys-color-on-primary opacity-0 scale-75',
|
|
9
9
|
indeterminateIcon: 'pointer-events-none absolute inset-0 m-auto block h-0.5 w-3 rounded-full bg-md-sys-color-on-primary opacity-0 scale-75',
|
|
10
10
|
label: 'md-sys-typescale-body-large leading-5 text-md-sys-color-on-surface cursor-pointer'
|