bits-ui 1.1.0 → 1.2.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 (38) hide show
  1. package/dist/bits/context-menu/components/context-menu-content-static.svelte +2 -0
  2. package/dist/bits/context-menu/components/context-menu-content.svelte +2 -0
  3. package/dist/bits/date-range-field/date-range-field.svelte.d.ts +0 -7
  4. package/dist/bits/date-range-field/date-range-field.svelte.js +58 -52
  5. package/dist/bits/dialog/dialog.svelte.d.ts +1 -3
  6. package/dist/bits/dialog/dialog.svelte.js +0 -14
  7. package/dist/bits/dropdown-menu/components/dropdown-menu-content-static.svelte +2 -0
  8. package/dist/bits/dropdown-menu/components/dropdown-menu-content.svelte +2 -0
  9. package/dist/bits/link-preview/components/link-preview-content-static.svelte +7 -22
  10. package/dist/bits/link-preview/components/link-preview-content.svelte +7 -22
  11. package/dist/bits/link-preview/link-preview.svelte.d.ts +14 -1
  12. package/dist/bits/link-preview/link-preview.svelte.js +24 -0
  13. package/dist/bits/menu/components/menu-content-static.svelte +2 -0
  14. package/dist/bits/menu/components/menu-content.svelte +2 -0
  15. package/dist/bits/menu/menu.svelte.d.ts +3 -1
  16. package/dist/bits/menu/menu.svelte.js +3 -1
  17. package/dist/bits/menubar/components/menubar-content-static.svelte +1 -9
  18. package/dist/bits/menubar/components/menubar-content.svelte +1 -9
  19. package/dist/bits/menubar/menubar.svelte.d.ts +10 -4
  20. package/dist/bits/menubar/menubar.svelte.js +14 -12
  21. package/dist/bits/popover/components/popover-content-static.svelte +2 -7
  22. package/dist/bits/popover/components/popover-content.svelte +2 -6
  23. package/dist/bits/popover/popover.svelte.d.ts +8 -3
  24. package/dist/bits/popover/popover.svelte.js +11 -9
  25. package/dist/bits/progress/components/progress.svelte +2 -0
  26. package/dist/bits/progress/progress.svelte.d.ts +7 -5
  27. package/dist/bits/progress/progress.svelte.js +6 -5
  28. package/dist/bits/progress/types.d.ts +11 -2
  29. package/dist/bits/select/components/select-content-static.svelte +7 -30
  30. package/dist/bits/select/components/select-content.svelte +4 -27
  31. package/dist/bits/select/select.svelte.d.ts +17 -2
  32. package/dist/bits/select/select.svelte.js +30 -3
  33. package/dist/bits/select/types.d.ts +2 -2
  34. package/dist/bits/tooltip/components/tooltip-content-static.svelte +7 -23
  35. package/dist/bits/tooltip/components/tooltip-content.svelte +7 -22
  36. package/dist/bits/tooltip/tooltip.svelte.d.ts +14 -1
  37. package/dist/bits/tooltip/tooltip.svelte.js +31 -1
  38. package/package.json +1 -1
