lithesome 0.6.1 → 0.6.2

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.
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { AccordionContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("accordion");
4
- </script>
5
-
3
+ export const { context, contextName } = setupContext();
4
+ </script>
5
+
6
6
  <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
7
7
  import { setContext } from "svelte";
8
8
  let { children, use = [], class: klass, self = $bindable(), single = $bindable(false), ...props } = $props();
@@ -12,15 +12,15 @@ setContext(contextName, ctx);
12
12
  $effect(() => {
13
13
  ctx.single = single;
14
14
  });
15
- </script>
16
-
17
- <div
18
- bind:this={self}
19
- use:useActions={use}
20
- id={ctx.uid()}
21
- class={classProp(klass, { active })}
22
- data-accordion=""
23
- {...props}
24
- >
25
- {@render children({ active })}
26
- </div>
15
+ </script>
16
+
17
+ <div
18
+ bind:this={self}
19
+ use:useActions={use}
20
+ id={ctx.uid()}
21
+ class={classProp(klass, { active })}
22
+ data-accordion=""
23
+ {...props}
24
+ >
25
+ {@render children({ active })}
26
+ </div>
@@ -11,21 +11,21 @@ const handleClick = (e) => {
11
11
  if (!item?.disabled)
12
12
  ctx.toggle(itemId);
13
13
  };
14
- </script>
15
-
16
- <button
17
- type="button"
18
- bind:this={self}
19
- use:useActions={use}
20
- class={classProp(klass, { active, disabled: item?.disabled || false })}
21
- aria-expanded={active}
22
- aria-disabled={item?.disabled}
23
- aria-controls={active ? ctx.uid('content') : undefined}
24
- tabindex={item?.disabled ? -1 : 0}
25
- data-accordionbutton=""
26
- data-active={active || undefined}
27
- onclick={handleClick}
28
- {...props}
29
- >
30
- {@render children({ active, disabled: item?.disabled || false })}
31
- </button>
14
+ </script>
15
+
16
+ <button
17
+ type="button"
18
+ bind:this={self}
19
+ use:useActions={use}
20
+ class={classProp(klass, { active, disabled: item?.disabled || false })}
21
+ aria-expanded={active}
22
+ aria-disabled={item?.disabled}
23
+ aria-controls={active ? ctx.uid('content') : undefined}
24
+ tabindex={item?.disabled ? -1 : 0}
25
+ data-accordionbutton=""
26
+ data-active={active || undefined}
27
+ onclick={handleClick}
28
+ {...props}
29
+ >
30
+ {@render children({ active, disabled: item?.disabled || false })}
31
+ </button>
@@ -12,23 +12,23 @@ const attrs = $derived({
12
12
  "data-active": active || void 0,
13
13
  class: classProp(klass, { active })
14
14
  });
15
- </script>
16
-
17
- {#if _transition}
18
- {#if active}
19
- <div
20
- bind:this={self}
21
- use:useActions={use}
22
- in:_transition.in.fn={_transition.in.params}
23
- out:_transition.out.fn={_transition.out.params}
24
- {...attrs}
25
- {...props}
26
- >
27
- {@render children({ active })}
28
- </div>
29
- {/if}
30
- {:else if active}
31
- <div bind:this={self} use:useActions={use} {...attrs} {...props}>
32
- {@render children({ active })}
33
- </div>
34
- {/if}
15
+ </script>
16
+
17
+ {#if _transition}
18
+ {#if active}
19
+ <div
20
+ bind:this={self}
21
+ use:useActions={use}
22
+ in:_transition.in.fn={_transition.in.params}
23
+ out:_transition.out.fn={_transition.out.params}
24
+ {...attrs}
25
+ {...props}
26
+ >
27
+ {@render children({ active })}
28
+ </div>
29
+ {/if}
30
+ {:else if active}
31
+ <div bind:this={self} use:useActions={use} {...attrs} {...props}>
32
+ {@render children({ active })}
33
+ </div>
34
+ {/if}
@@ -1,15 +1,15 @@
1
1
  <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
2
  let { children, class: klass, use = [], level = 3, self = $bindable(), ...props } = $props();
3
- </script>
4
-
5
- <div
6
- bind:this={self}
7
- use:useActions={use}
8
- class={classProp(klass)}
9
- role="heading"
10
- aria-level={level}
11
- data-accordionheading=""
12
- {...props}
13
- >
14
- {@render children({})}
15
- </div>
3
+ </script>
4
+
5
+ <div
6
+ bind:this={self}
7
+ use:useActions={use}
8
+ class={classProp(klass)}
9
+ role="heading"
10
+ aria-level={level}
11
+ data-accordionheading=""
12
+ {...props}
13
+ >
14
+ {@render children({})}
15
+ </div>
@@ -17,17 +17,17 @@ onMount(() => {
17
17
  $effect(() => {
18
18
  ctx.setDisabled(uid(), disabled);
19
19
  });
20
- </script>
21
-
22
- <div
23
- bind:this={self}
24
- use:useActions={use}
25
- id={uid()}
26
- class={classProp(klass, { active, disabled })}
27
- data-accordionitem=""
28
- data-disabled={disabled || undefined}
29
- data-state={active ? 'opened' : 'closed'}
30
- {...props}
31
- >
32
- {@render children({ active, disabled })}
33
- </div>
20
+ </script>
21
+
22
+ <div
23
+ bind:this={self}
24
+ use:useActions={use}
25
+ id={uid()}
26
+ class={classProp(klass, { active, disabled })}
27
+ data-accordionitem=""
28
+ data-disabled={disabled || undefined}
29
+ data-state={active ? 'opened' : 'closed'}
30
+ {...props}
31
+ >
32
+ {@render children({ active, disabled })}
33
+ </div>
@@ -11,7 +11,7 @@ let {
11
11
  self = $bindable(),
12
12
  checked = $bindable(false),
13
13
  required = false,
14
- disabled = false,
14
+ disabled = $bindable(false),
15
15
  onClick,
16
16
  ...props
17
17
  } = $props();
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { ComboboxContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("combobox");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts" generics="ValueType">import { useActions, classProp } from "../../internal/index.js";
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { HovercardContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("hovercard");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts">import { useActions, classProp, parseDelay } from "../../internal/index.js";
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { MenuContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("menu");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { ModalContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("modal");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts">import { createUID, useActions, portal, KEYS, isBrowser, classProp } from "../../internal/index.js";
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { PinContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("pin");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { PopoverContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("popover");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts">import { useActions, KEYS, classProp } from "../../internal/index.js";
@@ -30,7 +30,7 @@ const attrs = $derived({
30
30
  "aria-labelledby": ctx.uid("trigger"),
31
31
  role: "menu",
32
32
  class: classProp(klass, { visible: ctx.visible }),
33
- "data-menucontent": ""
33
+ "data-popovercontent": ""
34
34
  });
35
35
  onMount(async () => {
36
36
  if (!ctx)
@@ -14,6 +14,9 @@ export class PopoverContext extends Context {
14
14
  this.visible = !this.visible;
15
15
  }
16
16
  #effects = effects(() => {
17
- this.hooks?.onChange?.(this.visible);
17
+ $effect(() => {
18
+ if (this._mounted)
19
+ this.hooks?.onChange?.(this.visible);
20
+ });
18
21
  });
19
22
  }
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { RadiogroupContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("radiogroup");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { SelectContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("select");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts" generics="ValueType">import { useActions, classProp } from "../../internal/index.js";
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { TabsContext } from "./context.svelte.js";
3
- export const { context, contextName } = setupContext("tabs");
3
+ export const { context, contextName } = setupContext();
4
4
  </script>
5
5
 
6
6
  <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
@@ -1,16 +1,16 @@
1
1
  import { type UID } from './utils.svelte.js';
2
2
  export declare class Context<H = any> {
3
+ #private;
3
4
  uid: UID;
4
5
  protected hooks: H | null;
6
+ protected _mounted: boolean;
5
7
  constructor(name: string, hooks?: H);
6
8
  }
7
9
  /**
8
- * Helper function to create a svelte context with a
9
- * unique name to avoid naming collisions.
10
+ * Helper function to create a svelte context with a unique name to avoid naming collisions.
10
11
  * @param name The name of the context
11
- * @returns
12
12
  */
13
- export declare const setupContext: <T>(name: string) => {
13
+ export declare const setupContext: <T>() => {
14
14
  contextName: string;
15
15
  context: () => T;
16
16
  };
@@ -1,23 +1,27 @@
1
1
  import { createUID } from './utils.svelte.js';
2
- import { onDestroy, getContext } from 'svelte';
2
+ import { onDestroy, getContext, onMount } from 'svelte';
3
3
  export class Context {
4
4
  uid = $state();
5
5
  hooks = null;
6
+ _mounted = $state(false);
6
7
  constructor(name, hooks) {
7
8
  const { uid } = createUID(name);
8
9
  this.uid = uid;
9
10
  if (hooks)
10
11
  this.hooks = hooks;
11
12
  }
13
+ #onMount = effects(() => {
14
+ $effect(() => {
15
+ this._mounted = true;
16
+ });
17
+ });
12
18
  }
13
19
  /**
14
- * Helper function to create a svelte context with a
15
- * unique name to avoid naming collisions.
20
+ * Helper function to create a svelte context with a unique name to avoid naming collisions.
16
21
  * @param name The name of the context
17
- * @returns
18
22
  */
19
- export const setupContext = (name) => {
20
- let { uid } = createUID(name + 'Context');
23
+ export const setupContext = () => {
24
+ let { uid } = createUID('context');
21
25
  return {
22
26
  contextName: uid(),
23
27
  context: () => getContext(uid())
@@ -27,13 +31,16 @@ export const setupContext = (name) => {
27
31
  * Auto cleanup effects when the component is unmounted from the DOM.
28
32
  */
29
33
  export const effects = (fn) => {
30
- let cleanUp = $effect.root(fn);
34
+ let cleanUp = null;
31
35
  const destroy = () => {
32
36
  if (cleanUp === null)
33
37
  return;
34
38
  cleanUp();
35
39
  cleanUp = null;
36
40
  };
41
+ onMount(() => {
42
+ cleanUp = $effect.root(fn);
43
+ });
37
44
  onDestroy(destroy);
38
45
  return destroy;
39
46
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lithesome",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Gibbu/lithesome.git"
@@ -21,7 +21,7 @@
21
21
  "!dist/**/*.spec.*"
22
22
  ],
23
23
  "peerDependencies": {
24
- "svelte": "^5.0.0"
24
+ "svelte": "5.0.0-next.99"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@bitmachina/highlighter": "1.0.0-alpha.7",
@@ -48,7 +48,7 @@
48
48
  "rehype-slug": "^6.0.0",
49
49
  "remark-external-links": "^9.0.1",
50
50
  "shiki": "^1.2.0",
51
- "svelte": "5.0.0-next.94",
51
+ "svelte": "5.0.0-next.99",
52
52
  "svelte-check": "^3.6.6",
53
53
  "tailwind-merge": "^2.2.1",
54
54
  "tailwindcss": "^3.4.1",