lithesome 0.15.2 → 0.16.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.
- package/dist/components/Accordion/Accordion.svelte +31 -31
- package/dist/components/Accordion/AccordionButton.svelte +22 -22
- package/dist/components/Accordion/AccordionContent.svelte +27 -27
- package/dist/components/Accordion/AccordionHeading.svelte +13 -13
- package/dist/components/Accordion/AccordionItem.svelte +25 -25
- package/dist/components/Accordion/main.svelte.d.ts +5 -9
- package/dist/components/Accordion/main.svelte.js +6 -0
- package/dist/components/Accordion/types.d.ts +24 -3
- package/dist/components/Checkbox/Checkbox.svelte +40 -40
- package/dist/components/Checkbox/types.d.ts +5 -2
- package/dist/components/Collapsible/Collapsible.svelte +31 -0
- package/dist/components/Collapsible/Collapsible.svelte.d.ts +4 -0
- package/dist/components/Collapsible/CollapsibleButton.svelte +22 -0
- package/dist/components/Collapsible/CollapsibleButton.svelte.d.ts +4 -0
- package/dist/components/Collapsible/CollapsibleContent.svelte +34 -0
- package/dist/components/Collapsible/CollapsibleContent.svelte.d.ts +4 -0
- package/dist/components/Collapsible/index.d.ts +3 -0
- package/dist/components/Collapsible/index.js +3 -0
- package/dist/components/Collapsible/main.svelte.d.ts +46 -0
- package/dist/components/Collapsible/main.svelte.js +74 -0
- package/dist/components/Collapsible/types.d.ts +36 -0
- package/dist/components/Collapsible/types.js +1 -0
- package/dist/components/Combobox/Combobox.svelte +52 -52
- package/dist/components/Combobox/ComboboxArrow.svelte +11 -11
- package/dist/components/Combobox/ComboboxContent.svelte +38 -37
- package/dist/components/Combobox/ComboboxInput.svelte +23 -23
- package/dist/components/Combobox/ComboboxOption.svelte +42 -42
- package/dist/components/Combobox/main.svelte.d.ts +5 -14
- package/dist/components/Combobox/types.d.ts +27 -4
- package/dist/components/Hovercard/Hovercard.svelte +29 -29
- package/dist/components/Hovercard/HovercardArrow.svelte +11 -11
- package/dist/components/Hovercard/HovercardContent.svelte +38 -38
- package/dist/components/Hovercard/HovercardTrigger.svelte +17 -17
- package/dist/components/Hovercard/main.svelte.d.ts +4 -9
- package/dist/components/Hovercard/types.d.ts +5 -2
- package/dist/components/Menu/Menu.svelte +25 -25
- package/dist/components/Menu/MenuArrow.svelte +11 -11
- package/dist/components/Menu/MenuContent.svelte +38 -37
- package/dist/components/Menu/MenuItem.svelte +38 -38
- package/dist/components/Menu/MenuTrigger.svelte +17 -17
- package/dist/components/Menu/main.svelte.d.ts +5 -13
- package/dist/components/Menu/types.d.ts +36 -4
- package/dist/components/Modal/Modal.svelte +17 -17
- package/dist/components/Modal/ModalContent.svelte +41 -41
- package/dist/components/Modal/ModalDescription.svelte +13 -13
- package/dist/components/Modal/ModalOverlay.svelte +35 -35
- package/dist/components/Modal/ModalTitle.svelte +13 -13
- package/dist/components/Modal/main.svelte.d.ts +4 -8
- package/dist/components/Modal/main.svelte.js +0 -4
- package/dist/components/Pin/Pin.svelte +34 -34
- package/dist/components/Pin/PinInput.svelte +27 -27
- package/dist/components/Pin/PinValue.svelte +20 -20
- package/dist/components/Pin/main.svelte.d.ts +17 -22
- package/dist/components/Pin/types.d.ts +10 -3
- package/dist/components/Popover/Popover.svelte +25 -25
- package/dist/components/Popover/PopoverArrow.svelte +11 -11
- package/dist/components/Popover/PopoverContent.svelte +49 -49
- package/dist/components/Popover/PopoverTrigger.svelte +17 -17
- package/dist/components/Popover/main.svelte.d.ts +5 -9
- package/dist/components/Popover/main.svelte.js +3 -0
- package/dist/components/Popover/types.d.ts +5 -2
- package/dist/components/Portal/Portal.svelte +18 -18
- package/dist/components/RadioGroup/RadioGroup.svelte +28 -28
- package/dist/components/RadioGroup/RadioGroupItem.svelte +32 -32
- package/dist/components/RadioGroup/main.svelte.d.ts +7 -6
- package/dist/components/RadioGroup/main.svelte.js +3 -0
- package/dist/components/RadioGroup/types.d.ts +13 -2
- package/dist/components/Select/Select.svelte +38 -38
- package/dist/components/Select/SelectArrow.svelte +11 -11
- package/dist/components/Select/SelectContent.svelte +37 -37
- package/dist/components/Select/SelectOption.svelte +34 -34
- package/dist/components/Select/SelectTrigger.svelte +17 -17
- package/dist/components/Select/SelectValue.svelte +19 -19
- package/dist/components/Select/main.svelte.d.ts +13 -23
- package/dist/components/Select/main.svelte.js +3 -0
- package/dist/components/Select/types.d.ts +16 -5
- package/dist/components/Slider/Slider.svelte +49 -49
- package/dist/components/Slider/SliderRange.svelte +12 -12
- package/dist/components/Slider/SliderThumb.svelte +15 -15
- package/dist/components/Slider/SliderValue.svelte +19 -19
- package/dist/components/Slider/main.svelte.d.ts +34 -46
- package/dist/components/Slider/main.svelte.js +1 -1
- package/dist/components/Slider/types.d.ts +5 -2
- package/dist/components/Switch/Switch.svelte +41 -41
- package/dist/components/Switch/types.d.ts +5 -2
- package/dist/components/Tabs/Tabs.svelte +27 -27
- package/dist/components/Tabs/TabsButton.svelte +32 -32
- package/dist/components/Tabs/TabsContent.svelte +15 -15
- package/dist/components/Tabs/TabsList.svelte +13 -13
- package/dist/components/Tabs/main.svelte.d.ts +21 -26
- package/dist/components/Tabs/main.svelte.js +3 -0
- package/dist/components/Tabs/types.d.ts +18 -3
- package/dist/components/Tags/Tags.svelte +41 -41
- package/dist/components/Tags/TagsDelete.svelte +20 -20
- package/dist/components/Tags/TagsInput.svelte +18 -18
- package/dist/components/Tags/TagsItem.svelte +15 -15
- package/dist/components/Tags/main.svelte.d.ts +5 -7
- package/dist/components/Tags/main.svelte.js +4 -0
- package/dist/components/Tags/types.d.ts +19 -4
- package/dist/components/Toast/Toast.svelte +13 -13
- package/dist/components/Toast/ToastMessage.svelte +13 -13
- package/dist/components/Toast/ToastTitle.svelte +13 -13
- package/dist/components/Toast/Toaster.svelte +26 -26
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/components/FloatingArrow.svelte +26 -26
- package/dist/internal/components/FloatingArrow.svelte.d.ts +1 -1
- package/dist/internal/components/FloatingContent.svelte +75 -75
- package/package.json +77 -77
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useActions, classProp, stateValue } from '../../internal/index.js';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
children,
|
|
8
|
-
use = [],
|
|
9
|
-
class: klass,
|
|
10
|
-
value = $bindable([]),
|
|
11
|
-
self = $bindable(),
|
|
12
|
-
single = $bindable(false),
|
|
13
|
-
onChange,
|
|
14
|
-
...props
|
|
15
|
-
}: AccordionProps = $props();
|
|
16
|
-
|
|
17
|
-
const ctx = createAccordionRootContext({
|
|
18
|
-
single: stateValue(() => single),
|
|
19
|
-
value: stateValue(
|
|
20
|
-
() => value,
|
|
21
|
-
(v) => {
|
|
22
|
-
value = v;
|
|
23
|
-
onChange?.(v);
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
});
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<div bind:this={self} use:useActions={use} class={classProp(klass)} {...ctx.attrs} {...props}>
|
|
30
|
-
{@render children?.(
|
|
31
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useActions, classProp, stateValue } from '../../internal/index.js';
|
|
3
|
+
import { createAccordionRootContext } from './main.svelte.js';
|
|
4
|
+
import type { AccordionProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
use = [],
|
|
9
|
+
class: klass,
|
|
10
|
+
value = $bindable([]),
|
|
11
|
+
self = $bindable(),
|
|
12
|
+
single = $bindable(false),
|
|
13
|
+
onChange,
|
|
14
|
+
...props
|
|
15
|
+
}: AccordionProps = $props();
|
|
16
|
+
|
|
17
|
+
const ctx = createAccordionRootContext({
|
|
18
|
+
single: stateValue(() => single),
|
|
19
|
+
value: stateValue(
|
|
20
|
+
() => value,
|
|
21
|
+
(v) => {
|
|
22
|
+
value = v;
|
|
23
|
+
onChange?.(v);
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div bind:this={self} use:useActions={use} class={classProp(klass, ctx.state)} {...ctx.attrs} {...props}>
|
|
30
|
+
{@render children?.(ctx.state)}
|
|
31
|
+
</div>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useAccordionButton } from './main.svelte.js';
|
|
3
|
-
import { useActions, classProp } from '../../internal/index.js';
|
|
4
|
-
import type { AccordionButtonProps } from './types.js';
|
|
5
|
-
|
|
6
|
-
let { children, class: klass, use = [], self = $bindable(), onClick, ...props }: AccordionButtonProps = $props();
|
|
7
|
-
|
|
8
|
-
const ctx = useAccordionButton({
|
|
9
|
-
onClick
|
|
10
|
-
});
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<button
|
|
14
|
-
type="button"
|
|
15
|
-
bind:this={self}
|
|
16
|
-
use:useActions={use}
|
|
17
|
-
class={classProp(klass, ctx.state)}
|
|
18
|
-
{...ctx.attrs}
|
|
19
|
-
{...props}
|
|
20
|
-
>
|
|
21
|
-
{@render children?.(ctx.state)}
|
|
22
|
-
</button>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useAccordionButton } from './main.svelte.js';
|
|
3
|
+
import { useActions, classProp } from '../../internal/index.js';
|
|
4
|
+
import type { AccordionButtonProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let { children, class: klass, use = [], self = $bindable(), onClick, ...props }: AccordionButtonProps = $props();
|
|
7
|
+
|
|
8
|
+
const ctx = useAccordionButton({
|
|
9
|
+
onClick
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<button
|
|
14
|
+
type="button"
|
|
15
|
+
bind:this={self}
|
|
16
|
+
use:useActions={use}
|
|
17
|
+
class={classProp(klass, ctx.state)}
|
|
18
|
+
{...ctx.attrs}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
{@render children?.(ctx.state)}
|
|
22
|
+
</button>
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useAccordionContent } from './main.svelte.js';
|
|
3
|
-
import { useActions, getTransition, classProp } from '../../internal/index.js';
|
|
4
|
-
import type { AccordionContentProps } from './types.js';
|
|
5
|
-
|
|
6
|
-
let { children, class: klass, use = [], self = $bindable(), transition, ...props }: AccordionContentProps = $props();
|
|
7
|
-
|
|
8
|
-
const ctx = useAccordionContent();
|
|
9
|
-
|
|
10
|
-
const { inTransition, outTransition } = getTransition(transition);
|
|
11
|
-
const attrs = $derived({
|
|
12
|
-
...ctx.attrs,
|
|
13
|
-
class: classProp(klass)
|
|
14
|
-
} as const);
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
{#if inTransition && outTransition && ctx.item.Active}
|
|
18
|
-
{@const { config: inConf, transition: inFn } = inTransition}
|
|
19
|
-
{@const { config: outConf, transition: outFn } = outTransition}
|
|
20
|
-
<div bind:this={self} use:useActions={use} in:inFn={inConf} out:outFn={outConf} {...attrs} {...props}>
|
|
21
|
-
{@render children?.(
|
|
22
|
-
</div>
|
|
23
|
-
{:else if ctx.item.Active}
|
|
24
|
-
<div bind:this={self} use:useActions={use} {...attrs} {...props}>
|
|
25
|
-
{@render children?.(
|
|
26
|
-
</div>
|
|
27
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useAccordionContent } from './main.svelte.js';
|
|
3
|
+
import { useActions, getTransition, classProp } from '../../internal/index.js';
|
|
4
|
+
import type { AccordionContentProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let { children, class: klass, use = [], self = $bindable(), transition, ...props }: AccordionContentProps = $props();
|
|
7
|
+
|
|
8
|
+
const ctx = useAccordionContent();
|
|
9
|
+
|
|
10
|
+
const { inTransition, outTransition } = getTransition(transition);
|
|
11
|
+
const attrs = $derived({
|
|
12
|
+
...ctx.attrs,
|
|
13
|
+
class: classProp(klass, ctx.state)
|
|
14
|
+
} as const);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
{#if inTransition && outTransition && ctx.item.Active}
|
|
18
|
+
{@const { config: inConf, transition: inFn } = inTransition}
|
|
19
|
+
{@const { config: outConf, transition: outFn } = outTransition}
|
|
20
|
+
<div bind:this={self} use:useActions={use} in:inFn={inConf} out:outFn={outConf} {...attrs} {...props}>
|
|
21
|
+
{@render children?.(ctx.state)}
|
|
22
|
+
</div>
|
|
23
|
+
{:else if ctx.item.Active}
|
|
24
|
+
<div bind:this={self} use:useActions={use} {...attrs} {...props}>
|
|
25
|
+
{@render children?.(ctx.state)}
|
|
26
|
+
</div>
|
|
27
|
+
{/if}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useAccordionHeading } from './main.svelte.js';
|
|
3
|
-
import { useActions, classProp } from '../../internal/index.js';
|
|
4
|
-
import type { AccordionHeadingProps } from './types.js';
|
|
5
|
-
|
|
6
|
-
let { children, class: klass, use = [], level = 3, self = $bindable(), ...props }: AccordionHeadingProps = $props();
|
|
7
|
-
|
|
8
|
-
const ctx = useAccordionHeading({ level });
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<div bind:this={self} use:useActions={use} class={classProp(klass)} {...ctx.attrs} {...props}>
|
|
12
|
-
{@render children?.({})}
|
|
13
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useAccordionHeading } from './main.svelte.js';
|
|
3
|
+
import { useActions, classProp } from '../../internal/index.js';
|
|
4
|
+
import type { AccordionHeadingProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let { children, class: klass, use = [], level = 3, self = $bindable(), ...props }: AccordionHeadingProps = $props();
|
|
7
|
+
|
|
8
|
+
const ctx = useAccordionHeading({ level });
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div bind:this={self} use:useActions={use} class={classProp(klass)} {...ctx.attrs} {...props}>
|
|
12
|
+
{@render children?.({})}
|
|
13
|
+
</div>
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { createAccordionItemContext } from './main.svelte.js';
|
|
3
|
-
import { useActions, classProp, stateValue } from '../../internal/index.js';
|
|
4
|
-
|
|
5
|
-
import type { AccordionItemProps } from './types.js';
|
|
6
|
-
|
|
7
|
-
let {
|
|
8
|
-
children,
|
|
9
|
-
class: klass,
|
|
10
|
-
use = [],
|
|
11
|
-
self = $bindable(),
|
|
12
|
-
disabled = $bindable(false),
|
|
13
|
-
value,
|
|
14
|
-
...props
|
|
15
|
-
}: AccordionItemProps = $props();
|
|
16
|
-
|
|
17
|
-
const ctx = createAccordionItemContext({
|
|
18
|
-
value: stateValue(() => value),
|
|
19
|
-
disabled: stateValue(() => disabled)
|
|
20
|
-
});
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<div bind:this={self} use:useActions={use} {...ctx.attrs} class={classProp(klass, ctx.state)} {...props}>
|
|
24
|
-
{@render children?.(ctx.state)}
|
|
25
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createAccordionItemContext } from './main.svelte.js';
|
|
3
|
+
import { useActions, classProp, stateValue } from '../../internal/index.js';
|
|
4
|
+
|
|
5
|
+
import type { AccordionItemProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
class: klass,
|
|
10
|
+
use = [],
|
|
11
|
+
self = $bindable(),
|
|
12
|
+
disabled = $bindable(false),
|
|
13
|
+
value,
|
|
14
|
+
...props
|
|
15
|
+
}: AccordionItemProps = $props();
|
|
16
|
+
|
|
17
|
+
const ctx = createAccordionItemContext({
|
|
18
|
+
value: stateValue(() => value),
|
|
19
|
+
disabled: stateValue(() => disabled)
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div bind:this={self} use:useActions={use} {...ctx.attrs} class={classProp(klass, ctx.state)} {...props}>
|
|
24
|
+
{@render children?.(ctx.state)}
|
|
25
|
+
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type StateValues } from '../../internal/index.js';
|
|
2
|
-
import type { AccordionButtonEvents } from './types.js';
|
|
2
|
+
import type { AccordionButtonEvents, AccordionButtonState, AccordionContentState, AccordionItemState, AccordionState } from './types.js';
|
|
3
3
|
interface Item {
|
|
4
4
|
id: string;
|
|
5
5
|
disabled: boolean;
|
|
@@ -21,6 +21,7 @@ declare class AccordionRoot {
|
|
|
21
21
|
readonly 'data-value': string[] | undefined;
|
|
22
22
|
readonly 'data-accordion': "";
|
|
23
23
|
};
|
|
24
|
+
state: AccordionState;
|
|
24
25
|
}
|
|
25
26
|
type AccordionItemProps = StateValues<{
|
|
26
27
|
disabled: boolean;
|
|
@@ -40,10 +41,7 @@ declare class AccordionItem {
|
|
|
40
41
|
readonly 'data-state': "opened" | "closed";
|
|
41
42
|
readonly 'data-value': string | undefined;
|
|
42
43
|
};
|
|
43
|
-
state:
|
|
44
|
-
active: boolean;
|
|
45
|
-
disabled: boolean;
|
|
46
|
-
};
|
|
44
|
+
state: AccordionItemState;
|
|
47
45
|
}
|
|
48
46
|
interface AccordionHeadingProps {
|
|
49
47
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
@@ -72,10 +70,7 @@ declare class AccordionButton {
|
|
|
72
70
|
readonly 'data-active': true | undefined;
|
|
73
71
|
readonly onclick: import("../../internal/index.js").Handler<MouseEvent, HTMLButtonElement> | undefined;
|
|
74
72
|
};
|
|
75
|
-
state:
|
|
76
|
-
active: boolean;
|
|
77
|
-
disabled: boolean;
|
|
78
|
-
};
|
|
73
|
+
state: AccordionButtonState;
|
|
79
74
|
}
|
|
80
75
|
declare class AccordionContent {
|
|
81
76
|
item: AccordionItem;
|
|
@@ -90,6 +85,7 @@ declare class AccordionContent {
|
|
|
90
85
|
'data-accordioncontent'?: undefined;
|
|
91
86
|
'data-active'?: undefined;
|
|
92
87
|
};
|
|
88
|
+
state: AccordionContentState;
|
|
93
89
|
}
|
|
94
90
|
export declare const createAccordionRootContext: (props: AccordionRootProps) => AccordionRoot;
|
|
95
91
|
export declare const createAccordionItemContext: (props: AccordionItemProps) => AccordionItem;
|
|
@@ -33,6 +33,9 @@ class AccordionRoot {
|
|
|
33
33
|
'data-value': this.$value.val.length > 0 ? this.$value.val : undefined,
|
|
34
34
|
'data-accordion': ''
|
|
35
35
|
}));
|
|
36
|
+
state = $derived.by(() => ({
|
|
37
|
+
value: this.$value.val
|
|
38
|
+
}));
|
|
36
39
|
}
|
|
37
40
|
class AccordionItem {
|
|
38
41
|
uid = createUID('item');
|
|
@@ -119,6 +122,9 @@ class AccordionContent {
|
|
|
119
122
|
'data-active': this.item.Active
|
|
120
123
|
}
|
|
121
124
|
: {});
|
|
125
|
+
state = $derived.by(() => ({
|
|
126
|
+
active: this.item.Active
|
|
127
|
+
}));
|
|
122
128
|
}
|
|
123
129
|
//
|
|
124
130
|
// Builders
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { Props, Handler, Transition } from '../../internal/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The state that is exposed from the `Accordion` component.\
|
|
4
|
+
* Which can be used via the `class` prop function or `children` snippet block.
|
|
5
|
+
*/
|
|
6
|
+
export interface AccordionState {
|
|
7
|
+
value: string[];
|
|
8
|
+
}
|
|
2
9
|
export interface AccordionProps extends Props<HTMLDivElement> {
|
|
3
10
|
/**
|
|
4
11
|
* The value of the active item.\
|
|
@@ -14,6 +21,13 @@ export interface AccordionProps extends Props<HTMLDivElement> {
|
|
|
14
21
|
*/
|
|
15
22
|
onChange?: (values: string[]) => void;
|
|
16
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* The state that is exposed from the `AccordionContent` component.\
|
|
26
|
+
* Which can be used via the `class` prop function or `children` snippet block.
|
|
27
|
+
*/
|
|
28
|
+
export interface AccordionContentState {
|
|
29
|
+
active: boolean;
|
|
30
|
+
}
|
|
17
31
|
export interface AccordionContentProps extends Props<HTMLDivElement> {
|
|
18
32
|
/**
|
|
19
33
|
* The `svelte/transtion` you wish to use.
|
|
@@ -26,7 +40,11 @@ export interface AccordionHeadingProps extends Props<HTMLDivElement> {
|
|
|
26
40
|
/** The `aria-level` to be set. */
|
|
27
41
|
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
28
42
|
}
|
|
29
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The state that is exposed from the `AccordionButton` component.\
|
|
45
|
+
* Which can be used via the `class` prop function or `children` snippet block.
|
|
46
|
+
*/
|
|
47
|
+
export interface AccordionButtonState {
|
|
30
48
|
/** True if the item is opened. */
|
|
31
49
|
active: boolean;
|
|
32
50
|
/** True if the item is disabled. */
|
|
@@ -43,7 +61,11 @@ export interface AccordionButtonEvents {
|
|
|
43
61
|
}
|
|
44
62
|
export interface AccordionButtonProps extends Props<HTMLButtonElement, AccordionButtonState>, AccordionButtonEvents {
|
|
45
63
|
}
|
|
46
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The state that is exposed from the `AccordionItem` component.\
|
|
66
|
+
* Which can be used via the `class` prop function or `children` snippet block.
|
|
67
|
+
*/
|
|
68
|
+
export interface AccordionItemState {
|
|
47
69
|
/** True if the item is opened. */
|
|
48
70
|
active: boolean;
|
|
49
71
|
/** True if the item is disabled. */
|
|
@@ -59,4 +81,3 @@ export interface AccordionItemProps extends Props<HTMLDivElement, AccordionItemS
|
|
|
59
81
|
/** Disables the items, disallowing clicking and keyboard navigation. */
|
|
60
82
|
disabled?: boolean;
|
|
61
83
|
}
|
|
62
|
-
export {};
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useActions, classProp } from '../../internal/index.js';
|
|
3
|
-
import type { CheckboxProps } from './types.js';
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
children,
|
|
7
|
-
class: klass,
|
|
8
|
-
use = [],
|
|
9
|
-
self = $bindable(),
|
|
10
|
-
checked = $bindable(false),
|
|
11
|
-
required = false,
|
|
12
|
-
disabled = $bindable(false),
|
|
13
|
-
onClick,
|
|
14
|
-
...props
|
|
15
|
-
}: CheckboxProps = $props();
|
|
16
|
-
|
|
17
|
-
const handleClick: typeof onClick = (e) => {
|
|
18
|
-
if (disabled) return;
|
|
19
|
-
onClick?.(e);
|
|
20
|
-
|
|
21
|
-
checked = checked === 'mixed' ? true : !checked;
|
|
22
|
-
};
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<button
|
|
26
|
-
type="button"
|
|
27
|
-
bind:this={self}
|
|
28
|
-
use:useActions={use}
|
|
29
|
-
class={classProp(klass, { checked })}
|
|
30
|
-
role="checkbox"
|
|
31
|
-
aria-checked={checked}
|
|
32
|
-
aria-required={required}
|
|
33
|
-
disabled={disabled || undefined}
|
|
34
|
-
data-state={checked ? 'checked' : 'unchecked'}
|
|
35
|
-
data-checkbox=""
|
|
36
|
-
onclick={handleClick}
|
|
37
|
-
{...props}
|
|
38
|
-
>
|
|
39
|
-
{@render children?.({ checked })}
|
|
40
|
-
</button>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useActions, classProp } from '../../internal/index.js';
|
|
3
|
+
import type { CheckboxProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
class: klass,
|
|
8
|
+
use = [],
|
|
9
|
+
self = $bindable(),
|
|
10
|
+
checked = $bindable(false),
|
|
11
|
+
required = false,
|
|
12
|
+
disabled = $bindable(false),
|
|
13
|
+
onClick,
|
|
14
|
+
...props
|
|
15
|
+
}: CheckboxProps = $props();
|
|
16
|
+
|
|
17
|
+
const handleClick: typeof onClick = (e) => {
|
|
18
|
+
if (disabled) return;
|
|
19
|
+
onClick?.(e);
|
|
20
|
+
|
|
21
|
+
checked = checked === 'mixed' ? true : !checked;
|
|
22
|
+
};
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<button
|
|
26
|
+
type="button"
|
|
27
|
+
bind:this={self}
|
|
28
|
+
use:useActions={use}
|
|
29
|
+
class={classProp(klass, { checked })}
|
|
30
|
+
role="checkbox"
|
|
31
|
+
aria-checked={checked}
|
|
32
|
+
aria-required={required}
|
|
33
|
+
disabled={disabled || undefined}
|
|
34
|
+
data-state={checked ? 'checked' : 'unchecked'}
|
|
35
|
+
data-checkbox=""
|
|
36
|
+
onclick={handleClick}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
{@render children?.({ checked })}
|
|
40
|
+
</button>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Handler, Props } from '../../internal/index.js';
|
|
2
2
|
export type Checked = boolean | 'mixed';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The state that is exposed from the `CheckboxState` component.\
|
|
5
|
+
* Which can be used via the `class` prop function or `children` snippet block.
|
|
6
|
+
*/
|
|
7
|
+
export interface CheckboxState {
|
|
4
8
|
/** If the checkbox is checked or not. */
|
|
5
9
|
checked: Checked;
|
|
6
10
|
}
|
|
@@ -19,4 +23,3 @@ export interface CheckboxProps extends Props<HTMLButtonElement, CheckboxState> {
|
|
|
19
23
|
*/
|
|
20
24
|
onClick?: Handler<MouseEvent, HTMLButtonElement>;
|
|
21
25
|
}
|
|
22
|
-
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useActions, classProp, stateValue } from '../../internal/index.js';
|
|
3
|
+
import { createCollapsibleRootContext } from './main.svelte.js';
|
|
4
|
+
import type { CollapsibleProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
use = [],
|
|
9
|
+
class: klass,
|
|
10
|
+
visible = $bindable(false),
|
|
11
|
+
self = $bindable(),
|
|
12
|
+
disabled = $bindable(false),
|
|
13
|
+
onChange,
|
|
14
|
+
...props
|
|
15
|
+
}: CollapsibleProps = $props();
|
|
16
|
+
|
|
17
|
+
const ctx = createCollapsibleRootContext({
|
|
18
|
+
visible: stateValue(
|
|
19
|
+
() => visible,
|
|
20
|
+
(v) => {
|
|
21
|
+
visible = v;
|
|
22
|
+
onChange?.(v);
|
|
23
|
+
}
|
|
24
|
+
),
|
|
25
|
+
disabled: stateValue(() => disabled)
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div bind:this={self} use:useActions={use} class={classProp(klass, ctx.state)} {...ctx.attrs} {...props}>
|
|
30
|
+
{@render children?.(ctx.state)}
|
|
31
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useCollapsibleButton } from './main.svelte.js';
|
|
3
|
+
import { useActions, classProp } from '../../internal/index.js';
|
|
4
|
+
import type { CollapsibleButtonProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let { children, class: klass, use = [], self = $bindable(), onClick, ...props }: CollapsibleButtonProps = $props();
|
|
7
|
+
|
|
8
|
+
const ctx = useCollapsibleButton({
|
|
9
|
+
onClick
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<button
|
|
14
|
+
type="button"
|
|
15
|
+
bind:this={self}
|
|
16
|
+
use:useActions={use}
|
|
17
|
+
class={classProp(klass, ctx.state)}
|
|
18
|
+
{...ctx.attrs}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
{@render children?.(ctx.state)}
|
|
22
|
+
</button>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useCollapsibleContent } from './main.svelte.js';
|
|
3
|
+
import { useActions, getTransition, classProp } from '../../internal/index.js';
|
|
4
|
+
import type { CollapsibleContentProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
class: klass,
|
|
9
|
+
use = [],
|
|
10
|
+
self = $bindable(),
|
|
11
|
+
transition,
|
|
12
|
+
...props
|
|
13
|
+
}: CollapsibleContentProps = $props();
|
|
14
|
+
|
|
15
|
+
const ctx = useCollapsibleContent();
|
|
16
|
+
|
|
17
|
+
const { inTransition, outTransition } = getTransition(transition);
|
|
18
|
+
const attrs = $derived({
|
|
19
|
+
...ctx.attrs,
|
|
20
|
+
class: classProp(klass, ctx.state)
|
|
21
|
+
} as const);
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
{#if inTransition && outTransition && ctx.root.$visible.val}
|
|
25
|
+
{@const { config: inConf, transition: inFn } = inTransition}
|
|
26
|
+
{@const { config: outConf, transition: outFn } = outTransition}
|
|
27
|
+
<div bind:this={self} use:useActions={use} in:inFn={inConf} out:outFn={outConf} {...attrs} {...props}>
|
|
28
|
+
{@render children?.(ctx.state)}
|
|
29
|
+
</div>
|
|
30
|
+
{:else if ctx.root.$visible.val}
|
|
31
|
+
<div bind:this={self} use:useActions={use} {...attrs} {...props}>
|
|
32
|
+
{@render children?.(ctx.state)}
|
|
33
|
+
</div>
|
|
34
|
+
{/if}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type StateValues } from '../../internal/index.js';
|
|
2
|
+
import type { CollapsibleButtonEvents, CollapsibleState } from './types.js';
|
|
3
|
+
type CollapsibleRootProps = StateValues<{
|
|
4
|
+
visible: boolean;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
declare class CollapsibleRoot {
|
|
8
|
+
uid: (component?: string) => string;
|
|
9
|
+
$visible: CollapsibleRootProps['visible'];
|
|
10
|
+
$disabled: CollapsibleRootProps['disabled'];
|
|
11
|
+
constructor(props: CollapsibleRootProps);
|
|
12
|
+
attrs: {
|
|
13
|
+
id: string;
|
|
14
|
+
'data-collapsible': string;
|
|
15
|
+
'data-disabled': true | undefined;
|
|
16
|
+
'data-state': string;
|
|
17
|
+
};
|
|
18
|
+
state: CollapsibleState;
|
|
19
|
+
}
|
|
20
|
+
declare class CollapsibleButton {
|
|
21
|
+
#private;
|
|
22
|
+
root: CollapsibleRoot;
|
|
23
|
+
constructor(root: CollapsibleRoot, events: CollapsibleButtonEvents);
|
|
24
|
+
attrs: {
|
|
25
|
+
id: string;
|
|
26
|
+
'aria-expanded': boolean;
|
|
27
|
+
'data-collapsiblebutton': string;
|
|
28
|
+
'data-disabled': boolean;
|
|
29
|
+
'data-state': string;
|
|
30
|
+
onclick: import("../../internal/index.js").Handler<MouseEvent, HTMLButtonElement> | undefined;
|
|
31
|
+
};
|
|
32
|
+
state: CollapsibleState;
|
|
33
|
+
}
|
|
34
|
+
declare class CollapsibleContent {
|
|
35
|
+
root: CollapsibleRoot;
|
|
36
|
+
constructor(root: CollapsibleRoot);
|
|
37
|
+
attrs: {
|
|
38
|
+
id: string;
|
|
39
|
+
'data-collapsiblecontent': string;
|
|
40
|
+
};
|
|
41
|
+
state: CollapsibleState;
|
|
42
|
+
}
|
|
43
|
+
export declare const createCollapsibleRootContext: (props: CollapsibleRootProps) => CollapsibleRoot;
|
|
44
|
+
export declare const useCollapsibleButton: (events: CollapsibleButtonEvents) => CollapsibleButton;
|
|
45
|
+
export declare const useCollapsibleContent: () => CollapsibleContent;
|
|
46
|
+
export {};
|