@streamscloud/kit 0.95.1 → 0.95.3

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.
@@ -17,7 +17,7 @@ const cancelTimers = () => {
17
17
  const scheduleOpen = () => {
18
18
  cancelTimers();
19
19
  openTimer = setTimeout(() => {
20
- popover?.open();
20
+ popover?.open({ moveFocus: false });
21
21
  openTimer = undefined;
22
22
  }, openDelay);
23
23
  };
@@ -29,12 +29,6 @@ const scheduleClose = () => {
29
29
  }, closeDelay);
30
30
  };
31
31
  const isInsideRoot = (node) => node instanceof Node && !!rootEl?.contains(node);
32
- // Without the zone check, Escape returning focus to the trigger reopens the popover.
33
- const handleFocusIn = (event) => {
34
- if (!isInsideRoot(event.relatedTarget)) {
35
- scheduleOpen();
36
- }
37
- };
38
32
  const handleFocusOut = (event) => {
39
33
  if (!isInsideRoot(event.relatedTarget)) {
40
34
  scheduleClose();
@@ -49,23 +43,16 @@ $effect(() => {
49
43
  });
50
44
  </script>
51
45
 
52
- <span
53
- bind:this={rootEl}
54
- class="hover-popover"
55
- role="presentation"
56
- onmouseenter={scheduleOpen}
57
- onmouseleave={scheduleClose}
58
- onfocusin={handleFocusIn}
59
- onfocusout={handleFocusOut}>
46
+ <span bind:this={rootEl} class="hover-popover" role="presentation" onmouseenter={scheduleOpen} onmouseleave={scheduleClose} onfocusout={handleFocusOut}>
60
47
  <Popover bind:this={popover} {...rest} />
61
48
  </span>
62
49
 
63
50
  <!--
64
51
  @component
65
- HoverPopover — thin wrapper around Popover that opens on hover/focus instead of click.
66
- Content is rendered as a DOM descendant of the wrapper, so moving the cursor from trigger
67
- to content stays "inside" the hover zone (no close fires). The `closeDelay` covers the
68
- small visual gap between trigger and content. A click on the trigger still toggles; nested in another popover's content it makes a submenu.
52
+ HoverPopover — thin wrapper around Popover that also opens on hover. Hover leaves focus where it is; from the keyboard the
53
+ trigger opens like a Popover's (Enter / Space toggles and moves focus into the content), and focus leaving the trigger and
54
+ content closes it. Content is a DOM descendant of the wrapper, so moving the cursor from trigger to content stays inside
55
+ the hover zone; `closeDelay` covers the gap between them. Nested in another popover's content it makes a submenu.
69
56
 
70
57
  `bind:this` on HoverPopover forwards `open() / close() / toggle()` from the inner Popover.
71
58
  -->
@@ -14,6 +14,8 @@ type Props = {
14
14
  panel?: boolean;
15
15
  /** Keep open on any click inside the content. */
16
16
  keepOpen?: boolean;
17
+ /** Make the trigger fill its parent's box (`width: 100%; height: 100%`) — e.g. a submenu row spanning the menu width. */
18
+ fillContainer?: boolean;
17
19
  on?: {
18
20
  opened?: () => void;
19
21
  closed?: () => void;
@@ -29,10 +31,10 @@ type Props = {
29
31
  closeDelay?: number;
30
32
  };
31
33
  /**
32
- * HoverPopover — thin wrapper around Popover that opens on hover/focus instead of click.
33
- * Content is rendered as a DOM descendant of the wrapper, so moving the cursor from trigger
34
- * to content stays "inside" the hover zone (no close fires). The `closeDelay` covers the
35
- * small visual gap between trigger and content. A click on the trigger still toggles; nested in another popover's content it makes a submenu.
34
+ * HoverPopover — thin wrapper around Popover that also opens on hover. Hover leaves focus where it is; from the keyboard the
35
+ * trigger opens like a Popover's (Enter / Space toggles and moves focus into the content), and focus leaving the trigger and
36
+ * content closes it. Content is a DOM descendant of the wrapper, so moving the cursor from trigger to content stays inside
37
+ * the hover zone; `closeDelay` covers the gap between them. Nested in another popover's content it makes a submenu.
36
38
  *
37
39
  * `bind:this` on HoverPopover forwards `open() / close() / toggle()` from the inner Popover.
38
40
  */
@@ -20,12 +20,14 @@ let backdropEl = $state.raw(undefined);
20
20
  let resolvedPlacement = $state(position);
21
21
  let previouslyFocused = null;
22
22
  let closedByEscape = false;
23
+ let moveFocusOnOpen = true;
23
24
  const openPopoverEntry = Symbol();
24
25
  /** Imperative API — bind:this on the component to access. */
25
- export const open = () => {
26
+ export const open = ({ moveFocus = true } = {}) => {
26
27
  if (disabled || opened) {
27
28
  return;
28
29
  }
30
+ moveFocusOnOpen = moveFocus;
29
31
  opened = true;
30
32
  on?.opened?.();
31
33
  };
@@ -112,7 +114,9 @@ $effect(() => {
112
114
  }
113
115
  previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
114
116
  closedByEscape = false;
115
- void focusFirstFocusable();
117
+ if (moveFocusOnOpen) {
118
+ void focusFirstFocusable();
119
+ }
116
120
  return () => {
117
121
  // Only Escape: returning focus on any close flashes the trigger's focus ring when a dialog opened from an item closes.
118
122
  if (closedByEscape) {
@@ -360,7 +364,7 @@ Props for keeping the popover open during interaction:
360
364
  border-radius: inherit;
361
365
  }
362
366
  .popover__anchor {
363
- display: flex;
367
+ display: grid;
364
368
  width: 100%;
365
369
  }
366
370
  .popover--disabled {
@@ -29,6 +29,7 @@ type Props = {
29
29
  * A snippet is the content of the trigger `<button>`, so non-interactive only — `Button type="presentational"` for a button look.
30
30
  * `{ custom }` replaces the button with the consumer's own control: its clicks toggle the popover, and its `id`, `disabled`, `aria-expanded`
31
31
  * and `aria-haspopup` are the consumer's (`on.opened` / `on.closed` report the state). `id`, `tabbable` and the aria props here are not applied to it.
32
+ * The control stretches to the trigger's box, so with `fillContainer` or `--sc-kit--popover--width` it fills that width.
32
33
  * @default chevron-down icon
33
34
  */
34
35
  trigger?: Snippet | {
@@ -94,7 +95,9 @@ type Props = {
94
95
  * - `use:popoverIgnore={true}` action: block close for clicks anywhere in the marked sub-tree.
95
96
  */
96
97
  declare const Cmp: import("svelte").Component<Props, {
97
- /** Imperative API — bind:this on the component to access. */ open: () => void;
98
+ /** Imperative API — bind:this on the component to access. */ open: ({ moveFocus }?: {
99
+ moveFocus?: boolean;
100
+ }) => void;
98
101
  close: () => void;
99
102
  toggle: () => void;
100
103
  }, "">;
@@ -4,7 +4,10 @@ export { default as HoverPopover } from './cmp.hover-popover.svelte';
4
4
  export { popoverIgnore } from './popover-ignore';
5
5
  /** Imperative API exposed via `bind:this={instance}` on `<Popover>`. */
6
6
  export type PopoverInstance = {
7
- open: () => void;
7
+ /** `moveFocus: false` opens without focusing the first focusable in the content. */
8
+ open: (options?: {
9
+ moveFocus?: boolean;
10
+ }) => void;
8
11
  close: () => void;
9
12
  toggle: () => void;
10
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.95.1",
3
+ "version": "0.95.3",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",