@@ -202,10 +202,6 @@ class MenubarContentState {
202
202
  this.menu = menu;
203
203
  this.root = menu.root;
204
204
  this.focusScopeContext = FocusScopeContext.get();
205
- this.onCloseAutoFocus = this.onCloseAutoFocus.bind(this);
206
- this.onFocusOutside = this.onFocusOutside.bind(this);
207
- this.onInteractOutside = this.onInteractOutside.bind(this);
208
- this.onOpenAutoFocus = this.onOpenAutoFocus.bind(this);
209
205
  this.onkeydown = this.onkeydown.bind(this);
210
206
  useRefById({
211
207
  ...opts,
@@ -215,7 +211,7 @@ class MenubarContentState {
215
211
  deps: () => this.menu.open,
216
212
  });
217
213
  }
218
- onCloseAutoFocus(e) {
214
+ onCloseAutoFocus = (e) => {
219
215
  this.opts.onCloseAutoFocus.current(e);
220
216
  if (e.defaultPrevented)
221
217
  return;
@@ -226,8 +222,8 @@ class MenubarContentState {
226
222
  }
227
223
  this.hasInteractedOutside = false;
228
224
  e.preventDefault();
229
- }
230
- onFocusOutside(e) {
225
+ };
226
+ onFocusOutside = (e) => {
231
227
  const target = e.target;
232
228
  const isMenubarTrigger = this.root
233
229
  .getTriggers()
@@ -235,17 +231,17 @@ class MenubarContentState {
235
231
  if (isMenubarTrigger)
236
232
  e.preventDefault();
237
233
  this.opts.onFocusOutside.current(e);
238
- }
239
- onInteractOutside(e) {
234
+ };
235
+ onInteractOutside = (e) => {
240
236
  this.hasInteractedOutside = true;
241
237
  this.opts.onInteractOutside.current(e);
242
- }
243
- onOpenAutoFocus(e) {
238
+ };
239
+ onOpenAutoFocus = (e) => {
244
240
  this.opts.onOpenAutoFocus.current(e);
245
241
  if (e.defaultPrevented)
246
242
  return;
247
243
  afterTick(() => this.opts.ref.current?.focus());
248
- }
244
+ };
249
245
  onkeydown(e) {
250
246
  if (e.key !== kbd.ARROW_LEFT && e.key !== kbd.ARROW_RIGHT)
251
247
  return;
@@ -290,6 +286,12 @@ class MenubarContentState {
290
286
  onkeydown: this.onkeydown,
291
287
  "data-menu-content": "",
292
288
  }));
289
+ popperProps = {
290
+ onCloseAutoFocus: this.onCloseAutoFocus,
291
+ onFocusOutside: this.onFocusOutside,
292
+ onInteractOutside: this.onInteractOutside,
293
+ onOpenAutoFocus: this.onOpenAutoFocus,
294
+ };
293
295
  }
294
296
  const MenubarRootContext = new Context("Menubar.Root");
295
297
  const MenubarMenuContext = new Context("Menubar.Menu");
@@ -19,7 +19,6 @@
19
19
  onInteractOutside = noop,
20
20
  trapFocus = true,
21
21
  preventScroll = false,
22
-
23
22
  ...restProps
24
23
  }: PopoverContentStaticProps = $props();
25
24
 
@@ -40,12 +39,10 @@
40
39
  {#if forceMount}
41
40
  <PopperLayerForceMount
42
41
  {...mergedProps}
42
+ {...contentState.popperProps}
43
43
  isStatic
44
44
  enabled={contentState.root.opts.open.current}
45
45
  {id}
46
- onInteractOutside={contentState.handleInteractOutside}
47
- onEscapeKeydown={contentState.handleEscapeKeydown}
48
- onCloseAutoFocus={contentState.handleCloseAutoFocus}
49
46
  {trapFocus}
50
47
  {preventScroll}
51
48
  loop
@@ -67,12 +64,10 @@
67
64
  {:else if !forceMount}
68
65
  <PopperLayer
69
66
  {...mergedProps}
67
+ {...contentState.popperProps}
70
68
  isStatic
71
69
  present={contentState.root.opts.open.current}
72
70
  {id}
73
- onInteractOutside={contentState.handleInteractOutside}
74
- onEscapeKeydown={contentState.handleEscapeKeydown}
75
- onCloseAutoFocus={contentState.handleCloseAutoFocus}
76
71
  {trapFocus}
77
72
  {preventScroll}
78
73
  loop
@@ -39,11 +39,9 @@
39
39
  {#if forceMount}
40
40
  <PopperLayerForceMount
41
41
  {...mergedProps}
42
+ {...contentState.popperProps}
42
43
  enabled={contentState.root.opts.open.current}
43
44
  {id}
44
- onInteractOutside={contentState.handleInteractOutside}
45
- onEscapeKeydown={contentState.handleEscapeKeydown}
46
- onCloseAutoFocus={contentState.handleCloseAutoFocus}
47
45
  {trapFocus}
48
46
  {preventScroll}
49
47
  loop
@@ -67,11 +65,9 @@
67
65
  {:else if !forceMount}
68
66
  <PopperLayer
69
67
  {...mergedProps}
68
+ {...contentState.popperProps}
70
69
  present={contentState.root.opts.open.current}
71
70
  {id}
72
- onInteractOutside={contentState.handleInteractOutside}
73
- onEscapeKeydown={contentState.handleEscapeKeydown}
74
- onCloseAutoFocus={contentState.handleCloseAutoFocus}
75
71
  {trapFocus}
76
72
  {preventScroll}
77
73
  loop
@@ -45,9 +45,9 @@ declare class PopoverContentState {
45
45
  readonly opts: PopoverContentStateProps;
46
46
  readonly root: PopoverRootState;
47
47
  constructor(opts: PopoverContentStateProps, root: PopoverRootState);
48
- handleInteractOutside(e: PointerEvent): void;
49
- handleEscapeKeydown(e: KeyboardEvent): void;
50
- handleCloseAutoFocus(e: Event): void;
48
+ onInteractOutside: (e: PointerEvent) => void;
49
+ onEscapeKeydown: (e: KeyboardEvent) => void;
50
+ onCloseAutoFocus: (e: Event) => void;
51
51
  snippetProps: {
52
52
  open: boolean;
53
53
  };
@@ -60,6 +60,11 @@ declare class PopoverContentState {
60
60
  readonly pointerEvents: "auto";
61
61
  };
62
62
  };
63
+ popperProps: {
64
+ onInteractOutside: (e: PointerEvent) => void;
65
+ onEscapeKeydown: (e: KeyboardEvent) => void;
66
+ onCloseAutoFocus: (e: Event) => void;
67
+ };
63
68
  }
64
69
  type PopoverCloseStateProps = WithRefProps;
65
70
  declare class PopoverCloseState {
@@ -92,11 +92,8 @@ class PopoverContentState {
92
92
  this.root.contentNode = node;
93
93
  },
94
94
  });
