lithesome 0.5.0 → 0.6.1

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.
Files changed (64) hide show
  1. package/dist/components/Accordion/Accordion.svelte +3 -4
  2. package/dist/components/Accordion/Accordion.svelte.d.ts +1 -1
  3. package/dist/components/Accordion/AccordionButton.svelte +1 -1
  4. package/dist/components/Accordion/AccordionContent.svelte +1 -1
  5. package/dist/components/Accordion/AccordionHeading.svelte +1 -1
  6. package/dist/components/Accordion/AccordionItem.svelte +1 -1
  7. package/dist/components/Checkbox/Checkbox.svelte +2 -2
  8. package/dist/components/Checkbox/Checkbox.svelte.d.ts +1 -1
  9. package/dist/components/Combobox/Combobox.svelte +4 -5
  10. package/dist/components/Combobox/Combobox.svelte.d.ts +1 -1
  11. package/dist/components/Combobox/ComboboxDropdown.svelte +1 -1
  12. package/dist/components/Combobox/ComboboxDropdown.svelte.d.ts +2 -18
  13. package/dist/components/Combobox/ComboboxInput.svelte +1 -1
  14. package/dist/components/Combobox/ComboboxOption.svelte +1 -1
  15. package/dist/components/Hovercard/Hovercard.svelte +5 -24
  16. package/dist/components/Hovercard/Hovercard.svelte.d.ts +1 -5
  17. package/dist/components/Hovercard/HovercardContent.svelte +6 -5
  18. package/dist/components/Hovercard/HovercardContent.svelte.d.ts +2 -17
  19. package/dist/components/Hovercard/HovercardTrigger.svelte +1 -1
  20. package/dist/components/Hovercard/context.svelte.d.ts +2 -6
  21. package/dist/components/Hovercard/context.svelte.js +2 -3
  22. package/dist/components/Menu/Menu.svelte +3 -4
  23. package/dist/components/Menu/Menu.svelte.d.ts +1 -1
  24. package/dist/components/Menu/MenuDropdown.svelte +1 -1
  25. package/dist/components/Menu/MenuDropdown.svelte.d.ts +2 -18
  26. package/dist/components/Menu/MenuItem.svelte +1 -1
  27. package/dist/components/Menu/MenuTrigger.svelte +1 -1
  28. package/dist/components/Modal/Modal.svelte +3 -4
  29. package/dist/components/Modal/Modal.svelte.d.ts +1 -1
  30. package/dist/components/Modal/ModalContent.svelte +1 -1
  31. package/dist/components/Modal/ModalDescription.svelte +1 -1
  32. package/dist/components/Modal/ModalOverlay.svelte +1 -1
  33. package/dist/components/Modal/ModalTitle.svelte +1 -1
  34. package/dist/components/Pin/Pin.svelte +3 -4
  35. package/dist/components/Pin/Pin.svelte.d.ts +1 -1
  36. package/dist/components/Pin/PinInput.svelte +1 -1
  37. package/dist/components/Pin/PinValue.svelte +1 -1
  38. package/dist/components/Popover/Popover.svelte +3 -4
  39. package/dist/components/Popover/Popover.svelte.d.ts +1 -1
  40. package/dist/components/Popover/PopoverContent.svelte +1 -1
  41. package/dist/components/Popover/PopoverContent.svelte.d.ts +2 -18
  42. package/dist/components/Popover/PopoverTrigger.svelte +1 -1
  43. package/dist/components/RadioGroup/RadioGroup.svelte +3 -4
  44. package/dist/components/RadioGroup/RadioGroup.svelte.d.ts +1 -1
  45. package/dist/components/RadioGroup/RadioGroupItem.svelte +1 -1
  46. package/dist/components/Select/Select.svelte +4 -5
  47. package/dist/components/Select/Select.svelte.d.ts +1 -1
  48. package/dist/components/Select/SelectDropdown.svelte +1 -1
  49. package/dist/components/Select/SelectDropdown.svelte.d.ts +2 -18
  50. package/dist/components/Select/SelectOption.svelte +1 -1
  51. package/dist/components/Select/SelectTrigger.svelte +1 -1
  52. package/dist/components/Select/SelectValue.svelte +1 -1
  53. package/dist/components/Tabs/Tabs.svelte +4 -5
  54. package/dist/components/Tabs/Tabs.svelte.d.ts +1 -1
  55. package/dist/components/Tabs/TabsButton.svelte +1 -1
  56. package/dist/components/Tabs/TabsContent.svelte +1 -1
  57. package/dist/components/Tabs/TabsList.svelte +1 -1
  58. package/dist/internal/helpers/context.svelte.d.ts +13 -0
  59. package/dist/internal/helpers/context.svelte.js +17 -1
  60. package/dist/internal/helpers/utils.svelte.d.ts +1 -1
  61. package/dist/internal/types.d.ts +18 -1
  62. package/package.json +2 -2
  63. package/dist/components/Tags/context.svelte.d.ts +0 -15
  64. package/dist/components/Tags/context.svelte.js +0 -15
