@ui-sdk/svelte 0.1.0-beta.1 → 0.1.0-beta.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.
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
type SelectTriggerProps,
|
|
5
5
|
type SelectTriggerState,
|
|
6
6
|
} from "@ui-sdk/core/select"
|
|
7
|
-
import { useFieldControl } from "../field/context.js"
|
|
8
7
|
import Part from "../part.svelte"
|
|
9
8
|
import { provideInstance } from "../instance.js"
|
|
10
9
|
import {
|
|
11
10
|
useHandlePart,
|
|
12
11
|
wrapPart,
|
|
13
12
|
type PartProps,
|
|
13
|
+
type SlotAttributes,
|
|
14
14
|
} from "../use-primitive.svelte.js"
|
|
15
15
|
import type { SelectContext } from "./context.js"
|
|
16
16
|
import SelectValue from "./select-value.svelte"
|
|
@@ -19,11 +19,15 @@
|
|
|
19
19
|
// a trigger given another controller keeps its element and focus.
|
|
20
20
|
let {
|
|
21
21
|
owner,
|
|
22
|
+
control,
|
|
22
23
|
disabled,
|
|
23
24
|
children,
|
|
24
25
|
...rest
|
|
25
26
|
}: PartProps<"button", SelectTriggerState> &
|
|
26
|
-
SelectTriggerProps & {
|
|
27
|
+
SelectTriggerProps & {
|
|
28
|
+
owner: SelectContext
|
|
29
|
+
control?: (attributes: SlotAttributes) => SlotAttributes
|
|
30
|
+
} = $props()
|
|
27
31
|
|
|
28
32
|
// A trigger outside the select brings the select to the value inside it.
|
|
29
33
|
// Context is set once, so the handle it gets reads the current one.
|
|
@@ -39,15 +43,10 @@
|
|
|
39
43
|
},
|
|
40
44
|
controls: (key) => owner.controls(key),
|
|
41
45
|
})
|
|
42
|
-
const field = useFieldControl()
|
|
43
46
|
const trigger = useHandlePart(
|
|
44
47
|
() => owner,
|
|
45
48
|
"trigger",
|
|
46
|
-
() => ({ disabled, named: !!
|
|
47
|
-
)
|
|
48
|
-
const control = field?.control(
|
|
49
|
-
() => rest.id as string | undefined,
|
|
50
|
-
() => rest["aria-describedby"]
|
|
49
|
+
() => ({ disabled, named: !!control || rest["aria-labelledby"] != null })
|
|
51
50
|
)
|
|
52
51
|
</script>
|
|
53
52
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type SelectTriggerProps, type SelectTriggerState } from "@ui-sdk/core/select";
|
|
2
|
-
import { type PartProps } from "../use-primitive.svelte";
|
|
2
|
+
import { type PartProps, type SlotAttributes } from "../use-primitive.svelte";
|
|
3
3
|
import type { SelectContext } from "./context";
|
|
4
4
|
type $$ComponentProps = PartProps<"button", SelectTriggerState> & SelectTriggerProps & {
|
|
5
5
|
owner: SelectContext;
|
|
6
|
+
control?: (attributes: SlotAttributes) => SlotAttributes;
|
|
6
7
|
};
|
|
7
8
|
declare const SelectTriggerBinding: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
9
|
type SelectTriggerBinding = ReturnType<typeof SelectTriggerBinding>;
|
|
@@ -10,9 +10,10 @@ The button that opens the list: a combobox named by the label. Typing on it sele
|
|
|
10
10
|
type SelectTriggerState,
|
|
11
11
|
} from "@ui-sdk/core/select"
|
|
12
12
|
import { getContext } from "svelte"
|
|
13
|
+
import { useFieldControl } from "../field/context.js"
|
|
13
14
|
import Part from "../part.svelte"
|
|
14
15
|
import { useControllerTarget } from "../popup.svelte.js"
|
|
15
|
-
import { plainPart, type PartProps } from "../use-primitive.svelte.js"
|
|
16
|
+
import { plainPart, wrapPart, type PartProps } from "../use-primitive.svelte.js"
|
|
16
17
|
import type { SelectContext } from "./context.js"
|
|
17
18
|
import TriggerBinding from "./select-trigger-binding.svelte"
|
|
18
19
|
|
|
@@ -27,23 +28,30 @@ The button that opens the list: a combobox named by the label. Typing on it sele
|
|
|
27
28
|
getContext<SelectContext | undefined>(selectPrimitive)
|
|
28
29
|
)
|
|
29
30
|
const select = $derived(connected())
|
|
31
|
+
const control = useFieldControl()?.control(
|
|
32
|
+
() => rest.id as string | undefined,
|
|
33
|
+
() => rest["aria-describedby"]
|
|
34
|
+
)
|
|
30
35
|
</script>
|
|
31
36
|
|
|
32
37
|
{#if select}
|
|
33
|
-
<TriggerBinding owner={select} {disabled} {...rest} />
|
|
38
|
+
<TriggerBinding owner={select} {control} {disabled} {...rest} />
|
|
34
39
|
{:else}
|
|
35
40
|
<!-- Until the select it names mounts, a trigger outside the select is a plain button. -->
|
|
36
41
|
<Part
|
|
37
42
|
tag="button"
|
|
38
|
-
part={
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
part={wrapPart(
|
|
44
|
+
plainPart(
|
|
45
|
+
{
|
|
46
|
+
open: false,
|
|
47
|
+
disabled: !!disabled,
|
|
48
|
+
readOnly: false,
|
|
49
|
+
required: false,
|
|
50
|
+
placeholder: true,
|
|
51
|
+
},
|
|
52
|
+
{ type: "button" }
|
|
53
|
+
),
|
|
54
|
+
control
|
|
47
55
|
)}
|
|
48
56
|
props={rest}
|
|
49
57
|
/>
|
|
@@ -1297,6 +1297,9 @@ Additional behaviors:
|
|
|
1297
1297
|
- A pending open() resolves with reason unmount when the dialog leaves the page. Web components only.
|
|
1298
1298
|
- A form with method dialog closes the dialog and reports the submitter's value.
|
|
1299
1299
|
- A confirm helper resolves true for the action and false otherwise.
|
|
1300
|
+
- A confirm opened from inside a modal dialog takes focus and stays usable.
|
|
1301
|
+
- A confirm opened over a modal dialog with nothing focused stays usable.
|
|
1302
|
+
- A confirm opened as a modal dialog shows, before the page freezes, stays usable.
|
|
1300
1303
|
- Closing reports why, for every way a dialog closes.
|
|
1301
1304
|
|
|
1302
1305
|
**Shortcuts**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui-sdk/svelte",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.2",
|
|
4
4
|
"description": "UI SDK for Svelte.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|
|
@@ -381,7 +381,7 @@
|
|
|
381
381
|
],
|
|
382
382
|
"peerDependencies": {
|
|
383
383
|
"svelte": ">=5.33",
|
|
384
|
-
"@ui-sdk/core": "^0.1.0-beta.
|
|
384
|
+
"@ui-sdk/core": "^0.1.0-beta.2"
|
|
385
385
|
},
|
|
386
386
|
"devDependencies": {
|
|
387
387
|
"@sveltejs/package": "^2.5.8",
|
|
@@ -393,7 +393,7 @@
|
|
|
393
393
|
"typescript": "~5.9.3",
|
|
394
394
|
"vite": "^8.3.3",
|
|
395
395
|
"vitest": "^5.0.3",
|
|
396
|
-
"@ui-sdk/core": "0.1.0-beta.
|
|
396
|
+
"@ui-sdk/core": "0.1.0-beta.2"
|
|
397
397
|
},
|
|
398
398
|
"scripts": {
|
|
399
399
|
"build": "node ../../scripts/build/build-svelte-package.mjs",
|