95
- this.handleInteractOutside = this.handleInteractOutside.bind(this);
96
- this.handleEscapeKeydown = this.handleEscapeKeydown.bind(this);
97
- this.handleCloseAutoFocus = this.handleCloseAutoFocus.bind(this);
98
95
  }
99
- handleInteractOutside(e) {
96
+ onInteractOutside = (e) => {
100
97
  this.opts.onInteractOutside.current(e);
101
98
  if (e.defaultPrevented)
102
99
  return;
@@ -106,20 +103,20 @@ class PopoverContentState {
106
103
  if (closestTrigger === this.root.triggerNode)
107
104
  return;
108
105
  this.root.handleClose();
109
- }
110
- handleEscapeKeydown(e) {
106
+ };
107
+ onEscapeKeydown = (e) => {
111
108
  this.opts.onEscapeKeydown.current(e);
112
109
  if (e.defaultPrevented)
113
110
  return;
114
111
  this.root.handleClose();
115
- }
116
- handleCloseAutoFocus(e) {
112
+ };
113
+ onCloseAutoFocus = (e) => {
117
114
  this.opts.onCloseAutoFocus.current(e);
118
115
  if (e.defaultPrevented)
119
116
  return;
120
117
  e.preventDefault();
121
118
  this.root.triggerNode?.focus();
122
- }
119
+ };
123
120
  snippetProps = $derived.by(() => ({ open: this.root.opts.open.current }));
124
121
  props = $derived.by(() => ({
125
122
  id: this.opts.id.current,
@@ -130,6 +127,11 @@ class PopoverContentState {
130
127
  pointerEvents: "auto",
131
128
  },
132
129
  }));
130
+ popperProps = {
131
+ onInteractOutside: this.onInteractOutside,
132
+ onEscapeKeydown: this.onEscapeKeydown,
133
+ onCloseAutoFocus: this.onCloseAutoFocus,
134
+ };
133
135
  }
