@primitiv-ui/core 0.1.54 → 0.1.55
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/popover/policy.d.ts +31 -0
- package/dist/popover/policy.js +20 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export { accordionKeydown, accordionToggle, type AccordionKeyOutcome, type Accor
|
|
|
6
6
|
export { collapsibleKeydown, collapsibleToggle, type CollapsibleKeyOutcome, type CollapsibleState, } from "./collapsible/policy.js";
|
|
7
7
|
export { FOCUSABLE_SELECTOR } from "./focus/focusable.js";
|
|
8
8
|
export { modalPointerOutside, modalTabKeydown, type ModalBox, type ModalTabOutcome, type ModalTabState, } from "./modal/policy.js";
|
|
9
|
+
export { popoverKeydown, popoverPressDismisses, type PopoverKeyOutcome, type PopoverPress, } from "./popover/policy.js";
|
package/dist/index.js
CHANGED
|
@@ -6,3 +6,4 @@ export { accordionKeydown, accordionToggle, } from "./accordion/policy.js";
|
|
|
6
6
|
export { collapsibleKeydown, collapsibleToggle, } from "./collapsible/policy.js";
|
|
7
7
|
export { FOCUSABLE_SELECTOR } from "./focus/focusable.js";
|
|
8
8
|
export { modalPointerOutside, modalTabKeydown, } from "./modal/policy.js";
|
|
9
|
+
export { popoverKeydown, popoverPressDismisses, } from "./popover/policy.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** What a key press inside an open popover asks for: the open state to move to. */
|
|
2
|
+
export type PopoverKeyOutcome = {
|
|
3
|
+
open: false;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* The popover's keyboard contract for a key press inside its panel: Escape
|
|
7
|
+
* closes it (and the caller hands focus back to the trigger, since focus moved
|
|
8
|
+
* into the panel on open). Returns `null` for any other key, which tells the
|
|
9
|
+
* caller to leave the event alone.
|
|
10
|
+
*/
|
|
11
|
+
export declare function popoverKeydown(key: string): PopoverKeyOutcome | null;
|
|
12
|
+
/** Where a press landed, relative to an open popover, and whether the browser handles it. */
|
|
13
|
+
export type PopoverPress = {
|
|
14
|
+
/** Whether the popover is open. */
|
|
15
|
+
open: boolean;
|
|
16
|
+
/** Whether the browser light-dismisses `popover="auto"` itself (the Popover API exists). */
|
|
17
|
+
nativeLightDismiss: boolean;
|
|
18
|
+
/** Whether the press landed on (or in) the trigger. */
|
|
19
|
+
inTrigger: boolean;
|
|
20
|
+
/** Whether the press landed inside a popover — this one, or one nested in it. */
|
|
21
|
+
inPopover: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Whether a press dismisses the popover. A browser with the Popover API
|
|
25
|
+
* light-dismisses an `auto` popover on an outside press and reports it with a
|
|
26
|
+
* `toggle` event, so this only answers where it does not; answering there too
|
|
27
|
+
* would catch the very click that opened the popover from an outside control
|
|
28
|
+
* and close it again. A press on the trigger toggles it instead, and one inside
|
|
29
|
+
* any popover is inside.
|
|
30
|
+
*/
|
|
31
|
+
export declare function popoverPressDismisses({ open, nativeLightDismiss, inTrigger, inPopover }: PopoverPress): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The popover's keyboard contract for a key press inside its panel: Escape
|
|
3
|
+
* closes it (and the caller hands focus back to the trigger, since focus moved
|
|
4
|
+
* into the panel on open). Returns `null` for any other key, which tells the
|
|
5
|
+
* caller to leave the event alone.
|
|
6
|
+
*/
|
|
7
|
+
export function popoverKeydown(key) {
|
|
8
|
+
return key === "Escape" ? { open: false } : null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Whether a press dismisses the popover. A browser with the Popover API
|
|
12
|
+
* light-dismisses an `auto` popover on an outside press and reports it with a
|
|
13
|
+
* `toggle` event, so this only answers where it does not; answering there too
|
|
14
|
+
* would catch the very click that opened the popover from an outside control
|
|
15
|
+
* and close it again. A press on the trigger toggles it instead, and one inside
|
|
16
|
+
* any popover is inside.
|
|
17
|
+
*/
|
|
18
|
+
export function popoverPressDismisses({ open, nativeLightDismiss, inTrigger, inPopover }) {
|
|
19
|
+
return open && !nativeLightDismiss && !inTrigger && !inPopover;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primitiv-ui/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.55",
|
|
4
4
|
"description": "The framework-free behaviour core shared by every Primitiv surface — keyboard maps, roving-focus targets, id derivation and per-component policy, as pure functions with no DOM and no dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|