@ahrowe/ui 0.41.0 → 0.41.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/cjs-types/common/hooks/useAnchorTracking.d.ts +4 -3
- package/dist/cjs-types/common/hooks/useOverlay.d.ts +4 -1
- package/dist/cjs-types/common/popover/popover.types.d.ts +1 -1
- package/dist/cjs-types/common/popover/usePopoverPosition.d.ts +6 -1
- package/dist/esm/common/ahroweProvider/ahroweProvider.mjs +1 -1
- package/dist/esm/common/ahroweProvider/ahroweProvider.mjs.map +1 -1
- package/dist/esm/common/calendar/calendar.mjs +1 -1
- package/dist/esm/common/calendar/calendar.mjs.map +1 -1
- package/dist/esm/common/fab/fab.module.mjs.map +1 -1
- package/dist/esm/common/hooks/useAnchorTracking.mjs +1 -1
- package/dist/esm/common/hooks/useAnchorTracking.mjs.map +1 -1
- package/dist/esm/common/hooks/useFocusBoundary.mjs +1 -1
- package/dist/esm/common/hooks/useFocusBoundary.mjs.map +1 -1
- package/dist/esm/common/hooks/useOverlay.mjs +1 -1
- package/dist/esm/common/hooks/useOverlay.mjs.map +1 -1
- package/dist/esm/common/modal/modal.mjs +1 -1
- package/dist/esm/common/modal/modal.mjs.map +1 -1
- package/dist/esm/common/modal/modal.module.mjs.map +1 -1
- package/dist/esm/common/otpInput/otpInput.mjs +1 -1
- package/dist/esm/common/otpInput/otpInput.mjs.map +1 -1
- package/dist/esm/common/popover/popover.mjs +1 -1
- package/dist/esm/common/popover/popover.mjs.map +1 -1
- package/dist/esm/common/popover/popover.module.mjs.map +1 -1
- package/dist/esm/common/popover/popover.types.mjs.map +1 -1
- package/dist/esm/common/popover/usePopoverPosition.mjs +1 -1
- package/dist/esm/common/popover/usePopoverPosition.mjs.map +1 -1
- package/dist/esm/common/styles/sheet.module.mjs.map +1 -1
- package/dist/esm/common/timer/timer.mjs +1 -1
- package/dist/esm/common/timer/timer.mjs.map +1 -1
- package/dist/esm/common/tooltip/tooltip.module.mjs.map +1 -1
- package/dist/esm/common/virtualList/virtualList.mjs +1 -1
- package/dist/esm/common/virtualList/virtualList.mjs.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/common/hooks/useAnchorTracking.d.ts +4 -3
- package/dist/types/common/hooks/useOverlay.d.ts +4 -1
- package/dist/types/common/popover/popover.types.d.ts +1 -1
- package/dist/types/common/popover/usePopoverPosition.d.ts +6 -1
- package/docs/Modal.md +1 -1
- package/docs/Popover.md +2 -2
- package/package.json +1 -1
|
@@ -9,10 +9,11 @@ export interface UseAnchorTrackingArgs {
|
|
|
9
9
|
*/
|
|
10
10
|
elementRefs: RefObject<HTMLElement | null>[];
|
|
11
11
|
/**
|
|
12
|
-
* Positions the popup. Called once on setup and then on every scroll, resize
|
|
13
|
-
* change
|
|
12
|
+
* Positions the popup. Called once on setup and then on every scroll, resize, tracked size
|
|
13
|
+
* change and end of a CSS animation that moved the trigger, plus whenever it calls `rerun` for
|
|
14
|
+
* an end none of those report. Reads the caller's own refs for everything else.
|
|
14
15
|
*/
|
|
15
|
-
update: (trigger: HTMLElement, ancestors: HTMLElement[]) => void;
|
|
16
|
+
update: (trigger: HTMLElement, ancestors: HTMLElement[], rerun: () => void) => void;
|
|
16
17
|
/**
|
|
17
18
|
* Elements whose own size changes must re-run `update`: a popup whose content changes size
|
|
18
19
|
* while open (a filtered list shrinking, an async list loading in) otherwise keeps coordinates
|
|
@@ -6,7 +6,10 @@ export interface UseOverlayArgs {
|
|
|
6
6
|
containerRef: RefObject<HTMLElement | null>;
|
|
7
7
|
/** Called when Escape is pressed while this is the topmost overlay. Omit to not handle Escape. */
|
|
8
8
|
onEscape?: () => void;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Keep Tab inside the panel and restore focus to the previously focused element on close, unless
|
|
11
|
+
* an overlay opened after this one is still open.
|
|
12
|
+
*/
|
|
10
13
|
trapFocus?: boolean;
|
|
11
14
|
/** Prevent the page behind the overlay from scrolling. */
|
|
12
15
|
lockScroll?: boolean;
|
|
@@ -53,7 +53,7 @@ export interface PopoverProps extends Omit<HtmlProps, 'content'> {
|
|
|
53
53
|
offset?: number;
|
|
54
54
|
/** Render the arrow pointing at the trigger (default `true`). */
|
|
55
55
|
withArrow?: boolean;
|
|
56
|
-
/** Close
|
|
56
|
+
/** Close on a click outside, or when focus leaves the trigger and panel (default `true`). */
|
|
57
57
|
closeOnOutsideClick?: boolean;
|
|
58
58
|
/** Close when pressing Escape (default `true`). */
|
|
59
59
|
closeOnEscape?: boolean;
|
|
@@ -32,6 +32,11 @@ export interface UsePopoverPositionArgs {
|
|
|
32
32
|
* panel that overhangs it.
|
|
33
33
|
*/
|
|
34
34
|
shrinkToFit?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Called when a newly opened panel first becomes visible. Focus has to wait for it: a panel
|
|
37
|
+
* still hidden, waiting out an ancestor's animation, takes none.
|
|
38
|
+
*/
|
|
39
|
+
onShown?: () => void;
|
|
35
40
|
}
|
|
36
41
|
/**
|
|
37
42
|
* Positions a portaled, `position: fixed` popover on any of the four sides of its trigger with
|
|
@@ -42,4 +47,4 @@ export interface UsePopoverPositionArgs {
|
|
|
42
47
|
* `useAnchorTracking` supplies the lifecycle around this: mount wait, ancestor resolution, and
|
|
43
48
|
* re-running on scroll, viewport resize and panel size changes.
|
|
44
49
|
*/
|
|
45
|
-
export declare function usePopoverPosition({ isOpen, placement, align, offset, triggerRef, floatingRef, panelRef, arrowRef, matchTriggerWidth, shrinkToFit, }: UsePopoverPositionArgs): void;
|
|
50
|
+
export declare function usePopoverPosition({ isOpen, placement, align, offset, triggerRef, floatingRef, panelRef, arrowRef, matchTriggerWidth, shrinkToFit, onShown, }: UsePopoverPositionArgs): void;
|
package/docs/Modal.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
The panel itself never scrolls: the header is fixed and the children scroll inside the `body` slot, so the title and close button stay visible no matter how long the content is. Pass `footer` for anything that should stay put below the content, typically the action buttons.
|
|
10
10
|
|
|
11
|
-
While open, the modal traps focus (focus moves into the panel and returns to whatever was focused before on close), locks scrolling on the page behind it, and closes on Escape. Modals nest correctly: Escape closes only the topmost one, and the page stays locked until the last one closes. The same applies to anything opened from inside a modal — a `Menu`, `Dropdown` or `Popover` counts as the layer above it, so Escape closes that first, and the modal's focus trap leaves focus alone while it's open (all three render through the same portal, so their DOM sits beside the modal's panel rather than inside it).
|
|
11
|
+
While open, the modal traps focus (focus moves into the panel and returns to whatever was focused before on close), locks scrolling on the page behind it, and closes on Escape. A key already held down when it opens does not repeat into it, so holding Enter on the button that opens it does not go on to press whatever the modal focused first. Modals nest correctly: Escape closes only the topmost one, and the page stays locked until the last one closes. Modal, Popover and Tooltip share one `z-index`, so whichever opened last paints on top, a Modal opened from a Popover included. The same applies to anything opened from inside a modal — a `Menu`, `Dropdown` or `Popover` counts as the layer above it, so Escape closes that first, and the modal's focus trap leaves focus alone while it's open (all three render through the same portal, so their DOM sits beside the modal's panel rather than inside it).
|
|
12
12
|
|
|
13
13
|
```tsx
|
|
14
14
|
import { Modal, ActionButtons } from '@ahrowe/ui';
|
package/docs/Popover.md
CHANGED
|
@@ -65,7 +65,7 @@ const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
|
|
65
65
|
| `onOpenChange` | `(isOpen, { fromKeyboard }) => void` | — | Open-state change callback. `fromKeyboard` says whether a key caused it, which is what a menu uses to decide between putting the focus on an entry and leaving it on the trigger |
|
|
66
66
|
| `offset` | `number` | `10` | Gap in px between trigger and panel |
|
|
67
67
|
| `withArrow` | `boolean` | `true` | Render the arrow pointing at the trigger |
|
|
68
|
-
| `closeOnOutsideClick` | `boolean` | `true` | Close on click outside (ignored for hover trigger) |
|
|
68
|
+
| `closeOnOutsideClick` | `boolean` | `true` | Close on a click outside, or when focus leaves the trigger and panel (ignored for hover trigger) |
|
|
69
69
|
| `closeOnEscape` | `boolean` | `true` | Close on Escape |
|
|
70
70
|
| `openDelay` | `number` | `100` | Hover open delay in ms |
|
|
71
71
|
| `closeDelay` | `number` | `120` | Hover close delay in ms |
|
|
@@ -90,6 +90,6 @@ Only a `Click` trigger presents as a sheet. `Hover` and `Focus` open something s
|
|
|
90
90
|
|
|
91
91
|
**Scrolling:** where the browser supports CSS anchor positioning, including the trigger's transforms, the panel is anchored to the trigger in CSS, so it moves with a scrolling trigger in the same frame instead of catching up a frame later. Firefox resolves anchors without transforms, so it keeps the pixel positioning. While it is open the trigger carries an inline `anchor-name`, added to any inline one it already has; an `anchor-name` your stylesheet gives the trigger is overridden for that time.
|
|
92
92
|
|
|
93
|
-
**Keyboard & focus (click trigger):** the panel is portaled to the end of the DOM, so Tab can't reach it naturally. When the panel has focusable content and the keyboard opened it (Enter or Space on the trigger, or ArrowDown/ArrowUp), focus moves to the first focusable element and the panel gets `role="dialog"`; a pointer click leaves the focus where it already is. `focusOnOpen` forces either. Tabbing past the last element closes the popover and moves focus to the element after the trigger; Shift+Tab past the first element, and Escape, close it and return focus to the trigger. This is non-modal: focus is not trapped, and hover/focus triggers don't steal focus. Escape closes only the innermost open layer, so a popover inside a `Modal` closes on the first press and leaves the modal open. Popovers with only static content don't manage focus or claim the dialog role.
|
|
93
|
+
**Keyboard & focus (click trigger):** the panel is portaled to the end of the DOM, so Tab can't reach it naturally. When the panel has focusable content and the keyboard opened it (Enter or Space on the trigger, or ArrowDown/ArrowUp), focus moves to the first focusable element and the panel gets `role="dialog"`; a pointer click leaves the focus where it already is. `focusOnOpen` forces either. Tabbing past the last element closes the popover and moves focus to the element after the trigger; Shift+Tab past the first element, and Escape, close it and return focus to the trigger. However else it closes, such as a button inside it setting `isOpen` to `false`, focus that is still inside the panel goes back to the trigger too, as the native `hidePopover()` does; focus that has already moved elsewhere, or onto the page after a click outside, stays where it is. A key already held down when the panel opens does not repeat into it, so a held Enter does not go on to pick the first entry; in the field it opened from, such as one showing suggestions while you type, it keeps repeating. This is non-modal: focus is not trapped, and hover/focus triggers don't steal focus. Escape closes only the innermost open layer, so a popover inside a `Modal` closes on the first press and leaves the modal open. Popovers with only static content don't manage focus or claim the dialog role.
|
|
94
94
|
|
|
95
95
|
**Anchored (`anchor`):** your code opens the panel, not a key event Popover sees, so the default `focusOnOpen` looks at the click that opened it: Enter or Space on the anchor or on something inside it (a click with `detail === 0`) moves the focus into the panel, a pointer click leaves it where it is, and an open with no click at all, such as suggestions appearing while the user types into an anchored field, never takes it. Escape, Tab and Shift+Tab out of the panel continue from the anchor as they would from a trigger: from the anchor itself when it takes focus, otherwise from the first focusable element inside it.
|