134
136
  class PopoverCloseState {
135
137
  opts;
@@ -9,6 +9,7 @@
9
9
  children,
10
10
  value = 0,
11
11
  max = 100,
12
+ min = 0,
12
13
  id = useId(),
13
14
  ref = $bindable(null),
14
15
  ...restProps
@@ -17,6 +18,7 @@
17
18
  const rootState = useProgressRootState({
18
19
  value: box.with(() => value),
19
20
  max: box.with(() => max),
21
+ min: box.with(() => min),
20
22
  id: box.with(() => id),
21
23
  ref: box.with(
22
24
  () => ref,
@@ -3,20 +3,22 @@ import type { WithRefProps } from "../../internal/types.js";
3
3
  type ProgressRootStateProps = WithRefProps<ReadableBoxedValues<{
4
4
  value: number | null;
5
5
  max: number;
6
+ min: number;
6
7
  }>>;
7
8
  declare class ProgressRootState {
8
9
  readonly opts: ProgressRootStateProps;
9
10
  constructor(opts: ProgressRootStateProps);
10
11
  props: {
11
- readonly role: "meter";
12
+ readonly role: "progressbar";
12
13
  readonly value: number | null;
13
- readonly max: number;
14
- readonly "aria-valuemin": 0;
14
+ readonly "aria-valuemin": number;
15
15
  readonly "aria-valuemax": number;
16
- readonly "aria-valuenow": number | null;
17
- readonly "data-value": number | null;
16
+ readonly "aria-valuenow": number | undefined;
17
+ readonly "data-value": number | undefined;
18
18
  readonly "data-state": "indeterminate" | "loading" | "loaded";
19
19
  readonly "data-max": number;
20
+ readonly "data-min": number;
21
+ readonly "data-indeterminate": "" | undefined;
20
22
  readonly "data-progress-root": "";
21
23
  };
22
24
  }
@@ -7,15 +7,16 @@ class ProgressRootState {
7
7
  useRefById(opts);
8
8
  }
9
9
  props = $derived.by(() => ({
10
- role: "meter",
10
+ role: "progressbar",
11
11
  value: this.opts.value.current,
12
- max: this.opts.max.current,
13
- "aria-valuemin": 0,
12
+ "aria-valuemin": this.opts.min.current,
14
13
  "aria-valuemax": this.opts.max.current,
15
- "aria-valuenow": this.opts.value.current,
16
- "data-value": this.opts.value.current,
14
+ "aria-valuenow": this.opts.value.current === null ? undefined : this.opts.value.current,
15
+ "data-value": this.opts.value.current === null ? undefined : this.opts.value.current,
17
16
  "data-state": getProgressDataState(this.opts.value.current, this.opts.max.current),
18
17
  "data-max": this.opts.max.current,
18
+ "data-min": this.opts.min.current,
19
+ "data-indeterminate": this.opts.value.current === null ? "" : undefined,
19
20
  [ROOT_ATTR]: "",
20
21
  }));
21
22
  }
@@ -4,12 +4,21 @@ export type ProgressRootPropsWithoutHTML = WithChild<{
4
4
  /**
5
5
  * The current value of the progress bar.
6
6
  * If `null`, the progress bar will be in an indeterminate state.
7
+ *
8
+ * @default 0
7
9
  */
8
10
  value?: number | null;
9
11
  /**
10
- * The maximum value of the progress bar. Used to calculate the percentage
11
- * of the progress bar along with the `value` prop.
12
+ * The maximum value of the progress bar.
13
+ *
14
+ * @default 100
12
15
  */
13
16
  max?: number;
17
+ /**
18
+ * The minimum value of the progress bar.
19
+ *
20
+ * @default 0
21
+ */
22
+ min?: number;
14
23
  }>;
15
24
  export type ProgressRootProps = ProgressRootPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, ProgressRootPropsWithoutHTML>;
@@ -15,6 +15,7 @@
15
15
  onEscapeKeydown = noop,
16
16
  children,
17
17
  child,
18
+ preventScroll = false,
18
19
  ...restProps
19
20
  }: SelectContentStaticProps = $props();
20
21
 
@@ -24,39 +25,21 @@
24
25
  () => ref,
25
26
  (v) => (ref = v)
26
27
  ),
28
+ onInteractOutside: box.with(() => onInteractOutside),
29
+ onEscapeKeydown: box.with(() => onEscapeKeydown),
27
30
  });
28
31
 
29
32
  const mergedProps = $derived(mergeProps(restProps, contentState.props));
