@zag-js/popover 0.1.9 → 0.1.12
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/LICENSE +21 -0
- package/dist/index.d.ts +103 -3
- package/dist/index.js +294 -621
- package/dist/index.mjs +290 -625
- package/package.json +18 -14
- package/dist/popover.connect.d.ts +0 -17
- package/dist/popover.dom.d.ts +0 -28
- package/dist/popover.machine.d.ts +0 -2
- package/dist/popover.types.d.ts +0 -101
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popover",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Core logic for the popover widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,22 +29,26 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/aria-hidden": "0.1.
|
|
33
|
-
"@zag-js/core": "0.1.
|
|
34
|
-
"@zag-js/
|
|
35
|
-
"@zag-js/popper": "0.1.
|
|
36
|
-
"@zag-js/remove-scroll": "0.1.
|
|
37
|
-
"@zag-js/types": "0.2.
|
|
38
|
-
"@zag-js/utils": "0.1.2",
|
|
32
|
+
"@zag-js/aria-hidden": "0.1.1",
|
|
33
|
+
"@zag-js/core": "0.1.9",
|
|
34
|
+
"@zag-js/dismissable": "0.1.3",
|
|
35
|
+
"@zag-js/popper": "0.1.10",
|
|
36
|
+
"@zag-js/remove-scroll": "0.1.3",
|
|
37
|
+
"@zag-js/types": "0.2.3",
|
|
39
38
|
"focus-trap": "6.9.4"
|
|
40
39
|
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@zag-js/dom-utils": "0.1.9",
|
|
42
|
+
"@zag-js/utils": "0.1.3"
|
|
43
|
+
},
|
|
41
44
|
"scripts": {
|
|
42
|
-
"build
|
|
43
|
-
"start": "
|
|
44
|
-
"build": "
|
|
45
|
+
"build-fast": "tsup src/index.ts --format=esm,cjs",
|
|
46
|
+
"start": "pnpm build --watch",
|
|
47
|
+
"build": "tsup src/index.ts --format=esm,cjs --dts",
|
|
45
48
|
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
|
|
46
49
|
"lint": "eslint src --ext .ts,.tsx",
|
|
47
|
-
"test
|
|
48
|
-
"test
|
|
50
|
+
"test-ci": "pnpm test --ci --runInBand",
|
|
51
|
+
"test-watch": "pnpm test --watch -u",
|
|
52
|
+
"typecheck": "tsc --noEmit"
|
|
49
53
|
}
|
|
50
|
-
}
|
|
54
|
+
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
|
-
import type { Send, State } from "./popover.types";
|
|
3
|
-
export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
4
|
-
portalled: boolean;
|
|
5
|
-
isOpen: boolean;
|
|
6
|
-
open(): void;
|
|
7
|
-
close(): void;
|
|
8
|
-
arrowProps: T["element"];
|
|
9
|
-
innerArrowProps: T["element"];
|
|
10
|
-
anchorProps: T["element"];
|
|
11
|
-
triggerProps: T["button"];
|
|
12
|
-
positionerProps: T["element"];
|
|
13
|
-
contentProps: T["element"];
|
|
14
|
-
titleProps: T["element"];
|
|
15
|
-
descriptionProps: T["element"];
|
|
16
|
-
closeButtonProps: T["button"];
|
|
17
|
-
};
|
package/dist/popover.dom.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { MachineContext as Ctx } from "./popover.types";
|
|
2
|
-
export declare const dom: {
|
|
3
|
-
getDoc: (ctx: Ctx) => Document;
|
|
4
|
-
getWin: (ctx: Ctx) => Window & typeof globalThis;
|
|
5
|
-
getActiveEl: (ctx: Ctx) => Element;
|
|
6
|
-
getRootNode: (ctx: Ctx) => Document | ShadowRoot;
|
|
7
|
-
getAnchorId: (ctx: Ctx) => string;
|
|
8
|
-
getTriggerId: (ctx: Ctx) => string;
|
|
9
|
-
getContentId: (ctx: Ctx) => string;
|
|
10
|
-
getPositionerId: (ctx: Ctx) => string;
|
|
11
|
-
getArrowId: (ctx: Ctx) => string;
|
|
12
|
-
getTitleId: (ctx: Ctx) => string;
|
|
13
|
-
getDescriptionId: (ctx: Ctx) => string;
|
|
14
|
-
getCloseButtonId: (ctx: Ctx) => string;
|
|
15
|
-
getAnchorEl: (ctx: Ctx) => HTMLElement;
|
|
16
|
-
getTriggerEl: (ctx: Ctx) => HTMLElement;
|
|
17
|
-
getContentEl: (ctx: Ctx) => HTMLElement;
|
|
18
|
-
getPositionerEl: (ctx: Ctx) => HTMLElement;
|
|
19
|
-
getTitleEl: (ctx: Ctx) => HTMLElement;
|
|
20
|
-
getDescriptionEl: (ctx: Ctx) => HTMLElement;
|
|
21
|
-
getFocusableEls: (ctx: Ctx) => HTMLElement[];
|
|
22
|
-
getFirstFocusableEl: (ctx: Ctx) => HTMLElement;
|
|
23
|
-
getDocTabbableEls: (ctx: Ctx) => HTMLElement[];
|
|
24
|
-
getTabbableEls: (ctx: Ctx) => HTMLElement[];
|
|
25
|
-
getFirstTabbableEl: (ctx: Ctx) => HTMLElement;
|
|
26
|
-
getLastTabbableEl: (ctx: Ctx) => HTMLElement;
|
|
27
|
-
getInitialFocusEl: (ctx: Ctx) => HTMLElement;
|
|
28
|
-
};
|
package/dist/popover.types.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { StateMachine as S } from "@zag-js/core";
|
|
2
|
-
import type { DismissableElementHandlers } from "@zag-js/dimissable";
|
|
3
|
-
import type { PositioningOptions, Placement } from "@zag-js/popper";
|
|
4
|
-
import type { Context, MaybeElement } from "@zag-js/types";
|
|
5
|
-
declare type ElementIds = Partial<{
|
|
6
|
-
anchor: string;
|
|
7
|
-
trigger: string;
|
|
8
|
-
content: string;
|
|
9
|
-
title: string;
|
|
10
|
-
description: string;
|
|
11
|
-
closeBtn: string;
|
|
12
|
-
}>;
|
|
13
|
-
declare type PublicContext = DismissableElementHandlers & {
|
|
14
|
-
/**
|
|
15
|
-
* The ids of the elements in the popover. Useful for composition.
|
|
16
|
-
*/
|
|
17
|
-
ids?: ElementIds;
|
|
18
|
-
/**
|
|
19
|
-
* Whether the popover should be modal. When set to `true`:
|
|
20
|
-
* - interaction with outside elements will be disabled
|
|
21
|
-
* - only popover content will be visible to screen readers
|
|
22
|
-
* - scrolling is blocked
|
|
23
|
-
* - focus is trapped within the popover
|
|
24
|
-
*
|
|
25
|
-
* @default false
|
|
26
|
-
*/
|
|
27
|
-
modal?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Whether the popover is rendered in a portal
|
|
30
|
-
*/
|
|
31
|
-
portalled?: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Whether to automatically set focus on the first focusable
|
|
34
|
-
* content within the popover when opened.
|
|
35
|
-
*/
|
|
36
|
-
autoFocus?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* The element to focus on when the popover is opened.
|
|
39
|
-
*/
|
|
40
|
-
initialFocusEl?: MaybeElement | (() => MaybeElement);
|
|
41
|
-
/**
|
|
42
|
-
* Whether to close the popover when the user clicks outside of the popover.
|
|
43
|
-
*/
|
|
44
|
-
closeOnInteractOutside?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Whether to close the popover when the escape key is pressed.
|
|
47
|
-
*/
|
|
48
|
-
closeOnEsc?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Function invoked when the popover is opened.
|
|
51
|
-
*/
|
|
52
|
-
onOpenChange?: (open: boolean) => void;
|
|
53
|
-
/**
|
|
54
|
-
* The user provided options used to position the popover content
|
|
55
|
-
*/
|
|
56
|
-
positioning: PositioningOptions;
|
|
57
|
-
/**
|
|
58
|
-
* Whether to open the popover on page load
|
|
59
|
-
*/
|
|
60
|
-
defaultOpen?: boolean;
|
|
61
|
-
};
|
|
62
|
-
export declare type UserDefinedContext = Partial<PublicContext>;
|
|
63
|
-
declare type ComputedContext = Readonly<{
|
|
64
|
-
/**
|
|
65
|
-
* @computed
|
|
66
|
-
* The computed value of `portalled`
|
|
67
|
-
*/
|
|
68
|
-
currentPortalled: boolean;
|
|
69
|
-
}>;
|
|
70
|
-
declare type PrivateContext = Context<{
|
|
71
|
-
/**
|
|
72
|
-
* @internal
|
|
73
|
-
* The elements that are rendered on mount
|
|
74
|
-
*/
|
|
75
|
-
renderedElements: {
|
|
76
|
-
title: boolean;
|
|
77
|
-
description: boolean;
|
|
78
|
-
anchor: boolean;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* @internal
|
|
82
|
-
* The computed placement (maybe different from initial placement)
|
|
83
|
-
*/
|
|
84
|
-
currentPlacement?: Placement;
|
|
85
|
-
/**
|
|
86
|
-
* @internal
|
|
87
|
-
* Whether the dynamic placement has been computed
|
|
88
|
-
*/
|
|
89
|
-
isPlacementComplete?: boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Whether to prevent returning focus to the trigger
|
|
92
|
-
*/
|
|
93
|
-
focusTriggerOnClose?: boolean;
|
|
94
|
-
}>;
|
|
95
|
-
export declare type MachineContext = PublicContext & ComputedContext & PrivateContext;
|
|
96
|
-
export declare type MachineState = {
|
|
97
|
-
value: "unknown" | "open" | "closed";
|
|
98
|
-
};
|
|
99
|
-
export declare type State = S.State<MachineContext, MachineState>;
|
|
100
|
-
export declare type Send = S.Send<S.AnyEventObject>;
|
|
101
|
-
export {};
|