@primitiv-ui/core 0.1.54 → 0.1.56

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 CHANGED
@@ -6,3 +6,5 @@ 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";
10
+ export { TOOLTIP_GRACE_MS, tooltipOpenDelay, type TooltipDelayState } from "./tooltip/policy.js";
package/dist/index.js CHANGED
@@ -6,3 +6,5 @@ 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";
10
+ export { TOOLTIP_GRACE_MS, tooltipOpenDelay } from "./tooltip/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
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * How long the pointer has, after leaving a tooltip's trigger, to cross onto
3
+ * the tooltip itself before it closes — so hoverable content can be reached.
4
+ */
5
+ export declare const TOOLTIP_GRACE_MS: number;
6
+ /** What the open delay depends on. */
7
+ export type TooltipDelayState = {
8
+ /** Whether a tooltip in the same group closed within the group's skip-delay window. */
9
+ groupOpen: boolean;
10
+ /** The delay before opening on hover, in milliseconds. */
11
+ delay: number;
12
+ };
13
+ /**
14
+ * The delay before a hovered tooltip opens: its own delay, or none while the
15
+ * group is still in its skip-delay window — so moving along a row of triggers
16
+ * opens each next tooltip at once rather than waiting every time.
17
+ */
18
+ export declare function tooltipOpenDelay({ groupOpen, delay }: TooltipDelayState): number;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * How long the pointer has, after leaving a tooltip's trigger, to cross onto
3
+ * the tooltip itself before it closes — so hoverable content can be reached.
4
+ */
5
+ export const TOOLTIP_GRACE_MS = 100;
6
+ /**
7
+ * The delay before a hovered tooltip opens: its own delay, or none while the
8
+ * group is still in its skip-delay window — so moving along a row of triggers
9
+ * opens each next tooltip at once rather than waiting every time.
10
+ */
11
+ export function tooltipOpenDelay({ groupOpen, delay }) {
12
+ return groupOpen ? 0 : delay;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitiv-ui/core",
3
- "version": "0.1.54",
3
+ "version": "0.1.56",
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",