bits-ui 2.3.0 → 2.3.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.
Files changed (81) hide show
  1. package/dist/bits/accordion/accordion.svelte.d.ts +0 -5
  2. package/dist/bits/accordion/accordion.svelte.js +11 -14
  3. package/dist/bits/aspect-ratio/aspect-ratio.svelte.d.ts +0 -1
  4. package/dist/bits/aspect-ratio/aspect-ratio.svelte.js +6 -2
  5. package/dist/bits/avatar/avatar.svelte.d.ts +0 -3
  6. package/dist/bits/avatar/avatar.svelte.js +8 -6
  7. package/dist/bits/calendar/calendar.svelte.d.ts +2 -2
  8. package/dist/bits/calendar/calendar.svelte.js +4 -4
  9. package/dist/bits/checkbox/checkbox.svelte.d.ts +0 -3
  10. package/dist/bits/checkbox/checkbox.svelte.js +14 -14
  11. package/dist/bits/collapsible/collapsible.svelte.d.ts +0 -3
  12. package/dist/bits/collapsible/collapsible.svelte.js +8 -7
  13. package/dist/bits/command/command.svelte.d.ts +0 -12
  14. package/dist/bits/command/command.svelte.js +35 -31
  15. package/dist/bits/date-field/date-field.svelte.d.ts +2 -4
  16. package/dist/bits/date-field/date-field.svelte.js +8 -6
  17. package/dist/bits/date-picker/components/date-picker-trigger.svelte +2 -2
  18. package/dist/bits/date-range-field/date-range-field.svelte.d.ts +1 -3
  19. package/dist/bits/date-range-field/date-range-field.svelte.js +7 -5
  20. package/dist/bits/date-range-picker/components/date-range-picker-trigger.svelte +2 -2
  21. package/dist/bits/dialog/dialog.svelte.d.ts +2 -12
  22. package/dist/bits/dialog/dialog.svelte.js +16 -24
  23. package/dist/bits/label/label.svelte.d.ts +0 -1
  24. package/dist/bits/label/label.svelte.js +6 -2
  25. package/dist/bits/link-preview/link-preview.svelte.d.ts +0 -2
  26. package/dist/bits/link-preview/link-preview.svelte.js +7 -5
  27. package/dist/bits/menu/components/menu-sub-content-static.svelte +1 -1
  28. package/dist/bits/menu/components/menu-sub-content.svelte +1 -1
  29. package/dist/bits/menu/menu.svelte.d.ts +2 -1
  30. package/dist/bits/menu/menu.svelte.js +39 -21
  31. package/dist/bits/menubar/menubar.svelte.d.ts +1 -7
  32. package/dist/bits/menubar/menubar.svelte.js +12 -14
  33. package/dist/bits/meter/meter.svelte.d.ts +0 -1
  34. package/dist/bits/meter/meter.svelte.js +6 -2
  35. package/dist/bits/navigation-menu/navigation-menu.svelte.d.ts +2 -11
  36. package/dist/bits/navigation-menu/navigation-menu.svelte.js +30 -25
  37. package/dist/bits/pagination/pagination.svelte.d.ts +0 -4
  38. package/dist/bits/pagination/pagination.svelte.js +9 -10
  39. package/dist/bits/pin-input/pin-input.svelte.d.ts +0 -2
  40. package/dist/bits/pin-input/pin-input.svelte.js +7 -5
  41. package/dist/bits/popover/popover.svelte.d.ts +0 -3
  42. package/dist/bits/popover/popover.svelte.js +9 -5
  43. package/dist/bits/progress/progress.svelte.d.ts +0 -1
  44. package/dist/bits/progress/progress.svelte.js +6 -2
  45. package/dist/bits/radio-group/radio-group.svelte.d.ts +7 -9
  46. package/dist/bits/radio-group/radio-group.svelte.js +9 -10
  47. package/dist/bits/range-calendar/range-calendar.svelte.d.ts +38 -38
  48. package/dist/bits/range-calendar/range-calendar.svelte.js +79 -79
  49. package/dist/bits/rating-group/rating-group.svelte.d.ts +0 -2
  50. package/dist/bits/rating-group/rating-group.svelte.js +33 -11
  51. package/dist/bits/scroll-area/scroll-area.svelte.d.ts +15 -19
  52. package/dist/bits/scroll-area/scroll-area.svelte.js +10 -10
  53. package/dist/bits/select/select.svelte.d.ts +28 -30
  54. package/dist/bits/select/select.svelte.js +36 -48
  55. package/dist/bits/separator/separator.svelte.d.ts +1 -2
  56. package/dist/bits/separator/separator.svelte.js +6 -3
  57. package/dist/bits/slider/slider.svelte.d.ts +17 -24
  58. package/dist/bits/slider/slider.svelte.js +15 -17
  59. package/dist/bits/switch/switch.svelte.d.ts +6 -8
  60. package/dist/bits/switch/switch.svelte.js +7 -5
  61. package/dist/bits/tabs/tabs.svelte.d.ts +5 -9
  62. package/dist/bits/tabs/tabs.svelte.js +11 -11
  63. package/dist/bits/time-field/time-field.svelte.d.ts +1 -3
  64. package/dist/bits/time-field/time-field.svelte.js +7 -5
  65. package/dist/bits/time-range-field/time-range-field.svelte.d.ts +1 -3
  66. package/dist/bits/time-range-field/time-range-field.svelte.js +7 -5
  67. package/dist/bits/toggle/toggle.svelte.d.ts +3 -3
  68. package/dist/bits/toggle/toggle.svelte.js +6 -3
  69. package/dist/bits/toggle-group/toggle-group.svelte.d.ts +1 -2
  70. package/dist/bits/toggle-group/toggle-group.svelte.js +8 -6
  71. package/dist/bits/toolbar/toolbar.svelte.d.ts +11 -18
  72. package/dist/bits/toolbar/toolbar.svelte.js +14 -17
  73. package/dist/bits/tooltip/tooltip.svelte.d.ts +13 -14
  74. package/dist/bits/tooltip/tooltip.svelte.js +7 -5
  75. package/dist/internal/attrs.d.ts +14 -0
  76. package/dist/internal/attrs.js +18 -0
  77. package/dist/internal/date-time/calendar-helpers.svelte.d.ts +1 -0
  78. package/dist/internal/date-time/calendar-helpers.svelte.js +18 -1
  79. package/dist/internal/use-arrow-navigation.d.ts +2 -2
  80. package/dist/internal/use-arrow-navigation.js +1 -1
  81. package/package.json +1 -1