30
-
31
- function handleInteractOutside(e: PointerEvent) {
32
- contentState.handleInteractOutside(e);
33
- if (e.defaultPrevented) return;
34
- onInteractOutside(e);
35
- if (e.defaultPrevented) return;
36
- contentState.root.handleClose();
37
- }
38
-
39
- function handleEscapeKeydown(e: KeyboardEvent) {
40
- onEscapeKeydown(e);
41
- if (e.defaultPrevented) return;
42
- contentState.root.handleClose();
43
- }
44
33
  </script>
45
34
 
46
35
  {#if forceMount}
47
36
  <PopperLayerForceMount
48
37
  {...mergedProps}
38
+ {...contentState.popperProps}
49
39
  isStatic
50
40
  enabled={contentState.root.opts.open.current}
51
41
  {id}
52
- onInteractOutside={handleInteractOutside}
53
- onEscapeKeydown={handleEscapeKeydown}
54
- onOpenAutoFocus={(e) => e.preventDefault()}
55
- onCloseAutoFocus={(e) => e.preventDefault()}
56
- trapFocus={false}
57
- loop={false}
58
- preventScroll={false}
59
- onPlaced={() => (contentState.isPositioned = true)}
42
+ {preventScroll}
60
43
  forceMount={true}
61
44
  >
62
45
  {#snippet popper({ props })}
@@ -73,17 +56,11 @@
73
56
  {:else if !forceMount}
74
57
  <PopperLayer
75
58
  {...mergedProps}
59
+ {...contentState.popperProps}
76
60
  isStatic
77
61
  present={contentState.root.opts.open.current}
78
62
  {id}
79
- onInteractOutside={handleInteractOutside}
80
- onEscapeKeydown={handleEscapeKeydown}
81
- onOpenAutoFocus={(e) => e.preventDefault()}
82
- onCloseAutoFocus={(e) => e.preventDefault()}
83
- trapFocus={false}
84
- loop={false}
85
- preventScroll={false}
86
- onPlaced={() => (contentState.isPositioned = true)}
63
+ {preventScroll}
87
64
  forceMount={false}
88
65
  >
89
66
  {#snippet popper({ props })}
@@ -26,37 +26,20 @@
26
26
  () => ref,
27
27
  (v) => (ref = v)
28
28
  ),
29
+ onInteractOutside: box.with(() => onInteractOutside),
30
+ onEscapeKeydown: box.with(() => onEscapeKeydown),
29
31
  });
30
32
 
31
33
  const mergedProps = $derived(mergeProps(restProps, contentState.props));
32
-
33
- function handleInteractOutside(e: PointerEvent) {
34
- contentState.handleInteractOutside(e);
35
- if (e.defaultPrevented) return;
36
- onInteractOutside(e);
37
- if (e.defaultPrevented) return;
38
- contentState.root.handleClose();
39
- }
40
-
41
- function handleEscapeKeydown(e: KeyboardEvent) {
42
- onEscapeKeydown(e);
43
- if (e.defaultPrevented) return;
44
- contentState.root.handleClose();
45
- }
46
34
  </script>
47
35
 
