File size: 687 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
<script>import { getCtx } from "../ctx.js";
export let asChild = false;
export let el = void 0;
const {
  helpers: { isChecked, isIndeterminate },
  states: { checked },
  getAttrs
} = getCtx();
function getStateAttr(state) {
  if (state === "indeterminate")
    return "indeterminate";
  if (state)
    return "checked";
  return "unchecked";
}
$:
  attrs = {
    ...getAttrs("indicator"),
    "data-state": getStateAttr($checked)
  };
</script>

{#if asChild}
	<slot {attrs} isChecked={$isChecked} isIndeterminate={$isIndeterminate} />
{:else}
	<div bind:this={el} {...$$restProps} {...attrs}>
		<slot {attrs} isChecked={$isChecked} isIndeterminate={$isIndeterminate} />
	</div>
{/if}