@@ -1,10 +1,9 @@
1
- <script context="module">import { getContext } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { AccordionContext } from "./context.svelte.js";
3
- const contextName = "accordion-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("accordion");
5
4
  </script>
6
5
 
7
- <script>import { useActions, classProp } from "../../internal/index.js";
6
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
8
7
  import { setContext } from "svelte";
9
8
  let { children, use = [], class: klass, self = $bindable(), single = $bindable(false), ...props } = $props();
10
9
  const ctx = new AccordionContext({ single });
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { AccordionContext } from './context.svelte.js';
3
- export declare const context: () => AccordionContext;
3
+ export declare const context: () => AccordionContext, contextName: string;
4
4
  import { type BaseProps } from '../../internal/index.js';
5
5
  declare const __propDef: {
6
6
  props: BaseProps<HTMLDivElement, {
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Accordion.svelte";
1
+ <script lang="ts">import { context } from "./Accordion.svelte";
2
2
  import { useActions, classProp } from "../../internal/index.js";
3
3
  import { getContext } from "svelte";
4
4
  let { children, class: klass, use = [], self = $bindable(), onClick, ...props } = $props();
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Accordion.svelte";
1
+ <script lang="ts">import { context } from "./Accordion.svelte";
2
2
  import { useActions, getTransition, classProp } from "../../internal/index.js";
3
3
  import { getContext } from "svelte";
4
4
  let { children, class: klass, use = [], self = $bindable(), transition, ...props } = $props();
@@ -1,4 +1,4 @@
1
- <script>import { useActions, classProp } from "../../internal/index.js";
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
3
  </script>
4
4
 
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Accordion.svelte";
1
+ <script lang="ts">import { context } from "./Accordion.svelte";
2
2
  import { log, useActions, createUID, classProp } from "../../internal/index.js";
3
3
  import { onMount, setContext } from "svelte";
4
4
  let { children, class: klass, use = [], self = $bindable(), disabled = $bindable(false), ...props } = $props();
@@ -1,6 +1,6 @@
1
- <script context="module"></script>
1
+ <script lang="ts" context="module"></script>
2
2
 
3
- <script>import {
3
+ <script lang="ts">import {
4
4
  useActions,
5
5
  classProp
6
6
  } from "../../internal/index.js";
@@ -12,7 +12,7 @@ declare const __propDef: {
12
12
  _: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
13
13
  }) | undefined;
14
14
  use?: import("../../internal/index.js").HTMLActionArray | undefined;
15
- class?: import("../../internal/types").ClassProp<{
15
+ class?: import("../../internal/index.js").ClassProp<{
16
16
  checked: Checked;
17
17
  }>;
18
18
  self?: HTMLButtonElement | undefined;
@@ -1,11 +1,10 @@
1
- <script context="module">import { getContext, onMount, tick } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { ComboboxContext } from "./context.svelte.js";
3
- const contextName = "combobox-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("combobox");
5
4
  </script>
6
5
 
7
- <script generics="ValueType">import { useActions, classProp } from "../../internal/index.js";
8
- import { setContext } from "svelte";
6
+ <script lang="ts" generics="ValueType">import { useActions, classProp } from "../../internal/index.js";
7
+ import { setContext, onMount, tick } from "svelte";
9
8
  let {
10
9
  children,
11
10
  use = [],
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { ComboboxContext } from './context.svelte.js';
3
- export declare const context: () => ComboboxContext<any>;
3
+ export declare const context: () => ComboboxContext<any>, contextName: string;
4
4
  import { type BaseProps } from '../../internal/index.js';
5
5
  declare class __sveltets_Render<ValueType> {
6
6
  props(): BaseProps<HTMLDivElement, {
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Combobox.svelte";
1
+ <script lang="ts">import { context } from "./Combobox.svelte";
2
2
  import {
3
3
  clickOutside,
4
4
  anchorElement,
@@ -1,25 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type Transition, type BaseProps } from '../../internal/index.js';
3
- import type { Placement } from '@floating-ui/dom';
2
+ import { type BaseProps, type DropdownProps } from '../../internal/index.js';
4
3
  declare const __propDef: {
5
4
  props: BaseProps<HTMLDivElement, {
6
5
  visible: boolean;
7
- }> & {
8
- /**
9
- * The `svelte/transtion` you wish to use.
10
- *
11
- * @see https://lithesome.dev/docs/api#transition-prop
12
- */
13
- transition?: Transition | undefined;
14
- /** The element to portal the dropdown menu to. */
15
- portalTarget?: string | HTMLElement | undefined;
16
- /** The anchor point of the dropdown relative to the trigger. */
17
- placement?: Placement | undefined;
18
- /** Keeps the dropdown from ever growing outside of the viewport. */
19
- constrainViewport?: boolean | undefined;
20
- /** Makes the dropdown the same width as the trigger. */
21
- sameWidth?: boolean | undefined;
22
- };
6
+ }> & DropdownProps;
23
7
  events: {
24
8
  [evt: string]: CustomEvent<any>;
25
9
  };
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Combobox.svelte";
1
+ <script lang="ts">import { context } from "./Combobox.svelte";
2
2
  import {
3
3
  useActions,
4
4
  classProp,
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Combobox.svelte";
1
+ <script lang="ts">import { context } from "./Combobox.svelte";
2
2
  import {
3
3
  useActions,
4
4
  classProp,
@@ -1,33 +1,14 @@
1
- <script context="module">import { getContext } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { HovercardContext } from "./context.svelte.js";
3
- const contextName = "hovercard-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("hovercard");
5
4
  </script>
6
5
 
7
- <script>import { useActions, classProp, parseDelay } from "../../internal/index.js";
6
+ <script lang="ts">import { useActions, classProp, parseDelay } from "../../internal/index.js";
8
7
  import { setContext } from "svelte";
9
- let {
10
- children,
11
- use = [],
12
- class: klass,
13
- visible = $bindable(false),
14
- self = $bindable(),
15
- delay = 700,
16
- ...props
17
- } = $props();
8
+ let { children, use = [], class: klass, self = $bindable(), delay = 700, ...props } = $props();
18
9
  const delays = parseDelay(delay);
19
- const ctx = new HovercardContext(
20
- { visible, delays },
21
- {
22
- onChange(val) {
23
- visible = val;
24
- }
25
- }
26
- );
10
+ const ctx = new HovercardContext({ delays });
27
11
  setContext(contextName, ctx);
28
- $effect(() => {
29
- ctx.visible = visible;
30
- });
31
12
  </script>
32
13
 
33
14
  <div
@@ -1,15 +1,11 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { HovercardContext } from './context.svelte.js';
3
- export declare const context: () => HovercardContext;
3
+ export declare const context: () => HovercardContext, contextName: string;
4
4
  import { type BaseProps } from '../../internal/index.js';
5
5
  declare const __propDef: {
6
6
  props: BaseProps<HTMLDivElement, {
7
7
  visible: boolean;
8
8
  }> & {
9
- /**
10
- * Whether or not the content is visible or not.
11
- */
12
- visible?: boolean | undefined;
13
9
  /**
14
10
  * The delay between the the content being visible or not.
15
11
  *
@@ -1,10 +1,9 @@
1
- <script>import { context } from "./Hovercard.svelte";
1
+ <script lang="ts">import { context } from "./Hovercard.svelte";
2
2
  import {
3
3
  clickOutside,
4
4
  anchorElement,
5
5
  portal,
6
6
  useActions,
7
- trap,
8
7
  getTransition,
9
8
  classProp
10
9
  } from "../../internal/index.js";
@@ -31,9 +30,7 @@ const attrs = $derived({
31
30
  id: ctx.uid("content"),
32
31
  "aria-labelledby": ctx.uid("trigger"),
33
32
  class: classProp(klass, { visible: ctx.visible }),
34
- "data-menucontent": "",
35
- role: "menu",
36
- tabindex: -1
33
+ "data-hovercardcontent": ""
37
34
  });
38
35
  onMount(async () => {
39
36
  if (!ctx)
@@ -83,6 +80,8 @@ const handleMouseleave = (e) => {
83
80
  out:_transition.out.fn={_transition.out.params}
84
81
  onmouseenter={handleMouseenter}
85
82
  onmouseleave={handleMouseleave}
83
+ role="menu"
84
+ tabindex={-1}
86
85
  {...attrs}
87
86
  {...props}
88
87
  >
@@ -102,6 +101,8 @@ const handleMouseleave = (e) => {
102
101
  use:useActions={use}
103
102
  onmouseenter={handleMouseenter}
104
103
  onmouseleave={handleMouseleave}
104
+ role="menu"
105
+ tabindex={-1}
105
106
  {...attrs}
106
107
  {...props}
107
108
  >
@@ -1,24 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type Transition, type BaseProps, type Handler } from '../../internal/index.js';
3
- import type { Placement } from '@floating-ui/dom';
2
+ import { type BaseProps, type Handler, type DropdownProps } from '../../internal/index.js';
4
3
  declare const __propDef: {
5
4
  props: BaseProps<HTMLDivElement, {
6
5
  visible: boolean;
7
- }> & {
8
- /**
9
- * The `svelte/transtion` you wish to use.
10
- *
11
- * @see https://lithesome.dev/docs/api#transition-prop
12
- */
13
- transition?: Transition | undefined;
14
- /** The element to portal the content menu to. */
15
- portalTarget?: string | HTMLElement | undefined;
16
- /** The anchor point of the content relative to the trigger. */
17
- placement?: Placement | undefined;
18
- /** Keeps the content from ever growing outside of the viewport. */
19
- constrainViewport?: boolean | undefined;
20
- /** Makes the content the same width as the trigger. */
21
- sameWidth?: boolean | undefined;
6
+ }> & DropdownProps & {
22
7
  onMouseenter?: Handler<MouseEvent, HTMLDivElement> | undefined;
23
8
  onMouseleave?: Handler<MouseEvent, HTMLDivElement> | undefined;
24
9
  };
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Hovercard.svelte";
1
+ <script lang="ts">import { context } from "./Hovercard.svelte";
2
2
  import {
3
3
  log,
4
4
  setNodeProps,
@@ -1,15 +1,11 @@
1
1
  import { Context } from '../../internal/index.js';
2
2
  interface Init {
3
- visible: boolean;
4
3
  delays: {
5
4
  in: number;
6
5
  out: number;
7
6
  };
8
7
  }
9
- interface Hooks {
10
- onChange: (value: boolean) => void;
11
- }
12
- export declare class HovercardContext extends Context<Hooks> {
8
+ export declare class HovercardContext extends Context {
13
9
  #private;
14
10
  visible: boolean;
15
11
  trigger: HTMLElement | null;
@@ -20,7 +16,7 @@ export declare class HovercardContext extends Context<Hooks> {
20
16
  out: number;
21
17
  };
22
18
  hovered: boolean;
23
- constructor(init: Init, hooks: Hooks);
19
+ constructor(init: Init);
24
20
  open(): void;
25
21
  close(): void;
26
22
  }
@@ -6,9 +6,8 @@ export class HovercardContext extends Context {
6
6
  timeout = $state(null);
7
7
  delays = $state({ in: 700, out: 700 });
8
8
  hovered = $state(false);
9
- constructor(init, hooks) {
10
- super('hovercard', hooks);
11
- this.visible = init.visible;
9
+ constructor(init) {
10
+ super('hovercard');
12
11
  this.delays = init.delays;
13
12
  }
14
13
  open() {
@@ -1,10 +1,9 @@
1
- <script context="module">import { getContext } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { MenuContext } from "./context.svelte.js";
3
- const contextName = "menu-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("menu");
5
4
  </script>
6
5
 
7
- <script>import { useActions, classProp } from "../../internal/index.js";
6
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
8
7
  import { setContext } from "svelte";
9
8
  let { children, use = [], class: klass, self = $bindable(), ...props } = $props();
10
9
  const ctx = new MenuContext();
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { MenuContext } from './context.svelte.js';
3
- export declare const context: () => MenuContext;
3
+ export declare const context: () => MenuContext, contextName: string;
4
4
  import { type BaseProps } from '../../internal/index.js';
5
5
  declare const __propDef: {
6
6
  props: BaseProps<HTMLDivElement, {
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Menu.svelte";
1
+ <script lang="ts">import { context } from "./Menu.svelte";
2
2
  import {
3
3
  clickOutside,
4
4
  anchorElement,
@@ -1,25 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type Transition, type BaseProps } from '../../internal/index.js';
3
- import type { Placement } from '@floating-ui/dom';
2
+ import { type BaseProps, type DropdownProps } from '../../internal/index.js';
4
3
  declare const __propDef: {
5
4
  props: BaseProps<HTMLDivElement, {
6
5
  visible: boolean;
7
- }> & {
8
- /**
9
- * The `svelte/transtion` you wish to use.
10
- *
11
- * @see https://lithesome.dev/docs/api#transition-prop
12
- */
13
- transition?: Transition | undefined;
14
- /** The element to portal the dropdown menu to. */
15
- portalTarget?: string | HTMLElement | undefined;
16
- /** The anchor point of the dropdown relative to the trigger. */
17
- placement?: Placement | undefined;
18
- /** Keeps the dropdown from ever growing outside of the viewport. */
19
- constrainViewport?: boolean | undefined;
20
- /** Makes the dropdown the same width as the trigger. */
21
- sameWidth?: boolean | undefined;
22
- };
6
+ }> & DropdownProps;
23
7
  events: {
24
8
  [evt: string]: CustomEvent<any>;
25
9
  };
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Menu.svelte";
1
+ <script lang="ts">import { context } from "./Menu.svelte";
2
2
  import { useActions, classProp } from "../../internal/index.js";
3
3
  import { createUID } from "../../internal/index.js";
4
4
  import { onMount } from "svelte";
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Menu.svelte";
1
+ <script lang="ts">import { context } from "./Menu.svelte";
2
2
  import {
3
3
  log,
4
4
  setNodeProps,
@@ -1,10 +1,9 @@
1
- <script context="module">import { getContext } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { ModalContext } from "./context.svelte.js";
3
- const contextName = "modal-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("modal");
5
4
  </script>
6
5
 
7
- <script>import { createUID, useActions, portal, KEYS, isBrowser, classProp } from "../../internal/index.js";
6
+ <script lang="ts">import { createUID, useActions, portal, KEYS, isBrowser, classProp } from "../../internal/index.js";
8
7
  import { setContext } from "svelte";
9
8
  let {
10
9
  children,
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { ModalContext } from './context.svelte.js';
3
- export declare const context: () => ModalContext;
3
+ export declare const context: () => ModalContext, contextName: string;
4
4
  import { type BaseProps } from '../../internal/index.js';
5
5
  declare const __propDef: {
6
6
  props: BaseProps<HTMLDivElement, any> & {
@@ -1,4 +1,4 @@
1
- <script>import { useActions, getTransition, classProp, trap } from "../../internal/index.js";
1
+ <script lang="ts">import { useActions, getTransition, classProp, trap } from "../../internal/index.js";
2
2
  import { context } from "./Modal.svelte";
3
3
  let { children, class: klass, use = [], self = $bindable(), transition, ...props } = $props();
4
4
  const ctx = context();
@@ -1,4 +1,4 @@
1
- <script>import { useActions, classProp } from "../../internal/index.js";
1
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
2
  import { context } from "./Modal.svelte";
3
3
  let { children, class: klass, use = [], self = $bindable(), ...props } = $props();
4
4
  const ctx = context();
@@ -1,4 +1,4 @@
1
- <script>import {
1
+ <script lang="ts">import {
2
2
  useActions,
3
3
  getTransition,
4
4
  classProp
@@ -1,4 +1,4 @@
1
- <script>import { useActions, classProp } from "../../internal/index.js";
1
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
2
  import { context } from "./Modal.svelte";
3
3
  let { children, class: klass, use = [], self = $bindable(), ...props } = $props();
4
4
  const ctx = context();
@@ -1,10 +1,9 @@
1
- <script context="module">import { getContext } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { PinContext } from "./context.svelte.js";
3
- const contextName = "pin-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("pin");
5
4
  </script>
6
5
 
7
- <script>import { useActions, classProp } from "../../internal/index.js";
6
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
8
7
  import { setContext } from "svelte";
9
8
  let {
10
9
  children,
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { PinContext } from './context.svelte.js';
3
- export declare const context: () => PinContext;
3
+ export declare const context: () => PinContext, contextName: string;
4
4
  import { type BaseProps } from '../../internal/index.js';
5
5
  declare const __propDef: {
6
6
  props: BaseProps<HTMLDivElement, {
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Pin.svelte";
1
+ <script lang="ts">import { context } from "./Pin.svelte";
2
2
  import {
3
3
  log,
4
4
  useActions,
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Pin.svelte";
1
+ <script lang="ts">import { context } from "./Pin.svelte";
2
2
  import { log, useActions, classProp } from "../../internal/index.js";
3
3
  import { onMount } from "svelte";
4
4
  let { class: klass, use = [], self = $bindable(), name, ...props } = $props();
@@ -1,10 +1,9 @@
1
- <script context="module">import { getContext } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { PopoverContext } from "./context.svelte.js";
3
- const contextName = "popover-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("popover");
5
4
  </script>
6
5
 
7
- <script>import { createUID, useActions, KEYS, isBrowser, classProp } from "../../internal/index.js";
6
+ <script lang="ts">import { useActions, KEYS, classProp } from "../../internal/index.js";
8
7
  import { setContext } from "svelte";
9
8
  let { children, use = [], class: klass, self = $bindable(), visible = $bindable(false), ...props } = $props();
10
9
  const ctx = new PopoverContext(
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { PopoverContext } from './context.svelte.js';
3
- export declare const context: () => PopoverContext;
3
+ export declare const context: () => PopoverContext, contextName: string;
4
4
  import { type BaseProps } from '../../internal/index.js';
5
5
  declare const __propDef: {
6
6
  props: BaseProps<HTMLDivElement, {
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Popover.svelte";
1
+ <script lang="ts">import { context } from "./Popover.svelte";
2
2
  import {
3
3
  clickOutside,
4
4
  anchorElement,
@@ -1,25 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type Transition, type BaseProps } from '../../internal/index.js';
3
- import type { Placement } from '@floating-ui/dom';
2
+ import { type BaseProps, type DropdownProps } from '../../internal/index.js';
4
3
  declare const __propDef: {
5
4
  props: BaseProps<HTMLDivElement, {
6
5
  visible: boolean;
7
- }> & {
8
- /**
9
- * The `svelte/transtion` you wish to use.
10
- *
11
- * @see https://lithesome.dev/docs/api#transition-prop
12
- */
13
- transition?: Transition | undefined;
14
- /** The element to portal the content menu to. */
15
- portalTarget?: string | HTMLElement | undefined;
16
- /** The anchor point of the content relative to the trigger. */
17
- placement?: Placement | undefined;
18
- /** Keeps the content from ever growing outside of the viewport. */
19
- constrainViewport?: boolean | undefined;
20
- /** Makes the content the same width as the trigger. */
21
- sameWidth?: boolean | undefined;
22
- };
6
+ }> & DropdownProps;
23
7
  events: {
24
8
  [evt: string]: CustomEvent<any>;
25
9
  };
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Popover.svelte";
1
+ <script lang="ts">import { context } from "./Popover.svelte";
2
2
  import {
3
3
  log,
4
4
  setNodeProps,
@@ -1,10 +1,9 @@
1
- <script context="module">import { getContext } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { RadiogroupContext } from "./context.svelte.js";
3
- const contextName = "radiogroup-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("radiogroup");
5
4
  </script>
6
5
 
7
- <script>import { useActions, classProp } from "../../internal/index.js";
6
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
8
7
  import { setContext } from "svelte";
9
8
  let {
10
9
  children,
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { RadiogroupContext } from './context.svelte.js';
3
- export declare const context: () => RadiogroupContext;
3
+ export declare const context: () => RadiogroupContext, contextName: string;
4
4
  import { type BaseProps, type JsonValue } from '../../internal/index.js';
5
5
  declare const __propDef: {
6
6
  props: BaseProps<HTMLDivElement, any> & {
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./RadioGroup.svelte";
1
+ <script lang="ts">import { context } from "./RadioGroup.svelte";
2
2
  import {
3
3
  log,
4
4
  useActions,
@@ -1,11 +1,10 @@
1
- <script context="module">import { getContext, onMount, tick } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { SelectContext } from "./context.svelte.js";
3
- const contextName = "select-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("select");
5
4
  </script>
6
5
 
7
- <script generics="ValueType">import { useActions, classProp } from "../../internal/index.js";
8
- import { setContext } from "svelte";
6
+ <script lang="ts" generics="ValueType">import { useActions, classProp } from "../../internal/index.js";
7
+ import { setContext, onMount, tick } from "svelte";
9
8
  let {
10
9
  children,
11
10
  use = [],
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { SelectContext } from './context.svelte.js';
3
- export declare const context: () => SelectContext<any>;
3
+ export declare const context: () => SelectContext<any>, contextName: string;
4
4
  import { type BaseProps, type JsonValue } from '../../internal/index.js';
5
5
  declare class __sveltets_Render<ValueType> {
6
6
  props(): BaseProps<HTMLDivElement, {
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Select.svelte";
1
+ <script lang="ts">import { context } from "./Select.svelte";
2
2
  import {
3
3
  clickOutside,
4
4
  anchorElement,
@@ -1,25 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type Transition, type BaseProps } from '../../internal/index.js';
3
- import type { Placement } from '@floating-ui/dom';
2
+ import { type BaseProps, type DropdownProps } from '../../internal/index.js';
4
3
  declare const __propDef: {
5
4
  props: BaseProps<HTMLDivElement, {
6
5
  visible: boolean;
7
- }> & {
8
- /**
9
- * The `svelte/transtion` you wish to use.
10
- *
11
- * @see https://lithesome.dev/docs/api#transition-prop
12
- */
13
- transition?: Transition | undefined;
14
- /** The element to portal the dropdown menu to. */
15
- portalTarget?: string | HTMLElement | undefined;
16
- /** The anchor point of the dropdown relative to the trigger. */
17
- placement?: Placement | undefined;
18
- /** Keeps the dropdown from ever growing outside of the viewport. */
19
- constrainViewport?: boolean | undefined;
20
- /** Makes the dropdown the same width as the trigger. */
21
- sameWidth?: boolean | undefined;
22
- };
6
+ }> & DropdownProps;
23
7
  events: {
24
8
  [evt: string]: CustomEvent<any>;
25
9
  };
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Select.svelte";
1
+ <script lang="ts">import { context } from "./Select.svelte";
2
2
  import {
3
3
  useActions,
4
4
  classProp,
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Select.svelte";
1
+ <script lang="ts">import { context } from "./Select.svelte";
2
2
  import {
3
3
  log,
4
4
  setNodeProps,
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Select.svelte";
1
+ <script lang="ts">import { context } from "./Select.svelte";
2
2
  import { useActions, classProp } from "../../internal/index.js";
3
3
  let { class: klass, use = [], self = $bindable(), placeholder = "Select an option...", ...props } = $props();
4
4
  const ctx = context();
@@ -1,16 +1,15 @@
1
- <script context="module">import { getContext } from "svelte";
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { TabsContext } from "./context.svelte.js";
3
- const contextName = "tabs-context";
4
- export const context = () => getContext(contextName);
3
+ export const { context, contextName } = setupContext("tabs");
5
4
  </script>
6
5
 
7
- <script>import { useActions, classProp } from "../../internal/index.js";
6
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
8
7
  import { setContext } from "svelte";
9
8
  let {
10
9
  children,
11
10
  use = [],
12
11
  class: klass,
13
- self,
12
+ self = $bindable(),
14
13
  orientation = "horizontal",
15
14
  value = $bindable(""),
16
15
  ...props
@@ -1,6 +1,6 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { TabsContext } from './context.svelte.js';
3
- export declare const context: () => TabsContext;
3
+ export declare const context: () => TabsContext, contextName: string;
4
4
  import { type BaseProps } from '../../internal/index.js';
5
5
  declare const __propDef: {
6
6
  props: BaseProps<HTMLDivElement, {
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Tabs.svelte";
1
+ <script lang="ts">import { context } from "./Tabs.svelte";
2
2
  import {
3
3
  useActions,
4
4
  KEYS,
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Tabs.svelte";
1
+ <script lang="ts">import { context } from "./Tabs.svelte";
2
2
  import { useActions, classProp } from "../../internal/index.js";
3
3
  let { children, class: klass, use = [], self = $bindable(), value, ...props } = $props();
4
4
  const ctx = context();
@@ -1,4 +1,4 @@
1
- <script>import { context } from "./Tabs.svelte";
1
+ <script lang="ts">import { context } from "./Tabs.svelte";
2
2
  import { useActions, classProp } from "../../internal/index.js";
3
3
  let { children, class: klass, use = [], self, ...props } = $props();
4
4
  const ctx = context();
@@ -4,4 +4,17 @@ export declare class Context<H = any> {
4
4
  protected hooks: H | null;
5
5
  constructor(name: string, hooks?: H);
6
6
  }
7
+ /**
8
+ * Helper function to create a svelte context with a
9
+ * unique name to avoid naming collisions.
10
+ * @param name The name of the context
11
+ * @returns
12
+ */
13
+ export declare const setupContext: <T>(name: string) => {
14
+ contextName: string;
15
+ context: () => T;
16
+ };
17
+ /**
18
+ * Auto cleanup effects when the component is unmounted from the DOM.
19
+ */
7
20
  export declare const effects: (fn: () => void) => () => void;
@@ -1,5 +1,5 @@
1
1
  import { createUID } from './utils.svelte.js';
2
- import { onDestroy } from 'svelte';
2
+ import { onDestroy, getContext } from 'svelte';
3
3
  export class Context {
4
4
  uid = $state();
5
5
  hooks = null;
@@ -10,6 +10,22 @@ export class Context {
10
10
  this.hooks = hooks;
11
11
  }
12
12
  }
13
+ /**
14
+ * Helper function to create a svelte context with a
15
+ * unique name to avoid naming collisions.
16
+ * @param name The name of the context
17
+ * @returns
18
+ */
19
+ export const setupContext = (name) => {
20
+ let { uid } = createUID(name + 'Context');
21
+ return {
22
+ contextName: uid(),
23
+ context: () => getContext(uid())
24
+ };
25
+ };
26
+ /**
27
+ * Auto cleanup effects when the component is unmounted from the DOM.
28
+ */
13
29
  export const effects = (fn) => {
14
30
  let cleanUp = $effect.root(fn);
15
31
  const destroy = () => {
@@ -1,5 +1,6 @@
1
1
  import type { JsonValue, ClassProp } from '../types.js';
2
2
  export type CalcIndexAction = 'prev' | 'next' | 'first' | 'last';
3
+ export type UID = (component?: string) => string;
3
4
  /**
4
5
  * Calculates the index position of the action given.
5
6
  * @param action Which direction to navigate the index.
@@ -8,7 +9,6 @@ export type CalcIndexAction = 'prev' | 'next' | 'first' | 'last';
8
9
  * @param loop Loops around the items array if true.
9
10
  */
10
11
  export declare const calculateIndex: (action: CalcIndexAction, items: any[], index: number, loop?: boolean) => number;
11
- export type UID = (component?: string) => string;
12
12
  /**
13
13
  * Creates a unique ID to be used for accessability.
14
14
  */
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
- import type { HTMLActionArray } from './index.js';
3
+ import type { HTMLActionArray, Transition } from './index.js';
4
+ import type { Placement } from '@floating-ui/dom';
4
5
  export type JsonObject = {
5
6
  [key: string]: JsonValue;
6
7
  };
@@ -34,3 +35,19 @@ export interface BaseProps<T extends HTMLElement, C extends Record<string, any>
34
35
  self?: T;
35
36
  }
36
37
  export type BasePropsNoChildren<T extends HTMLElement, C extends Record<string, any> = any> = Omit<BaseProps<T, C>, 'children'>;
38
+ export interface DropdownProps {
39
+ /**
40
+ * The `svelte/transtion` you wish to use.
41
+ *
42
+ * @see https://lithesome.dev/docs/api#transition-prop
43
+ */
44
+ transition?: Transition;
45
+ /** The element to portal the dropdown menu to. */
46
+ portalTarget?: string | HTMLElement;
47
+ /** The anchor point of the dropdown relative to the trigger. */
48
+ placement?: Placement;
49
+ /** Keeps the dropdown from ever growing outside of the viewport. */
50
+ constrainViewport?: boolean;
51
+ /** Makes the dropdown the same width as the trigger. */
52
+ sameWidth?: boolean;
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lithesome",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Gibbu/lithesome.git"
@@ -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.84",
51
+ "svelte": "5.0.0-next.94",
52
52
  "svelte-check": "^3.6.6",
53
53
  "tailwind-merge": "^2.2.1",
54
54
  "tailwindcss": "^3.4.1",
@@ -1,15 +0,0 @@
1
- import { Context } from '../../internal/helpers/context.svelte.js';
2
- interface Hooks {
3
- onChange: (value: string[]) => void;
4
- }
5
- interface Init {
6
- value: string[];
7
- disabled: boolean;
8
- }
9
- export declare class TagsContext extends Context<Hooks> {
10
- #private;
11
- value: string[];
12
- disabled: boolean;
13
- constructor(init: Init, hooks: Hooks);
14
- }
15
- export {};
@@ -1,15 +0,0 @@
1
- import { Context, effects } from '../../internal/helpers/context.svelte.js';
2
- export class TagsContext extends Context {
3
- value = $state([]);
4
- disabled = $state(false);
5
- constructor(init, hooks) {
6
- super('tags', hooks);
7
- this.value = init.value;
8
- this.disabled = init.disabled;
9
- }
10
- #cleanup = effects(() => {
11
- $effect(() => {
12
- this.hooks?.onChange(this.value);
13
- });
14
- });
15
- }