48
36
  {#if forceMount}
49
37
  <PopperLayerForceMount
50
38
  {...mergedProps}
39
+ {...contentState.popperProps}
51
40
  {side}
52
41
  enabled={contentState.root.opts.open.current}
53
42
  {id}
54
- onInteractOutside={handleInteractOutside}
55
- onEscapeKeydown={handleEscapeKeydown}
56
- onOpenAutoFocus={(e) => e.preventDefault()}
57
- onCloseAutoFocus={(e) => e.preventDefault()}
58
- trapFocus={false}
59
- loop={false}
60
43
  {preventScroll}
61
44
  onPlaced={() => (contentState.isPositioned = true)}
62
45
  forceMount={true}
@@ -77,17 +60,11 @@
77
60
  {:else if !forceMount}
78
61
  <PopperLayer
79
62
  {...mergedProps}
63
+ {...contentState.popperProps}
80
64
  {side}
81
65
  present={contentState.root.opts.open.current}
82
66
  {id}
83
- onInteractOutside={handleInteractOutside}
84
- onEscapeKeydown={handleEscapeKeydown}
85
- onOpenAutoFocus={(e) => e.preventDefault()}
86
- onCloseAutoFocus={(e) => e.preventDefault()}
87
- trapFocus={false}
88
- loop={false}
89
67
  {preventScroll}
90
- onPlaced={() => (contentState.isPositioned = true)}
91
68
  forceMount={false}
92
69
  >
93
70
  {#snippet popper({ props, wrapperProps })}
@@ -151,7 +151,10 @@ declare class SelectTriggerState {
151
151
  readonly onpointerup: (e: BitsPointerEvent) => void;
152
152
  };
153
153
  }
154
- type SelectContentStateProps = WithRefProps;
154
+ type SelectContentStateProps = WithRefProps & ReadableBoxedValues<{
155
+ onInteractOutside: (e: PointerEvent) => void;
156
+ onEscapeKeydown: (e: KeyboardEvent) => void;
157
+ }>;
155
158
  declare class SelectContentState {
156
159
  #private;
157
160
  readonly opts: SelectContentStateProps;
@@ -160,7 +163,10 @@ declare class SelectContentState {
160
163
  isPositioned: boolean;
161
164
  constructor(opts: SelectContentStateProps, root: SelectRootState);
162
165
  onpointermove(_: BitsPointerEvent): void;
163
- handleInteractOutside(e: PointerEvent): void;
166
+ onInteractOutside: (e: PointerEvent) => void;
167
+ onEscapeKeydown: (e: KeyboardEvent) => void;
168
+ onOpenAutoFocus: (e: Event) => void;
169
+ onCloseAutoFocus: (e: Event) => void;
164
170
  snippetProps: {
165
171
  open: boolean;
166
172
  };
@@ -184,6 +190,15 @@ declare class SelectContentState {
184
190
  };
185
191
  readonly onpointermove: (_: BitsPointerEvent) => void;
186
192
  };
193
+ popperProps: {
194
+ onInteractOutside: (e: PointerEvent) => void;
195
+ onEscapeKeydown: (e: KeyboardEvent) => void;
196
+ onOpenAutoFocus: (e: Event) => void;
197
+ onCloseAutoFocus: (e: Event) => void;
198
+ trapFocus: boolean;
199
+ loop: boolean;
200
+ onPlaced: () => void;
201
+ };
187
202
  }
188
203
  type SelectItemStateProps = WithRefProps<ReadableBoxedValues<{
189
204
  value: string;
@@ -618,7 +618,6 @@ class SelectContentState {
618
618
  this.isPositioned = false;
619
619
  });
620
620
  this.onpointermove = this.onpointermove.bind(this);
621
- this.handleInteractOutside = this.handleInteractOutside.bind(this);
622
621
  }
623
622
  onpointermove(_) {
624
623
  this.root.isUsingKeyboard = false;
@@ -633,11 +632,28 @@ class SelectContentState {
633
632
  [`${prefix}-anchor-height`]: "var(--bits-floating-anchor-height)",
634
633
  };
635
634
  });
636
- handleInteractOutside(e) {
635
+ onInteractOutside = (e) => {
637
636
  if (e.target === this.root.triggerNode || e.target === this.root.inputNode) {
638
637
  e.preventDefault();
638
+ return;
639
639
  }
640
- }
640
+ this.opts.onInteractOutside.current(e);
641
+ if (e.defaultPrevented)
642
+ return;
643
+ this.root.handleClose();
644
+ };
645
+ onEscapeKeydown = (e) => {
646
+ this.opts.onEscapeKeydown.current(e);
647
+ if (e.defaultPrevented)
648
+ return;
649
+ this.root.handleClose();
650
+ };
651
+ onOpenAutoFocus = (e) => {
652
+ e.preventDefault();
653
+ };
654
+ onCloseAutoFocus = (e) => {
655
+ e.preventDefault();
656
+ };
641
657
  snippetProps = $derived.by(() => ({ open: this.root.opts.open.current }));
642
658
  props = $derived.by(() => ({
643
659
  id: this.opts.id.current,
@@ -654,6 +670,17 @@ class SelectContentState {
654
670
  },
655
671
  onpointermove: this.onpointermove,
656
672
  }));
