@ui-sdk/svelte 0.1.0-beta.7 → 0.1.0-beta.9

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.
Files changed (48) hide show
  1. package/dist/autocomplete/autocomplete.svelte +2 -2
  2. package/dist/autocomplete/autocomplete.svelte.d.ts +2 -2
  3. package/dist/autocomplete.d.ts +1 -1
  4. package/dist/combobox/combobox.svelte +4 -2
  5. package/dist/combobox/combobox.svelte.d.ts +1 -1
  6. package/dist/dialog/dialog-content.svelte +9 -3
  7. package/dist/dialog/dialog-content.svelte.d.ts +1 -0
  8. package/dist/drawer/drawer-content.svelte.d.ts +2 -6
  9. package/dist/listbox/listbox.svelte +7 -1
  10. package/dist/listbox/listbox.svelte.d.ts +2 -0
  11. package/dist/pagination/pagination.svelte +4 -0
  12. package/dist/pagination/pagination.svelte.d.ts +2 -0
  13. package/dist/popover/popover-content.svelte +4 -2
  14. package/dist/popover/popover-content.svelte.d.ts +1 -0
  15. package/dist/segmented-control.d.ts +1 -1
  16. package/dist/select/select.svelte +7 -1
  17. package/dist/select/select.svelte.d.ts +2 -0
  18. package/dist/use-primitive.svelte.js +20 -3
  19. package/docs/agents.md +2 -2
  20. package/docs/components/alert-dialog.md +2 -1
  21. package/docs/components/autocomplete.md +4 -2
  22. package/docs/components/calendar.md +2 -2
  23. package/docs/components/collapsible.md +1 -0
  24. package/docs/components/combobox.md +5 -3
  25. package/docs/components/command.md +1 -0
  26. package/docs/components/date-input.md +1 -0
  27. package/docs/components/date-picker.md +1 -1
  28. package/docs/components/dialog.md +47 -1
  29. package/docs/components/drawer.md +3 -1
  30. package/docs/components/file-input.md +3 -3
  31. package/docs/components/hover-card.md +1 -1
  32. package/docs/components/image-cropper.md +12 -12
  33. package/docs/components/listbox.md +55 -2
  34. package/docs/components/menu.md +3 -1
  35. package/docs/components/pagination.md +3 -2
  36. package/docs/components/popover.md +40 -2
  37. package/docs/components/resizable.md +2 -1
  38. package/docs/components/segmented-control.md +9 -0
  39. package/docs/components/select.md +13 -2
  40. package/docs/components/time-input.md +1 -0
  41. package/docs/core.md +21 -0
  42. package/docs/forms.md +1 -1
  43. package/docs/llms.txt +13 -8
  44. package/docs/popups.md +1 -1
  45. package/docs/styling-and-animation.md +4 -0
  46. package/docs/utilities/async-options.md +6 -5
  47. package/docs/utilities/shortcuts.md +1 -1
  48. package/package.json +3 -3
@@ -12,7 +12,7 @@ A text field that suggests as you type. The text is the value. Renders no elemen
12
12
  type AutocompleteDismissReason,
13
13
  type AutocompleteOpenChangeReason,
14
14
  type AutocompleteSubmitDetails,
15
- type AutocompleteValueChangeReason,
15
+ type AutocompleteValueChangeDetails,
16
16
  type ListAnnouncement,
17
17
  type ListData,
18
18
  type ListHighlightDetails,
@@ -28,7 +28,7 @@ A text field that suggests as you type. The text is the value. Renders no elemen
28
28
  import { ContainerKey, OwnContentKey } from "./context.js"
29
29
  import AutocompleteContent from "./autocomplete-content.svelte"
30
30
 
31
- type ValueDetails = ChangeDetails<AutocompleteValueChangeReason>
31
+ type ValueDetails = AutocompleteValueChangeDetails
32
32
  type OpenDetails = ChangeDetails<AutocompleteOpenChangeReason>
33
33
 
