bits-ui 1.5.0 → 1.5.2
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/bits/calendar/calendar.svelte.d.ts +2 -1
- package/dist/bits/calendar/components/calendar.svelte +1 -1
- package/dist/bits/date-field/date-field.svelte.d.ts +1 -0
- package/dist/bits/date-field/date-field.svelte.js +2 -1
- package/dist/bits/date-picker/components/date-picker.svelte +1 -1
- package/dist/bits/date-picker/date-picker.svelte.d.ts +1 -1
- package/dist/bits/date-range-picker/components/date-range-picker.svelte +1 -1
- package/dist/bits/date-range-picker/date-range-picker.svelte.d.ts +1 -1
- package/dist/bits/navigation-menu/navigation-menu.svelte.js +1 -2
- package/dist/bits/range-calendar/components/range-calendar.svelte +1 -1
- package/dist/bits/range-calendar/range-calendar.svelte.d.ts +2 -1
- package/dist/internal/date-time/calendar-helpers.svelte.d.ts +4 -4
- package/dist/internal/date-time/calendar-helpers.svelte.js +6 -2
- package/dist/internal/use-roving-focus.svelte.d.ts +6 -2
- package/dist/internal/use-roving-focus.svelte.js +2 -1
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import type { DateMatcher, Month } from "../../shared/index.js";
|
|
|
7
7
|
import { type Announcer } from "../../internal/date-time/announcer.js";
|
|
8
8
|
import { type Formatter } from "../../internal/date-time/formatter.js";
|
|
9
9
|
import { type CalendarParts } from "../../internal/date-time/calendar-helpers.svelte.js";
|
|
10
|
+
import type { WeekStartsOn } from "../../shared/date/types.js";
|
|
10
11
|
type CalendarRootStateProps = WithRefProps<WritableBoxedValues<{
|
|
11
12
|
value: DateValue | undefined | DateValue[];
|
|
12
13
|
placeholder: DateValue;
|
|
@@ -16,7 +17,7 @@ type CalendarRootStateProps = WithRefProps<WritableBoxedValues<{
|
|
|
16
17
|
maxValue: DateValue | undefined;
|
|
17
18
|
disabled: boolean;
|
|
18
19
|
pagedNavigation: boolean;
|
|
19
|
-
weekStartsOn:
|
|
20
|
+
weekStartsOn: WeekStartsOn | undefined;
|
|
20
21
|
weekdayFormat: Intl.DateTimeFormatOptions["weekday"];
|
|
21
22
|
isDateDisabled: DateMatcher;
|
|
22
23
|
isDateUnavailable: DateMatcher;
|
|
@@ -317,12 +317,13 @@ export class DateFieldRootState {
|
|
|
317
317
|
const inferred = inferGranularity(this.placeholder.current, this.granularity.current);
|
|
318
318
|
return inferred;
|
|
319
319
|
});
|
|
320
|
+
dateRef = $derived.by(() => this.value.current ?? this.placeholder.current);
|
|
320
321
|
allSegmentContent = $derived.by(() => createContent({
|
|
321
322
|
segmentValues: this.segmentValues,
|
|
322
323
|
formatter: this.formatter,
|
|
323
324
|
locale: this.locale.current,
|
|
324
325
|
granularity: this.inferredGranularity,
|
|
325
|
-
dateRef: this.
|
|
326
|
+
dateRef: this.dateRef,
|
|
326
327
|
hideTimeZone: this.hideTimeZone.current,
|
|
327
328
|
hourCycle: this.hourCycle.current,
|
|
328
329
|
}));
|
|
@@ -22,7 +22,7 @@ type DatePickerRootStateProps = WritableBoxedValues<{
|
|
|
22
22
|
required: boolean;
|
|
23
23
|
preventDeselect: boolean;
|
|
24
24
|
pagedNavigation: boolean;
|
|
25
|
-
weekStartsOn: WeekStartsOn;
|
|
25
|
+
weekStartsOn: WeekStartsOn | undefined;
|
|
26
26
|
weekdayFormat: Intl.DateTimeFormatOptions["weekday"];
|
|
27
27
|
fixedWeeks: boolean;
|
|
28
28
|
numberOfMonths: number;
|
|
@@ -24,7 +24,7 @@ type DateRangePickerRootStateProps = WritableBoxedValues<{
|
|
|
24
24
|
required: boolean;
|
|
25
25
|
preventDeselect: boolean;
|
|
26
26
|
pagedNavigation: boolean;
|
|
27
|
-
weekStartsOn: WeekStartsOn;
|
|
27
|
+
weekStartsOn: WeekStartsOn | undefined;
|
|
28
28
|
weekdayFormat: Intl.DateTimeFormatOptions["weekday"];
|
|
29
29
|
fixedWeeks: boolean;
|
|
30
30
|
numberOfMonths: number;
|
|
@@ -173,8 +173,7 @@ class NavigationMenuListState {
|
|
|
173
173
|
});
|
|
174
174
|
this.rovingFocusGroup = useRovingFocus({
|
|
175
175
|
rootNodeId: opts.id,
|
|
176
|
-
|
|
177
|
-
candidateSelector: `:is([${NAVIGATION_MENU_TRIGGER_ATTR}], [data-list-link]):not([data-disabled])`,
|
|
176
|
+
candidateSelector: `:is([${NAVIGATION_MENU_TRIGGER_ATTR}], [${NAVIGATION_MENU_LINK_ATTR}]):not([data-disabled])`,
|
|
178
177
|
loop: box.with(() => false),
|
|
179
178
|
orientation: this.context.opts.orientation,
|
|
180
179
|
});
|
|
@@ -5,6 +5,7 @@ import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, WithRefProps }
|
|
|
5
5
|
import { type Announcer } from "../../internal/date-time/announcer.js";
|
|
6
6
|
import { type Formatter } from "../../internal/date-time/formatter.js";
|
|
7
7
|
import { type CalendarParts } from "../../internal/date-time/calendar-helpers.svelte.js";
|
|
8
|
+
import type { WeekStartsOn } from "../../shared/date/types.js";
|
|
8
9
|
type RangeCalendarRootStateProps = WithRefProps<WritableBoxedValues<{
|
|
9
10
|
value: DateRange;
|
|
10
11
|
placeholder: DateValue;
|
|
@@ -16,7 +17,7 @@ type RangeCalendarRootStateProps = WithRefProps<WritableBoxedValues<{
|
|
|
16
17
|
maxValue: DateValue | undefined;
|
|
17
18
|
disabled: boolean;
|
|
18
19
|
pagedNavigation: boolean;
|
|
19
|
-
weekStartsOn:
|
|
20
|
+
weekStartsOn: WeekStartsOn | undefined;
|
|
20
21
|
weekdayFormat: Intl.DateTimeFormatOptions["weekday"];
|
|
21
22
|
isDateDisabled: (date: DateValue) => boolean;
|
|
22
23
|
isDateUnavailable: (date: DateValue) => boolean;
|
|
@@ -21,7 +21,7 @@ export type CreateMonthProps = {
|
|
|
21
21
|
/**
|
|
22
22
|
* The day of the week to start the calendar on (0 for Sunday, 1 for Monday, etc.).
|
|
23
23
|
*/
|
|
24
|
-
weekStartsOn: number;
|
|
24
|
+
weekStartsOn: number | undefined;
|
|
25
25
|
/**
|
|
26
26
|
* Whether to always render 6 weeks in the calendar, even if the month doesn't
|
|
27
27
|
* span 6 weeks.
|
|
@@ -102,7 +102,7 @@ type HandleCalendarPageProps = {
|
|
|
102
102
|
setMonths: (months: Month<DateValue>[]) => void;
|
|
103
103
|
numberOfMonths: number;
|
|
104
104
|
pagedNavigation: boolean;
|
|
105
|
-
weekStartsOn: number;
|
|
105
|
+
weekStartsOn: number | undefined;
|
|
106
106
|
locale: string;
|
|
107
107
|
fixedWeeks: boolean;
|
|
108
108
|
setPlaceholder: (date: DateValue) => void;
|
|
@@ -116,7 +116,7 @@ type GetWeekdaysProps = {
|
|
|
116
116
|
};
|
|
117
117
|
export declare function getWeekdays({ months, formatter, weekdayFormat }: GetWeekdaysProps): string[];
|
|
118
118
|
type UseMonthViewSyncProps = {
|
|
119
|
-
weekStartsOn: ReadableBox<number>;
|
|
119
|
+
weekStartsOn: ReadableBox<number | undefined>;
|
|
120
120
|
locale: ReadableBox<string>;
|
|
121
121
|
fixedWeeks: ReadableBox<boolean>;
|
|
122
122
|
numberOfMonths: ReadableBox<number>;
|
|
@@ -141,7 +141,7 @@ export declare function createAccessibleHeading({ calendarNode, label, accessibl
|
|
|
141
141
|
type UseMonthViewPlaceholderSyncProps = {
|
|
142
142
|
placeholder: WritableBox<DateValue>;
|
|
143
143
|
getVisibleMonths: () => DateValue[];
|
|
144
|
-
weekStartsOn: ReadableBox<number>;
|
|
144
|
+
weekStartsOn: ReadableBox<number | undefined>;
|
|
145
145
|
locale: ReadableBox<string>;
|
|
146
146
|
fixedWeeks: ReadableBox<boolean>;
|
|
147
147
|
numberOfMonths: ReadableBox<number>;
|
|
@@ -52,8 +52,12 @@ function createMonth(props) {
|
|
|
52
52
|
const datesArray = Array.from({ length: daysInMonth }, (_, i) => dateObj.set({ day: i + 1 }));
|
|
53
53
|
const firstDayOfMonth = startOfMonth(dateObj);
|
|
54
54
|
const lastDayOfMonth = endOfMonth(dateObj);
|
|
55
|
-
const lastSunday =
|
|
56
|
-
|
|
55
|
+
const lastSunday = weekStartsOn !== undefined
|
|
56
|
+
? getLastFirstDayOfWeek(firstDayOfMonth, weekStartsOn, "en-US")
|
|
57
|
+
: getLastFirstDayOfWeek(firstDayOfMonth, 0, locale);
|
|
58
|
+
const nextSaturday = weekStartsOn !== undefined
|
|
59
|
+
? getNextLastDayOfWeek(lastDayOfMonth, weekStartsOn, "en-US")
|
|
60
|
+
: getNextLastDayOfWeek(lastDayOfMonth, 0, locale);
|
|
57
61
|
const lastMonthDays = getDaysBetween(lastSunday.subtract({ days: 1 }), firstDayOfMonth);
|
|
58
62
|
const nextMonthDays = getDaysBetween(lastDayOfMonth, nextSaturday.add({ days: 1 }));
|
|
59
63
|
const totalDays = lastMonthDays.length + datesArray.length + nextMonthDays.length;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { type ReadableBox } from "svelte-toolbelt";
|
|
2
2
|
import type { Orientation } from "../shared/index.js";
|
|
3
|
-
type UseRovingFocusProps = {
|
|
3
|
+
type UseRovingFocusProps = ({
|
|
4
4
|
/**
|
|
5
5
|
* The selector used to find the focusable candidates.
|
|
6
6
|
*/
|
|
7
7
|
candidateAttr: string;
|
|
8
|
+
candidateSelector?: undefined;
|
|
9
|
+
} | {
|
|
8
10
|
/**
|
|
9
11
|
* Custom candidate selector
|
|
10
12
|
*/
|
|
11
|
-
candidateSelector
|
|
13
|
+
candidateSelector: string;
|
|
14
|
+
candidateAttr?: undefined;
|
|
15
|
+
}) & {
|
|
12
16
|
/**
|
|
13
17
|
* The id of the root node
|
|
14
18
|
*/
|
|
@@ -15,10 +15,11 @@ export function useRovingFocus(props) {
|
|
|
15
15
|
const candidates = Array.from(node.querySelectorAll(props.candidateSelector));
|
|
16
16
|
return candidates;
|
|
17
17
|
}
|
|
18
|
-
else {
|
|
18
|
+
else if (props.candidateAttr) {
|
|
19
19
|
const candidates = Array.from(node.querySelectorAll(`[${props.candidateAttr}]:not([data-disabled])`));
|
|
20
20
|
return candidates;
|
|
21
21
|
}
|
|
22
|
+
return [];
|
|
22
23
|
}
|
|
23
24
|
function focusFirstCandidate() {
|
|
24
25
|
const items = getCandidateNodes();
|