lithesome 0.10.3 → 0.11.0

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
3
  export const { context, contextName } = setupContext();
4
- </script>
5
-
4
+ </script>
5
+
6
6
  <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
7
7
  import { setContext } from "svelte";
8
8
  let {
@@ -19,15 +19,15 @@ setContext(contextName, ctx);
19
19
  $effect(() => {
20
20
  ctx.single = single;
21
21
  });
22
- </script>
23
-
24
- <div
25
- bind:this={self}
26
- use:useActions={use}
27
- id={ctx.uid()}
28
- class={classProp(klass, { active })}
29
- data-accordion=""
30
- {...props}
31
- >
32
- {@render children({ active })}
33
- </div>
22
+ </script>
23
+
24
+ <div
25
+ bind:this={self}
26
+ use:useActions={use}
27
+ id={ctx.uid()}
28
+ class={classProp(klass, { active })}
29
+ data-accordion=""
30
+ {...props}
31
+ >
32
+ {@render children({ active })}
33
+ </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>
@@ -1,14 +1,15 @@
1
1
  import { SvelteComponent } from "svelte";
2
+ import type { AccordionButtonProps } from './types.js';
2
3
  declare const __propDef: {
3
- props: any;
4
+ props: AccordionButtonProps;
4
5
  events: {
5
6
  [evt: string]: CustomEvent<any>;
6
7
  };
7
8
  slots: {};
8
9
  };
9
- export type AccordionButtonProps = typeof __propDef.props;
10
+ type AccordionButtonProps_ = typeof __propDef.props;
11
+ export { AccordionButtonProps_ as AccordionButtonProps };
10
12
  export type AccordionButtonEvents = typeof __propDef.events;
11
13
  export type AccordionButtonSlots = typeof __propDef.slots;
12
- export default class AccordionButton extends SvelteComponent<AccordionButtonProps, AccordionButtonEvents, AccordionButtonSlots> {
14
+ export default class AccordionButton extends SvelteComponent<AccordionButtonProps_, AccordionButtonEvents, AccordionButtonSlots> {
13
15
  }
14
- export {};
@@ -16,22 +16,21 @@ const handleClick = (e) => {
16
16
  return;
17
17
  checked = checked === "mixed" ? true : !checked;
18
18
  };
19
- </script>
20
-
21
- <button
22
- type="button"
23
- bind:this={self}
24
- use:useActions={use}
25
- class={classProp(klass, { checked })}
26
- role="checkbox"
27
- aria-checked={checked}
28
- aria-required={required}
29
- data-state={checked ? 'checked' : 'unchecked'}
30
- data-checkbox=""
31
- onclick={handleClick}
32
- {...props}
33
- >
34
- {#if children}
35
- {@render children({ checked })}
36
- {/if}
37
- </button>
19
+ </script>
20
+
21
+ <button
22
+ type="button"
23
+ bind:this={self}
24
+ use:useActions={use}
25
+ class={classProp(klass, { checked })}
26
+ role="checkbox"
27
+ aria-checked={checked}
28
+ aria-required={required}
29
+ disabled={disabled || undefined}
30
+ data-state={checked ? 'checked' : 'unchecked'}
31
+ data-checkbox=""
32
+ onclick={handleClick}
33
+ {...props}
34
+ >
35
+ {@render children?.({ checked })}
36
+ </button>
@@ -52,38 +52,38 @@ $effect(() => {
52
52
  contentCleanup?.();
53
53
  };
54
54
  });
55
- </script>
56
-
57
- {#if inTransition && outTransition && ctx.visible}
58
- {@const { config: inConf, transition: inFn } = inTransition}
59
- {@const { config: outConf, transition: outFn } = outTransition}
60
- <div
61
- bind:this={self}
62
- use:useOutside={{
63
- exclude: ctx.trigger,
64
- callback: () => ctx.close()
65
- }}
66
- use:usePortal={portalTarget}
67
- use:useActions={use}
68
- in:inFn={inConf}
69
- out:outFn={outConf}
70
- {...attrs}
71
- {...props}
72
- >
73
- {@render children({ visible: ctx.visible })}
74
- </div>
75
- {:else if ctx.visible}
76
- <div
77
- bind:this={self}
78
- use:useOutside={{
79
- exclude: ctx.trigger,
80
- callback: () => ctx.close()
81
- }}
82
- use:usePortal={portalTarget}
83
- use:useActions={use}
84
- {...attrs}
85
- {...props}
86
- >
87
- {@render children({ visible: ctx.visible })}
88
- </div>
89
- {/if}
55
+ </script>
56
+
57
+ {#if inTransition && outTransition && ctx.visible}
58
+ {@const { config: inConf, transition: inFn } = inTransition}
59
+ {@const { config: outConf, transition: outFn } = outTransition}
60
+ <div
61
+ bind:this={self}
62
+ use:useOutside={{
63
+ exclude: ctx.trigger,
64
+ callback: () => ctx.close()
65
+ }}
66
+ use:usePortal={portalTarget}
67
+ use:useActions={use}
68
+ in:inFn={inConf}
69
+ out:outFn={outConf}
70
+ {...attrs}
71
+ {...props}
72
+ >
73
+ {@render children({ visible: ctx.visible })}
74
+ </div>
75
+ {:else if ctx.visible}
76
+ <div
77
+ bind:this={self}
78
+ use:useOutside={{
79
+ exclude: ctx.trigger,
80
+ callback: () => ctx.close()
81
+ }}
82
+ use:usePortal={portalTarget}
83
+ use:useActions={use}
84
+ {...attrs}
85
+ {...props}
86
+ >
87
+ {@render children({ visible: ctx.visible })}
88
+ </div>
89
+ {/if}
@@ -62,50 +62,50 @@ const handleMouseleave = (e) => {
62
62
  ctx.hovered = false;
63
63
  ctx.close();
64
64
  };
65
- </script>
66
-
67
- {#if inTransition && outTransition && ctx.visible}
68
- {@const { config: inConf, transition: inFn } = inTransition}
69
- {@const { config: outConf, transition: outFn } = outTransition}
70
- <div
71
- bind:this={self}
72
- use:useOutside={{
73
- exclude: ctx.trigger,
74
- callback: () => {
75
- ctx.visible = false;
76
- }
77
- }}
78
- use:usePortal={portalTarget}
79
- use:useActions={use}
80
- in:inFn={inConf}
81
- out:outFn={outConf}
82
- onmouseenter={handleMouseenter}
83
- onmouseleave={handleMouseleave}
84
- role="menu"
85
- tabindex={-1}
86
- {...attrs}
87
- {...props}
88
- >
89
- {@render children({ visible: ctx.visible })}
90
- </div>
91
- {:else if ctx.visible}
92
- <div
93
- bind:this={self}
94
- use:useOutside={{
95
- exclude: ctx.trigger,
96
- callback: () => {
97
- ctx.visible = false;
98
- }
99
- }}
100
- use:usePortal={portalTarget}
101
- use:useActions={use}
102
- onmouseenter={handleMouseenter}
103
- onmouseleave={handleMouseleave}
104
- role="menu"
105
- tabindex={-1}
106
- {...attrs}
107
- {...props}
108
- >
109
- {@render children({ visible: ctx.visible })}
110
- </div>
111
- {/if}
65
+ </script>
66
+
67
+ {#if inTransition && outTransition && ctx.visible}
68
+ {@const { config: inConf, transition: inFn } = inTransition}
69
+ {@const { config: outConf, transition: outFn } = outTransition}
70
+ <div
71
+ bind:this={self}
72
+ use:useOutside={{
73
+ exclude: ctx.trigger,
74
+ callback: () => {
75
+ ctx.visible = false;
76
+ }
77
+ }}
78
+ use:usePortal={portalTarget}
79
+ use:useActions={use}
80
+ in:inFn={inConf}
81
+ out:outFn={outConf}
82
+ onmouseenter={handleMouseenter}
83
+ onmouseleave={handleMouseleave}
84
+ role="menu"
85
+ tabindex={-1}
86
+ {...attrs}
87
+ {...props}
88
+ >
89
+ {@render children({ visible: ctx.visible })}
90
+ </div>
91
+ {:else if ctx.visible}
92
+ <div
93
+ bind:this={self}
94
+ use:useOutside={{
95
+ exclude: ctx.trigger,
96
+ callback: () => {
97
+ ctx.visible = false;
98
+ }
99
+ }}
100
+ use:usePortal={portalTarget}
101
+ use:useActions={use}
102
+ onmouseenter={handleMouseenter}
103
+ onmouseleave={handleMouseleave}
104
+ role="menu"
105
+ tabindex={-1}
106
+ {...attrs}
107
+ {...props}
108
+ >
109
+ {@render children({ visible: ctx.visible })}
110
+ </div>
111
+ {/if}
@@ -51,32 +51,32 @@ $effect(() => {
51
51
  contentCleanup?.();
52
52
  };
53
53
  });
54
- </script>
55
-
56
- {#if inTransition && outTransition && ctx.visible}
57
- {@const { config: inConf, transition: inFn } = inTransition}
58
- {@const { config: outConf, transition: outFn } = outTransition}
59
- <div
60
- bind:this={self}
61
- use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
62
- use:usePortal={portalTarget}
63
- use:useActions={use}
64
- in:inFn={inConf}
65
- out:outFn={outConf}
66
- {...attrs}
67
- {...props}
68
- >
69
- {@render children({ visible: ctx.visible })}
70
- </div>
71
- {:else if ctx.visible}
72
- <div
73
- bind:this={self}
74
- use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
75
- use:usePortal={portalTarget}
76
- use:useActions={use}
77
- {...attrs}
78
- {...props}
79
- >
80
- {@render children({ visible: ctx.visible })}
81
- </div>
82
- {/if}
54
+ </script>
55
+
56
+ {#if inTransition && outTransition && ctx.visible}
57
+ {@const { config: inConf, transition: inFn } = inTransition}
58
+ {@const { config: outConf, transition: outFn } = outTransition}
59
+ <div
60
+ bind:this={self}
61
+ use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
62
+ use:usePortal={portalTarget}
63
+ use:useActions={use}
64
+ in:inFn={inConf}
65
+ out:outFn={outConf}
66
+ {...attrs}
67
+ {...props}
68
+ >
69
+ {@render children({ visible: ctx.visible })}
70
+ </div>
71
+ {:else if ctx.visible}
72
+ <div
73
+ bind:this={self}
74
+ use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
75
+ use:usePortal={portalTarget}
76
+ use:useActions={use}
77
+ {...attrs}
78
+ {...props}
79
+ >
80
+ {@render children({ visible: ctx.visible })}
81
+ </div>
82
+ {/if}
@@ -14,24 +14,24 @@ const attrs = $derived({
14
14
  "aria-labelledby": ctx.uid("title"),
15
15
  "data-modalcontent": ""
16
16
  });
17
- </script>
18
-
19
- {#if inTransition && outTransition && ctx.visible}
20
- {@const { config: inConf, transition: inFn } = inTransition}
21
- {@const { config: outConf, transition: outFn } = outTransition}
22
- <div
23
- bind:this={self}
24
- use:useTrap={{ allowOutsideClick: true }}
25
- use:useActions={use}
26
- in:inFn|global={inConf}
27
- out:outFn|global={outConf}
28
- {...props}
29
- {...attrs}
30
- >
31
- {@render children({})}
32
- </div>
33
- {:else if ctx.visible}
34
- <div bind:this={self} use:useTrap={{ allowOutsideClick: true }} use:useActions={use} {...props} {...attrs}>
35
- {@render children({})}
36
- </div>
37
- {/if}
17
+ </script>
18
+
19
+ {#if inTransition && outTransition && ctx.visible}
20
+ {@const { config: inConf, transition: inFn } = inTransition}
21
+ {@const { config: outConf, transition: outFn } = outTransition}
22
+ <div
23
+ bind:this={self}
24
+ use:useTrap={{ allowOutsideClick: true }}
25
+ use:useActions={use}
26
+ in:inFn|global={inConf}
27
+ out:outFn|global={outConf}
28
+ {...props}
29
+ {...attrs}
30
+ >
31
+ {@render children({})}
32
+ </div>
33
+ {:else if ctx.visible}
34
+ <div bind:this={self} use:useTrap={{ allowOutsideClick: true }} use:useActions={use} {...props} {...attrs}>
35
+ {@render children({})}
36
+ </div>
37
+ {/if}
@@ -51,54 +51,54 @@ $effect(() => {
51
51
  contentCleanup?.();
52
52
  };
53
53
  });
54
- </script>
55
-
56
- {#if inTransition && outTransition && ctx.visible}
57
- {@const { config: inConf, transition: inFn } = inTransition}
58
- {@const { config: outConf, transition: outFn } = outTransition}
59
- <div
60
- bind:this={self}
61
- use:useOutside={{
62
- exclude: ctx.trigger,
63
- callback: () => {
64
- ctx.close();
65
- }
66
- }}
67
- use:usePortal={portalTarget}
68
- use:useActions={use}
69
- use:useTrap={{
70
- allowOutsideClick: true,
71
- onDeactivate: () => {
72
- ctx.visible = false;
73
- }
74
- }}
75
- in:inFn={inConf}
76
- out:outFn={outConf}
77
- {...attrs}
78
- {...props}
79
- >
80
- {@render children({ visible: ctx.visible })}
81
- </div>
82
- {:else if ctx.visible}
83
- <div
84
- bind:this={self}
85
- use:useOutside={{
86
- exclude: ctx.trigger,
87
- callback: () => {
88
- ctx.close();
89
- }
90
- }}
91
- use:usePortal={portalTarget}
92
- use:useActions={use}
93
- use:useTrap={{
94
- allowOutsideClick: true,
95
- onDeactivate: () => {
96
- ctx.visible = false;
97
- }
98
- }}
99
- {...attrs}
100
- {...props}
101
- >
102
- {@render children({ visible: ctx.visible })}
103
- </div>
104
- {/if}
54
+ </script>
55
+
56
+ {#if inTransition && outTransition && ctx.visible}
57
+ {@const { config: inConf, transition: inFn } = inTransition}
58
+ {@const { config: outConf, transition: outFn } = outTransition}
59
+ <div
60
+ bind:this={self}
61
+ use:useOutside={{
62
+ exclude: ctx.trigger,
63
+ callback: () => {
64
+ ctx.close();
65
+ }
66
+ }}
67
+ use:usePortal={portalTarget}
68
+ use:useActions={use}
69
+ use:useTrap={{
70
+ allowOutsideClick: true,
71
+ onDeactivate: () => {
72
+ ctx.visible = false;
73
+ }
74
+ }}
75
+ in:inFn={inConf}
76
+ out:outFn={outConf}
77
+ {...attrs}
78
+ {...props}
79
+ >
80
+ {@render children({ visible: ctx.visible })}
81
+ </div>
82
+ {:else if ctx.visible}
83
+ <div
84
+ bind:this={self}
85
+ use:useOutside={{
86
+ exclude: ctx.trigger,
87
+ callback: () => {
88
+ ctx.close();
89
+ }
90
+ }}
91
+ use:usePortal={portalTarget}
92
+ use:useActions={use}
93
+ use:useTrap={{
94
+ allowOutsideClick: true,
95
+ onDeactivate: () => {
96
+ ctx.visible = false;
97
+ }
98
+ }}
99
+ {...attrs}
100
+ {...props}
101
+ >
102
+ {@render children({ visible: ctx.visible })}
103
+ </div>
104
+ {/if}
@@ -8,8 +8,8 @@ let {
8
8
  target = $bindable("body"),
9
9
  ...props
10
10
  } = $props();
11
- </script>
12
-
13
- <div bind:this={self} use:useActions={use} use:usePortal={target} class={classProp(klass)} data-portal="" {...props}>
14
- {@render children({})}
15
- </div>
11
+ </script>
12
+
13
+ <div bind:this={self} use:useActions={use} use:usePortal={target} class={classProp(klass)} data-portal="" {...props}>
14
+ {@render children({})}
15
+ </div>
@@ -52,32 +52,32 @@ $effect(() => {
52
52
  contentCleanup?.();
53
53
  };
54
54
  });
55
- </script>
56
-
57
- {#if inTransition && outTransition && ctx.visible}
58
- {@const { config: inConf, transition: inFn } = inTransition}
59
- {@const { config: outConf, transition: outFn } = outTransition}
60
- <div
61
- bind:this={self}
62
- use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
63
- use:usePortal={portalTarget}
64
- use:useActions={use}
65
- in:inFn={inConf}
66
- out:outFn={outConf}
67
- {...attrs}
68
- {...props}
69
- >
70
- {@render children({ visible: ctx.visible })}
71
- </div>
72
- {:else if ctx.visible}
73
- <div
74
- bind:this={self}
75
- use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
76
- use:usePortal={portalTarget}
77
- use:useActions={use}
78
- {...attrs}
79
- {...props}
80
- >
81
- {@render children({ visible: ctx.visible })}
82
- </div>
83
- {/if}
55
+ </script>
56
+
57
+ {#if inTransition && outTransition && ctx.visible}
58
+ {@const { config: inConf, transition: inFn } = inTransition}
59
+ {@const { config: outConf, transition: outFn } = outTransition}
60
+ <div
61
+ bind:this={self}
62
+ use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
63
+ use:usePortal={portalTarget}
64
+ use:useActions={use}
65
+ in:inFn={inConf}
66
+ out:outFn={outConf}
67
+ {...attrs}
68
+ {...props}
69
+ >
70
+ {@render children({ visible: ctx.visible })}
71
+ </div>
72
+ {:else if ctx.visible}
73
+ <div
74
+ bind:this={self}
75
+ use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
76
+ use:usePortal={portalTarget}
77
+ use:useActions={use}
78
+ {...attrs}
79
+ {...props}
80
+ >
81
+ {@render children({ visible: ctx.visible })}
82
+ </div>
83
+ {/if}
@@ -0,0 +1,37 @@
1
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
+ let {
3
+ children,
4
+ class: klass,
5
+ use = [],
6
+ self = $bindable(),
7
+ checked = $bindable(false),
8
+ required = false,
9
+ disabled = $bindable(false),
10
+ onClick,
11
+ ...props
12
+ } = $props();
13
+ const handleClick = (e) => {
14
+ onClick?.(e);
15
+ if (disabled)
16
+ return;
17
+ checked = !checked;
18
+ };
19
+ </script>
20
+
21
+ <button
22
+ type="button"
23
+ bind:this={self}
24
+ use:useActions={use}
25
+ class={classProp(klass, { checked, disabled })}
26
+ role="switch"
27
+ aria-checked={checked}
28
+ aria-required={required}
29
+ aria-readonly={disabled || undefined}
30
+ disabled={disabled || undefined}
31
+ data-state={checked ? 'checked' : 'unchecked'}
32
+ data-switch=""
33
+ onclick={handleClick}
34
+ {...props}
35
+ >
36
+ {@render children?.({ checked, disabled })}
37
+ </button>
@@ -0,0 +1,15 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { SwitchProps } from './types.js';
3
+ declare const __propDef: {
4
+ props: SwitchProps;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {};
9
+ };
10
+ type SwitchProps_ = typeof __propDef.props;
11
+ export { SwitchProps_ as SwitchProps };
12
+ export type SwitchEvents = typeof __propDef.events;
13
+ export type SwitchSlots = typeof __propDef.slots;
14
+ export default class Switch extends SvelteComponent<SwitchProps_, SwitchEvents, SwitchSlots> {
15
+ }
@@ -0,0 +1,2 @@
1
+ export { default as Switch } from './Switch.svelte';
2
+ export type * from './types.js';
@@ -0,0 +1 @@
1
+ export { default as Switch } from './Switch.svelte';
@@ -0,0 +1,17 @@
1
+ import type { Handler, PropsMaybeChildren } from '../../internal/types.js';
2
+ interface SwitchState {
3
+ /** If the Switch is checked or not. */
4
+ checked: boolean;
5
+ /** If the Switch is disabled or not. */
6
+ disabled: boolean;
7
+ }
8
+ export interface SwitchProps extends PropsMaybeChildren<HTMLButtonElement, SwitchState> {
9
+ /** If the switch is checked or not. */
10
+ checked?: boolean;
11
+ /** Adds aria attributes. */
12
+ required?: boolean;
13
+ /** Disabled the switch, disallowing the internal events. */
14
+ disabled?: boolean;
15
+ onClick?: Handler<MouseEvent, HTMLButtonElement>;
16
+ }
17
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './components/Popover/index.js';
10
10
  export * from './components/Combobox/index.js';
11
11
  export * from './components/Hovercard/index.js';
12
12
  export * from './components/Portal/index.js';
13
+ export * from './components/Switch/index.js';
13
14
  export * from './actions/portal.js';
14
15
  export * from './actions/outside.js';
15
16
  export * from './actions/trap.js';
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ export * from './components/Popover/index.js';
10
10
  export * from './components/Combobox/index.js';
11
11
  export * from './components/Hovercard/index.js';
12
12
  export * from './components/Portal/index.js';
13
+ export * from './components/Switch/index.js';
13
14
  export * from './actions/portal.js';
14
15
  export * from './actions/outside.js';
15
16
  export * from './actions/trap.js';
@@ -19,6 +19,6 @@ onMount(() => {
19
19
  throw log.error(`Cannot initialize arrow node of <${component}Arrow />.`);
20
20
  ctx.arrow = self;
21
21
  });
22
- </script>
23
-
24
- <div bind:this={self} use:useActions={use} class={classProp(klass, state)} {...dataProps} {...props}></div>
22
+ </script>
23
+
24
+ <div bind:this={self} use:useActions={use} class={classProp(klass, state)} {...dataProps} {...props}></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lithesome",
3
- "version": "0.10.3",
3
+ "version": "0.11.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Gibbu/lithesome.git"