bits-ui 1.0.0-next.16 → 1.0.0-next.18
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/bits/combobox/components/combobox-input.svelte +2 -2
- package/dist/bits/combobox/components/combobox-trigger.svelte +2 -2
- package/dist/bits/combobox/components/combobox.svelte +9 -7
- package/dist/bits/combobox/exports.d.ts +8 -8
- package/dist/bits/combobox/exports.js +8 -8
- package/dist/bits/combobox/types.d.ts +1 -1
- package/dist/bits/index.d.ts +0 -1
- package/dist/bits/index.js +0 -1
- package/dist/bits/menu/menu.svelte.js +2 -2
- package/dist/bits/menubar/menubar.svelte.js +1 -1
- package/dist/bits/pagination/types.d.ts +1 -0
- package/dist/bits/{listbox/components/listbox-content-static.svelte → select/components/select-content-static.svelte} +6 -6
- package/dist/bits/{listbox/components/listbox-group-heading.svelte.d.ts → select/components/select-content-static.svelte.d.ts} +4 -4
- package/dist/bits/select/components/select-content.svelte +56 -35
- package/dist/bits/select/components/select-group-heading.svelte +3 -3
- package/dist/bits/select/components/select-group.svelte +4 -3
- package/dist/bits/{listbox/components/listbox-hidden-input.svelte → select/components/select-hidden-input.svelte} +4 -4
- package/dist/bits/{listbox/components/listbox-hidden-input.svelte.d.ts → select/components/select-hidden-input.svelte.d.ts} +4 -4
- package/dist/bits/select/components/select-item.svelte +14 -9
- package/dist/bits/select/components/select-scroll-down-button.svelte +20 -9
- package/dist/bits/select/components/select-scroll-down-button.svelte.d.ts +2 -2
- package/dist/bits/select/components/select-scroll-up-button.svelte +21 -10
- package/dist/bits/select/components/select-trigger.svelte +5 -7
- package/dist/bits/select/components/select-viewport.svelte +10 -0
- package/dist/bits/select/components/select.svelte +54 -56
- package/dist/bits/select/exports.d.ts +4 -7
- package/dist/bits/select/exports.js +3 -6
- package/dist/bits/select/select.svelte.d.ts +272 -258
- package/dist/bits/select/select.svelte.js +764 -831
- package/dist/bits/select/types.d.ts +128 -79
- package/dist/internal/arrays.d.ts +23 -0
- package/dist/internal/arrays.js +35 -0
- package/dist/internal/use-data-typeahead.svelte.d.ts +12 -0
- package/dist/internal/use-data-typeahead.svelte.js +30 -0
- package/dist/internal/use-dom-typeahead.svelte.d.ts +11 -0
- package/dist/internal/use-dom-typeahead.svelte.js +30 -0
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
- package/dist/bits/listbox/components/listbox-content-static.svelte.d.ts +0 -19
- package/dist/bits/listbox/components/listbox-content.svelte +0 -76
- package/dist/bits/listbox/components/listbox-content.svelte.d.ts +0 -19
- package/dist/bits/listbox/components/listbox-group-heading.svelte +0 -32
- package/dist/bits/listbox/components/listbox-group.svelte +0 -32
- package/dist/bits/listbox/components/listbox-group.svelte.d.ts +0 -19
- package/dist/bits/listbox/components/listbox-item.svelte +0 -43
- package/dist/bits/listbox/components/listbox-item.svelte.d.ts +0 -19
- package/dist/bits/listbox/components/listbox-scroll-down-button.svelte +0 -39
- package/dist/bits/listbox/components/listbox-scroll-down-button.svelte.d.ts +0 -19
- package/dist/bits/listbox/components/listbox-scroll-up-button.svelte +0 -39
- package/dist/bits/listbox/components/listbox-scroll-up-button.svelte.d.ts +0 -19
- package/dist/bits/listbox/components/listbox-trigger.svelte +0 -35
- package/dist/bits/listbox/components/listbox-trigger.svelte.d.ts +0 -19
- package/dist/bits/listbox/components/listbox-viewport.svelte +0 -54
- package/dist/bits/listbox/components/listbox-viewport.svelte.d.ts +0 -19
- package/dist/bits/listbox/components/listbox.svelte +0 -81
- package/dist/bits/listbox/components/listbox.svelte.d.ts +0 -18
- package/dist/bits/listbox/exports.d.ts +0 -12
- package/dist/bits/listbox/exports.js +0 -11
- package/dist/bits/listbox/index.d.ts +0 -1
- package/dist/bits/listbox/index.js +0 -1
- package/dist/bits/listbox/listbox.svelte.d.ts +0 -399
- package/dist/bits/listbox/listbox.svelte.js +0 -973
- package/dist/bits/listbox/types.d.ts +0 -177
- package/dist/bits/listbox/types.js +0 -1
- package/dist/bits/select/components/select-arrow.svelte +0 -21
- package/dist/bits/select/components/select-arrow.svelte.d.ts +0 -18
- package/dist/bits/select/components/select-content-floating.svelte +0 -73
- package/dist/bits/select/components/select-content-floating.svelte.d.ts +0 -33
- package/dist/bits/select/components/select-content-impl.svelte +0 -90
- package/dist/bits/select/components/select-content-impl.svelte.d.ts +0 -90
- package/dist/bits/select/components/select-content-item-aligned.svelte +0 -37
- package/dist/bits/select/components/select-content-item-aligned.svelte.d.ts +0 -29
- package/dist/bits/select/components/select-icon.svelte +0 -36
- package/dist/bits/select/components/select-icon.svelte.d.ts +0 -19
- package/dist/bits/select/components/select-item-text.svelte +0 -39
- package/dist/bits/select/components/select-item-text.svelte.d.ts +0 -19
- package/dist/bits/select/components/select-native.svelte +0 -36
- package/dist/bits/select/components/select-native.svelte.d.ts +0 -30
- package/dist/bits/select/components/select-provider.svelte +0 -10
- package/dist/bits/select/components/select-provider.svelte.d.ts +0 -23
- package/dist/bits/select/components/select-scroll-down-button-mounted.svelte +0 -33
- package/dist/bits/select/components/select-scroll-down-button-mounted.svelte.d.ts +0 -29
- package/dist/bits/select/components/select-scroll-up-button-mounted.svelte +0 -33
- package/dist/bits/select/components/select-scroll-up-button-mounted.svelte.d.ts +0 -29
- package/dist/bits/select/components/select-separator.svelte +0 -32
- package/dist/bits/select/components/select-separator.svelte.d.ts +0 -19
- package/dist/bits/select/components/select-value.svelte +0 -35
- package/dist/bits/select/components/select-value.svelte.d.ts +0 -19
- package/dist/internal/use-typeahead.svelte.d.ts +0 -34
- package/dist/internal/use-typeahead.svelte.js +0 -64
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type { ComboboxInputProps } from "../types.js";
|
|
4
4
|
import { useId } from "../../../internal/use-id.js";
|
|
5
5
|
import { FloatingLayer } from "../../utilities/floating-layer/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useSelectInput } from "../../select/select.svelte.js";
|
|
7
7
|
|
|
8
8
|
let {
|
|
9
9
|
id = useId(),
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
...restProps
|
|
14
14
|
}: ComboboxInputProps = $props();
|
|
15
15
|
|
|
16
|
-
const inputState =
|
|
16
|
+
const inputState = useSelectInput({
|
|
17
17
|
id: box.with(() => id),
|
|
18
18
|
ref: box.with(
|
|
19
19
|
() => ref,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { box, mergeProps } from "svelte-toolbelt";
|
|
3
3
|
import type { ComboboxTriggerProps } from "../types.js";
|
|
4
4
|
import { useId } from "../../../internal/use-id.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useSelectComboTrigger } from "../../select/select.svelte.js";
|
|
6
6
|
|
|
7
7
|
let {
|
|
8
8
|
id = useId(),
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
...restProps
|
|
13
13
|
}: ComboboxTriggerProps = $props();
|
|
14
14
|
|
|
15
|
-
const triggerState =
|
|
15
|
+
const triggerState = useSelectComboTrigger({
|
|
16
16
|
id: box.with(() => id),
|
|
17
17
|
ref: box.with(
|
|
18
18
|
() => ref,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import type { ComboboxRootProps } from "../types.js";
|
|
4
4
|
import { noop } from "../../../internal/noop.js";
|
|
5
5
|
import FloatingLayer from "../../utilities/floating-layer/components/floating-layer.svelte";
|
|
6
|
-
import {
|
|
7
|
-
import ListboxHiddenInput from "../../
|
|
6
|
+
import { useSelectRoot } from "../../select/select.svelte.js";
|
|
7
|
+
import ListboxHiddenInput from "../../select/components/select-hidden-input.svelte";
|
|
8
8
|
|
|
9
9
|
let {
|
|
10
10
|
value = $bindable(),
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
required = false,
|
|
20
20
|
controlledOpen = false,
|
|
21
21
|
controlledValue = false,
|
|
22
|
+
items = [],
|
|
22
23
|
children,
|
|
23
24
|
}: ComboboxRootProps = $props();
|
|
24
25
|
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
const rootState = useSelectRoot({
|
|
35
36
|
type,
|
|
36
37
|
value: box.with(
|
|
37
38
|
() => value!,
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
scrollAlignment: box.with(() => scrollAlignment),
|
|
62
63
|
name: box.with(() => name),
|
|
63
64
|
isCombobox: true,
|
|
65
|
+
items: box.with(() => items),
|
|
64
66
|
});
|
|
65
67
|
</script>
|
|
66
68
|
|
|
@@ -68,14 +70,14 @@
|
|
|
68
70
|
{@render children?.()}
|
|
69
71
|
</FloatingLayer>
|
|
70
72
|
|
|
71
|
-
{#if Array.isArray(value)}
|
|
72
|
-
{#if value.length === 0}
|
|
73
|
+
{#if Array.isArray(rootState.value.current)}
|
|
74
|
+
{#if rootState.value.current.length === 0}
|
|
73
75
|
<ListboxHiddenInput value="" />
|
|
74
76
|
{:else}
|
|
75
|
-
{#each value as item}
|
|
77
|
+
{#each rootState.value.current as item}
|
|
76
78
|
<ListboxHiddenInput value={item} />
|
|
77
79
|
{/each}
|
|
78
80
|
{/if}
|
|
79
81
|
{:else}
|
|
80
|
-
<ListboxHiddenInput {value} />
|
|
82
|
+
<ListboxHiddenInput bind:value={rootState.value.current as string} />
|
|
81
83
|
{/if}
|
|
@@ -4,12 +4,12 @@ export { default as Separator } from "../separator/components/separator.svelte";
|
|
|
4
4
|
export { default as Arrow } from "../utilities/arrow/arrow.svelte";
|
|
5
5
|
export { default as Trigger } from "./components/combobox-trigger.svelte";
|
|
6
6
|
export { default as Portal } from "../utilities/portal/portal.svelte";
|
|
7
|
-
export { default as Content } from "../
|
|
8
|
-
export { default as ContentStatic } from "../
|
|
9
|
-
export { default as Item } from "../
|
|
10
|
-
export { default as Group } from "../
|
|
11
|
-
export { default as GroupHeading } from "../
|
|
12
|
-
export { default as Viewport } from "../
|
|
13
|
-
export { default as ScrollDownButton } from "../
|
|
14
|
-
export { default as ScrollUpButton } from "../
|
|
7
|
+
export { default as Content } from "../select/components/select-content.svelte";
|
|
8
|
+
export { default as ContentStatic } from "../select/components/select-content-static.svelte";
|
|
9
|
+
export { default as Item } from "../select/components/select-item.svelte";
|
|
10
|
+
export { default as Group } from "../select/components/select-group.svelte";
|
|
11
|
+
export { default as GroupHeading } from "../select/components/select-group-heading.svelte";
|
|
12
|
+
export { default as Viewport } from "../select/components/select-viewport.svelte";
|
|
13
|
+
export { default as ScrollDownButton } from "../select/components/select-scroll-down-button.svelte";
|
|
14
|
+
export { default as ScrollUpButton } from "../select/components/select-scroll-up-button.svelte";
|
|
15
15
|
export type { ComboboxRootProps as RootProps, ComboboxContentProps as ContentProps, ComboboxContentStaticProps as ContentStaticProps, ComboboxInputProps as InputProps, ComboboxItemProps as ItemProps, ComboboxGroupProps as GroupProps, ComboboxGroupHeadingProps as GroupHeadingProps, ComboboxPortalProps as PortalProps, ComboboxArrowProps as ArrowProps, ComboboxTriggerProps as TriggerProps, ComboboxScrollDownButtonProps as ScrollDownButtonProps, ComboboxScrollUpButtonProps as ScrollUpButtonProps, ComboboxViewportProps as ViewportProps, } from "./types.js";
|
|
@@ -4,11 +4,11 @@ export { default as Separator } from "../separator/components/separator.svelte";
|
|
|
4
4
|
export { default as Arrow } from "../utilities/arrow/arrow.svelte";
|
|
5
5
|
export { default as Trigger } from "./components/combobox-trigger.svelte";
|
|
6
6
|
export { default as Portal } from "../utilities/portal/portal.svelte";
|
|
7
|
-
export { default as Content } from "../
|
|
8
|
-
export { default as ContentStatic } from "../
|
|
9
|
-
export { default as Item } from "../
|
|
10
|
-
export { default as Group } from "../
|
|
11
|
-
export { default as GroupHeading } from "../
|
|
12
|
-
export { default as Viewport } from "../
|
|
13
|
-
export { default as ScrollDownButton } from "../
|
|
14
|
-
export { default as ScrollUpButton } from "../
|
|
7
|
+
export { default as Content } from "../select/components/select-content.svelte";
|
|
8
|
+
export { default as ContentStatic } from "../select/components/select-content-static.svelte";
|
|
9
|
+
export { default as Item } from "../select/components/select-item.svelte";
|
|
10
|
+
export { default as Group } from "../select/components/select-group.svelte";
|
|
11
|
+
export { default as GroupHeading } from "../select/components/select-group-heading.svelte";
|
|
12
|
+
export { default as Viewport } from "../select/components/select-viewport.svelte";
|
|
13
|
+
export { default as ScrollDownButton } from "../select/components/select-scroll-down-button.svelte";
|
|
14
|
+
export { default as ScrollUpButton } from "../select/components/select-scroll-up-button.svelte";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BitsPrimitiveInputAttributes } from "../../shared/attributes.js";
|
|
2
2
|
import type { WithChild, Without } from "../../internal/types.js";
|
|
3
|
-
export type {
|
|
3
|
+
export type { SelectBaseRootPropsWithoutHTML as ComboboxBaseRootPropsWithoutHTML, SelectContentProps as ComboboxContentProps, SelectContentPropsWithoutHTML as ComboboxContentPropsWithoutHTML, SelectContentStaticProps as ComboboxContentStaticProps, SelectContentStaticPropsWithoutHTML as ComboboxContentStaticPropsWithoutHTML, SelectItemProps as ComboboxItemProps, SelectItemPropsWithoutHTML as ComboboxItemPropsWithoutHTML, SelectItemSnippetProps as ComboboxItemSnippetProps, SelectMultipleRootProps as ComboboxMultipleRootProps, SelectMultipleRootPropsWithoutHTML as ComboboxMultipleRootPropsWithoutHTML, SelectRootProps as ComboboxRootProps, SelectRootPropsWithoutHTML as ComboboxRootPropsWithoutHTML, SelectSingleRootProps as ComboboxSingleRootProps, SelectSingleRootPropsWithoutHTML as ComboboxSingleRootPropsWithoutHTML, SelectTriggerProps as ComboboxTriggerProps, SelectTriggerPropsWithoutHTML as ComboboxTriggerPropsWithoutHTML, SelectGroupPropsWithoutHTML as ComboboxGroupPropsWithoutHTML, SelectGroupProps as ComboboxGroupProps, SelectGroupHeadingPropsWithoutHTML as ComboboxGroupHeadingPropsWithoutHTML, SelectGroupHeadingProps as ComboboxGroupHeadingProps, SelectViewportPropsWithoutHTML as ComboboxViewportPropsWithoutHTML, SelectViewportProps as ComboboxViewportProps, SelectScrollDownButtonProps as ComboboxScrollDownButtonProps, SelectScrollDownButtonPropsWithoutHTML as ComboboxScrollDownButtonPropsWithoutHTML, SelectScrollUpButtonProps as ComboboxScrollUpButtonProps, SelectScrollUpButtonPropsWithoutHTML as ComboboxScrollUpButtonPropsWithoutHTML, SelectArrowProps as ComboboxArrowProps, SelectArrowPropsWithoutHTML as ComboboxArrowPropsWithoutHTML, SelectPortalProps as ComboboxPortalProps, SelectPortalPropsWithoutHTML as ComboboxPortalPropsWithoutHTML, } from "../select/types.js";
|
|
4
4
|
export type ComboboxInputPropsWithoutHTML = WithChild<{
|
|
5
5
|
/**
|
|
6
6
|
* The default value of the input. This is not a reactive prop and is only used to populate
|
package/dist/bits/index.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export { Dialog } from "./dialog/index.js";
|
|
|
17
17
|
export { DropdownMenu } from "./dropdown-menu/index.js";
|
|
18
18
|
export { Label } from "./label/index.js";
|
|
19
19
|
export { LinkPreview } from "./link-preview/index.js";
|
|
20
|
-
export { Listbox } from "./listbox/index.js";
|
|
21
20
|
export { Menubar } from "./menubar/index.js";
|
|
22
21
|
export { NavigationMenu } from "./navigation-menu/index.js";
|
|
23
22
|
export { Pagination } from "./pagination/index.js";
|
package/dist/bits/index.js
CHANGED
|
@@ -17,7 +17,6 @@ export { Dialog } from "./dialog/index.js";
|
|
|
17
17
|
export { DropdownMenu } from "./dropdown-menu/index.js";
|
|
18
18
|
export { Label } from "./label/index.js";
|
|
19
19
|
export { LinkPreview } from "./link-preview/index.js";
|
|
20
|
-
export { Listbox } from "./listbox/index.js";
|
|
21
20
|
export { Menubar } from "./menubar/index.js";
|
|
22
21
|
export { NavigationMenu } from "./navigation-menu/index.js";
|
|
23
22
|
export { Pagination } from "./pagination/index.js";
|
|
@@ -4,7 +4,7 @@ import { IsFocusWithin } from "runed";
|
|
|
4
4
|
import { FIRST_LAST_KEYS, LAST_KEYS, SELECTION_KEYS, SUB_OPEN_KEYS, getCheckedState, isMouseEvent, } from "./utils.js";
|
|
5
5
|
import { focusFirst } from "../../internal/focus.js";
|
|
6
6
|
import { addEventListener } from "../../internal/events.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useDOMTypeahead } from "../../internal/use-dom-typeahead.svelte.js";
|
|
8
8
|
import { isElement, isElementOrSVGElement, isHTMLElement } from "../../internal/is.js";
|
|
9
9
|
import { useRovingFocus } from "../../internal/use-roving-focus.svelte.js";
|
|
10
10
|
import { kbd } from "../../internal/kbd.js";
|
|
@@ -116,7 +116,7 @@ class MenuContentState {
|
|
|
116
116
|
onDestroyEffect(() => {
|
|
117
117
|
window.clearTimeout(this.#timer);
|
|
118
118
|
});
|
|
119
|
-
this.#handleTypeaheadSearch =
|
|
119
|
+
this.#handleTypeaheadSearch = useDOMTypeahead().handleTypeaheadSearch;
|
|
120
120
|
this.rovingFocusGroup = useRovingFocus({
|
|
121
121
|
rootNodeId: this.parentMenu.contentId,
|
|
122
122
|
candidateAttr: this.parentMenu.root.getAttr("item"),
|
|
@@ -4,7 +4,7 @@ import { useRovingFocus, } from "../../internal/use-roving-focus.svelte.js";
|
|
|
4
4
|
import { createContext } from "../../internal/create-context.js";
|
|
5
5
|
import { getAriaExpanded, getDataDisabled, getDataOpenClosed } from "../../internal/attrs.js";
|
|
6
6
|
import { kbd } from "../../internal/kbd.js";
|
|
7
|
-
import { wrapArray } from "../../internal/
|
|
7
|
+
import { wrapArray } from "../../internal/arrays.js";
|
|
8
8
|
import { isBrowser } from "../../internal/is.js";
|
|
9
9
|
const ROOT_ATTR = "data-menubar-root";
|
|
10
10
|
const TRIGGER_ATTR = "data-menubar-trigger";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { box, mergeProps } from "svelte-toolbelt";
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
3
|
+
import type { SelectContentStaticProps } from "../types.js";
|
|
4
|
+
import { useSelectContent } from "../select.svelte.js";
|
|
5
5
|
import PopperLayer from "../../utilities/popper-layer/popper-layer.svelte";
|
|
6
6
|
import { useId } from "../../../internal/use-id.js";
|
|
7
7
|
import { noop } from "../../../internal/noop.js";
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
children,
|
|
16
16
|
child,
|
|
17
17
|
...restProps
|
|
18
|
-
}:
|
|
18
|
+
}: SelectContentStaticProps = $props();
|
|
19
19
|
|
|
20
|
-
const contentState =
|
|
20
|
+
const contentState = useSelectContent({
|
|
21
21
|
id: box.with(() => id),
|
|
22
22
|
ref: box.with(
|
|
23
23
|
() => ref,
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
if (e.defaultPrevented) return;
|
|
39
39
|
onInteractOutside(e);
|
|
40
40
|
if (e.defaultPrevented) return;
|
|
41
|
-
contentState.root.
|
|
41
|
+
contentState.root.handleClose();
|
|
42
42
|
}}
|
|
43
43
|
onEscapeKeydown={(e) => {
|
|
44
44
|
onEscapeKeydown(e);
|
|
45
45
|
if (e.defaultPrevented) return;
|
|
46
|
-
contentState.root.
|
|
46
|
+
contentState.root.handleClose();
|
|
47
47
|
}}
|
|
48
48
|
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
49
49
|
onCloseAutoFocus={(e) => e.preventDefault()}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SelectContentStaticProps } from "../types.js";
|
|
2
2
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
3
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
4
|
$$bindings?: Bindings;
|
|
@@ -12,8 +12,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
12
12
|
};
|
|
13
13
|
z_$$bindings?: Bindings;
|
|
14
14
|
}
|
|
15
|
-
declare const
|
|
15
|
+
declare const SelectContentStatic: $$__sveltets_2_IsomorphicComponent<SelectContentStaticProps, {
|
|
16
16
|
[evt: string]: CustomEvent<any>;
|
|
17
17
|
}, {}, {}, "ref">;
|
|
18
|
-
type
|
|
19
|
-
export default
|
|
18
|
+
type SelectContentStatic = InstanceType<typeof SelectContentStatic>;
|
|
19
|
+
export default SelectContentStatic;
|
|
@@ -1,55 +1,76 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { box } from "svelte-toolbelt";
|
|
2
|
+
import { box, mergeProps } from "svelte-toolbelt";
|
|
3
3
|
import type { SelectContentProps } from "../types.js";
|
|
4
|
-
import { useSelectContent
|
|
5
|
-
import
|
|
6
|
-
import SelectContentImpl from "./select-content-impl.svelte";
|
|
4
|
+
import { useSelectContent } from "../select.svelte.js";
|
|
5
|
+
import PopperLayer from "../../utilities/popper-layer/popper-layer.svelte";
|
|
7
6
|
import { useId } from "../../../internal/use-id.js";
|
|
8
|
-
import
|
|
9
|
-
import PresenceLayer from "../../utilities/presence-layer/presence-layer.svelte";
|
|
7
|
+
import { noop } from "../../../internal/noop.js";
|
|
10
8
|
|
|
11
9
|
let {
|
|
12
10
|
id = useId(),
|
|
13
11
|
ref = $bindable(null),
|
|
14
12
|
forceMount = false,
|
|
15
|
-
|
|
13
|
+
side = "bottom",
|
|
14
|
+
onInteractOutside = noop,
|
|
15
|
+
onEscapeKeydown = noop,
|
|
16
|
+
children,
|
|
17
|
+
child,
|
|
16
18
|
...restProps
|
|
17
19
|
}: SelectContentProps = $props();
|
|
18
20
|
|
|
19
|
-
const contentState =
|
|
20
|
-
|
|
21
|
-
const contentContext = useSelectContent({
|
|
21
|
+
const contentState = useSelectContent({
|
|
22
22
|
id: box.with(() => id),
|
|
23
|
-
position: box.with(() => position),
|
|
24
23
|
ref: box.with(
|
|
25
24
|
() => ref,
|
|
26
25
|
(v) => (ref = v)
|
|
27
26
|
),
|
|
28
27
|
});
|
|
29
28
|
|
|
30
|
-
const
|
|
29
|
+
const mergedProps = $derived(mergeProps(restProps, contentState.props));
|
|
31
30
|
</script>
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
32
|
+
<PopperLayer
|
|
33
|
+
{...mergedProps}
|
|
34
|
+
{side}
|
|
35
|
+
present={contentState.root.open.current || forceMount}
|
|
36
|
+
{id}
|
|
37
|
+
onInteractOutside={(e) => {
|
|
38
|
+
contentState.handleInteractOutside(e);
|
|
39
|
+
if (e.defaultPrevented) return;
|
|
40
|
+
onInteractOutside(e);
|
|
41
|
+
if (e.defaultPrevented) return;
|
|
42
|
+
contentState.root.handleClose();
|
|
43
|
+
}}
|
|
44
|
+
onEscapeKeydown={(e) => {
|
|
45
|
+
onEscapeKeydown(e);
|
|
46
|
+
if (e.defaultPrevented) return;
|
|
47
|
+
contentState.root.handleClose();
|
|
48
|
+
}}
|
|
49
|
+
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
50
|
+
onCloseAutoFocus={(e) => e.preventDefault()}
|
|
51
|
+
trapFocus={false}
|
|
52
|
+
loop={false}
|
|
53
|
+
preventScroll={false}
|
|
54
|
+
onPlaced={() => (contentState.isPositioned = true)}
|
|
55
|
+
{forceMount}
|
|
56
|
+
>
|
|
57
|
+
{#snippet popper({ props })}
|
|
58
|
+
{@const finalProps = mergeProps(props, {
|
|
59
|
+
style: {
|
|
60
|
+
"--bits-select-content-transform-origin": "var(--bits-floating-transform-origin)",
|
|
61
|
+
"--bits-select-content-available-width": "var(--bits-floating-available-width)",
|
|
62
|
+
"--bits-select-content-available-height": "var(--bits-floating-available-height)",
|
|
63
|
+
"--bits-select-anchor-width": "var(--bits-floating-anchor-width)",
|
|
64
|
+
"--bits-select-anchor-height": "var(--bits-floating-anchor-height)",
|
|
65
|
+
...contentState.props.style,
|
|
66
|
+
},
|
|
67
|
+
})}
|
|
68
|
+
{#if child}
|
|
69
|
+
{@render child({ props: finalProps, ...contentState.snippetProps })}
|
|
70
|
+
{:else}
|
|
71
|
+
<div {...finalProps}>
|
|
72
|
+
{@render children?.()}
|
|
73
|
+
</div>
|
|
74
|
+
{/if}
|
|
75
|
+
{/snippet}
|
|
76
|
+
</PopperLayer>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { box, mergeProps } from "svelte-toolbelt";
|
|
3
|
-
import type { SelectGroupProps } from "../types.js";
|
|
4
3
|
import { useSelectGroup } from "../select.svelte.js";
|
|
4
|
+
import type { SelectGroupProps } from "../types.js";
|
|
5
5
|
import { useId } from "../../../internal/use-id.js";
|
|
6
6
|
|
|
7
7
|
let {
|
|
8
|
-
children,
|
|
9
|
-
child,
|
|
10
8
|
id = useId(),
|
|
11
9
|
ref = $bindable(null),
|
|
10
|
+
children,
|
|
11
|
+
child,
|
|
12
12
|
...restProps
|
|
13
13
|
}: SelectGroupProps = $props();
|
|
14
14
|
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
(v) => (ref = v)
|
|
20
20
|
),
|
|
21
21
|
});
|
|
22
|
+
|
|
22
23
|
const mergedProps = $derived(mergeProps(restProps, groupState.props));
|
|
23
24
|
</script>
|
|
24
25
|
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { box } from "svelte-toolbelt";
|
|
3
|
-
import {
|
|
3
|
+
import { useSelectHiddenInput } from "../select.svelte.js";
|
|
4
4
|
import VisuallyHidden from "../../utilities/visually-hidden/visually-hidden.svelte";
|
|
5
5
|
|
|
6
6
|
type Props = {
|
|
7
7
|
value?: string;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
let { value = "" }: Props = $props();
|
|
10
|
+
let { value = $bindable("") }: Props = $props();
|
|
11
11
|
|
|
12
|
-
const hiddenInputState =
|
|
12
|
+
const hiddenInputState = useSelectHiddenInput({
|
|
13
13
|
value: box.with(() => value),
|
|
14
14
|
});
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<VisuallyHidden>
|
|
18
18
|
{#if hiddenInputState.shouldRender}
|
|
19
|
-
<input {...hiddenInputState.props} />
|
|
19
|
+
<input {...hiddenInputState.props} bind:value />
|
|
20
20
|
{/if}
|
|
21
21
|
</VisuallyHidden>
|
|
@@ -11,10 +11,10 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
11
11
|
};
|
|
12
12
|
z_$$bindings?: Bindings;
|
|
13
13
|
}
|
|
14
|
-
declare const
|
|
14
|
+
declare const SelectHiddenInput: $$__sveltets_2_IsomorphicComponent<{
|
|
15
15
|
value?: string;
|
|
16
16
|
}, {
|
|
17
17
|
[evt: string]: CustomEvent<any>;
|
|
18
|
-
}, {}, {}, "">;
|
|
19
|
-
type
|
|
20
|
-
export default
|
|
18
|
+
}, {}, {}, "value">;
|
|
19
|
+
type SelectHiddenInput = InstanceType<typeof SelectHiddenInput>;
|
|
20
|
+
export default SelectHiddenInput;
|
|
@@ -1,38 +1,43 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { box, mergeProps } from "svelte-toolbelt";
|
|
3
|
-
import type { SelectItemProps } from "../types.js";
|
|
4
3
|
import { useSelectItem } from "../select.svelte.js";
|
|
4
|
+
import type { SelectItemProps } from "../types.js";
|
|
5
5
|
import { useId } from "../../../internal/use-id.js";
|
|
6
|
+
import { noop } from "../../../internal/noop.js";
|
|
6
7
|
|
|
7
8
|
let {
|
|
8
9
|
id = useId(),
|
|
9
|
-
value,
|
|
10
|
-
textValue = "",
|
|
11
10
|
ref = $bindable(null),
|
|
11
|
+
value,
|
|
12
|
+
label = value,
|
|
13
|
+
disabled = false,
|
|
12
14
|
children,
|
|
13
15
|
child,
|
|
14
|
-
|
|
16
|
+
onHighlight = noop,
|
|
17
|
+
onUnhighlight = noop,
|
|
15
18
|
...restProps
|
|
16
19
|
}: SelectItemProps = $props();
|
|
17
20
|
|
|
18
21
|
const itemState = useSelectItem({
|
|
19
22
|
id: box.with(() => id),
|
|
20
|
-
disabled: box.with(() => disabled),
|
|
21
|
-
value: box.with(() => value),
|
|
22
|
-
textValue: box.with(() => textValue),
|
|
23
23
|
ref: box.with(
|
|
24
24
|
() => ref,
|
|
25
25
|
(v) => (ref = v)
|
|
26
26
|
),
|
|
27
|
+
value: box.with(() => value),
|
|
28
|
+
disabled: box.with(() => disabled),
|
|
29
|
+
label: box.with(() => label),
|
|
30
|
+
onHighlight: box.with(() => onHighlight),
|
|
31
|
+
onUnhighlight: box.with(() => onUnhighlight),
|
|
27
32
|
});
|
|
28
33
|
|
|
29
34
|
const mergedProps = $derived(mergeProps(restProps, itemState.props));
|
|
30
35
|
</script>
|
|
31
36
|
|
|
32
37
|
{#if child}
|
|
33
|
-
{@render child({ props: mergedProps,
|
|
38
|
+
{@render child({ props: mergedProps, ...itemState.snippetProps })}
|
|
34
39
|
{:else}
|
|
35
40
|
<div {...mergedProps}>
|
|
36
|
-
{@render children?.(
|
|
41
|
+
{@render children?.(itemState.snippetProps)}
|
|
37
42
|
</div>
|
|
38
43
|
{/if}
|
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { box, mergeProps } from "svelte-toolbelt";
|
|
3
|
-
import type {
|
|
3
|
+
import type { SelectScrollDownButtonProps } from "../types.js";
|
|
4
4
|
import { useSelectScrollDownButton } from "../select.svelte.js";
|
|
5
|
-
import SelectScrollDownButtonMounted from "./select-scroll-down-button-mounted.svelte";
|
|
6
5
|
import { useId } from "../../../internal/use-id.js";
|
|
6
|
+
import { Mounted } from "../../utilities/index.js";
|
|
7
7
|
|
|
8
|
-
let {
|
|
8
|
+
let {
|
|
9
|
+
id = useId(),
|
|
10
|
+
ref = $bindable(null),
|
|
11
|
+
child,
|
|
12
|
+
children,
|
|
13
|
+
...restProps
|
|
14
|
+
}: SelectScrollDownButtonProps = $props();
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
let mounted = $state(false);
|
|
11
17
|
|
|
12
18
|
const scrollDownButtonState = useSelectScrollDownButton({
|
|
13
19
|
id: box.with(() => id),
|
|
14
|
-
mounted: box.
|
|
20
|
+
mounted: box.with(() => mounted),
|
|
15
21
|
ref: box.with(
|
|
16
22
|
() => ref,
|
|
17
23
|
(v) => (ref = v)
|
|
18
24
|
),
|
|
19
25
|
});
|
|
20
26
|
|
|
21
|
-
const
|
|
22
|
-
const mergedProps = $derived(mergeProps(restWithoutChildren, scrollDownButtonState.props));
|
|
23
|
-
const { style: _style, ...restWithoutStyle } = restProps;
|
|
27
|
+
const mergedProps = $derived(mergeProps(restProps, scrollDownButtonState.props));
|
|
24
28
|
</script>
|
|
25
29
|
|
|
26
30
|
{#if scrollDownButtonState.canScrollDown}
|
|
27
|
-
<
|
|
31
|
+
<Mounted onMountedChange={(m) => (mounted = m)} />
|
|
32
|
+
{#if child}
|
|
33
|
+
{@render child({ props: restProps })}
|
|
34
|
+
{:else}
|
|
35
|
+
<div {...mergedProps}>
|
|
36
|
+
{@render children?.()}
|
|
37
|
+
</div>
|
|
38
|
+
{/if}
|
|
28
39
|
{/if}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SelectScrollDownButtonProps } from "../types.js";
|
|
2
2
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
3
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
4
|
$$bindings?: Bindings;
|
|
@@ -12,7 +12,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
12
12
|
};
|
|
13
13
|
z_$$bindings?: Bindings;
|
|
14
14
|
}
|
|
15
|
-
declare const SelectScrollDownButton: $$__sveltets_2_IsomorphicComponent<
|
|
15
|
+
declare const SelectScrollDownButton: $$__sveltets_2_IsomorphicComponent<SelectScrollDownButtonProps, {
|
|
16
16
|
[evt: string]: CustomEvent<any>;
|
|
17
17
|
}, {}, {}, "ref">;
|
|
18
18
|
type SelectScrollDownButton = InstanceType<typeof SelectScrollDownButton>;
|
|
@@ -2,27 +2,38 @@
|
|
|
2
2
|
import { box, mergeProps } from "svelte-toolbelt";
|
|
3
3
|
import type { SelectScrollUpButtonProps } from "../types.js";
|
|
4
4
|
import { useSelectScrollUpButton } from "../select.svelte.js";
|
|
5
|
-
import SelectScrollUpButtonMounted from "./select-scroll-up-button-mounted.svelte";
|
|
6
5
|
import { useId } from "../../../internal/use-id.js";
|
|
6
|
+
import { Mounted } from "../../utilities/index.js";
|
|
7
7
|
|
|
8
|
-
let {
|
|
8
|
+
let {
|
|
9
|
+
id = useId(),
|
|
10
|
+
ref = $bindable(null),
|
|
11
|
+
child,
|
|
12
|
+
children,
|
|
13
|
+
...restProps
|
|
14
|
+
}: SelectScrollUpButtonProps = $props();
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
let mounted = $state(false);
|
|
11
17
|
|
|
12
|
-
const
|
|
18
|
+
const scrollDownButtonState = useSelectScrollUpButton({
|
|
13
19
|
id: box.with(() => id),
|
|
14
|
-
mounted: box.
|
|
20
|
+
mounted: box.with(() => mounted),
|
|
15
21
|
ref: box.with(
|
|
16
22
|
() => ref,
|
|
17
23
|
(v) => (ref = v)
|
|
18
24
|
),
|
|
19
25
|
});
|
|
20
26
|
|
|
21
|
-
const
|
|
22
|
-
const mergedProps = $derived(mergeProps(restWithoutChildren, scrollUpButtonState.props));
|
|
23
|
-
const { style: _style, ...restWithoutStyle } = restProps;
|
|
27
|
+
const mergedProps = $derived(mergeProps(restProps, scrollDownButtonState.props));
|
|
24
28
|
</script>
|
|
25
29
|
|
|
26
|
-
{#if
|
|
27
|
-
<
|
|
30
|
+
{#if scrollDownButtonState.canScrollUp}
|
|
31
|
+
<Mounted onMountedChange={(m) => (mounted = m)} />
|
|
32
|
+
{#if child}
|
|
33
|
+
{@render child({ props: restProps })}
|
|
34
|
+
{:else}
|
|
35
|
+
<div {...mergedProps}>
|
|
36
|
+
{@render children?.()}
|
|
37
|
+
</div>
|
|
38
|
+
{/if}
|
|
28
39
|
{/if}
|