bits-ui 1.5.1 → 1.5.3

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.
@@ -148,7 +148,6 @@ class AccordionContentState {
148
148
  constructor(opts, item) {
149
149
  this.opts = opts;
150
150
  this.item = item;
151
- this.item = item;
152
151
  this.#isMountAnimationPrevented = this.item.isActive;
153
152
  useRefById(opts);
154
153
  $effect.pre(() => {
@@ -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: 0 | 1 | 2 | 3 | 4 | 5 | 6;
20
+ weekStartsOn: WeekStartsOn | undefined;
20
21
  weekdayFormat: Intl.DateTimeFormatOptions["weekday"];
21
22
  isDateDisabled: DateMatcher;
22
23
  isDateUnavailable: DateMatcher;
@@ -18,7 +18,7 @@
18
18
  placeholder = $bindable(),
19
19
  onPlaceholderChange = noop,
20
20
  weekdayFormat = "narrow",
21
- weekStartsOn = 0,
21
+ weekStartsOn,
22
22
  pagedNavigation = false,
23
23
  isDateDisabled = () => false,
24
24
  isDateUnavailable = () => false,
@@ -94,6 +94,7 @@ export declare class DateFieldRootState {
94
94
  };
95
95
  isInvalid: boolean;
96
96
  inferredGranularity: Granularity;
97
+ dateRef: DateValue;
97
98
  allSegmentContent: {
98
99
  obj: import("../../internal/date-time/field/types.js").SegmentContentObj;
99
100
  arr: {
@@ -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.placeholder.current,
326
+ dateRef: this.dateRef,
326
327
  hideTimeZone: this.hideTimeZone.current,
327
328
  hourCycle: this.hourCycle.current,
328
329
  }));
@@ -35,7 +35,7 @@
35
35
  disableDaysOutsideMonth = true,
36
36
  preventDeselect = false,
37
37
  pagedNavigation = false,
38
- weekStartsOn = 0,
38
+ weekStartsOn,
39
39
  weekdayFormat = "narrow",
40
40
  isDateDisabled = () => false,
41
41
  fixedWeeks = false,
@@ -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;
@@ -37,7 +37,7 @@
37
37
  disableDaysOutsideMonth = true,
38
38
  preventDeselect = false,
39
39
  pagedNavigation = false,
40
- weekStartsOn = 0,
40
+ weekStartsOn,
41
41
  weekdayFormat = "narrow",
42
42
  isDateDisabled = () => false,
43
43
  fixedWeeks = false,
@@ -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;
@@ -625,7 +625,6 @@ class MenuRadioGroupState {
625
625
  constructor(opts, content) {
626
626
  this.opts = opts;
627
627
  this.content = content;
628
- this.content = content;
629
628
  this.root = content.parentMenu.root;
630
629
  useRefById(opts);
631
630
  }
@@ -18,7 +18,7 @@
18
18
  placeholder = $bindable(),
19
19
  onPlaceholderChange = noop,
20
20
  weekdayFormat = "narrow",
21
- weekStartsOn = 0,
21
+ weekStartsOn,
22
22
  pagedNavigation = false,
23
23
  isDateDisabled = () => false,
24
24
  isDateUnavailable = () => false,
@@ -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: 0 | 1 | 2 | 3 | 4 | 5 | 6;
20
+ weekStartsOn: WeekStartsOn | undefined;
20
21
  weekdayFormat: Intl.DateTimeFormatOptions["weekday"];
21
22
  isDateDisabled: (date: DateValue) => boolean;
22
23
  isDateUnavailable: (date: DateValue) => boolean;
@@ -336,7 +336,6 @@ class ScrollAreaScrollbarXState {
336
336
  constructor(opts, scrollbarVis) {
337
337
  this.opts = opts;
338
338
  this.scrollbarVis = scrollbarVis;
339
- this.scrollbarVis = scrollbarVis;
340
339
  this.root = scrollbarVis.root;
341
340
  this.scrollbar = scrollbarVis.scrollbar;
342
341
  useRefById({
@@ -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 = getLastFirstDayOfWeek(firstDayOfMonth, weekStartsOn, locale);
56
- const nextSaturday = getNextLastDayOfWeek(lastDayOfMonth, weekStartsOn, locale);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",
@@ -30,7 +30,7 @@
30
30
  "svelte": "^5.22.6",
31
31
  "svelte-check": "^4.1.4",
32
32
  "tslib": "^2.8.1",
33
- "typescript": "^5.6.3",
33
+ "typescript": "^5.8.3",
34
34
  "vite": "^5.4.11",
35
35
  "vitest": "^2.1.8"
36
36
  },