File size: 1,152 Bytes
bc20498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<script>import { melt } from "@melt-ui/svelte";
import { setCtx } from "../ctx.js";
export let orientation = void 0;
export let activateOnFocus = void 0;
export let loop = void 0;
export let autoSet = void 0;
export let value = void 0;
export let onValueChange = void 0;
export let asChild = false;
export let el = void 0;
const {
  elements: { root },
  states: { value: localValue },
  updateOption,
  getAttrs
} = setCtx({
  orientation,
  activateOnFocus,
  loop,
  autoSet,
  defaultValue: value,
  onValueChange: ({ next }) => {
    if (value !== next) {
      onValueChange?.(next);
      value = next;
    }
    return next;
  }
});
const attrs = getAttrs("root");
$:
  value !== void 0 && localValue.set(value);
$:
  updateOption("orientation", orientation);
$:
  updateOption("activateOnFocus", activateOnFocus);
$:
  updateOption("loop", loop);
$:
  updateOption("autoSet", autoSet);
$:
  builder = $root;
$:
  Object.assign(builder, attrs);
</script>

{#if asChild}
	<slot {builder} value={$localValue} />
{:else}
	<div bind:this={el} {...builder} use:builder.action {...$$restProps}>
		<slot {builder} value={$localValue} />
	</div>
{/if}