bits-ui 1.0.0-next.52 → 1.0.0-next.54

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.
@@ -26,6 +26,7 @@ declare class PopoverTriggerState {
26
26
  readonly "data-state": "open" | "closed";
27
27
  readonly "aria-controls": string | undefined;
28
28
  readonly "data-popover-trigger": "";
29
+ readonly disabled: boolean;
29
30
  readonly onpointerdown: (e: PointerEvent) => void;
30
31
  readonly onkeydown: (e: KeyboardEvent) => void;
31
32
  readonly onpointerup: (e: PointerEvent) => void;
@@ -73,6 +73,7 @@ class PopoverTriggerState {
73
73
  "data-state": getDataOpenClosed(this.#root.open.current),
74
74
  "aria-controls": this.#getAriaControls(),
75
75
  "data-popover-trigger": "",
76
+ disabled: this.#disabled.current,
76
77
  //
77
78
  onpointerdown: this.#onpointerdown,
78
79
  onkeydown: this.#onkeydown,
@@ -4,6 +4,7 @@
4
4
  import type { SelectItemProps } from "../types.js";
5
5
  import { useId } from "../../../internal/use-id.js";
6
6
  import { noop } from "../../../internal/noop.js";
7
+ import Mounted from "../../utilities/mounted.svelte";
7
8
 
8
9
  let {
9
10
  id = useId(),
@@ -41,3 +42,9 @@
41
42
  {@render children?.(itemState.snippetProps)}
42
43
  </div>
43
44
  {/if}
45
+
46
+ <Mounted
47
+ onMountedChange={(m) => {
48
+ itemState.mounted = m;
49
+ }}
50
+ />
@@ -65,7 +65,6 @@ type SelectSingleRootStateProps = SelectBaseRootStateProps & WritableBoxedValues
65
65
  value: string;
66
66
  }>;
67
67
  declare class SelectSingleRootState extends SelectBaseRootState {
68
- #private;
69
68
  value: SelectSingleRootStateProps["value"];
70
69
  isMulti: false;
71
70
  hasValue: boolean;
@@ -75,18 +74,19 @@ declare class SelectSingleRootState extends SelectBaseRootState {
75
74
  constructor(props: SelectSingleRootStateProps);
76
75
  includesItem: (itemValue: string) => boolean;
77
76
  toggleItem: (itemValue: string, itemLabel?: string) => void;
77
+ setInitialHighlightedNode: () => void;
78
78
  }
79
79
  type SelectMultipleRootStateProps = SelectBaseRootStateProps & WritableBoxedValues<{
80
80
  value: string[];
81
81
  }>;
82
82
  declare class SelectMultipleRootState extends SelectBaseRootState {
83
- #private;
84
83
  value: SelectMultipleRootStateProps["value"];
85
84
  isMulti: true;
86
85
  hasValue: boolean;
87
86
  constructor(props: SelectMultipleRootStateProps);
88
87
  includesItem: (itemValue: string) => boolean;
89
88
  toggleItem: (itemValue: string, itemLabel?: string) => void;
89
+ setInitialHighlightedNode: () => void;
90
90
  }
91
91
  type SelectRootState = SelectSingleRootState | SelectMultipleRootState;
92
92
  type SelectInputStateProps = WithRefProps;
@@ -252,6 +252,7 @@ declare class SelectItemState {
252
252
  isHighlighted: boolean;
253
253
  prevHighlighted: Previous<boolean>;
254
254
  textId: string;
255
+ mounted: boolean;
255
256
  constructor(props: SelectItemStateProps, root: SelectRootState);
256
257
  snippetProps: {
257
258
  selected: boolean;
@@ -146,7 +146,7 @@ class SelectSingleRootState extends SelectBaseRootState {
146
146
  if (!this.open.current)
147
147
  return;
148
148
  afterTick(() => {
149
- this.#setInitialHighlightedNode();
149
+ this.setInitialHighlightedNode();
150
150
  });
151
151
  });
152
152
  }
@@ -157,8 +157,8 @@ class SelectSingleRootState extends SelectBaseRootState {
157
157
  this.value.current = this.includesItem(itemValue) ? "" : itemValue;
158
158
  this.inputValue = itemLabel;
159
159
  };
160
- #setInitialHighlightedNode = () => {
161
- if (this.highlightedNode)
160
+ setInitialHighlightedNode = () => {
161
+ if (this.highlightedNode && document.contains(this.highlightedNode))
162
162
  return;
163
163
  if (this.value.current !== "") {
164
164
  const node = this.getNodeByValue(this.value.current);
@@ -186,7 +186,7 @@ class SelectMultipleRootState extends SelectBaseRootState {
186
186
  return;
187
187
  afterTick(() => {
188
188
  if (!this.highlightedNode) {
189
- this.#setInitialHighlightedNode();
189
+ this.setInitialHighlightedNode();
190
190
  }
191
191
  });
192
192
  });
@@ -203,7 +203,7 @@ class SelectMultipleRootState extends SelectBaseRootState {
203
203
  }
204
204
  this.inputValue = itemLabel;
205
205
  };
206
- #setInitialHighlightedNode = () => {
206
+ setInitialHighlightedNode = () => {
207
207
  if (this.highlightedNode)
208
208
  return;
209
209
  if (this.value.current.length && this.value.current[0] !== "") {
@@ -702,6 +702,7 @@ class SelectItemState {
702
702
  isHighlighted = $derived.by(() => this.root.highlightedValue === this.value.current);
703
703
  prevHighlighted = new Previous(() => this.isHighlighted);
704
704
  textId = $state("");
705
+ mounted = $state(false);
705
706
  constructor(props, root) {
706
707
  this.root = root;
707
708
  this.value = props.value;
@@ -723,6 +724,11 @@ class SelectItemState {
723
724
  id: this.#id,
724
725
  ref: this.#ref,
725
726
  });
727
+ $effect(() => {
728
+ if (!this.mounted)
729
+ return;
730
+ this.root.setInitialHighlightedNode();
731
+ });
726
732
  }
727
733
  snippetProps = $derived.by(() => ({
728
734
  selected: this.isSelected,
@@ -69,6 +69,7 @@ declare class TooltipTriggerState {
69
69
  "data-delay-duration": string;
70
70
  "data-tooltip-trigger": string;
71
71
  tabindex: number | undefined;
72
+ disabled: boolean;
72
73
  onpointerup: () => void;
73
74
  onpointerdown: () => void;
74
75
  onpointermove: (e: PointerEvent) => void;
@@ -207,6 +207,7 @@ class TooltipTriggerState {
207
207
  "data-delay-duration": `${this.#root.delayDuration}`,
208
208
  [TRIGGER_ATTR]: "",
209
209
  tabindex: this.#isDisabled ? undefined : 0,
210
+ disabled: this.#disabled.current,
210
211
  onpointerup: this.#onpointerup,
211
212
  onpointerdown: this.#onpointerdown,
212
213
  onpointermove: this.#onpointermove,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "1.0.0-next.52",
3
+ "version": "1.0.0-next.54",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",