@noxlovette/material 0.4.8 → 0.5.1
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/Shapes.stories.svelte +56 -0
- package/dist/animation/Shapes.stories.svelte.d.ts +3 -0
- package/dist/animation/TransitionPatterns.stories.svelte +359 -0
- package/dist/animation/TransitionPatterns.stories.svelte.d.ts +3 -0
- package/dist/animation/containerTransform.d.ts +35 -12
- package/dist/animation/containerTransform.js +31 -138
- package/dist/animation/enterExit.d.ts +30 -3
- package/dist/animation/enterExit.js +69 -22
- package/dist/animation/index.d.ts +2 -1
- package/dist/animation/index.js +2 -1
- package/dist/animation/presence.svelte.d.ts +47 -0
- package/dist/animation/presence.svelte.js +84 -0
- package/dist/animation/shapeMorph.svelte.d.ts +52 -0
- package/dist/animation/shapeMorph.svelte.js +112 -0
- package/dist/animation/shapesAnimatableSmall.d.ts +28 -22
- package/dist/animation/shapesAnimatableSmall.js +32 -23
- package/dist/animation/sharedAxisTransition.d.ts +57 -37
- package/dist/animation/sharedAxisTransition.js +74 -22
- package/dist/animation/skeleton.d.ts +16 -0
- package/dist/animation/skeleton.js +28 -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 +99 -92
- package/dist/components/date/DateField.svelte.d.ts +4 -5
- package/dist/components/date/DateRangeField.svelte +127 -155
- package/dist/components/date/DateRangeField.svelte.d.ts +4 -5
- package/dist/components/date/calendarMotion.d.ts +9 -0
- package/dist/components/date/calendarMotion.js +23 -0
- package/dist/components/date/theme.d.ts +95 -0
- package/dist/components/date/theme.js +103 -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 +12 -0
- package/dist/components/forms/textfield/theme.js +30 -10
- 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/TabHolder.svelte +29 -3
- package/dist/components/nav/tabs/TabHolder.svelte.d.ts +3 -1
- package/dist/components/nav/tabs/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/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 +1 -1
- 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 +69 -62
- package/dist/components/time/TimeField.svelte.d.ts +6 -0
- package/dist/components/time/TimepickerInput.svelte +8 -4
- package/dist/components/time/types.d.ts +11 -1
- 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 +16 -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,113 @@
|
|
|
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
|
+
|
|
6
|
+
Changing the visible month slides the grid with the M3 lateral transition (see calendarMotion.ts).
|
|
5
7
|
|
|
6
8
|
@see https://m3.material.io/components/date-pickers/guidelines
|
|
7
9
|
-->
|
|
8
10
|
<script lang="ts">
|
|
9
|
-
import { DateRangePicker } from 'bits-ui';
|
|
11
|
+
import { DateRangePicker, Portal, useId } from 'bits-ui';
|
|
12
|
+
import type { DateValue } from '@internationalized/date';
|
|
13
|
+
import { enterExit, presence } from '../../animation/index.js';
|
|
10
14
|
import ButtonIcon from '../buttons/ButtonIcon.svelte';
|
|
11
15
|
import Icon from '../../utils/icon/Icon.svelte';
|
|
12
16
|
import Layer from '../../utils/Layer.svelte';
|
|
13
17
|
import type { DateRangeFieldProps } from './types';
|
|
14
|
-
import {
|
|
18
|
+
import { slideMonth } from './calendarMotion.js';
|
|
19
|
+
import { dateCalendar, dateRangeField, dateSegment } from './theme';
|
|
15
20
|
|
|
16
21
|
let {
|
|
17
22
|
value = $bindable(),
|
|
18
23
|
label,
|
|
19
24
|
startLabel = 'Start',
|
|
20
25
|
endLabel = 'End',
|
|
21
|
-
id,
|
|
26
|
+
id = useId(),
|
|
22
27
|
required = false,
|
|
23
28
|
disabled = false,
|
|
24
29
|
error = false,
|
|
25
30
|
variant = 'outlined',
|
|
26
31
|
supportingText,
|
|
27
32
|
name,
|
|
33
|
+
locale,
|
|
34
|
+
weekStartsOn,
|
|
28
35
|
leadingIconProps
|
|
29
|
-
}: DateRangeFieldProps
|
|
36
|
+
}: DateRangeFieldProps = $props();
|
|
30
37
|
|
|
31
38
|
const cls = $derived(dateRangeField({ disabled, error, variant }));
|
|
39
|
+
const calendar = dateCalendar();
|
|
40
|
+
|
|
41
|
+
// Starts undefined on purpose: bits-ui writes its own default (from value, else today) through
|
|
42
|
+
// the setter on mount, which is why the getter below can assert.
|
|
43
|
+
let placeholder = $state<DateValue>();
|
|
44
|
+
let grids = $state<HTMLElement | null>(null);
|
|
45
|
+
const setPlaceholder = (next: DateValue) =>
|
|
46
|
+
slideMonth(placeholder, next, grids, (date) => (placeholder = date));
|
|
32
47
|
</script>
|
|
33
48
|
|
|
49
|
+
{#snippet rangeInput(type: 'start' | 'end', fieldLabel: string)}
|
|
50
|
+
<div class={cls.inputWrapper()}>
|
|
51
|
+
<DateRangePicker.Input
|
|
52
|
+
{type}
|
|
53
|
+
class={cls.input()}
|
|
54
|
+
name={type === 'start' ? name : undefined}
|
|
55
|
+
id={`${id}-${type}`}
|
|
56
|
+
>
|
|
57
|
+
{#snippet children({ segments })}
|
|
58
|
+
<div class="flex w-full pt-4 tabular-nums">
|
|
59
|
+
{#each segments as { part, value: segment }}
|
|
60
|
+
<DateRangePicker.Segment
|
|
61
|
+
{part}
|
|
62
|
+
class={dateSegment({ part: part === 'literal' ? 'literal' : 'value' })}
|
|
63
|
+
>
|
|
64
|
+
{segment}
|
|
65
|
+
</DateRangePicker.Segment>
|
|
66
|
+
{/each}
|
|
67
|
+
</div>
|
|
68
|
+
{/snippet}
|
|
69
|
+
</DateRangePicker.Input>
|
|
70
|
+
|
|
71
|
+
<span class={cls.label()}>
|
|
72
|
+
{fieldLabel}{#if required}<span class={cls.requiredAsterisk()} aria-hidden="true">*</span
|
|
73
|
+
>{/if}
|
|
74
|
+
</span>
|
|
75
|
+
</div>
|
|
76
|
+
{/snippet}
|
|
77
|
+
|
|
34
78
|
<DateRangePicker.Root
|
|
35
79
|
bind:value
|
|
36
|
-
|
|
80
|
+
bind:placeholder={() => placeholder as DateValue, setPlaceholder}
|
|
81
|
+
{weekStartsOn}
|
|
37
82
|
{required}
|
|
38
83
|
{disabled}
|
|
39
|
-
locale
|
|
40
|
-
weekdayFormat="
|
|
84
|
+
{locale}
|
|
85
|
+
weekdayFormat="narrow"
|
|
41
86
|
fixedWeeks
|
|
42
87
|
closeOnRangeSelect
|
|
43
88
|
>
|
|
44
89
|
<div class="relative w-full">
|
|
90
|
+
{#if label}
|
|
91
|
+
<DateRangePicker.Label class="sr-only">{label}</DateRangePicker.Label>
|
|
92
|
+
{/if}
|
|
45
93
|
<div class={cls.base()} data-invalid={error || undefined}>
|
|
46
94
|
{#if leadingIconProps}
|
|
47
95
|
<Icon class={cls.leadingIcon()} {...leadingIconProps} />
|
|
48
96
|
{/if}
|
|
49
97
|
|
|
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
|
-
|
|
98
|
+
{@render rangeInput('start', startLabel)}
|
|
91
99
|
<span class={cls.separator()}>–</span>
|
|
100
|
+
{@render rangeInput('end', endLabel)}
|
|
92
101
|
|
|
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" />
|
|
102
|
+
<DateRangePicker.Trigger>
|
|
103
|
+
{#snippet child({ props })}
|
|
104
|
+
<ButtonIcon
|
|
105
|
+
{...props}
|
|
106
|
+
{disabled}
|
|
107
|
+
class={cls.trailingIcon()}
|
|
108
|
+
iconProps={{ name: 'date_range' }}
|
|
109
|
+
/>
|
|
110
|
+
{/snippet}
|
|
138
111
|
</DateRangePicker.Trigger>
|
|
139
112
|
</div>
|
|
140
113
|
|
|
@@ -145,68 +118,67 @@ segment inputs and a shared calendar popover.
|
|
|
145
118
|
{/if}
|
|
146
119
|
</div>
|
|
147
120
|
|
|
148
|
-
<
|
|
149
|
-
<DateRangePicker.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
121
|
+
<Portal>
|
|
122
|
+
<DateRangePicker.Content sideOffset={4} align="start">
|
|
123
|
+
{#snippet child({ wrapperProps, props, open })}
|
|
124
|
+
<div {...wrapperProps}>
|
|
125
|
+
<div {...props} {@attach presence(() => open, enterExit.scale)}>
|
|
126
|
+
<DateRangePicker.Calendar class={calendar.surface()}>
|
|
127
|
+
{#snippet children({ months, weekdays })}
|
|
128
|
+
<DateRangePicker.Header class={calendar.header()}>
|
|
129
|
+
<DateRangePicker.Heading class={calendar.heading()} />
|
|
130
|
+
<div class={calendar.nav()}>
|
|
131
|
+
<DateRangePicker.PrevButton>
|
|
132
|
+
{#snippet child({ props })}
|
|
133
|
+
<ButtonIcon {...props} iconProps={{ name: 'chevron_left' }} />
|
|
134
|
+
{/snippet}
|
|
135
|
+
</DateRangePicker.PrevButton>
|
|
136
|
+
<DateRangePicker.NextButton>
|
|
137
|
+
{#snippet child({ props })}
|
|
138
|
+
<ButtonIcon {...props} iconProps={{ name: 'chevron_right' }} />
|
|
139
|
+
{/snippet}
|
|
140
|
+
</DateRangePicker.NextButton>
|
|
141
|
+
</div>
|
|
142
|
+
</DateRangePicker.Header>
|
|
164
143
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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>
|
|
144
|
+
<div bind:this={grids}>
|
|
145
|
+
{#each months as month (month.value.toString())}
|
|
146
|
+
<DateRangePicker.Grid class={calendar.grid()}>
|
|
147
|
+
<DateRangePicker.GridHead>
|
|
148
|
+
<DateRangePicker.GridRow class={calendar.row()}>
|
|
149
|
+
{#each weekdays as day, i (i)}
|
|
150
|
+
<DateRangePicker.HeadCell class={calendar.weekday()}>
|
|
151
|
+
{day}
|
|
152
|
+
</DateRangePicker.HeadCell>
|
|
153
|
+
{/each}
|
|
154
|
+
</DateRangePicker.GridRow>
|
|
155
|
+
</DateRangePicker.GridHead>
|
|
156
|
+
<DateRangePicker.GridBody>
|
|
157
|
+
{#each month.weeks as weekDates, i (i)}
|
|
158
|
+
<DateRangePicker.GridRow class={calendar.row()}>
|
|
159
|
+
{#each weekDates as date (date.toString())}
|
|
160
|
+
<DateRangePicker.Cell
|
|
161
|
+
{date}
|
|
162
|
+
month={month.value}
|
|
163
|
+
class={calendar.cell()}
|
|
164
|
+
>
|
|
165
|
+
<DateRangePicker.Day class={calendar.day()}>
|
|
166
|
+
<Layer />
|
|
167
|
+
{date.day}
|
|
168
|
+
</DateRangePicker.Day>
|
|
169
|
+
</DateRangePicker.Cell>
|
|
170
|
+
{/each}
|
|
171
|
+
</DateRangePicker.GridRow>
|
|
172
|
+
{/each}
|
|
173
|
+
</DateRangePicker.GridBody>
|
|
174
|
+
</DateRangePicker.Grid>
|
|
203
175
|
{/each}
|
|
204
|
-
</
|
|
205
|
-
{/
|
|
206
|
-
</DateRangePicker.
|
|
207
|
-
</
|
|
208
|
-
|
|
176
|
+
</div>
|
|
177
|
+
{/snippet}
|
|
178
|
+
</DateRangePicker.Calendar>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
209
181
|
{/snippet}
|
|
210
|
-
</DateRangePicker.
|
|
211
|
-
</
|
|
182
|
+
</DateRangePicker.Content>
|
|
183
|
+
</Portal>
|
|
212
184
|
</DateRangePicker.Root>
|
|
@@ -1,13 +1,12 @@
|
|
|
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.
|
|
5
|
+
*
|
|
6
|
+
* Changing the visible month slides the grid with the M3 lateral transition (see calendarMotion.ts).
|
|
8
7
|
*
|
|
9
8
|
* @see https://m3.material.io/components/date-pickers/guidelines
|
|
10
9
|
*/
|
|
11
|
-
declare const DateRangeField: import("svelte").Component
|
|
10
|
+
declare const DateRangeField: import("svelte").Component<DateRangeFieldProps, {}, "value">;
|
|
12
11
|
type DateRangeField = ReturnType<typeof DateRangeField>;
|
|
13
12
|
export default DateRangeField;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DateValue } from '@internationalized/date';
|
|
2
|
+
/**
|
|
3
|
+
* Applies a new calendar placeholder (the month the grid shows). When the visible month changes
|
|
4
|
+
* while the calendar is open, the grid runs the M3 lateral transition — months are peers, so a
|
|
5
|
+
* later month pushes in from the right and an earlier one from the left. Covers every way the
|
|
6
|
+
* month changes: prev/next buttons, arrow keys past the month edge, picking an outside day.
|
|
7
|
+
* https://m3.material.io/styles/motion/transitions/transition-patterns#lateral
|
|
8
|
+
*/
|
|
9
|
+
export declare const slideMonth: (current: DateValue | undefined, next: DateValue, target: HTMLElement | null | undefined, apply: (next: DateValue) => void) => undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { lateral } from '../../animation/index.js';
|
|
2
|
+
import { tick } from 'svelte';
|
|
3
|
+
const monthIndex = (date) => date.year * 12 + date.month;
|
|
4
|
+
/**
|
|
5
|
+
* Applies a new calendar placeholder (the month the grid shows). When the visible month changes
|
|
6
|
+
* while the calendar is open, the grid runs the M3 lateral transition — months are peers, so a
|
|
7
|
+
* later month pushes in from the right and an earlier one from the left. Covers every way the
|
|
8
|
+
* month changes: prev/next buttons, arrow keys past the month edge, picking an outside day.
|
|
9
|
+
* https://m3.material.io/styles/motion/transitions/transition-patterns#lateral
|
|
10
|
+
*/
|
|
11
|
+
export const slideMonth = (current, next, target, apply) => {
|
|
12
|
+
const update = async () => {
|
|
13
|
+
apply(next);
|
|
14
|
+
await tick();
|
|
15
|
+
};
|
|
16
|
+
if (!current || !target?.isConnected || monthIndex(current) === monthIndex(next)) {
|
|
17
|
+
return void update();
|
|
18
|
+
}
|
|
19
|
+
lateral(update, {
|
|
20
|
+
target,
|
|
21
|
+
direction: monthIndex(next) > monthIndex(current) ? 'forward' : 'backward'
|
|
22
|
+
});
|
|
23
|
+
};
|
|
@@ -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
|
+
}>>;
|