673
+ popperProps = {
674
+ onInteractOutside: this.onInteractOutside,
675
+ onEscapeKeydown: this.onEscapeKeydown,
676
+ onOpenAutoFocus: this.onOpenAutoFocus,
677
+ onCloseAutoFocus: this.onCloseAutoFocus,
678
+ trapFocus: false,
679
+ loop: false,
680
+ onPlaced: () => {
681
+ this.isPositioned = true;
682
+ },
683
+ };
657
684
  }
658
685
  class SelectItemState {
659
686
  opts;
@@ -123,9 +123,9 @@ export type _SharedSelectContentProps = {
123
123
  */
124
124
  loop?: boolean;
125
125
  };
126
- export type SelectContentPropsWithoutHTML = Expand<WithChildNoChildrenSnippetProps<Omit<PopperLayerProps, "content" | "onOpenAutoFocus" | "trapFocus"> & _SharedSelectContentProps, FloatingContentSnippetProps>>;
126
+ export type SelectContentPropsWithoutHTML = Expand<WithChildNoChildrenSnippetProps<Omit<PopperLayerProps, "content" | "onOpenAutoFocus" | "trapFocus" | "onCloseAutoFocus"> & _SharedSelectContentProps, FloatingContentSnippetProps>>;
127
127
  export type SelectContentProps = SelectContentPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, SelectContentPropsWithoutHTML>;
128
- export type SelectContentStaticPropsWithoutHTML = Expand<WithChildNoChildrenSnippetProps<Omit<PopperLayerStaticProps, "content" | "onOpenAutoFocus" | "trapFocus"> & _SharedSelectContentProps, StaticContentSnippetProps>>;
128
+ export type SelectContentStaticPropsWithoutHTML = Expand<WithChildNoChildrenSnippetProps<Omit<PopperLayerStaticProps, "content" | "onOpenAutoFocus" | "onCloseAutoFocus" | "trapFocus"> & _SharedSelectContentProps, StaticContentSnippetProps>>;
129
129
  export type SelectContentStaticProps = SelectContentStaticPropsWithoutHTML & Without<BitsPrimitiveDivAttributes, SelectContentStaticPropsWithoutHTML>;
130
130
  export type SelectTriggerPropsWithoutHTML = WithChild;
131
131
  export type SelectTriggerProps = SelectTriggerPropsWithoutHTML & Without<BitsPrimitiveButtonAttributes, SelectTriggerPropsWithoutHTML>;
@@ -6,15 +6,15 @@
6
6
  import PopperLayer from "../../utilities/popper-layer/popper-layer.svelte";
7
7
  import { getFloatingContentCSSVars } from "../../../internal/floating-svelte/floating-utils.svelte.js";
8
8
  import PopperLayerForceMount from "../../utilities/popper-layer/popper-layer-force-mount.svelte";
9
+ import { noop } from "../../../internal/noop.js";
9
10
 
10
11
  let {
11
12
  children,
12
13
  child,
13
14
  id = useId(),
14
15
  ref = $bindable(null),
15
-
16
- onInteractOutside,
17
- onEscapeKeydown,
16
+ onInteractOutside = noop,
17
+ onEscapeKeydown = noop,
18
18
  forceMount = false,
19
19
  ...restProps
20
20
  }: TooltipContentStaticProps = $props();
@@ -25,33 +25,20 @@
25
25
  () => ref,
26
26
  (v) => (ref = v)
27
27
  ),
28
+ onInteractOutside: box.with(() => onInteractOutside),
29
+ onEscapeKeydown: box.with(() => onEscapeKeydown),
28
30
  });
29
31
 
30
32
  const mergedProps = $derived(mergeProps(restProps, contentState.props));
31
-
32
- function handleInteractOutside(e: PointerEvent) {
33
- onInteractOutside?.(e);
34
- if (e.defaultPrevented) return;
35
- contentState.root.handleClose();
36
- }
37
-
38
- function handleEscapeKeydown(e: KeyboardEvent) {
39
- onEscapeKeydown?.(e);
40
- if (e.defaultPrevented) return;
41
- contentState.root.handleClose();
42
- }
43
33
  </script>
44
34
 