34
34
  let {
@@ -1,9 +1,9 @@
1
1
  import type { ChangeDetails, DismissAttemptDetails } from "@ui-sdk/core";
2
2
  import type { AsyncOptionsStatus } from "@ui-sdk/core/async-options";
3
- import { type AutocompleteController, type AutocompleteDismissReason, type AutocompleteOpenChangeReason, type AutocompleteSubmitDetails, type AutocompleteValueChangeReason, type ListAnnouncement, type ListData, type ListHighlightDetails, type SearchFilter } from "@ui-sdk/core/autocomplete";
3
+ import { type AutocompleteController, type AutocompleteDismissReason, type AutocompleteOpenChangeReason, type AutocompleteSubmitDetails, type AutocompleteValueChangeDetails, type ListAnnouncement, type ListData, type ListHighlightDetails, type SearchFilter } from "@ui-sdk/core/autocomplete";
4
4
  import { type Snippet } from "svelte";
5
5
  import { type PopupContainer } from "../popup.svelte";
6
- type ValueDetails = ChangeDetails<AutocompleteValueChangeReason>;
6
+ type ValueDetails = AutocompleteValueChangeDetails;
7
7
  type OpenDetails = ChangeDetails<AutocompleteOpenChangeReason>;
8
8
  type $$ComponentProps = {
9
9
  /** The text. Bind it with `bind:value` to control it. */
@@ -16,4 +16,4 @@ export { default as AutocompleteSeparator } from "./autocomplete/autocomplete-se
16
16
  export { default as AutocompleteStatus } from "./autocomplete/autocomplete-status.svelte";
17
17
  export { default as AutocompleteTrigger } from "./autocomplete/autocomplete-trigger.svelte";
18
18
  export { createAutocompleteController } from "@ui-sdk/core/autocomplete";
19
- export type { AutocompleteApi, AutocompleteArrowState, AutocompleteChangeOptions, AutocompleteClearProps, AutocompleteClearState, AutocompleteContentProps, AutocompleteContentState, AutocompleteController, AutocompleteDismissReason, AutocompleteEmptyState, AutocompleteInputState, AutocompleteItemIconProps, AutocompleteItemIconState, AutocompleteItemProps, AutocompleteItemState, AutocompleteItemTextState, AutocompleteOpenChangeReason, AutocompleteOptions, AutocompletePrimitive, AutocompleteStatusState, AutocompleteSubmitDetails, AutocompleteTriggerState, AutocompleteValueChangeReason, ListAnnouncement, ListData, ListFilter, ListGroup, ListHighlightDetails, ListItem, ListSeparator, MatchSegment, SearchFilter, } from "@ui-sdk/core/autocomplete";
19
+ export type { AutocompleteApi, AutocompleteArrowState, AutocompleteChangeOptions, AutocompleteClearProps, AutocompleteClearState, AutocompleteContentProps, AutocompleteContentState, AutocompleteController, AutocompleteDismissReason, AutocompleteEmptyState, AutocompleteInputState, AutocompleteItemIconProps, AutocompleteItemIconState, AutocompleteItemProps, AutocompleteItemState, AutocompleteItemTextState, AutocompleteOpenChangeReason, AutocompleteOptions, AutocompletePrimitive, AutocompleteStatusState, AutocompleteSubmitDetails, AutocompleteTriggerState, AutocompleteValueChangeDetails, AutocompleteValueChangeReason, ListAnnouncement, ListData, ListFilter, ListGroup, ListHighlightDetails, ListItem, ListSeparator, MatchSegment, SearchFilter, } from "@ui-sdk/core/autocomplete";
@@ -144,7 +144,7 @@ list are its parts.
144
144
  /** Whether an item's value is the selected value, for object values that aren't the same object. */
145
145
  isItemEqualToValue?: (itemValue: T, value: T) => boolean
146
146
  /** Whether the first matching item is highlighted while typing, so Enter chooses it. `"always"` also highlights the selected item, or the first, when the list opens. */
147
- autoHighlight?: boolean | "always"
147
+ autoHighlight?: boolean | "always" | "selected"
148
148
  /** With `multiple`, whether the input keeps its text after an item is chosen. */
149
149
  keepQuery?: boolean
150
150
  /** What screen readers hear once the Create part's action has been pending for a second. An empty string says nothing. */
@@ -269,6 +269,8 @@ list are its parts.
269
269
  // more per value with `multiple`. The input's attributes change with the
270
270
  // value, so reading them keeps the list of values current.
271
271
  const formInput = useHandlePart(combobox, "form-input")
272
+ // A textarea's value is its text, which the server renders too.
273
+ const { value: formValue, ...formAttrs } = $derived(formInput.slot())
272
274
  const values = $derived(
273
275
  (formInput.attrs,
274
276
  combobox.state.multiple ? combobox.api.internal.serialized() : [])
@@ -279,7 +281,7 @@ list are its parts.
279
281
  {#if items && !own()}
280
282
  <ComboboxContent fromRoot />
281
283
  {/if}
282
- <input {...formInput.slot()} />
284
+ <textarea {...formAttrs}>{formValue}</textarea>
283
285
  {#each values as key (key)}
284
286
  <ValueInput owner={combobox} value={key} />
285
287
  {/each}
@@ -30,7 +30,7 @@ declare function $$render<T = string, Multiple extends boolean | undefined = fal
30
30
  /** Whether an item's value is the selected value, for object values that aren't the same object. */
31
31
  isItemEqualToValue?: (itemValue: T, value: T) => boolean;
32
32
  /** Whether the first matching item is highlighted while typing, so Enter chooses it. `"always"` also highlights the selected item, or the first, when the list opens. */
33
- autoHighlight?: boolean | "always";
33
+ autoHighlight?: boolean | "always" | "selected";
34
34
  /** With `multiple`, whether the input keeps its text after an item is chosen. */
35
35
  keepQuery?: boolean;
36
36
  /** What screen readers hear once the Create part's action has been pending for a second. An empty string says nothing. */
@@ -22,6 +22,7 @@ The dialog itself, named by its title and described by its description.
22
22
  initialFocus,
23
23
  finalFocus,
24
24
  keepMounted,
25
+ inline,
25
26
  container,
26
27
  ...rest
27
28
  }: PartProps<"div", DialogContentState<Payload>> &
@@ -37,13 +38,18 @@ The dialog itself, named by its title and described by its description.
37
38
  // what moves into the container and the top layer. An alert dialog never
38
39
  // presents as a sheet, so it has no viewport to bind.
39
40
  const viewport = dialog.sheet
40
- ? useHandlePart(dialog.handle, "viewport", () => ({}), portalTo(target))
41
+ ? useHandlePart(
42
+ dialog.handle,
43
+ "viewport",
44
+ () => ({}),
45
+ portalTo(() => (inline ? false : target()))
46
+ )
41
47
  : undefined
42
48
  const content = useHandlePart(
43
49
  dialog.handle,
44
50
  "content",
45
- () => ({ initialFocus, finalFocus, keepMounted }),
46
- portalTo(() => (viewport?.present ? false : target()))
51
+ () => ({ initialFocus, finalFocus, keepMounted, inline }),
52
+ portalTo(() => (inline || viewport?.present ? false : target()))
47
53
  )
48
54
  </script>
49
55
 
@@ -14,6 +14,7 @@ declare function $$render<Payload = unknown>(): {
14
14
  initialFocus?: import("@ui-sdk/core/dialog").DialogInitialFocus;
15
15
  finalFocus?: import("@ui-sdk/core/dialog").DialogFinalFocus;
16
16
  keepMounted?: boolean;
17
+ inline?: boolean;
17
18
  } & {
18
19
  /** Renders the popup into this element instead of in place. */
19
20
  container?: PopupContainer;
@@ -1,4 +1,4 @@
1
- import type { DrawerContentState } from "@ui-sdk/core/drawer";
1
+ import type { DrawerContentProps, DrawerContentState } from "@ui-sdk/core/drawer";
2
2
  import { type PopupContainer } from "../popup.svelte";
3
3
  declare function $$render<Payload = unknown>(): {
4
4
  props: Omit<import("svelte/elements").HTMLAttributes<HTMLDivElement>, "children"> & {
@@ -10,11 +10,7 @@ declare function $$render<Payload = unknown>(): {
10
10
  children?: import("svelte").Snippet<[DrawerContentState<Payload>]> | undefined;
11
11
  }]> | undefined;
12
12
  children?: import("svelte").Snippet<[DrawerContentState<Payload>]> | undefined;
13
- } & import("@ui-sdk/core").PortalProps & {
14
- initialFocus?: import("@ui-sdk/core/dialog").DialogInitialFocus;
15
- finalFocus?: import("@ui-sdk/core/dialog").DialogFinalFocus;
16
- keepMounted?: boolean;
17
- } & {
13
+ } & DrawerContentProps & {
18
14
  /** Renders the drawer into this element instead of in place. */
19
15
  container?: PopupContainer;
20
16
  };
@@ -36,6 +36,7 @@ An always-visible list to choose one option from, or several with `multiple`.
36
36
  deselectable,
37
37
  orientation,
38
38
  loop,
39
+ virtualFocus,
39
40
  keepInView,
40
41
  items,
41
42
  itemToValue,
@@ -66,6 +67,8 @@ An always-visible list to choose one option from, or several with `multiple`.
66
67
  orientation?: "horizontal" | "vertical"
67
68
  /** Whether arrow keys wrap from the last item to the first. */
68
69
  loop?: boolean
70
+ /** Keeps focus on the list, which points at the highlighted option with `aria-activedescendant`. */
71
+ virtualFocus?: boolean
69
72
  /** Whether the list scrolls the option keys move to into view, and the selected option when it first shows. */
70
73
  keepInView?: boolean
71
74
  /** The items as data. Renders them for you. */
@@ -107,6 +110,7 @@ An always-visible list to choose one option from, or several with `multiple`.
107
110
  deselectable,
108
111
  orientation,
109
112
  loop,
113
+ virtualFocus,
110
114
  keepInView,
111
115
  items,
112
116
  itemToValue,
@@ -137,6 +141,8 @@ An always-visible list to choose one option from, or several with `multiple`.
137
141
  // more per value with `multiple`. The input's attributes change with the
138
142
  // value, so reading them keeps the list of values current.
139
143
  const formInput = useHandlePart(listbox, "form-input")
144
+ // A textarea's value is its text, which the server renders too.
145
+ const { value: formValue, ...formAttrs } = $derived(formInput.slot())
140
146
  const values = $derived(
141
147
  (formInput.attrs,
142
148
  listbox.state.multiple ? listbox.api.internal.serialized() : [])
@@ -153,7 +159,7 @@ An always-visible list to choose one option from, or several with `multiple`.
153
159
  part={wrapPart(root, control)}
154
160
  props={{ ...rest, children: children ?? data }}
155
161
  />
156
- <input {...formInput.slot()} />
162
+ <textarea {...formAttrs}>{formValue}</textarea>
157
163
  {#each values as key (key)}
158
164
  <ValueInput owner={listbox} value={key} />
159
165
  {/each}
@@ -17,6 +17,8 @@ type $$ComponentProps = PartProps<"div", ListboxState> & {
17
17
  orientation?: "horizontal" | "vertical";
18
18
  /** Whether arrow keys wrap from the last item to the first. */
19
19
  loop?: boolean;
20
+ /** Keeps focus on the list, which points at the highlighted option with `aria-activedescendant`. */
21
+ virtualFocus?: boolean;
20
22
  /** Whether the list scrolls the option keys move to into view, and the selected option when it first shows. */
21
23
  keepInView?: boolean;
22
24
  /** The items as data. Renders them for you. */
@@ -31,6 +31,7 @@ A navigation landmark around the page links. Name it with `aria-label`.
31
31
  siblings,
32
32
  boundaries,
33
33
  getHref,
34
+ disabled,
34
35
  controller,
35
36
  debug,
36
37
  onPageChange,
@@ -52,6 +53,8 @@ A navigation landmark around the page links. Name it with `aria-label`.
52
53
  boundaries?: number
53
54
  /** The URL of a page. With it, parts are links that work before JavaScript loads. Without it, they're buttons. */
54
55
  getHref?: (page: number) => string
56
+ /** Whether every page and step does nothing, like a step at its end. A controller still pages it. */
57
+ disabled?: boolean
55
58
  /** Pages it from anywhere. Create one with `createPaginationController()`. */
56
59
  controller?: PaginationController
57
60
  /** Logs every change with its reason. */
@@ -73,6 +76,7 @@ A navigation landmark around the page links. Name it with `aria-label`.
73
76
  siblings,
74
77
  boundaries,
75
78
  getHref,
79
+ disabled,
76
80
  controller,
77
81
  debug,
78
82
  onPageChange: (next: number, details: Details) => {
@@ -19,6 +19,8 @@ type $$ComponentProps = PartProps<"nav", PaginationState> & {
19
19
  boundaries?: number;
20
20
  /** The URL of a page. With it, parts are links that work before JavaScript loads. Without it, they're buttons. */
21
21
  getHref?: (page: number) => string;
22
+ /** Whether every page and step does nothing, like a step at its end. A controller still pages it. */
23
+ disabled?: boolean;
22
24
  /** Pages it from anywhere. Create one with `createPaginationController()`. */
23
25
  controller?: PaginationController;
24
26
  /** Logs every change with its reason. */
@@ -32,6 +32,7 @@ The panel itself, positioned against its trigger, named by its title and describ
32
32
  initialFocus,
33
33
  finalFocus,
34
34
  keepMounted,
35
+ inline,
35
36
  container,
36
37
  ...rest
37
38
  }: PartProps<"div", PopoverContentState<Payload>> &
@@ -50,7 +51,7 @@ The panel itself, positioned against its trigger, named by its title and describ
50
51
  popover,
51
52
  "viewport",
52
53
  () => ({}),
53
- portalTo(target)
54
+ portalTo(() => (inline ? false : target()))
54
55
  )
55
56
  const content = useHandlePart(
56
57
  popover,
@@ -66,8 +67,9 @@ The panel itself, positioned against its trigger, named by its title and describ
66
67
  initialFocus,
67
68
  finalFocus,
68
69
  keepMounted,
70
+ inline,
69
71
  }),
70
- portalTo(() => (viewport.present ? false : target()))
72
+ portalTo(() => (inline || viewport.present ? false : target()))
71
73
  )
72
74
  </script>
73
75
 
@@ -18,6 +18,7 @@ declare function $$render<Payload = unknown>(): {
18
18
  initialFocus?: import("@ui-sdk/core/popover").PopoverInitialFocus;
19
19
  finalFocus?: import("@ui-sdk/core/popover").PopoverFinalFocus;
20
20
  keepMounted?: boolean;
21
+ inline?: boolean;
21
22
  } & {
22
23
  /** Renders the popup into this element instead of in place. */
23
24
  container?: PopupContainer;
@@ -2,4 +2,4 @@ export { default as SegmentedControl } from "./segmented-control/segmented-contr
2
2
  export { default as SegmentedControlIndicator } from "./segmented-control/segmented-control-indicator.svelte";
3
3
  export { default as SegmentedControlItem } from "./segmented-control/segmented-control-item.svelte";
4
4
  export { createSegmentedControlController } from "@ui-sdk/core/segmented-control";
5
- export type { SegmentedControlApi, SegmentedControlChangeOptions, SegmentedControlController, SegmentedControlIndicatorState, SegmentedControlItemProps, SegmentedControlItemState, SegmentedControlOptions, SegmentedControlOrientation, SegmentedControlPrimitive, SegmentedControlState, SegmentedControlValueChangeReason, } from "@ui-sdk/core/segmented-control";
5
+ export type { SegmentedControlApi, SegmentedControlChangeOptions, SegmentedControlController, SegmentedControlDirection, SegmentedControlIndicatorState, SegmentedControlItemProps, SegmentedControlItemState, SegmentedControlOptions, SegmentedControlOrientation, SegmentedControlPrimitive, SegmentedControlState, SegmentedControlValueChangeReason, } from "@ui-sdk/core/segmented-control";
@@ -92,6 +92,7 @@ Picks one value, or several with `multiple`, from a list in a popup.
92
92
  itemToLabel,
93
93
  isItemEqualToValue,
94
94
  loop,
95
+ virtualFocus,
95
96
  modal,
96
97
  presentation,
97
98
  disabled,
@@ -141,6 +142,8 @@ Picks one value, or several with `multiple`, from a list in a popup.
141
142
  isItemEqualToValue?: (itemValue: T, value: T) => boolean
142
143
  /** Whether arrow keys wrap from the last item to the first. */
143
144
  loop?: boolean
145
+ /** Keeps focus on the trigger while the list is open, which points at the highlighted item. */
146
+ virtualFocus?: boolean
144
147
  /** Whether the page behind the list is inert, or only shielded from the pointer. */
145
148
  modal?: boolean | "pointer"
146
149
  /** How the list presents: a popover, a sheet, or `"auto"` for a sheet on small touch screens. */
@@ -210,6 +213,7 @@ Picks one value, or several with `multiple`, from a list in a popup.
210
213
  itemToLabel,
211
214
  isItemEqualToValue,
212
215
  loop,
216
+ virtualFocus,
213
217
  modal,
214
218
  presentation,
215
219
  disabled: disabled || field?.disabled(),
@@ -253,6 +257,8 @@ Picks one value, or several with `multiple`, from a list in a popup.
253
257
  // more per value with `multiple`. The input's attributes change with the
254
258
  // value, so reading them keeps the list of values current.
255
259
  const formInput = useHandlePart(select, "form-input")
260
+ // A textarea's value is its text, which the server renders too.
261
+ const { value: formValue, ...formAttrs } = $derived(formInput.slot())
256
262
  const values = $derived(
257
263
  (formInput.attrs,
258
264
  select.state.multiple ? select.api.internal.serialized() : [])
@@ -263,7 +269,7 @@ Picks one value, or several with `multiple`, from a list in a popup.
263
269
  {#if items && !own()}
264
270
  <SelectContent fromRoot />
265
271
  {/if}
266
- <input {...formInput.slot()} />
272
+ <textarea {...formAttrs}>{formValue}</textarea>
267
273
  {#each values as key (key)}
268
274
  <ValueInput owner={select} value={key} />
269
275
  {/each}
@@ -33,6 +33,8 @@ declare function $$render<T = string, Multiple extends boolean | undefined = fal
33
33
  isItemEqualToValue?: (itemValue: T, value: T) => boolean;
34
34
  /** Whether arrow keys wrap from the last item to the first. */
35
35
  loop?: boolean;
36
+ /** Keeps focus on the trigger while the list is open, which points at the highlighted item. */
37
+ virtualFocus?: boolean;
36
38
  /** Whether the page behind the list is inert, or only shielded from the pointer. */
37
39
  modal?: boolean | "pointer";
38
40
  /** How the list presents: a popover, a sheet, or `"auto"` for a sheet on small touch screens. */
@@ -11,6 +11,10 @@ const deliveries = new WeakMap();
11
11
  // Svelte starts a `transition:` or `out:` outro only once the core has
12
12
  // finished closing, so a close completes when those outros end.
13
13
  const exits = new WeakMap();
14
+ // Svelte runs an element's cleanup in the teardown of the effect removing it,
15
+ // where reading `current` runs it again and it stops following the props.
16
+ // Reads from such a cleanup get the options delivered last.
17
+ let tearingDown = 0;
14
18
  const memo = (compute) => {
15
19
  const value = $derived.by(compute);
16
20
  return () => value;
@@ -59,7 +63,8 @@ function usePrimitive(primitive, options) {
59
63
  // `value`, from here: a read sees it in the same update as the parent's own
60
64
  // state, before the effect below hands it over. Untracked, or every part
61
65
  // would hear every prop.
62
- const delivered = instance.follow(() => untrack(() => current));
66
+ let seen;
67
+ const delivered = instance.follow(() => tearingDown && seen ? seen : (seen = untrack(() => current)));
63
68
  // What the props changed in it, counted by the names parts read it by
64
69
  // (`followed`). Each part compares its own counts, so a value moving
65
70
  // between two of 500 items updates two. Both sides read the state held
@@ -277,7 +282,13 @@ function useHandlePart(owner, name, props = () => ({}), portal) {
277
282
  return () => {
278
283
  cleanups.forEach((cleanup) => cleanup());
279
284
  bound = undefined;
280
- ref(null);
285
+ tearingDown++;
286
+ try {
287
+ ref(null);
288
+ }
289
+ finally {
290
+ tearingDown--;
291
+ }
281
292
  restore();
282
293
  removed?.();
283
294
  removed = undefined;
@@ -294,7 +305,13 @@ function useHandlePart(owner, name, props = () => ({}), portal) {
294
305
  // element shows is what Svelte gets, so its write changes nothing.
295
306
  const styleFor = (merged) => {
296
307
  styleShown = merged;
297
- if (!bound || typeof merged !== "string") {
308
+ if (!bound) {
309
+ return merged;
310
+ }
311
+ // A style that goes away takes what it wrote with it, even when the owner
312
+ // left `style` out of its spread and Svelte writes nothing.
313
+ if (typeof merged !== "string") {
314
+ applyAttrs(bound, { style: undefined }, "svelte-style");
298
315
  return merged;
299
316
  }
300
317
  applyAttrs(bound, { style: merged }, "svelte-style");
package/docs/agents.md CHANGED
@@ -1014,7 +1014,7 @@ The snapshot lists the button with `confirm: "Charges $20 to your card for 1,000
1014
1014
  Needs a person: "Charges $20 to your card for 1,000 credits". Ask them to press "Buy credits" themselves.
1015
1015
  ```
1016
1016
 
1017
- With `allow`, the step waits for your callback, and `step.confirm` carries the sentence. Show it to the person and return their answer:
1017
+ With `allow`, the step waits for your callback, and `step.confirm` carries the sentence. A step that touches several marks, like replacing one marked option with another, carries every sentence, joined by semicolons. Show it to the person and return their answer:
1018
1018
 
1019
1019
  ```ts
1020
1020
  const agent = createAgent({
@@ -1051,7 +1051,7 @@ Two more marks change what the agent sees:
1051
1051
  </Field>
1052
1052
  ```
1053
1053
 
1054
- Changes inside `data-agent-hidden` still reach [Observe](./agents.md#observe-changes), so your own logs see them, while `agent.subscribe` stays quiet. A secret value stays out of `snapshot`, `act` results and change events, and the field's error text reads `"[redacted]"` too. Password, card and one-time-code fields are treated as secret without a mark. A hidden input is left out without one.
1054
+ Changes inside `data-agent-hidden` still reach [Observe](./agents.md#observe-changes), so your own logs see them, while `agent.subscribe` stays quiet. A secret value stays out of `snapshot`, `act` results and change events, and the field's error text reads `"[redacted]"` too. A secret File Input lists its files without their names. Password, card and one-time-code fields are treated as secret without a mark. A hidden input is left out without one.
1055
1055
 
1056
1056
  In development, a misspelled mark such as `data-agent-confim` logs a warning with the name it meant.
1057
1057
 
@@ -674,7 +674,8 @@ Dims the page behind the dialog. Renders a `div` and accepts its attributes and
674
674
  - `container?` (`DocumentFragment | Element | null`): Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
675
675
  - `initialFocus?` (`DialogInitialFocus`): Where focus goes when the dialog opens. Opening with touch focuses the dialog itself, so no on-screen keyboard appears.
676
676
  - `finalFocus?` (`PopupFocusTarget`): Where focus goes when the dialog closes while focus is inside it.
677
- - `keepMounted?` (`boolean`): Whether the dialog stays in the page, hidden, while closed. For animation libraries that drive the exit from state.
677
+ - `keepMounted?` (`boolean`): Whether the dialog stays in the page, hidden, while closed. Its content keeps its state between opens.
678
+ - `inline?` (`boolean`): Renders the dialog and its backdrop where they are in the page instead of above it, so it can stay inside a frame, like an app preview. Pair it with `modal="trap-focus"` to keep the rest of the page usable. A `container` on the dialog still moves its backdrop, so leave it off.
678
679
 
679
680
  ### AlertDialogTitle
680
681
 
@@ -746,7 +746,7 @@ Suggestions can change while the list is open. The highlight stays with its sugg
746
746
 
747
747
  ## Controlled
748
748
 
749
- The value is always a string. Control it with `value` and `onValueChange`, or start uncontrolled with `defaultValue`. Suggestions have a separate `open` state and `onOpenChange`. Callbacks receive the proposed value first, then change details. Call `details.cancel()` to reject a text or open change. [State and Events](../state-and-events.md) covers controlled state and cancellation.
749
+ The value is always a string. Control it with `value` and `onValueChange`, or start uncontrolled with `defaultValue`. Suggestions have a separate `open` state and `onOpenChange`. Callbacks receive the proposed value first, then change details. Call `details.cancel()` to reject a text or open change. When a suggestion is chosen, `details.item` holds its `value` and `label`, so suggestions that share a label can still be told apart. [State and Events](../state-and-events.md) covers controlled state and cancellation.
750
750
 
751
751
  ```svelte title="controlled.svelte"
752
752
  <script lang="ts">
@@ -1560,7 +1560,7 @@ to decide.
1560
1560
  - `container?` (`DocumentFragment | Element | null`): Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
1561
1561
  - `value?` (`string`): The text. Pass it to control it.
1562
1562
  - `defaultValue?` (`string`): The text at first, when uncontrolled. A form reset returns to it.
1563
- - `onValueChange?` (`((value: string, details: ChangeDetails<AutocompleteValueChangeReason>) => void)`): Runs when the text wants to change: typing, choosing a suggestion, a Clear part, a form reset or a controller. `details.cancel()` keeps it as it was.
1563
+ - `onValueChange?` (`((value: string, details: AutocompleteValueChangeDetails) => void)`): Runs when the text wants to change: typing, choosing a suggestion, a Clear part, a form reset or a controller. `details.cancel()` keeps it as it was.
1564
1564
  - `open?` (`boolean`): Whether the suggestions are open. Pass it to control them.
1565
1565
  - `defaultOpen?` (`boolean`): Whether the suggestions start open, when uncontrolled.
1566
1566
  - `onOpenChange?` (`((open: boolean, details: ChangeDetails<AutocompleteOpenChangeReason>) => void)`): Runs when the suggestions want to open or close. `details.reason` says why, and `details.cancel()` stops it.
@@ -1770,6 +1770,8 @@ Create one with `createAutocompleteController()` and pass it as `controller`.
1770
1770
  - `getValue()` (`() => string`): The text.
1771
1771
  - `setValue(value, options?)` (`(value: string, options?: AutocompleteChangeOptions<AutocompleteValueChangeReason> | undefined) => boolean`): Changes the text, which filters the suggestions. Returns false when the change was canceled or nothing changed.
1772
1772
  - `clear(options?)` (`(options?: AutocompleteChangeOptions<AutocompleteValueChangeReason> | undefined) => boolean`): Empties the field. Returns false when the change was canceled or nothing changed.
1773
+ - `getHighlighted()` (`() => string | null`): The value of the highlighted suggestion, or null when none is.
1774
+ - `highlight(value)` (`(value: string | null) => boolean`): Highlights the suggestion with this value in the open list, scrolled into view, or none with null. Returns false when the suggestions are closed, or no enabled suggestion has the value.
1773
1775
  - `focus()` (`() => void`): Moves focus to the field.
1774
1776
 
1775
1777
  ### Events
@@ -602,7 +602,7 @@ Choose a year and month to jump directly to a birthday, then choose the day.
602
602
 
603
603
  ## Custom Month and Year Selects
604
604
 
605
- The month and year selects are native `select` elements. To use your own select, control the calendar's `month` and drive it from your select's value, as with the [Select](./select.md) component here. Keep a `CalendarHeading` in the calendar, visually hidden if you like, so the grid stays named.
605
+ The month and year selects are native `select` elements. To use your own select, control the calendar's `month` and drive it from your select's value, as with the [Select](./select.md) component here. Keep a `CalendarHeading` in the calendar, visually hidden if you like, so a month change is still announced. Each grid names itself.
606
606
 
607
607
  ```svelte title="custom-select.svelte"
608
608
  <script lang="ts">
@@ -1465,7 +1465,7 @@ Renders the week rows. Its `children` snippet receives each cell, with its `date
1465
1465
  ### CalendarDay
1466
1466
 
1467
1467
  - `value` (`string`): Its ISO date.
1468
- - `offset?` (`number`): The offset of the grid it's in.
1468
+ - `offset?` (`number`): The offset of the grid it's in, read from that grid, so you don't pass it.
1469
1469
 
1470
1470
  ### State
1471
1471
 
@@ -509,6 +509,7 @@ Beyond the pattern's baseline:
509
509
 
510
510
  - Closing the panel while focus is inside it moves focus to the trigger.
511
511
  - OnOpenChangeComplete runs once the animation has finished.
512
+ - An inert its owner writes during the exit stays once the exit ends.
512
513
  - Find in page reports its own reason and opens without an animation.
513
514
  - A canceled find in page keeps the panel hidden until found.
514
515
  - An infinite exit animation still unmounts the panel.
@@ -333,7 +333,7 @@ Choose a framework, then press the clear button. The selection and text clear, f
333
333
 
334
334
  ## Auto Highlight
335
335
 
336
- Add `autoHighlight` to highlight the first match while typing, so Enter can choose it immediately. With `autoHighlight="always"`, opening the list also highlights the selected item, or the first, so the arrow keys move from there. A highlight it placed follows the list as items arrive, and one the user moved stays while its item is there.
336
+ Add `autoHighlight` to highlight the first match while typing, so Enter can choose it immediately. With `autoHighlight="always"`, opening the list also highlights the selected item, or the first, so the arrow keys move from there. `autoHighlight="selected"` highlights only the selected item when the list opens, and nothing when none is. A highlight it placed follows the list as items arrive, and one the user moved stays while its item is there.
337
337
 
338
338
  ```svelte title="auto-highlight.svelte"
339
339
  <script lang="ts">
@@ -2869,7 +2869,7 @@ Props and callbacks are the same as below, as Svelte props. `value`, `query` and
2869
2869
  - `itemToValue?` (`((value: T) => string)`): The string an item's value submits as and is identified by, for object values. Strings pass through, and objects use their `value` or `id`.
2870
2870
  - `itemToLabel?` (`((value: T) => string)`): The text a value shows, for values whose item isn't rendered, like async results.
2871
2871
  - `isItemEqualToValue?` (`((itemValue: T, value: T) => boolean)`): Whether an item's value is the selected value, for object values that aren't the same object.
2872
- - `autoHighlight?` (`"always" | boolean`): Whether the first matching item is highlighted while typing, so Enter chooses it. `"always"` also highlights the selected item, or the first, when the list opens, so arrows move from there.
2872
+ - `autoHighlight?` (`"always" | "selected" | boolean`): Whether the first matching item is highlighted while typing, so Enter chooses it. `"always"` also highlights the selected item, or the first, when the list opens, so arrows move from there. `"selected"` highlights only the selected item when the list opens, and nothing when none is.
2873
2873
  - `keepQuery?` (`boolean`): With `multiple`, whether the input keeps its text after an item is chosen.
2874
2874
  - `pendingAnnouncement?` (`string`): What screen readers hear once the Create part's `onCreate` has been pending for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing.
2875
2875
  - `allowCustomValue?` (`boolean`): Whether text that matches no item becomes the value, when Enter is pressed with nothing highlighted, or, without `multiple`, when the list closes. The value is the text itself.
@@ -2918,7 +2918,7 @@ Holds the chips and the input for a multiple selection. Renders a `div`.
2918
2918
 
2919
2919
  ### ComboboxValue
2920
2920
 
2921
- - `maxLabels?` (`number`): With `multiple`, how many labels the `label` in its state shows before the rest are counted, as in "France, Chile and 2 more", joined the way the page's language joins lists.
2921
+ - `maxLabels?` (`number`): With `multiple`, how many labels the `label` in its state shows before the rest are counted, as in "France, Chile and 2 more", joined the way the page's language joins lists, or in English with the default `getMoreLabel`.
2922
2922
  - `getMoreLabel?` (`((count: number) => string)`): The words for the labels past `maxLabels`.
2923
2923
 
2924
2924
  ### ComboboxChip
@@ -3182,6 +3182,8 @@ Every write method takes an optional `{ reason, event }`, passed to the change c
3182
3182
  - `clear(options?)` (`(options?: ComboboxChangeOptions<ComboboxValueChangeReason> | undefined) => boolean`): Selects nothing and empties the input. Returns false when the change was canceled or nothing changed.
3183
3183
  - `getQuery()` (`() => string`): The input's text.
3184
3184
  - `setQuery(query, options?)` (`(query: string, options?: ComboboxChangeOptions<ComboboxQueryChangeReason> | undefined) => boolean`): Changes the input's text, which filters the list. Returns false when the change was canceled or nothing changed.
3185
+ - `getHighlighted()` (`() => T | null`): The value of the highlighted item, or null when none is.
3186
+ - `highlight(value)` (`(value: T | null) => boolean`): Highlights the item with this value in the open list, scrolled into view, or none with null. Returns false when the list is closed, or no enabled item has the value.
3185
3187
  - `focus()` (`() => void`): Moves focus to the input.
3186
3188
 
3187
3189
  ### Events
@@ -1399,6 +1399,7 @@ The first available command is highlighted by default. Set `autoHighlight` to `f
1399
1399
  **Field**
1400
1400
 
1401
1401
  - Is a combobox that controls an always-expanded listbox.
1402
+ - The list is named by the field, not by what's typed.
1402
1403
  - The first command is highlighted from the start.
1403
1404
 
1404
1405
  **Filtering**
@@ -508,6 +508,7 @@ Every line below is an automated test.
508
508
  - A canceled change keeps the date.
509
509
  - The form submits the ISO date and time under their names.
510
510
  - Enter submits the form with what was typed.
511
+ - Enter submits a form with no submit button, in a segment or the form's one text field.
511
512
  - Resetting the form brings back the default date.
512
513
  - A partly filled date can't be submitted.
513
514
  - A required empty date can't be submitted.
@@ -1122,7 +1122,7 @@ Clears the value and focuses the input. Renders a `button`.
1122
1122
  - `anchor?` (`string | Anchor | null`): Positions the popup against this instead of its trigger: an element, a CSS selector, a point like `{ x, y }`, or anything with `getBoundingClientRect()`. It's read on every check, so it can move. A controller's `open({ anchor })` wins for that open.
1123
1123
  - `container?` (`DocumentFragment | Element | null`): Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
1124
1124
  - `finalFocus?` (`PopupFocusTarget`): Where focus goes when the popup closes while focus is inside it.
1125
- - `keepMounted?` (`boolean`): Whether the popup stays in the page, hidden, while closed. For animation libraries that drive the exit from state.
1125
+ - `keepMounted?` (`boolean`): Whether the popup stays in the page, hidden, while closed. Its content keeps its state between opens.
1126
1126
  ### DatePickerPreset
1127
1127
 
1128
1128
  - `value` (`DatePickerValue`): The value it selects: an ISO date, or `[start, end]` in range mode.
@@ -574,6 +574,45 @@ Dialogs render where you put them and use the browser's top layer. Set `containe
574
574
 
575
575
  Choose a mode, open Notes, and try Tab or clicking the page. Check Close on outside press to compare dismissal.
576
576
 
577
+ ## Inside a Frame
578
+
579
+ A dialog opens above the whole page. Set `inline` on the content to keep it and its backdrop where they are in the page, like inside an app preview. Your CSS sizes and places them in their frame. Pair it with `modal="trap-focus"` so the page around the frame stays usable.
580
+
581
+ ```svelte title="inline.svelte"
582
+ <script lang="ts">
583
+ import {
584
+ Dialog,
585
+ DialogBackdrop,
586
+ DialogClose,
587
+ DialogContent,
588
+ DialogDescription,
589
+ DialogTitle,
590
+ DialogTrigger,
591
+ } from "@ui-sdk/svelte/dialog"
592
+ </script>
593
+
594
+ <div data-slot="dialog-frame">
595
+ <Dialog modal="trap-focus" closeOnOutsidePress={false}>
596
+ <DialogTrigger>Delete Draft</DialogTrigger>
597
+ <DialogBackdrop />
598
+ <DialogContent inline>
599
+ <div data-slot="stack">
600
+ <DialogTitle>Delete this draft?</DialogTitle>
601
+ <DialogDescription
602
+ >The preview keeps its dialog inside the frame.</DialogDescription
603
+ >
604
+ </div>
605
+ <div data-slot="row">
606
+ <DialogClose>Cancel</DialogClose>
607
+ <DialogClose data-variant="destructive">Delete</DialogClose>
608
+ </div>
609
+ </DialogContent>
610
+ </Dialog>
611
+ </div>
612
+ ```
613
+
614
+ Open Delete Draft. The dialog and its dim cover only the frame, and Tab stays inside the dialog.
615
+
577
616
  ## Warn Before Closing a Dirty Form
578
617
 
579
618
  Set `dismissible` to false while there are unsaved changes. Escape, an outside press, or a back gesture then keeps the dialog open and reports `onDismissAttempt`. Explicit Close parts and controller calls still work, so you can offer a deliberate way out.
@@ -1069,7 +1108,8 @@ Dims the page behind a modal dialog. Renders a `div`.
1069
1108
  - `container?` (`DocumentFragment | Element | null`): Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
1070
1109
  - `initialFocus?` (`DialogInitialFocus`): Where focus goes when the dialog opens. Opening with touch focuses the dialog itself, so no on-screen keyboard appears.
1071
1110
  - `finalFocus?` (`PopupFocusTarget`): Where focus goes when the dialog closes while focus is inside it.
1072
- - `keepMounted?` (`boolean`): Whether the dialog stays in the page, hidden, while closed. For animation libraries that drive the exit from state.
1111
+ - `keepMounted?` (`boolean`): Whether the dialog stays in the page, hidden, while closed. Its content keeps its state between opens.
1112
+ - `inline?` (`boolean`): Renders the dialog and its backdrop where they are in the page instead of above it, so it can stay inside a frame, like an app preview. Pair it with `modal="trap-focus"` to keep the rest of the page usable. A `container` on the dialog still moves its backdrop, so leave it off.
1073
1113
 
1074
1114
  ### DialogTitle
1075
1115
 
@@ -1209,6 +1249,7 @@ The trigger is a button that opens a dialog, and the dialog follows the [WAI-ARI
1209
1249
  - Tab moves through the dialog in order.
1210
1250
  - Tab from the last element wraps to the first.
1211
1251
  - Shift+Tab from the first element wraps to the last.
1252
+ - … from inside an iframe that is the … element wraps around the dialog.
1212
1253
  - Shift+Tab from the first element wraps to the checked radio of a group outside a form.
1213
1254
  - Tab reaches radios whose group's checked radio is behind the dialog.
1214
1255
  - Tab visits a positive tabindex first, like the browser.
@@ -1217,8 +1258,12 @@ The trigger is a button that opens a dialog, and the dialog follows the [WAI-ARI
1217
1258
  - With a positive tabindex in the dialog, Tab still moves through a shadow root and slots.
1218
1259
  - With a positive tabindex in the dialog, Tab from a focused element outside the tab order goes to the next stop.
1219
1260
  - Tab from a custom element with a positive tabindex enters its shadow root.
1261
+ - Tab from a last control inside a shadow root wraps to the first, and Shift+Tab comes back to it.
1262
+ - Tab wraps past a shadow root that Tab skips, under an inert or tabindex -1 host.
1263
+ - Tab wraps from the last stop of a shadow root that orders a positive tabindex first.
1220
1264
  - Opening focuses the first field even when a later one has a positive tabindex.
1221
1265
  - Escape closes the dialog and returns focus to the trigger.
1266
+ - An ancestor hears Escape already handled.
1222
1267
  - Escape after a click returns focus to the trigger.
1223
1268
  - The close button closes the dialog and returns focus to the trigger.
1224
1269
  - A virtual click from a screen reader moves focus into the dialog.
@@ -1229,6 +1274,7 @@ The trigger is a button that opens a dialog, and the dialog follows the [WAI-ARI
1229
1274
 
1230
1275
  - Pressing the backdrop closes the dialog.
1231
1276
  - Pressing the backdrop returns focus to the trigger.
1277
+ - After pressing the backdrop, Space on the trigger opens it again.
1232
1278
  - Clicking inside the dialog keeps it open.
1233
1279
  - An outside press doesn't reach the page.
1234
1280