@pzerelles/headlessui-svelte 2.1.2-next.11 → 2.1.2-next.13

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.
@@ -27,7 +27,8 @@ export function useControllable(input, onchange, defaultValue) {
27
27
  }
28
28
  else {
29
29
  internalValue = value;
30
- input.controlledValue = value;
30
+ if (isControlled)
31
+ input.controlledValue = value;
31
32
  }
32
33
  },
33
34
  };
@@ -234,7 +234,7 @@ function useResolvePxValue(options) {
234
234
  const immediateValue = $derived(computeValue(input, element)[0]);
235
235
  let explicitValue = $state();
236
236
  const setValue = (value) => (explicitValue = value);
237
- const value = explicitValue ?? immediateValue;
237
+ const value = $derived(explicitValue ?? immediateValue);
238
238
  $effect(() => {
239
239
  const [value, watcher] = computeValue(input, element);
240
240
  setValue(value);
@@ -198,7 +198,7 @@ const stateReducer = (initialState) => {
198
198
  };
199
199
  let {
200
200
  ref = $bindable(),
201
- value: controlledValue,
201
+ value: controlledValue = $bindable(),
202
202
  defaultValue,
203
203
  form,
204
204
  name,
@@ -218,6 +218,9 @@ const controllable = useControllable(
218
218
  {
219
219
  get controlledValue() {
220
220
  return controlledValue;
221
+ },
222
+ set controlledValue(value2) {
223
+ controlledValue = value2;
221
224
  }
222
225
  },
223
226
  controlledOnChange,
@@ -48,7 +48,7 @@ declare class __sveltets_Render<TType, TActualType, TTag extends ElementType = t
48
48
  [evt: string]: CustomEvent<any>;
49
49
  };
50
50
  slots(): {};
51
- bindings(): "ref";
51
+ bindings(): "ref" | "value";
52
52
  exports(): {};
53
53
  }
54
54
  interface $$IsomorphicComponent {
@@ -27,7 +27,8 @@ let {
27
27
  const usedInSelectedOption = getContext("SelectedOptionContext") === true;
28
28
  const data = useData("ListboxOption");
29
29
  const actions = useActions("ListboxOption");
30
- const active = $derived(data.activeOptionIndex !== null ? data.options[data.activeOptionIndex].id === id : false);
30
+ const { activeOptionIndex, options } = $derived(data);
31
+ const active = $derived(activeOptionIndex !== null ? options[activeOptionIndex].id === id : false);
31
32
  const selected = $derived(data.isSelected(value));
32
33
  const getTextValue = useTextValue({
33
34
  get element() {
@@ -43,6 +44,7 @@ const bag = $derived({
43
44
  }
44
45
  });
45
46
  $effect(() => {
47
+ if (usedInSelectedOption) return;
46
48
  if (!ref) {
47
49
  data.listElements.delete(id);
48
50
  } else {
@@ -245,14 +245,65 @@ const ourProps = $derived({
245
245
  }),
246
246
  ...transitionDataAttributes(transitionData)
247
247
  });
248
- const derivedData = {
248
+ const derivedData = $derived({
249
249
  ...data,
250
250
  get isSelected() {
251
251
  return data.mode === ValueMode.Multi ? data.isSelected : isSelected;
252
252
  }
253
- };
254
- setContext("ListboxDataContext", derivedData);
255
- $inspect(styles);
253
+ });
254
+ setContext("ListboxDataContext", {
255
+ get value() {
256
+ return data.value;
257
+ },
258
+ get disabled() {
259
+ return data.disabled;
260
+ },
261
+ get invalid() {
262
+ return data.invalid;
263
+ },
264
+ get mode() {
265
+ return data.mode;
266
+ },
267
+ get orientation() {
268
+ return data.orientation;
269
+ },
270
+ get activeOptionIndex() {
271
+ return data.activeOptionIndex;
272
+ },
273
+ get compare() {
274
+ return data.compare;
275
+ },
276
+ get isSelected() {
277
+ return data.mode === ValueMode.Multi ? data.isSelected : isSelected;
278
+ },
279
+ get optionsProps() {
280
+ return data.optionsProps;
281
+ },
282
+ get listElements() {
283
+ return data.listElements;
284
+ },
285
+ get buttonElement() {
286
+ return data.buttonElement;
287
+ },
288
+ get optionsElement() {
289
+ return data.optionsElement;
290
+ },
291
+ get listboxState() {
292
+ return data.listboxState;
293
+ },
294
+ get options() {
295
+ return data.options;
296
+ },
297
+ get searchQuery() {
298
+ return data.searchQuery;
299
+ },
300
+ get activationTrigger() {
301
+ return data.activationTrigger;
302
+ },
303
+ get __demoMode() {
304
+ return data.__demoMode;
305
+ }
306
+ });
256
307
  </script>
257
308
 
258
309
  <Portal enabled={portal ? theirProps.static || visible : false}>
@@ -75,7 +75,6 @@ export function useFloating(options = {}) {
75
75
  config.platform = platformRef.current;
76
76
  }
77
77
  computePosition(referenceRef.current, floatingRef.current, config).then(async (data) => {
78
- console.log("computing", config);
79
78
  const fullData = {
80
79
  ...data,
81
80
  // The floating element's position may be recomputed while it's closed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pzerelles/headlessui-svelte",
3
- "version": "2.1.2-next.11",
3
+ "version": "2.1.2-next.13",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",