45
35
  {#if forceMount}
46
36
  <PopperLayerForceMount
47
37
  {...mergedProps}
38
+ {...contentState.popperProps}
48
39
  isStatic
49
40
  enabled={contentState.root.opts.open.current}
50
41
  {id}
51
- onInteractOutside={handleInteractOutside}
52
- onEscapeKeydown={handleEscapeKeydown}
53
- onOpenAutoFocus={(e) => e.preventDefault()}
54
- onCloseAutoFocus={(e) => e.preventDefault()}
55
42
  trapFocus={false}
56
43
  loop={false}
57
44
  preventScroll={false}
@@ -73,13 +60,10 @@
73
60
  {:else if !forceMount}
74
61
  <PopperLayer
75
62
  {...mergedProps}
63
+ {...contentState.popperProps}
76
64
  isStatic
77
65
  present={contentState.root.opts.open.current}
78
66
  {id}
79
- onInteractOutside={handleInteractOutside}
80
- onEscapeKeydown={handleEscapeKeydown}
81
- onOpenAutoFocus={(e) => e.preventDefault()}
82
- onCloseAutoFocus={(e) => e.preventDefault()}
83
67
  trapFocus={false}
84
68
  loop={false}
85
69
  preventScroll={false}
@@ -6,6 +6,7 @@
6
6
  import PopperLayer from "../../utilities/popper-layer/popper-layer.svelte";
7
7
  import { getFloatingContentCSSVars } from "../../../internal/floating-svelte/floating-utils.svelte.js";
8
8
  import PopperLayerForceMount from "../../utilities/popper-layer/popper-layer-force-mount.svelte";
9
+ import { noop } from "../../../internal/noop.js";
9
10
 
10
11
  let {
11
12
  children,
@@ -20,8 +21,8 @@
20
21
  sticky = "partial",
21
22
  hideWhenDetached = false,
22
23
  collisionPadding = 0,
23
- onInteractOutside,
24
- onEscapeKeydown,
24
+ onInteractOutside = noop,
25
+ onEscapeKeydown = noop,
25
26
  forceMount = false,
26
27
  ...restProps
27
28
  }: TooltipContentProps = $props();
@@ -32,6 +33,8 @@
32
33
  () => ref,
33
34
  (v) => (ref = v)
34
35
  ),
36
+ onInteractOutside: box.with(() => onInteractOutside),
37
+ onEscapeKeydown: box.with(() => onEscapeKeydown),
35
38
  });
36
39
 
37
40
  const floatingProps = $derived({
@@ -46,29 +49,14 @@
46
49
  });
47
50
 
48
51
  const mergedProps = $derived(mergeProps(restProps, floatingProps, contentState.props));
49
-
50
- function handleInteractOutside(e: PointerEvent) {
51
- onInteractOutside?.(e);
52
- if (e.defaultPrevented) return;
53
- contentState.root.handleClose();
54
- }
55
-
56
- function handleEscapeKeydown(e: KeyboardEvent) {
57
- onEscapeKeydown?.(e);
58
- if (e.defaultPrevented) return;
59
- contentState.root.handleClose();
60
- }
61
52
  </script>
62
53
 
63
54
  {#if forceMount}
64
55
  <PopperLayerForceMount
65
56
  {...mergedProps}
57
+ {...contentState.popperProps}
66
58
  enabled={contentState.root.opts.open.current}
67
59
  {id}
68
- onInteractOutside={handleInteractOutside}
69
- onEscapeKeydown={handleEscapeKeydown}
70
- onOpenAutoFocus={(e) => e.preventDefault()}
71
- onCloseAutoFocus={(e) => e.preventDefault()}
72
60
  trapFocus={false}
73
61
  loop={false}
74
62
  preventScroll={false}
@@ -92,12 +80,9 @@
92
80
  {:else if !forceMount}
93
81
  <PopperLayer
94
82
  {...mergedProps}
83
+ {...contentState.popperProps}
95
84
  present={contentState.root.opts.open.current}
96
85
  {id}
97
- onInteractOutside={handleInteractOutside}
98
- onEscapeKeydown={handleEscapeKeydown}
99
- onOpenAutoFocus={(e) => e.preventDefault()}
100
- onCloseAutoFocus={(e) => e.preventDefault()}
101
86
  trapFocus={false}
102
87
  loop={false}
103
88
  preventScroll={false}