bits-ui 1.0.0-next.60 → 1.0.0-next.62

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.
@@ -11,6 +11,7 @@
11
11
  child,
12
12
  children,
13
13
  disabled = false,
14
+ type = "button",
14
15
  ...restProps
15
16
  }: MenuTriggerProps = $props();
16
17
 
@@ -23,7 +24,7 @@
23
24
  ),
24
25
  });
25
26
 
26
- const mergedProps = $derived(mergeProps(restProps, triggerState.props));
27
+ const mergedProps = $derived(mergeProps(restProps, triggerState.props, { type }));
27
28
  </script>
28
29
 
29
30
  <FloatingLayerAnchor {id}>
@@ -1,4 +1,5 @@
1
1
  import { SvelteMap } from "svelte/reactivity";
2
+ import type { FocusEventHandler, KeyboardEventHandler, MouseEventHandler } from "svelte/elements";
2
3
  import type { TabsActivationMode } from "./types.js";
3
4
  import type { ReadableBoxedValues, WritableBoxedValues } from "../../internal/box.svelte.js";
4
5
  import type { WithRefProps } from "../../internal/types.js";
@@ -67,10 +68,9 @@ declare class TabsTriggerState {
67
68
  readonly "data-tabs-trigger": "";
68
69
  readonly disabled: true | undefined;
69
70
  readonly tabindex: number;
70
- readonly onpointerdown: (e: PointerEvent) => void;
71
- readonly onpointerup: (e: PointerEvent) => void;
72
- readonly onfocus: () => void;
73
- readonly onkeydown: (e: KeyboardEvent) => void;
71
+ readonly onclick: MouseEventHandler<HTMLButtonElement>;
72
+ readonly onfocus: FocusEventHandler<HTMLButtonElement>;
73
+ readonly onkeydown: KeyboardEventHandler<HTMLButtonElement>;
74
74
  };
75
75
  }
76
76
  type TabsContentStateProps = WithRefProps<ReadableBoxedValues<{
@@ -122,8 +122,12 @@ class TabsTriggerState {
122
122
  });
123
123
  });
124
124
  $effect(() => {
125
- if (this.#root.triggerIds.length) {
126
- this.#tabIndex = this.#root.rovingFocusGroup.getTabIndex(this.#ref.current);
125
+ this.#root.triggerIds.length;
126
+ if (this.#isActive || !this.#root.value.current) {
127
+ this.#tabIndex = 0;
128
+ }
129
+ else {
130
+ this.#tabIndex = -1;
127
131
  }
128
132
  });
129
133
  }
@@ -133,28 +137,15 @@ class TabsTriggerState {
133
137
  this.#root.setValue(this.#value.current);
134
138
  };
135
139
  #onfocus = () => {
136
- if (this.#root.activationMode.current !== "automatic" || this.#disabled.current)
140
+ if (this.#root.activationMode.current !== "automatic" || this.#isDisabled)
137
141
  return;
138
142
  this.activate();
139
143
  };
140
- #onpointerdown = (e) => {
141
- if (this.#disabled.current)
144
+ #onclick = (e) => {
145
+ if (this.#isDisabled)
142
146
  return;
143
- if (e.pointerType === "touch" || e.button !== 0)
144
- return e.preventDefault();
145
- e.preventDefault();
146
- this.#ref.current?.focus();
147
147
  this.activate();
148
148
  };
149
- #onpointerup = (e) => {
150
- if (this.#disabled.current)
151
- return;
152
- if (e.pointerType === "touch") {
153
- e.preventDefault();
154
- this.#ref.current?.focus();
155
- this.activate();
156
- }
157
- };
158
149
  #onkeydown = (e) => {
159
150
  if (this.#isDisabled)
160
151
  return;
@@ -171,15 +162,14 @@ class TabsTriggerState {
171
162
  "data-state": getTabDataState(this.#isActive),
172
163
  "data-value": this.#value.current,
173
164
  "data-orientation": getDataOrientation(this.#root.orientation.current),
174
- "data-disabled": getDataDisabled(this.#disabled.current),
165
+ "data-disabled": getDataDisabled(this.#isDisabled),
175
166
  "aria-selected": getAriaSelected(this.#isActive),
176
167
  "aria-controls": this.#ariaControls,
177
168
  [TRIGGER_ATTR]: "",
178
- disabled: getDisabled(this.#disabled.current),
169
+ disabled: getDisabled(this.#isDisabled),
179
170
  tabindex: this.#tabIndex,
180
171
  //
181
- onpointerdown: this.#onpointerdown,
182
- onpointerup: this.#onpointerup,
172
+ onclick: this.#onclick,
183
173
  onfocus: this.#onfocus,
184
174
  onkeydown: this.#onkeydown,
185
175
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "1.0.0-next.60",
3
+ "version": "1.0.0-next.62",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",