@@ -2,13 +2,15 @@ import { Previous, watch } from "runed";
2
2
  import { onMount } from "svelte";
3
3
  import { box, attachRef, DOMContext } from "svelte-toolbelt";
4
4
  import { usePasswordManagerBadge } from "./usePasswordManager.svelte.js";
5
- import { getDisabled } from "../../internal/attrs.js";
5
+ import { createBitsAttrs, getDisabled } from "../../internal/attrs.js";
6
6
  import { on } from "svelte/events";
7
7
  export const REGEXP_ONLY_DIGITS = "^\\d+$";
8
8
  export const REGEXP_ONLY_CHARS = "^[a-zA-Z]+$";
9
9
  export const REGEXP_ONLY_DIGITS_AND_CHARS = "^[a-zA-Z0-9]+$";
10
- const ROOT_ATTR = "data-pin-input-root";
11
- const CELL_ATTR = "data-pin-input-cell";
10
+ const pinInputAttrs = createBitsAttrs({
11
+ component: "pin-input",
12
+ parts: ["root", "cell"],
13
+ });
12
14
  const KEYS_TO_IGNORE = [
13
15
  "Backspace",
14
16
  "Delete",
@@ -151,7 +153,7 @@ class PinInputRootState {
151
153
  }));
152
154
  rootProps = $derived.by(() => ({
153
155
  id: this.opts.id.current,
154
- [ROOT_ATTR]: "",
156
+ [pinInputAttrs.root]: "",
155
157
  style: this.#rootStyles,
156
158
  ...attachRef(this.opts.ref),
157
159
  }));
@@ -394,7 +396,7 @@ class PinInputCellState {
394
396
  }
