bits-ui 2.9.7 → 2.9.9
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/app.d.ts +1 -0
- package/dist/bits/accordion/components/accordion.svelte +1 -1
- package/dist/bits/calendar/components/calendar.svelte +1 -1
- package/dist/bits/command/compute-command-score.js +1 -1
- package/dist/bits/date-field/components/date-field.svelte +12 -5
- package/dist/bits/date-field/date-field.svelte.js +18 -12
- package/dist/bits/menu/menu.svelte.d.ts +3 -1
- package/dist/bits/menu/menu.svelte.js +12 -0
- package/dist/bits/pin-input/pin-input.svelte.js +1 -1
- package/dist/bits/scroll-area/components/scroll-area-scrollbar-x.svelte +1 -1
- package/dist/bits/scroll-area/components/scroll-area-scrollbar-y.svelte +1 -1
- package/dist/bits/select/components/select.svelte +1 -1
- package/dist/bits/time-field/time-field.svelte.js +1 -1
- package/dist/bits/utilities/dismissible-layer/use-dismissable-layer.svelte.js +2 -2
- package/dist/internal/date-time/calendar-helpers.svelte.js +2 -2
- package/dist/internal/debounce.js +1 -1
- package/dist/internal/focus.js +1 -1
- package/dist/shared/css.d.ts +1 -2
- package/package.json +7 -7
package/dist/app.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// oxlint-disable no-var
|
|
1
2
|
import type { ReadableBox } from "svelte-toolbelt";
|
|
2
3
|
import type { DismissibleLayerState } from "./bits/utilities/dismissible-layer/use-dismissable-layer.svelte.ts";
|
|
3
4
|
import type { InteractOutsideBehaviorType } from "./bits/utilities/dismissible-layer/types.ts";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { watch } from "runed";
|
|
3
3
|
import { box } from "svelte-toolbelt";
|
|
4
|
-
import type { DateValue } from "@internationalized/date";
|
|
5
4
|
import { DateFieldRootState } from "../date-field.svelte.js";
|
|
6
5
|
import type { DateFieldRootProps } from "../types.js";
|
|
7
6
|
import { noop } from "../../../internal/noop.js";
|
|
@@ -29,15 +28,19 @@
|
|
|
29
28
|
children,
|
|
30
29
|
}: DateFieldRootProps = $props();
|
|
31
30
|
|
|
32
|
-
function handleDefaultPlaceholder() {
|
|
33
|
-
if (placeholder !== undefined) return;
|
|
31
|
+
function handleDefaultPlaceholder(setPlaceholder = true) {
|
|
32
|
+
if (placeholder !== undefined) return placeholder;
|
|
34
33
|
|
|
35
34
|
const defaultPlaceholder = getDefaultDate({
|
|
36
35
|
granularity,
|
|
37
36
|
defaultValue: value,
|
|
38
37
|
});
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
if (setPlaceholder) {
|
|
40
|
+
placeholder = defaultPlaceholder;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return defaultPlaceholder;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
// SSR
|
|
@@ -64,8 +67,12 @@
|
|
|
64
67
|
}
|
|
65
68
|
),
|
|
66
69
|
placeholder: box.with(
|
|
67
|
-
() =>
|
|
70
|
+
() => {
|
|
71
|
+
if (placeholder === undefined) return handleDefaultPlaceholder(false);
|
|
72
|
+
return placeholder;
|
|
73
|
+
},
|
|
68
74
|
(v) => {
|
|
75
|
+
if (v === undefined) return;
|
|
69
76
|
placeholder = v;
|
|
70
77
|
onPlaceholderChange(v);
|
|
71
78
|
}
|
|
@@ -33,7 +33,11 @@ const SEGMENT_CONFIGS = {
|
|
|
33
33
|
max: 12,
|
|
34
34
|
cycle: 1,
|
|
35
35
|
padZero: true,
|
|
36
|
-
getAnnouncement: (month, root) =>
|
|
36
|
+
getAnnouncement: (month, root) => {
|
|
37
|
+
if (!root.placeholder.current)
|
|
38
|
+
return "";
|
|
39
|
+
return `${month} - ${root.formatter.fullMonth(toDate(root.placeholder.current.set({ month })))}`;
|
|
40
|
+
},
|
|
37
41
|
},
|
|
38
42
|
year: {
|
|
39
43
|
min: 1,
|
|
@@ -384,16 +388,18 @@ export class DateFieldRootState {
|
|
|
384
388
|
const inferred = inferGranularity(this.placeholder.current, this.granularity.current);
|
|
385
389
|
return inferred;
|
|
386
390
|
});
|
|
387
|
-
dateRef = $derived.by(() => this.value.current
|
|
388
|
-
allSegmentContent = $derived.by(() =>
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
391
|
+
dateRef = $derived.by(() => this.value.current !== undefined ? this.value.current : this.placeholder.current);
|
|
392
|
+
allSegmentContent = $derived.by(() => {
|
|
393
|
+
return createContent({
|
|
394
|
+
segmentValues: this.segmentValues,
|
|
395
|
+
formatter: this.formatter,
|
|
396
|
+
locale: this.locale.current,
|
|
397
|
+
granularity: this.inferredGranularity,
|
|
398
|
+
dateRef: this.dateRef,
|
|
399
|
+
hideTimeZone: this.hideTimeZone.current,
|
|
400
|
+
hourCycle: this.hourCycle.current,
|
|
401
|
+
});
|
|
402
|
+
});
|
|
397
403
|
segmentContents = $derived.by(() => this.allSegmentContent.arr);
|
|
398
404
|
sharedSegmentAttrs = {
|
|
399
405
|
role: "spinbutton",
|
|
@@ -1055,7 +1061,7 @@ class DateFieldHourSegmentState extends BaseNumericSegmentState {
|
|
|
1055
1061
|
// Add special handling for hour display with dayPeriod
|
|
1056
1062
|
if (isNumberString(e.key)) {
|
|
1057
1063
|
const oldUpdateSegment = this.root.updateSegment.bind(this.root);
|
|
1058
|
-
//
|
|
1064
|
+
// oxlint-disable-next-line no-explicit-any
|
|
1059
1065
|
this.root.updateSegment = (part, cb) => {
|
|
1060
1066
|
const result = oldUpdateSegment(part, cb);
|
|
1061
1067
|
// After updating hour, check if we need to display "12" instead of "0"
|
|
@@ -4,7 +4,7 @@ import { CustomEventDispatcher } from "../../internal/events.js";
|
|
|
4
4
|
import type { AnyFn, BitsFocusEvent, BitsKeyboardEvent, BitsMouseEvent, BitsPointerEvent, OnChangeFn, RefAttachment, WithRefOpts } from "../../internal/types.js";
|
|
5
5
|
import type { Direction } from "../../shared/index.js";
|
|
6
6
|
import { IsUsingKeyboard } from "../../index.js";
|
|
7
|
-
import type { KeyboardEventHandler, PointerEventHandler } from "svelte/elements";
|
|
7
|
+
import type { KeyboardEventHandler, PointerEventHandler, MouseEventHandler } from "svelte/elements";
|
|
8
8
|
import { RovingFocusGroup } from "../../internal/roving-focus-group.js";
|
|
9
9
|
export declare const CONTEXT_MENU_TRIGGER_ATTR = "data-context-menu-trigger";
|
|
10
10
|
export declare const MenuCheckboxGroupContext: Context<MenuCheckboxGroupState>;
|
|
@@ -346,6 +346,7 @@ export declare class DropdownMenuTriggerState {
|
|
|
346
346
|
readonly parentMenu: MenuMenuState;
|
|
347
347
|
readonly attachment: RefAttachment;
|
|
348
348
|
constructor(opts: DropdownMenuTriggerStateOpts, parentMenu: MenuMenuState);
|
|
349
|
+
onclick: MouseEventHandler<HTMLElement>;
|
|
349
350
|
onpointerdown: PointerEventHandler<HTMLElement>;
|
|
350
351
|
onpointerup: PointerEventHandler<HTMLElement>;
|
|
351
352
|
onkeydown: KeyboardEventHandler<HTMLElement>;
|
|
@@ -357,6 +358,7 @@ export declare class DropdownMenuTriggerState {
|
|
|
357
358
|
readonly "aria-controls": string | undefined;
|
|
358
359
|
readonly "data-disabled": "" | undefined;
|
|
359
360
|
readonly "data-state": "open" | "closed";
|
|
361
|
+
readonly onclick: MouseEventHandler<HTMLElement>;
|
|
360
362
|
readonly onpointerdown: PointerEventHandler<HTMLElement>;
|
|
361
363
|
readonly onpointerup: PointerEventHandler<HTMLElement>;
|
|
362
364
|
readonly onkeydown: KeyboardEventHandler<HTMLElement>;
|
|
@@ -768,6 +768,17 @@ export class DropdownMenuTriggerState {
|
|
|
768
768
|
this.parentMenu = parentMenu;
|
|
769
769
|
this.attachment = attachRef(this.opts.ref, (v) => (this.parentMenu.triggerNode = v));
|
|
770
770
|
}
|
|
771
|
+
onclick = (e) => {
|
|
772
|
+
/**
|
|
773
|
+
* MacOS VoiceOver sends a click in Safari/Firefox bypassing the keydown event
|
|
774
|
+
* when V0+Space is pressed. Since we already handle the keydown event and the
|
|
775
|
+
* pointerdown events separately, we ignore it if the detail is not 0.
|
|
776
|
+
*/
|
|
777
|
+
if (this.opts.disabled.current || e.detail !== 0)
|
|
778
|
+
return;
|
|
779
|
+
this.parentMenu.toggleOpen();
|
|
780
|
+
e.preventDefault();
|
|
781
|
+
};
|
|
771
782
|
onpointerdown = (e) => {
|
|
772
783
|
if (this.opts.disabled.current)
|
|
773
784
|
return;
|
|
@@ -817,6 +828,7 @@ export class DropdownMenuTriggerState {
|
|
|
817
828
|
"data-state": getDataOpenClosed(this.parentMenu.opts.open.current),
|
|
818
829
|
[this.parentMenu.root.getBitsAttr("trigger")]: "",
|
|
819
830
|
//
|
|
831
|
+
onclick: this.onclick,
|
|
820
832
|
onpointerdown: this.onpointerdown,
|
|
821
833
|
onpointerup: this.onpointerup,
|
|
822
834
|
onkeydown: this.onkeydown,
|
|
@@ -413,7 +413,7 @@ export class PinInputCellState {
|
|
|
413
413
|
...this.attachment,
|
|
414
414
|
}));
|
|
415
415
|
}
|
|
416
|
-
//
|
|
416
|
+
// oxlint-disable-next-line no-explicit-any
|
|
417
417
|
export function syncTimeouts(cb, domContext) {
|
|
418
418
|
const t1 = domContext.setTimeout(cb, 0); // For faster machines
|
|
419
419
|
const t2 = domContext.setTimeout(cb, 1_0);
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
const scrollbarXState = ScrollAreaScrollbarXState.create({
|
|
13
13
|
mounted: box.with(() => isMounted.current),
|
|
14
14
|
});
|
|
15
|
-
//
|
|
15
|
+
// oxlint-disable-next-line no-explicit-any
|
|
16
16
|
const mergedProps = $derived(mergeProps(restProps, scrollbarXState.props)) as any;
|
|
17
17
|
</script>
|
|
18
18
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
mounted: box.with(() => isMounted.current),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
//
|
|
16
|
+
// oxlint-disable-next-line no-explicit-any
|
|
17
17
|
const mergedProps = $derived(mergeProps(restProps, scrollbarYState.props)) as any;
|
|
18
18
|
</script>
|
|
19
19
|
|
|
@@ -796,7 +796,7 @@ class TimeFieldHourSegmentState extends BaseTimeSegmentState {
|
|
|
796
796
|
onkeydown(e) {
|
|
797
797
|
if (isNumberString(e.key)) {
|
|
798
798
|
const oldUpdateSegment = this.root.updateSegment.bind(this.root);
|
|
799
|
-
//
|
|
799
|
+
// oxlint-disable-next-line no-explicit-any
|
|
800
800
|
this.root.updateSegment = (part, cb) => {
|
|
801
801
|
const result = oldUpdateSegment(part, cb);
|
|
802
802
|
// after updating hour, check if we need to display "12" instead of "0"
|
|
@@ -227,10 +227,10 @@ function createWrappedEvent(e) {
|
|
|
227
227
|
return isPrevented;
|
|
228
228
|
}
|
|
229
229
|
if (prop in target) {
|
|
230
|
-
//
|
|
230
|
+
// oxlint-disable-next-line no-explicit-any
|
|
231
231
|
return target[prop];
|
|
232
232
|
}
|
|
233
|
-
//
|
|
233
|
+
// oxlint-disable-next-line no-explicit-any
|
|
234
234
|
return e[prop];
|
|
235
235
|
},
|
|
236
236
|
});
|
|
@@ -227,7 +227,7 @@ export function handleCalendarKeydown({ event, handleCellClick, shiftFocus, plac
|
|
|
227
227
|
const currentCell = event.target;
|
|
228
228
|
if (!isCalendarDayNode(currentCell))
|
|
229
229
|
return;
|
|
230
|
-
//
|
|
230
|
+
// oxlint-disable-next-line no-explicit-any
|
|
231
231
|
if (!ARROW_KEYS.includes(event.key) && !SELECT_KEYS.includes(event.key))
|
|
232
232
|
return;
|
|
233
233
|
event.preventDefault();
|
|
@@ -237,7 +237,7 @@ export function handleCalendarKeydown({ event, handleCellClick, shiftFocus, plac
|
|
|
237
237
|
[kbd.ARROW_LEFT]: -1,
|
|
238
238
|
[kbd.ARROW_RIGHT]: 1,
|
|
239
239
|
};
|
|
240
|
-
//
|
|
240
|
+
// oxlint-disable-next-line no-explicit-any
|
|
241
241
|
if (ARROW_KEYS.includes(event.key)) {
|
|
242
242
|
const add = kbdFocusMap[event.key];
|
|
243
243
|
if (add !== undefined) {
|
package/dist/internal/focus.js
CHANGED
|
@@ -84,7 +84,7 @@ export function getTabbableCandidates(container) {
|
|
|
84
84
|
const nodes = [];
|
|
85
85
|
const doc = getDocument(container);
|
|
86
86
|
const walker = doc.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
87
|
-
//
|
|
87
|
+
// oxlint-disable-next-line no-explicit-any
|
|
88
88
|
acceptNode: (node) => {
|
|
89
89
|
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
90
90
|
if (node.disabled || node.hidden || isHiddenInput)
|
package/dist/shared/css.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
1
|
import type * as CSS from "csstype";
|
|
3
2
|
|
|
4
3
|
declare module "csstype" {
|
|
5
4
|
interface Properties {
|
|
6
5
|
// Allow any CSS Custom Properties
|
|
7
|
-
//
|
|
6
|
+
// oxlint-disable-next-line no-explicit-any
|
|
8
7
|
[index: `--${string}`]: any;
|
|
9
8
|
}
|
|
10
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bits-ui",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "github:huntabyte/bits-ui",
|
|
6
6
|
"funding": "https://github.com/sponsors/huntabyte",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@internationalized/date": "^3.8.2",
|
|
23
23
|
"@sveltejs/kit": "^2.31.0",
|
|
24
|
-
"@sveltejs/package": "
|
|
25
|
-
"@sveltejs/vite-plugin-svelte": "^6.
|
|
24
|
+
"@sveltejs/package": "2.5.0",
|
|
25
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.0",
|
|
26
26
|
"@types/node": "^20.19.0",
|
|
27
27
|
"@types/resize-observer-browser": "^0.1.11",
|
|
28
28
|
"csstype": "^3.1.3",
|
|
29
29
|
"jsdom": "^24.1.3",
|
|
30
30
|
"publint": "^0.2.12",
|
|
31
|
-
"svelte": "^5.38.
|
|
31
|
+
"svelte": "^5.38.10",
|
|
32
32
|
"svelte-check": "^4.3.1",
|
|
33
|
-
"typescript": "^5.
|
|
34
|
-
"vite": "^7.
|
|
35
|
-
"vitest": "^3.2.
|
|
33
|
+
"typescript": "^5.9.2",
|
|
34
|
+
"vite": "^7.1.5",
|
|
35
|
+
"vitest": "^3.2.4"
|
|
36
36
|
},
|
|
37
37
|
"svelte": "./dist/index.js",
|
|
38
38
|
"types": "./dist/index.d.ts",
|