lithesome 0.14.1 → 0.14.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.
- package/dist/components/Accordion/Accordion.svelte +20 -16
- package/dist/components/Accordion/AccordionButton.svelte +11 -7
- package/dist/components/Accordion/AccordionContent.svelte +16 -11
- package/dist/components/Accordion/AccordionHeading.svelte +9 -5
- package/dist/components/Accordion/AccordionItem.svelte +19 -14
- package/dist/components/Checkbox/Checkbox.svelte +22 -17
- package/dist/components/Checkbox/types.d.ts +2 -2
- package/dist/components/Combobox/Combobox.svelte +48 -43
- package/dist/components/Combobox/ComboboxArrow.svelte +8 -4
- package/dist/components/Combobox/ComboboxContent.svelte +20 -16
- package/dist/components/Combobox/ComboboxInput.svelte +20 -15
- package/dist/components/Combobox/ComboboxOption.svelte +31 -27
- package/dist/components/Combobox/main.svelte.d.ts +3 -0
- package/dist/components/Combobox/main.svelte.js +16 -13
- package/dist/components/Combobox/types.d.ts +2 -0
- package/dist/components/Hovercard/Hovercard.svelte +25 -20
- package/dist/components/Hovercard/HovercardArrow.svelte +8 -4
- package/dist/components/Hovercard/HovercardContent.svelte +19 -15
- package/dist/components/Hovercard/HovercardTrigger.svelte +12 -7
- package/dist/components/Menu/Menu.svelte +20 -16
- package/dist/components/Menu/MenuArrow.svelte +8 -4
- package/dist/components/Menu/MenuContent.svelte +19 -15
- package/dist/components/Menu/MenuItem.svelte +26 -22
- package/dist/components/Menu/MenuTrigger.svelte +12 -7
- package/dist/components/Modal/Modal.svelte +15 -11
- package/dist/components/Modal/ModalContent.svelte +12 -8
- package/dist/components/Modal/ModalDescription.svelte +9 -5
- package/dist/components/Modal/ModalOverlay.svelte +10 -6
- package/dist/components/Modal/ModalTitle.svelte +9 -5
- package/dist/components/Pin/Pin.svelte +29 -24
- package/dist/components/Pin/PinInput.svelte +24 -20
- package/dist/components/Pin/PinValue.svelte +8 -4
- package/dist/components/Popover/Popover.svelte +20 -16
- package/dist/components/Popover/PopoverArrow.svelte +8 -4
- package/dist/components/Popover/PopoverContent.svelte +20 -16
- package/dist/components/Popover/PopoverTrigger.svelte +12 -7
- package/dist/components/Portal/Portal.svelte +14 -11
- package/dist/components/RadioGroup/RadioGroup.svelte +24 -20
- package/dist/components/RadioGroup/RadioGroupItem.svelte +27 -23
- package/dist/components/Select/Select.svelte +32 -28
- package/dist/components/Select/SelectArrow.svelte +8 -4
- package/dist/components/Select/SelectContent.svelte +19 -15
- package/dist/components/Select/SelectOption.svelte +30 -26
- package/dist/components/Select/SelectTrigger.svelte +13 -8
- package/dist/components/Select/SelectValue.svelte +14 -10
- package/dist/components/Slider/Slider.svelte +45 -41
- package/dist/components/Slider/SliderRange.svelte +9 -4
- package/dist/components/Slider/SliderThumb.svelte +12 -7
- package/dist/components/Slider/SliderValue.svelte +9 -4
- package/dist/components/Switch/Switch.svelte +22 -17
- package/dist/components/Switch/types.d.ts +2 -2
- package/dist/components/Tabs/Tabs.svelte +20 -16
- package/dist/components/Tabs/TabsButton.svelte +28 -24
- package/dist/components/Tabs/TabsContent.svelte +11 -7
- package/dist/components/Tabs/TabsList.svelte +9 -5
- package/dist/components/Toast/Toast.svelte +9 -5
- package/dist/components/Toast/ToastMessage.svelte +9 -5
- package/dist/components/Toast/ToastTitle.svelte +9 -5
- package/dist/components/Toast/Toaster.svelte +15 -12
- package/dist/internal/components/FloatingArrow.svelte +23 -12
- package/dist/internal/components/FloatingContent.svelte +46 -34
- package/dist/internal/types.d.ts +1 -1
- package/package.json +77 -77
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useActions, classProp, stateValue } from '../../internal/index.js';
|
|
3
|
+
import type { AccordionProps } from './types.js';
|
|
4
|
+
import { createAccordionRootContext } from './main.svelte.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
use = [],
|
|
9
|
+
class: klass,
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
self = $bindable(),
|
|
12
|
+
single = $bindable(false),
|
|
13
|
+
...props
|
|
14
|
+
}: AccordionProps = $props();
|
|
15
|
+
|
|
16
|
+
const ctx = createAccordionRootContext({
|
|
17
|
+
single: stateValue(() => single),
|
|
18
|
+
value: stateValue(() => value)
|
|
19
|
+
});
|
|
16
20
|
</script>
|
|
17
21
|
|
|
18
22
|
<div bind:this={self} use:useActions={use} class={classProp(klass)} {...ctx.attrs} {...props}>
|
|
19
|
-
{@render children({})}
|
|
23
|
+
{@render children?.({})}
|
|
20
24
|
</div>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
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
|
+
});
|
|
7
11
|
</script>
|
|
8
12
|
|
|
9
13
|
<button
|
|
@@ -14,5 +18,5 @@ const ctx = useAccordionButton({
|
|
|
14
18
|
{...ctx.attrs}
|
|
15
19
|
{...props}
|
|
16
20
|
>
|
|
17
|
-
{@render children(ctx.state)}
|
|
21
|
+
{@render children?.(ctx.state)}
|
|
18
22
|
</button>
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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);
|
|
10
15
|
</script>
|
|
11
16
|
|
|
12
17
|
{#if inTransition && outTransition && ctx.item.Active}
|
|
13
18
|
{@const { config: inConf, transition: inFn } = inTransition}
|
|
14
19
|
{@const { config: outConf, transition: outFn } = outTransition}
|
|
15
20
|
<div bind:this={self} use:useActions={use} in:inFn={inConf} out:outFn={outConf} {...attrs} {...props}>
|
|
16
|
-
{@render children({})}
|
|
21
|
+
{@render children?.({})}
|
|
17
22
|
</div>
|
|
18
23
|
{:else if ctx.item.Active}
|
|
19
24
|
<div bind:this={self} use:useActions={use} {...attrs} {...props}>
|
|
20
|
-
{@render children({})}
|
|
25
|
+
{@render children?.({})}
|
|
21
26
|
</div>
|
|
22
27
|
{/if}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
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 });
|
|
5
9
|
</script>
|
|
6
10
|
|
|
7
11
|
<div bind:this={self} use:useActions={use} class={classProp(klass)} {...ctx.attrs} {...props}>
|
|
8
|
-
{@render children({})}
|
|
12
|
+
{@render children?.({})}
|
|
9
13
|
</div>
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
...props
|
|
14
|
+
}: AccordionItemProps = $props();
|
|
15
|
+
|
|
16
|
+
const ctx = createAccordionItemContext({
|
|
17
|
+
disabled: stateValue(() => disabled)
|
|
18
|
+
});
|
|
14
19
|
</script>
|
|
15
20
|
|
|
16
21
|
<div bind:this={self} use:useActions={use} {...ctx.attrs} class={classProp(klass, ctx.state)} {...props}>
|
|
17
|
-
{@render children(ctx.state)}
|
|
22
|
+
{@render children?.(ctx.state)}
|
|
18
23
|
</div>
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
};
|
|
18
23
|
</script>
|
|
19
24
|
|
|
20
25
|
<button
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Handler,
|
|
1
|
+
import type { Handler, Props } from '../../internal/index.js';
|
|
2
2
|
export type Checked = boolean | 'mixed';
|
|
3
3
|
interface CheckboxState {
|
|
4
4
|
/** If the checkbox is checked or not. */
|
|
5
5
|
checked: Checked;
|
|
6
6
|
}
|
|
7
|
-
export interface CheckboxProps extends
|
|
7
|
+
export interface CheckboxProps extends Props<HTMLButtonElement, CheckboxState> {
|
|
8
8
|
/** If the checkbox is checked or not. */
|
|
9
9
|
checked?: Checked;
|
|
10
10
|
/** Adds aria attributes. */
|
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useActions, classProp, stateValue } from '../../internal/index.js';
|
|
3
|
+
import { createRootContext } from './main.svelte.js';
|
|
4
|
+
import type { ComboboxProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
use = [],
|
|
9
|
+
class: klass,
|
|
10
|
+
value = $bindable(),
|
|
11
|
+
label = $bindable(),
|
|
12
|
+
touched = $bindable(false),
|
|
13
|
+
disabled = $bindable(false),
|
|
14
|
+
visible = $bindable(true),
|
|
15
|
+
controlled,
|
|
16
|
+
self = $bindable(),
|
|
17
|
+
onChange,
|
|
18
|
+
...props
|
|
19
|
+
}: ComboboxProps = $props();
|
|
20
|
+
|
|
21
|
+
const ctx = createRootContext({
|
|
22
|
+
value: stateValue(
|
|
23
|
+
() => value,
|
|
24
|
+
(v) => {
|
|
25
|
+
value = v;
|
|
26
|
+
onChange?.({ value: v });
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
disabled: stateValue(() => disabled),
|
|
30
|
+
label: stateValue(
|
|
31
|
+
() => label || self?.textContent?.trim() || '',
|
|
32
|
+
(v) => {
|
|
33
|
+
label = v;
|
|
34
|
+
onChange?.({ label: v });
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
multiple: stateValue(() => Array.isArray(value)),
|
|
38
|
+
touched: stateValue(
|
|
39
|
+
() => touched,
|
|
40
|
+
(v) => (touched = v)
|
|
41
|
+
),
|
|
42
|
+
visible: stateValue(
|
|
43
|
+
() => visible,
|
|
44
|
+
(v) => (visible = v)
|
|
45
|
+
),
|
|
46
|
+
controlled: stateValue(() => controlled)
|
|
47
|
+
});
|
|
43
48
|
</script>
|
|
44
49
|
|
|
45
50
|
<div bind:this={self} use:useActions={use} class={classProp(klass, ctx.state)} {...ctx.attrs} {...props}>
|
|
46
|
-
{@render children(ctx.state)}
|
|
51
|
+
{@render children?.(ctx.state)}
|
|
47
52
|
</div>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { FloatingArrow } from '../../internal/index.js';
|
|
3
|
+
import { useComboboxArrow } from './main.svelte.js';
|
|
4
|
+
import type { ComboboxArrowProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let { class: klass, use = [], self = $bindable(), ...props }: ComboboxArrowProps = $props();
|
|
7
|
+
|
|
8
|
+
const ctx = useComboboxArrow();
|
|
5
9
|
</script>
|
|
6
10
|
|
|
7
11
|
<FloatingArrow {ctx} component="Combobox" class={klass} {...props} />
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { FloatingContent } from '../../internal/index.js';
|
|
3
|
+
import { useComboboxContent } from './main.svelte.js';
|
|
4
|
+
import type { ComboboxContentProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
transition,
|
|
9
|
+
use = [],
|
|
10
|
+
portalTarget = 'body',
|
|
11
|
+
sameWidth = false,
|
|
12
|
+
class: klass,
|
|
13
|
+
self = $bindable(),
|
|
14
|
+
placement = 'bottom',
|
|
15
|
+
constrainViewport = false,
|
|
16
|
+
...props
|
|
17
|
+
}: ComboboxContentProps = $props();
|
|
18
|
+
|
|
19
|
+
const ctx = useComboboxContent();
|
|
16
20
|
</script>
|
|
17
21
|
|
|
18
22
|
<FloatingContent
|
|
19
23
|
{children}
|
|
20
24
|
componentName="Combobox"
|
|
21
|
-
visible={ctx.root
|
|
25
|
+
visible={ctx.root.SuperVisible}
|
|
22
26
|
{ctx}
|
|
23
27
|
{transition}
|
|
24
28
|
{use}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useActions, classProp } from '../../internal/index.js';
|
|
3
|
+
import { useComboboxInput } from './main.svelte.js';
|
|
4
|
+
import type { ComboboxInputProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
class: klass,
|
|
8
|
+
use = [],
|
|
9
|
+
value = $bindable(),
|
|
10
|
+
self = $bindable(),
|
|
11
|
+
onClick,
|
|
12
|
+
onKeydown,
|
|
13
|
+
...props
|
|
14
|
+
}: ComboboxInputProps = $props();
|
|
15
|
+
|
|
16
|
+
const ctx = useComboboxInput({ onClick, onKeydown });
|
|
17
|
+
|
|
18
|
+
$effect(() => {
|
|
19
|
+
if (self) ctx.registerTrigger(self);
|
|
20
|
+
});
|
|
16
21
|
</script>
|
|
17
22
|
|
|
18
23
|
<input bind:this={self} use:useActions={use} class={classProp(klass, ctx.state)} bind:value {...ctx.attrs} {...props} />
|
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useActions, classProp, stateValue } from '../../internal/index.js';
|
|
3
|
+
import { useComboboxOption } from './main.svelte.js';
|
|
4
|
+
import type { ComboboxElement, ComboboxOptionProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
class: klass,
|
|
9
|
+
use = [],
|
|
10
|
+
value,
|
|
11
|
+
label,
|
|
12
|
+
self = $bindable(),
|
|
13
|
+
disabled = $bindable(false),
|
|
14
|
+
onClick,
|
|
15
|
+
onMouseover,
|
|
16
|
+
...props
|
|
17
|
+
}: ComboboxOptionProps = $props();
|
|
18
|
+
let optionEl: ComboboxElement;
|
|
19
|
+
|
|
20
|
+
const ctx = useComboboxOption(
|
|
21
|
+
{
|
|
22
|
+
disabled: stateValue(() => disabled),
|
|
23
|
+
value: stateValue(() => value),
|
|
24
|
+
label: stateValue(() => label || self?.textContent?.trim() || '')
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
onClick,
|
|
28
|
+
onMouseover
|
|
29
|
+
}
|
|
30
|
+
);
|
|
27
31
|
</script>
|
|
28
32
|
|
|
29
33
|
<button
|
|
@@ -34,5 +38,5 @@ const ctx = useComboboxOption(
|
|
|
34
38
|
{...ctx.attrs}
|
|
35
39
|
{...props}
|
|
36
40
|
>
|
|
37
|
-
{@render children(ctx.state)}
|
|
41
|
+
{@render children?.(ctx.state)}
|
|
38
42
|
</button>
|
|
@@ -7,6 +7,7 @@ type ComboboxRootProps = StateValues<{
|
|
|
7
7
|
label: string;
|
|
8
8
|
multiple: boolean;
|
|
9
9
|
disabled: boolean;
|
|
10
|
+
controlled: boolean | undefined;
|
|
10
11
|
}>;
|
|
11
12
|
declare class ComboboxRoot extends Floating {
|
|
12
13
|
uid: (component?: string) => string;
|
|
@@ -16,11 +17,13 @@ declare class ComboboxRoot extends Floating {
|
|
|
16
17
|
$label: ComboboxRootProps['label'];
|
|
17
18
|
$multiple: ComboboxRootProps['multiple'];
|
|
18
19
|
$disabled: ComboboxRootProps['disabled'];
|
|
20
|
+
$controlled: ComboboxRootProps['controlled'];
|
|
19
21
|
options: HTMLElement[];
|
|
20
22
|
selectedOptions: HTMLElement[];
|
|
21
23
|
mounted: boolean;
|
|
22
24
|
hoveredIndex: number;
|
|
23
25
|
HoveredOption: HTMLElement | undefined;
|
|
26
|
+
SuperVisible: boolean;
|
|
24
27
|
constructor(props: ComboboxRootProps);
|
|
25
28
|
open: () => void;
|
|
26
29
|
close: () => void;
|
|
@@ -8,11 +8,13 @@ class ComboboxRoot extends Floating {
|
|
|
8
8
|
$label;
|
|
9
9
|
$multiple;
|
|
10
10
|
$disabled;
|
|
11
|
+
$controlled;
|
|
11
12
|
options = $state([]);
|
|
12
13
|
selectedOptions = $state([]);
|
|
13
14
|
mounted = $state(false);
|
|
14
15
|
hoveredIndex = $state(-1);
|
|
15
16
|
HoveredOption = $derived.by(() => this.options[this.hoveredIndex]);
|
|
17
|
+
SuperVisible = $derived.by(() => typeof this.$controlled.val === 'boolean' ? this.$controlled.val && this.$visible.val : this.$visible.val);
|
|
16
18
|
constructor(props) {
|
|
17
19
|
super();
|
|
18
20
|
this.$visible = props.visible;
|
|
@@ -21,19 +23,20 @@ class ComboboxRoot extends Floating {
|
|
|
21
23
|
this.$label = props.label;
|
|
22
24
|
this.$multiple = props.multiple;
|
|
23
25
|
this.$disabled = props.disabled;
|
|
26
|
+
this.$controlled = props.controlled;
|
|
24
27
|
onMount(async () => {
|
|
25
28
|
await tick();
|
|
26
29
|
this.setInitialSelected(this.$value.val);
|
|
27
30
|
});
|
|
28
31
|
$effect(() => {
|
|
29
|
-
disableScroll(this
|
|
32
|
+
disableScroll(this.SuperVisible && !document.body.style.overflow);
|
|
30
33
|
});
|
|
31
34
|
$effect(() => {
|
|
32
|
-
if (!this
|
|
35
|
+
if (!this.SuperVisible || !this.options || this.hoveredIndex > this.options.length - 1)
|
|
33
36
|
this.hoveredIndex = -1;
|
|
34
37
|
});
|
|
35
38
|
$effect(() => {
|
|
36
|
-
if (this
|
|
39
|
+
if (this.SuperVisible) {
|
|
37
40
|
tick().then(() => {
|
|
38
41
|
const index = this.options.findIndex((option) => option.ariaSelected === 'true');
|
|
39
42
|
this.hoveredIndex = index ?? 0;
|
|
@@ -104,10 +107,10 @@ class ComboboxRoot extends Floating {
|
|
|
104
107
|
attrs = $derived.by(() => ({
|
|
105
108
|
id: this.uid(),
|
|
106
109
|
'data-combobox': '',
|
|
107
|
-
'data-state': this
|
|
110
|
+
'data-state': this.SuperVisible && this.mounted ? 'opened' : 'closed'
|
|
108
111
|
}));
|
|
109
112
|
state = $derived.by(() => ({
|
|
110
|
-
visible: this
|
|
113
|
+
visible: this.SuperVisible && this.mounted
|
|
111
114
|
}));
|
|
112
115
|
}
|
|
113
116
|
//
|
|
@@ -136,12 +139,12 @@ class ComboboxInput {
|
|
|
136
139
|
const { key } = e;
|
|
137
140
|
if (!PREVENT_KEYS.includes(key)) {
|
|
138
141
|
this.root.$touched.val = true;
|
|
139
|
-
if (!this.root
|
|
142
|
+
if (!this.root.SuperVisible)
|
|
140
143
|
this.root.open();
|
|
141
144
|
}
|
|
142
145
|
if (key === KEYS.arrowUp || key === KEYS.arrowDown || key === KEYS.end || key === KEYS.home) {
|
|
143
146
|
e.preventDefault();
|
|
144
|
-
if (!this.root
|
|
147
|
+
if (!this.root.SuperVisible)
|
|
145
148
|
this.root.open();
|
|
146
149
|
}
|
|
147
150
|
if (key === KEYS.home)
|
|
@@ -156,7 +159,7 @@ class ComboboxInput {
|
|
|
156
159
|
this.root.close();
|
|
157
160
|
if (key === KEYS.enter) {
|
|
158
161
|
e.preventDefault();
|
|
159
|
-
if (this.root.HoveredOption && this.root
|
|
162
|
+
if (this.root.HoveredOption && this.root.SuperVisible) {
|
|
160
163
|
this.root.HoveredOption.click();
|
|
161
164
|
if (!this.root.$multiple.val)
|
|
162
165
|
this.root.close();
|
|
@@ -174,15 +177,15 @@ class ComboboxInput {
|
|
|
174
177
|
role: 'combobox',
|
|
175
178
|
'aria-autocomplete': 'list',
|
|
176
179
|
'aria-haspopup': 'listbox',
|
|
177
|
-
'aria-controls': this.root
|
|
178
|
-
'aria-expanded': this.root
|
|
180
|
+
'aria-controls': this.root.SuperVisible ? this.root.uid('content') : undefined,
|
|
181
|
+
'aria-expanded': this.root.SuperVisible,
|
|
179
182
|
'aria-activedescendant': this.root.HoveredOption?.id || undefined,
|
|
180
183
|
autocomplete: 'off',
|
|
181
184
|
onclick: this.#handleCick,
|
|
182
185
|
onkeydown: this.#handleKeydown
|
|
183
186
|
}));
|
|
184
187
|
state = $derived.by(() => ({
|
|
185
|
-
visible: this.root
|
|
188
|
+
visible: this.root.SuperVisible
|
|
186
189
|
}));
|
|
187
190
|
}
|
|
188
191
|
//
|
|
@@ -209,7 +212,7 @@ class ComboboxContent {
|
|
|
209
212
|
hidden: !this.root.mounted || undefined
|
|
210
213
|
}));
|
|
211
214
|
state = $derived.by(() => ({
|
|
212
|
-
visible: this.root
|
|
215
|
+
visible: this.root.SuperVisible
|
|
213
216
|
}));
|
|
214
217
|
}
|
|
215
218
|
class ComboboxOption {
|
|
@@ -230,7 +233,7 @@ class ComboboxOption {
|
|
|
230
233
|
onMount(() => {
|
|
231
234
|
this.root.queryElements();
|
|
232
235
|
return async () => {
|
|
233
|
-
if (!this.root
|
|
236
|
+
if (!this.root.SuperVisible)
|
|
234
237
|
return;
|
|
235
238
|
await tick();
|
|
236
239
|
this.root.queryElements();
|
|
@@ -15,6 +15,8 @@ export interface ComboboxProps extends Props<HTMLDivElement, ComboboxState> {
|
|
|
15
15
|
visible?: boolean;
|
|
16
16
|
/** If the user has modified the selected value in anyway. */
|
|
17
17
|
touched?: boolean;
|
|
18
|
+
/** Allows for the combobox content to be visible only when this condition is met. */
|
|
19
|
+
controlled?: boolean;
|
|
18
20
|
onChange?: (payload?: {
|
|
19
21
|
value?: JsonValue;
|
|
20
22
|
label?: string;
|