395
397
  props = $derived.by(() => ({
396
398
  id: this.opts.id.current,
397
- [CELL_ATTR]: "",
399
+ [pinInputAttrs.cell]: "",
398
400
  "data-active": this.opts.cell.current.isActive ? "" : undefined,
399
401
  "data-inactive": !this.opts.cell.current.isActive ? "" : undefined,
400
402
  ...attachRef(this.opts.ref),
@@ -28,7 +28,6 @@ declare class PopoverTriggerState {
28
28
  readonly "aria-expanded": "true" | "false";
29
29
  readonly "data-state": "open" | "closed";
30
30
  readonly "aria-controls": string | undefined;
31
- readonly "data-popover-trigger": "";
32
31
  readonly disabled: boolean;
33
32
  readonly onkeydown: (e: BitsKeyboardEvent) => void;
34
33
  readonly onclick: (e: BitsMouseEvent) => void;
@@ -53,7 +52,6 @@ declare class PopoverContentState {
53
52
  readonly id: string;
54
53
  readonly tabindex: -1;
55
54
  readonly "data-state": "open" | "closed";
56
- readonly "data-popover-content": "";
57
55
  readonly style: {
58
56
  readonly pointerEvents: "auto";
59
57
  };
@@ -76,7 +74,6 @@ declare class PopoverCloseState {
76
74
  readonly onclick: (_: BitsPointerEvent) => void;
77
75
  readonly onkeydown: (e: BitsKeyboardEvent) => void;
78
76
  readonly type: "button";
79
- readonly "data-popover-close": "";
80
77
  };
81
78
  }
82
79
  export declare function usePopoverRoot(props: PopoverRootStateProps): PopoverRootState;
@@ -1,8 +1,12 @@
1
1
  import { attachRef } from "svelte-toolbelt";
2
2
  import { Context } from "runed";
3
3
  import { kbd } from "../../internal/kbd.js";
4
- import { getAriaExpanded, getDataOpenClosed } from "../../internal/attrs.js";
4
+ import { createBitsAttrs, getAriaExpanded, getDataOpenClosed } from "../../internal/attrs.js";
5
5
  import { isElement } from "../../internal/is.js";
6
+ const popoverAttrs = createBitsAttrs({
7
+ component: "popover",
8
+ parts: ["root", "trigger", "content", "close"],
9
+ });
6
10
  class PopoverRootState {
7
11
  opts;
8
12
  contentNode = $state(null);
@@ -55,7 +59,7 @@ class PopoverTriggerState {
55
59
  "aria-expanded": getAriaExpanded(this.root.opts.open.current),
56
60
  "data-state": getDataOpenClosed(this.root.opts.open.current),
57
61
  "aria-controls": this.#getAriaControls(),
58
- "data-popover-trigger": "",
62
+ [popoverAttrs.trigger]: "",
59
63
  disabled: this.opts.disabled.current,
60
64
  //
61
65
  onkeydown: this.onkeydown,
@@ -76,7 +80,7 @@ class PopoverContentState {
76
80
  return;
77
81
  if (!isElement(e.target))
78
82
  return;
79
- const closestTrigger = e.target.closest(`[data-popover-trigger]`);
83
+ const closestTrigger = e.target.closest(popoverAttrs.selector("trigger"));
80
84
  if (closestTrigger === this.root.triggerNode)
81
85
  return;
82
86
  this.root.handleClose();
@@ -99,7 +103,7 @@ class PopoverContentState {
99
103
  id: this.opts.id.current,
100
104
  tabindex: -1,
101
105
  "data-state": getDataOpenClosed(this.root.opts.open.current),
102
- "data-popover-content": "",
106
+ [popoverAttrs.content]: "",
103
107
  style: {
104
108
  pointerEvents: "auto",
105
109
  },
@@ -134,7 +138,7 @@ class PopoverCloseState {
134
138
  onclick: this.onclick,
135
139
  onkeydown: this.onkeydown,
136
140
  type: "button",
137
- "data-popover-close": "",
141
+ [popoverAttrs.close]: "",
138
142
  ...attachRef(this.opts.ref),
139
143
  }));
140
144
  }
@@ -19,7 +19,6 @@ declare class ProgressRootState {
19
19
  readonly "data-max": number;
20
20
  readonly "data-min": number;
21
21
  readonly "data-indeterminate": "" | undefined;
22
- readonly "data-progress-root": "";
23
22
  };
24
23
  }
25
24
  export declare function useProgressRootState(props: ProgressRootStateProps): ProgressRootState;
@@ -1,5 +1,9 @@
1
1
  import { attachRef } from "svelte-toolbelt";
2
- const ROOT_ATTR = "data-progress-root";
2
+ import { createBitsAttrs } from "../../internal/attrs.js";
3
+ const progressAttrs = createBitsAttrs({
4
+ component: "progress",
5
+ parts: ["root"],
6
+ });
3
7
  class ProgressRootState {
4
8
  opts;
5
9
  constructor(opts) {
@@ -16,7 +20,7 @@ class ProgressRootState {
16
20
  "data-max": this.opts.max.current,
17
21
  "data-min": this.opts.min.current,
18
22
  "data-indeterminate": this.opts.value.current === null ? "" : undefined,
19
- [ROOT_ATTR]: "",
23
+ [progressAttrs.root]: "",
20
24
  ...attachRef(this.opts.ref),
21
25
  }));
22
26
  }
@@ -13,18 +13,17 @@ type RadioGroupRootStateProps = WithRefProps<ReadableBoxedValues<{
13
13
  }>>;
14
14
  declare class RadioGroupRootState {
15
15
  readonly opts: RadioGroupRootStateProps;
16
+ readonly hasValue: boolean;
16
17
  rovingFocusGroup: UseRovingFocusReturn;
17
- hasValue: boolean;
18
18
  constructor(opts: RadioGroupRootStateProps);
19
19
  isChecked(value: string): boolean;
20
20
  setValue(value: string): void;
21
- props: {
21
+ readonly props: {
22
22
  readonly id: string;
23
23
  readonly role: "radiogroup";
24
24
  readonly "aria-required": "true" | "false";
25
25
  readonly "data-disabled": "" | undefined;
26
26
  readonly "data-orientation": Orientation;
27
- readonly "data-radio-group-root": "";
28
27
  };
29
28
  }
30
29
  type RadioGroupItemStateProps = WithRefProps<ReadableBoxedValues<{
@@ -35,15 +34,15 @@ declare class RadioGroupItemState {
35
34
  #private;
36
35
  readonly opts: RadioGroupItemStateProps;
37
36
  readonly root: RadioGroupRootState;
38
- checked: boolean;
37
+ readonly checked: boolean;
39
38
  constructor(opts: RadioGroupItemStateProps, root: RadioGroupRootState);
40
39
  onclick(_: BitsMouseEvent): void;
41
40
  onfocus(_: BitsFocusEvent): void;
42
41
  onkeydown(e: BitsKeyboardEvent): void;
43
- snippetProps: {
42
+ readonly snippetProps: {
44
43
  checked: boolean;
45
44
  };
46
- props: {
45
+ readonly props: {
47
46
  readonly id: string;
48
47
  readonly disabled: true | undefined;
49
48
  readonly "data-value": string;
@@ -51,7 +50,6 @@ declare class RadioGroupItemState {
51
50
  readonly "data-disabled": "" | undefined;
52
51
  readonly "data-state": "checked" | "unchecked";
53
52
  readonly "aria-checked": "true" | "false" | "mixed";
54
- readonly "data-radio-group-item": "";
55
53
  readonly type: "button";
56
54
  readonly role: "radio";
57
55
  readonly tabindex: number;
@@ -62,8 +60,8 @@ declare class RadioGroupItemState {
62
60
  }
63
61
  declare class RadioGroupInputState {
64
62
  readonly root: RadioGroupRootState;
65
- shouldRender: boolean;
66
- props: {
63
+ readonly shouldRender: boolean;
64
+ readonly props: {
67
65
  readonly name: string | undefined;
68
66
  readonly value: string;
69
67
  readonly required: boolean;
@@ -1,19 +1,21 @@
1
1
  import { attachRef } from "svelte-toolbelt";
2
2
  import { Context, watch } from "runed";
3
- import { getAriaChecked, getAriaRequired, getDataDisabled } from "../../internal/attrs.js";
3
+ import { createBitsAttrs, getAriaChecked, getAriaRequired, getDataDisabled, } from "../../internal/attrs.js";
4
4
  import { useRovingFocus, } from "../../internal/use-roving-focus.svelte.js";
5
5
  import { kbd } from "../../internal/kbd.js";
6
- const RADIO_GROUP_ROOT_ATTR = "data-radio-group-root";
7
- const RADIO_GROUP_ITEM_ATTR = "data-radio-group-item";
6
+ const radioGroupAttrs = createBitsAttrs({
7
+ component: "radio-group",
8
+ parts: ["root", "item"],
9
+ });
8
10
  class RadioGroupRootState {
9
11
  opts;
10
- rovingFocusGroup;
11
12
  hasValue = $derived.by(() => this.opts.value.current !== "");
13
+ rovingFocusGroup;
12
14
  constructor(opts) {
13
15
  this.opts = opts;
14
16
  this.rovingFocusGroup = useRovingFocus({
15
17
  rootNode: this.opts.ref,
16
- candidateAttr: RADIO_GROUP_ITEM_ATTR,
18
+ candidateAttr: radioGroupAttrs.item,
17
19
  loop: this.opts.loop,
18
20
  orientation: this.opts.orientation,
19
21
  });
@@ -30,7 +32,7 @@ class RadioGroupRootState {
30
32
  "aria-required": getAriaRequired(this.opts.required.current),
31
33
  "data-disabled": getDataDisabled(this.opts.disabled.current),
32
34
  "data-orientation": this.opts.orientation.current,
33
- [RADIO_GROUP_ROOT_ATTR]: "",
35
+ [radioGroupAttrs.root]: "",
34
36
  ...attachRef(this.opts.ref),
35
37
  }));
36
38
  }
@@ -93,7 +95,7 @@ class RadioGroupItemState {
93
95
  "data-disabled": getDataDisabled(this.#isDisabled),
94
96
  "data-state": this.#isChecked ? "checked" : "unchecked",
95
97
  "aria-checked": getAriaChecked(this.#isChecked, false),
96
- [RADIO_GROUP_ITEM_ATTR]: "",
98
+ [radioGroupAttrs.item]: "",
97
99
  type: "button",
98
100
  role: "radio",
99
101
  tabindex: this.#tabIndex,
@@ -104,9 +106,6 @@ class RadioGroupItemState {
104
106
  ...attachRef(this.opts.ref),
105
107
  }));
106
108
  }
107
- //
108
- // INPUT
109
- //
110
109
  class RadioGroupInputState {
111
110
  root;
112
111
  shouldRender = $derived.by(() => this.root.opts.name.current !== undefined);
@@ -5,7 +5,7 @@ import type { ReadableBoxedValues, WritableBoxedValues } from "../../internal/bo
5
5
  import type { BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, WithRefProps } from "../../internal/types.js";
6
6
  import { type Announcer } from "../../internal/date-time/announcer.js";
7
7
  import { type Formatter } from "../../internal/date-time/formatter.js";
8
- import { type CalendarParts } from "../../internal/date-time/calendar-helpers.svelte.js";
8
+ import { calendarAttrs } from "../../internal/date-time/calendar-helpers.svelte.js";
9
9
  import type { WeekStartsOn } from "../../shared/date/types.js";
10
10
  type RangeCalendarRootStateProps = WithRefProps<WritableBoxedValues<{
11
11
  value: DateRange;
@@ -39,16 +39,14 @@ type RangeCalendarRootStateProps = WithRefProps<WritableBoxedValues<{
39
39
  export declare class RangeCalendarRootState {
40
40
  #private;
41
41
  readonly opts: RangeCalendarRootStateProps;
42
+ readonly visibleMonths: DateValue[];
42
43
  months: Month<DateValue>[];
43
- visibleMonths: DateValue[];
44
44
  announcer: Announcer;
45
45
  formatter: Formatter;
46
46
  accessibleHeadingId: string;
47
47
  focusedValue: DateValue | undefined;
48
48
  lastPressedDateValue: DateValue | undefined;
49
49
  domContext: DOMContext;
50
- constructor(opts: RangeCalendarRootStateProps);
51
- setMonths: (months: Month<DateValue>[]) => void;
52
50
  /**
53
51
  * This derived state holds an array of localized day names for the current
54
52
  * locale and calendar view. It dynamically syncs with the 'weekStartsOn' option,
@@ -56,24 +54,26 @@ export declare class RangeCalendarRootState {
56
54
  * calendar's days of the week is strongly recommended, as it guarantees that
57
55
  * the days are correctly formatted for the current locale and calendar view.
58
56
  */
59
- weekdays: string[];
57
+ readonly weekdays: string[];
58
+ readonly isStartInvalid: boolean;
59
+ readonly isEndInvalid: boolean;
60
+ readonly isInvalid: boolean;
61
+ readonly isNextButtonDisabled: boolean;
62
+ readonly isPrevButtonDisabled: boolean;
63
+ readonly headingValue: string;
64
+ readonly fullCalendarLabel: string;
65
+ readonly highlightedRange: {
66
+ start: DateValue;
67
+ end: DateValue;
68
+ } | null;
69
+ constructor(opts: RangeCalendarRootStateProps);
70
+ setMonths: (months: Month<DateValue>[]) => void;
60
71
  isOutsideVisibleMonths(date: DateValue): boolean;
61
72
  isDateDisabled(date: DateValue): boolean;
62
73
  isDateUnavailable(date: DateValue): boolean;
63
- isStartInvalid: boolean;
64
- isEndInvalid: boolean;
65
- isInvalid: boolean;
66
- isNextButtonDisabled: boolean;
67
- isPrevButtonDisabled: boolean;
68
- headingValue: string;
69
- fullCalendarLabel: string;
70
74
  isSelectionStart(date: DateValue): boolean;
71
75
  isSelectionEnd(date: DateValue): boolean;
72
76
  isSelected(date: DateValue): boolean;
73
- highlightedRange: {
74
- start: DateValue;
75
- end: DateValue;
76
- } | null;
77
77
  shiftFocus(node: HTMLElement, add: number): void;
78
78
  handleCellClick(e: Event, date: DateValue): void;
79
79
  onkeydown(event: BitsKeyboardEvent): void;
@@ -89,12 +89,12 @@ export declare class RangeCalendarRootState {
89
89
  prevYear(): void;
90
90
  setYear(year: number): void;
91
91
  setMonth(month: number): void;
92
- getBitsAttr(part: CalendarParts): string;
93
- snippetProps: {
92
+ getBitsAttr: (typeof calendarAttrs)["getAttr"];
93
+ readonly snippetProps: {
94
94
  months: Month<DateValue>[];
95
95
  weekdays: string[];
96
96
  };
97
- props: {
97
+ readonly props: {
98
98
  readonly onkeydown: (event: BitsKeyboardEvent) => void;
99
99
  readonly id: string;
100
100
  readonly role: "application";
@@ -111,26 +111,26 @@ type RangeCalendarCellStateProps = WithRefProps<ReadableBoxedValues<{
111
111
  export declare class RangeCalendarCellState {
112
112
  readonly opts: RangeCalendarCellStateProps;
113
113
  readonly root: RangeCalendarRootState;
114
- cellDate: Date;
115
- isDisabled: boolean;
116
- isUnavailable: boolean;
117
- isDateToday: boolean;
118
- isOutsideMonth: boolean;
119
- isOutsideVisibleMonths: boolean;
120
- isFocusedDate: boolean;
121
- isSelectedDate: boolean;
122
- isSelectionStart: boolean;
123
- isSelectionEnd: boolean;
124
- isHighlighted: boolean;
125
- labelText: string;
114
+ readonly cellDate: Date;
115
+ readonly isDisabled: boolean;
116
+ readonly isUnavailable: boolean;
117
+ readonly isDateToday: boolean;
118
+ readonly isOutsideMonth: boolean;
119
+ readonly isOutsideVisibleMonths: boolean;
120
+ readonly isFocusedDate: boolean;
121
+ readonly isSelectedDate: boolean;
122
+ readonly isSelectionStart: boolean;
123
+ readonly isSelectionEnd: boolean;
124
+ readonly isHighlighted: boolean;
125
+ readonly labelText: string;
126
126
  constructor(opts: RangeCalendarCellStateProps, root: RangeCalendarRootState);
127
- snippetProps: {
127
+ readonly snippetProps: {
128
128
  disabled: boolean;
129
129
  unavailable: boolean;
130
130
  selected: boolean;
131
131
  };
132
- ariaDisabled: boolean;
133
- sharedDataAttrs: {
132
+ readonly ariaDisabled: boolean;
133
+ readonly sharedDataAttrs: {
134
134
  readonly "data-unavailable": "" | undefined;
135
135
  readonly "data-today": "" | undefined;
136
136
  readonly "data-outside-month": "" | undefined;
@@ -144,7 +144,7 @@ export declare class RangeCalendarCellState {
144
144
  readonly "data-type": string;
145
145
  readonly "data-disabled": "" | undefined;
146
146
  };
147
- props: {
147
+ readonly props: {
148
148
  readonly "data-unavailable": "" | undefined;
149
149
  readonly "data-today": "" | undefined;
150
150
  readonly "data-outside-month": "" | undefined;
@@ -172,14 +172,14 @@ declare class RangeCalendarDayState {
172
172
  onclick(e: BitsMouseEvent): void;
173
173
  onmouseenter(_: BitsMouseEvent): void;
174
174
  onfocusin(_: BitsFocusEvent): void;
175
- snippetProps: {
175
+ readonly snippetProps: {
176
176
  disabled: boolean;
177
177
  unavailable: boolean;
178
178
  selected: boolean;
179
179
  day: string;
180
180
  };
181
- props: {
182
- readonly tabindex: number | undefined;
181
+ readonly props: {
182
+ readonly tabindex: 0 | -1 | undefined;
183
183
  readonly "data-bits-day": "";
184
184
  readonly onclick: (e: BitsMouseEvent) => void;
185
185
  readonly onmouseenter: (_: BitsMouseEvent) => void;
@@ -6,19 +6,93 @@ import { useId } from "../../internal/use-id.js";
6
6
  import { getAriaDisabled, getAriaSelected, getDataDisabled, getDataSelected, getDataUnavailable, } from "../../internal/attrs.js";
7
7
  import { getAnnouncer } from "../../internal/date-time/announcer.js";
8
8
  import { createFormatter } from "../../internal/date-time/formatter.js";
9
- import { createMonths, getCalendarElementProps, getCalendarHeadingValue, getIsNextButtonDisabled, getIsPrevButtonDisabled, getWeekdays, handleCalendarKeydown, handleCalendarNextPage, handleCalendarPrevPage, shiftCalendarFocus, useEnsureNonDisabledPlaceholder, useMonthViewOptionsSync, useMonthViewPlaceholderSync, } from "../../internal/date-time/calendar-helpers.svelte.js";
9
+ import { calendarAttrs, createMonths, getCalendarElementProps, getCalendarHeadingValue, getIsNextButtonDisabled, getIsPrevButtonDisabled, getWeekdays, handleCalendarKeydown, handleCalendarNextPage, handleCalendarPrevPage, shiftCalendarFocus, useEnsureNonDisabledPlaceholder, useMonthViewOptionsSync, useMonthViewPlaceholderSync, } from "../../internal/date-time/calendar-helpers.svelte.js";
10
10
  import { areAllDaysBetweenValid, getDateValueType, isAfter, isBefore, isBetweenInclusive, toDate, } from "../../internal/date-time/utils.js";
11
11
  import { onMount } from "svelte";
12
12
  export class RangeCalendarRootState {
13
13
  opts;
14
- months = $state([]);
15
14
  visibleMonths = $derived.by(() => this.months.map((month) => month.value));
15
+ months = $state([]);
16
16
  announcer;
17
17
  formatter;
18
18
  accessibleHeadingId = useId();
19
19
  focusedValue = $state(undefined);
20
20
  lastPressedDateValue = undefined;
21
21
  domContext;
22
+ /**
23
+ * This derived state holds an array of localized day names for the current
24
+ * locale and calendar view. It dynamically syncs with the 'weekStartsOn' option,
25
+ * updating its content when the option changes. Using this state to render the
26
+ * calendar's days of the week is strongly recommended, as it guarantees that
27
+ * the days are correctly formatted for the current locale and calendar view.
28
+ */
29
+ weekdays = $derived.by(() => {
30
+ return getWeekdays({
31
+ months: this.months,
32
+ formatter: this.formatter,
33
+ weekdayFormat: this.opts.weekdayFormat.current,
34
+ });
35
+ });
36
+ isStartInvalid = $derived.by(() => {
37
+ if (!this.opts.startValue.current)
38
+ return false;
39
+ return (this.isDateUnavailable(this.opts.startValue.current) ||
40
+ this.isDateDisabled(this.opts.startValue.current));
41
+ });
42
+ isEndInvalid = $derived.by(() => {
43
+ if (!this.opts.endValue.current)
44
+ return false;
45
+ return (this.isDateUnavailable(this.opts.endValue.current) ||
46
+ this.isDateDisabled(this.opts.endValue.current));
47
+ });
48
+ isInvalid = $derived.by(() => {
49
+ if (this.isStartInvalid || this.isEndInvalid)
50
+ return true;
51
+ if (this.opts.endValue.current &&
52
+ this.opts.startValue.current &&
53
+ isBefore(this.opts.endValue.current, this.opts.startValue.current))
54
+ return true;
55
+ return false;
56
+ });
57
+ isNextButtonDisabled = $derived.by(() => {
58
+ return getIsNextButtonDisabled({
59
+ maxValue: this.opts.maxValue.current,
60
+ months: this.months,
61
+ disabled: this.opts.disabled.current,
62
+ });
63
+ });
64
+ isPrevButtonDisabled = $derived.by(() => {
65
+ return getIsPrevButtonDisabled({
66
+ minValue: this.opts.minValue.current,
67
+ months: this.months,
68
+ disabled: this.opts.disabled.current,
69
+ });
70
+ });
71
+ headingValue = $derived.by(() => {
72
+ return getCalendarHeadingValue({
73
+ months: this.months,
74
+ formatter: this.formatter,
75
+ locale: this.opts.locale.current,
76
+ });
77
+ });
78
+ fullCalendarLabel = $derived.by(() => `${this.opts.calendarLabel.current} ${this.headingValue}`);
79
+ highlightedRange = $derived.by(() => {
80
+ if (this.opts.startValue.current && this.opts.endValue.current)
81
+ return null;
82
+ if (!this.opts.startValue.current || !this.focusedValue)
83
+ return null;
84
+ const isStartBeforeFocused = isBefore(this.opts.startValue.current, this.focusedValue);
85
+ const start = isStartBeforeFocused ? this.opts.startValue.current : this.focusedValue;
86
+ const end = isStartBeforeFocused ? this.focusedValue : this.opts.startValue.current;
87
+ const range = { start, end };
88
+ if (isSameDay(start.add({ days: 1 }), end) || isSameDay(start, end)) {
89
+ return range;
90
+ }
91
+ const isValid = areAllDaysBetweenValid(start, end, this.isDateUnavailable, this.isDateDisabled);
92
+ if (isValid)
93
+ return range;
94
+ return null;
95
+ });
22
96
  constructor(opts) {
23
97
  this.opts = opts;
24
98
  this.domContext = new DOMContext(opts.ref);
@@ -173,20 +247,6 @@ export class RangeCalendarRootState {
173
247
  setMonths = (months) => {
174
248
  this.months = months;
175
249
  };
176
- /**
177
- * This derived state holds an array of localized day names for the current
178
- * locale and calendar view. It dynamically syncs with the 'weekStartsOn' option,
179
- * updating its content when the option changes. Using this state to render the
180
- * calendar's days of the week is strongly recommended, as it guarantees that
181
- * the days are correctly formatted for the current locale and calendar view.
182
- */
183
- weekdays = $derived.by(() => {
184
- return getWeekdays({
185
- months: this.months,
186
- formatter: this.formatter,
187
- weekdayFormat: this.opts.weekdayFormat.current,
188
- });
189
- });
190
250
  isOutsideVisibleMonths(date) {
191
251
  return !this.visibleMonths.some((month) => isSameMonth(date, month));
192
252
  }
@@ -206,49 +266,6 @@ export class RangeCalendarRootState {
206
266
  return true;
207
267
  return false;
208
268
  }
209
- isStartInvalid = $derived.by(() => {
210
- if (!this.opts.startValue.current)
211
- return false;
212
- return (this.isDateUnavailable(this.opts.startValue.current) ||
213
- this.isDateDisabled(this.opts.startValue.current));
214
- });
215
- isEndInvalid = $derived.by(() => {
216
- if (!this.opts.endValue.current)
217
- return false;
218
- return (this.isDateUnavailable(this.opts.endValue.current) ||
219
- this.isDateDisabled(this.opts.endValue.current));
220
- });
221
- isInvalid = $derived.by(() => {
222
- if (this.isStartInvalid || this.isEndInvalid)
223
- return true;
224
- if (this.opts.endValue.current &&
225
- this.opts.startValue.current &&
226
- isBefore(this.opts.endValue.current, this.opts.startValue.current))
227
- return true;
228
- return false;
229
- });
230
- isNextButtonDisabled = $derived.by(() => {
231
- return getIsNextButtonDisabled({
232
- maxValue: this.opts.maxValue.current,
233
- months: this.months,
234
- disabled: this.opts.disabled.current,
235
- });
236
- });
237
- isPrevButtonDisabled = $derived.by(() => {
238
- return getIsPrevButtonDisabled({
239
- minValue: this.opts.minValue.current,
240
- months: this.months,
241
- disabled: this.opts.disabled.current,
242
- });
243
- });
244
- headingValue = $derived.by(() => {
245
- return getCalendarHeadingValue({
246
- months: this.months,
247
- formatter: this.formatter,
248
- locale: this.opts.locale.current,
249
- });
250
- });
251
- fullCalendarLabel = $derived.by(() => `${this.opts.calendarLabel.current} ${this.headingValue}`);
252
269
  isSelectionStart(date) {
253
270
  if (!this.opts.startValue.current)
254
271
  return false;
@@ -269,23 +286,6 @@ export class RangeCalendarRootState {
269
286
  }
270
287
  return false;
271
288
  }
272
- highlightedRange = $derived.by(() => {
273
- if (this.opts.startValue.current && this.opts.endValue.current)
274
- return null;
275
- if (!this.opts.startValue.current || !this.focusedValue)
276
- return null;
277
- const isStartBeforeFocused = isBefore(this.opts.startValue.current, this.focusedValue);
278
- const start = isStartBeforeFocused ? this.opts.startValue.current : this.focusedValue;
279
- const end = isStartBeforeFocused ? this.focusedValue : this.opts.startValue.current;
280
- const range = { start, end };
281
- if (isSameDay(start.add({ days: 1 }), end) || isSameDay(start, end)) {
282
- return range;
283
- }
284
- const isValid = areAllDaysBetweenValid(start, end, this.isDateUnavailable, this.isDateDisabled);
285
- if (isValid)
286
- return range;
287
- return null;
288
- });
289
289
  shiftFocus(node, add) {
290
290
  return shiftCalendarFocus({
291
291
  node,
@@ -403,9 +403,9 @@ export class RangeCalendarRootState {
403
403
  setMonth(month) {
404
404
  this.opts.placeholder.current = this.opts.placeholder.current.set({ month });
405
405
  }
406
- getBitsAttr(part) {
407
- return `data-range-calendar-${part}`;
408
- }
406
+ getBitsAttr = (part) => {
407
+ return calendarAttrs.getAttr(part, "range-calendar");
408
+ };
409
409
  snippetProps = $derived.by(() => ({
410
410
  months: this.months,
411
411
  weekdays: this.weekdays,
@@ -65,7 +65,6 @@ declare class RatingGroupRootState {
65
65
  readonly "data-readonly": "" | undefined;
66
66
  readonly "data-orientation": Orientation;
67
67
  readonly tabindex: 0 | -1;
68
- readonly "data-rating-group-root": "";
69
68
  readonly onkeydown: (e: BitsKeyboardEvent) => void;
70
69
  readonly onpointerleave: () => void;
71
70
  };
@@ -92,7 +91,6 @@ declare class RatingGroupItemState {
92
91
  readonly "data-disabled": "" | undefined;
93
92
  readonly "data-readonly": "" | undefined;
94
93
  readonly "data-state": RatingGroupItemStateType;
95
- readonly "data-rating-group-item": "";
96
94
  readonly onclick: (e: BitsMouseEvent) => void;
97
95
  readonly onpointermove: (e: BitsPointerEvent) => void;
98
96
  };