@invopop/popui 0.0.101 → 0.0.102

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.
@@ -5,18 +5,24 @@ import { dispatchWcEvent } from "./wcdispatch.js";
5
5
  const dispatch = createEventDispatcher();
6
6
  const sw = createSwitch({ label: "Set Preference" });
7
7
  let rootEl;
8
+ export let id = Math.random().toString(36).slice(2, 7);
8
9
  export let checked = false;
10
+ export let label = "";
9
11
  $:
10
12
  $sw.checked = checked;
11
13
  $:
12
14
  togleStyles = clsx({ "bg-gray-200": !$sw.checked }, { "bg-workspace-accent": $sw.checked });
13
15
  function handleChange() {
16
+ checked = $sw.checked;
14
17
  dispatch("change", $sw.checked);
15
18
  dispatchWcEvent(rootEl, "change", $sw.checked);
16
19
  }
17
20
  </script>
18
21
 
19
- <div bind:this={rootEl} class="flex w-full flex-col items-center justify-center">
22
+ <label bind:this={rootEl} class="flex w-full items-center justify-between space-x-2">
23
+ {#if label}
24
+ <span class="text-base text-neutral-500">{label}</span>
25
+ {/if}
20
26
  <button
21
27
  class="{togleStyles} relative inline-flex h-5 w-8 flex-shrink-0 cursor-pointer rounded-md border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-0 focus:ring-offset-0"
22
28
  use:sw.toggle
@@ -30,4 +36,4 @@ function handleChange() {
30
36
  : 'translate-x-0'} pointer-events-none inline-block h-4 w-4 transform rounded bg-white shadow ring-0 transition duration-200 ease-in-out"
31
37
  />
32
38
  </button>
33
- </div>
39
+ </label>
@@ -1,7 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ id?: string | undefined;
4
5
  checked?: boolean | undefined;
6
+ label?: string | undefined;
5
7
  };
6
8
  events: {
7
9
  change: CustomEvent<any>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@invopop/popui",
3
3
  "license": "MIT",
4
- "version": "0.0.101",
4
+ "version": "0.0.102",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run package",