@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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Chakra UI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { RequiredBy, CommonProperties, MaybeElement, Context, PropTypes, NormalizeProps } from '@zag-js/types';
|
|
2
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
3
|
+
import { StateMachine } from '@zag-js/core';
|
|
4
|
+
import { DismissableElementHandlers } from '@zag-js/dismissable';
|
|
5
|
+
import { PositioningOptions } from '@zag-js/popper';
|
|
6
|
+
|
|
7
|
+
declare type ElementIds = Partial<{
|
|
8
|
+
anchor: string;
|
|
9
|
+
trigger: string;
|
|
10
|
+
content: string;
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
closeBtn: string;
|
|
14
|
+
}>;
|
|
15
|
+
declare type PublicContext = DismissableElementHandlers & CommonProperties & {
|
|
16
|
+
/**
|
|
17
|
+
* The ids of the elements in the popover. Useful for composition.
|
|
18
|
+
*/
|
|
19
|
+
ids?: ElementIds;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the popover should be modal. When set to `true`:
|
|
22
|
+
* - interaction with outside elements will be disabled
|
|
23
|
+
* - only popover content will be visible to screen readers
|
|
24
|
+
* - scrolling is blocked
|
|
25
|
+
* - focus is trapped within the popover
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
modal?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the popover is rendered in a portal
|
|
32
|
+
*/
|
|
33
|
+
portalled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to automatically set focus on the first focusable
|
|
36
|
+
* content within the popover when opened.
|
|
37
|
+
*/
|
|
38
|
+
autoFocus?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The element to focus on when the popover is opened.
|
|
41
|
+
*/
|
|
42
|
+
initialFocusEl?: MaybeElement | (() => MaybeElement);
|
|
43
|
+
/**
|
|
44
|
+
* Whether to close the popover when the user clicks outside of the popover.
|
|
45
|
+
*/
|
|
46
|
+
closeOnInteractOutside?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to close the popover when the escape key is pressed.
|
|
49
|
+
*/
|
|
50
|
+
closeOnEsc?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Function invoked when the popover is opened.
|
|
53
|
+
*/
|
|
54
|
+
onOpenChange?: (open: boolean) => void;
|
|
55
|
+
/**
|
|
56
|
+
* The user provided options used to position the popover content
|
|
57
|
+
*/
|
|
58
|
+
positioning: PositioningOptions;
|
|
59
|
+
/**
|
|
60
|
+
* Whether to open the popover on page load
|
|
61
|
+
*/
|
|
62
|
+
defaultOpen?: boolean;
|
|
63
|
+
};
|
|
64
|
+
declare type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
65
|
+
declare type ComputedContext = Readonly<{
|
|
66
|
+
/**
|
|
67
|
+
* @computed
|
|
68
|
+
* The computed value of `portalled`
|
|
69
|
+
*/
|
|
70
|
+
currentPortalled: boolean;
|
|
71
|
+
}>;
|
|
72
|
+
declare type PrivateContext = Context<{
|
|
73
|
+
/**
|
|
74
|
+
* Whether to prevent returning focus to the trigger
|
|
75
|
+
*/
|
|
76
|
+
focusTriggerOnClose?: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
declare type MachineContext = PublicContext & ComputedContext & PrivateContext;
|
|
79
|
+
declare type MachineState = {
|
|
80
|
+
value: "unknown" | "open" | "closed";
|
|
81
|
+
};
|
|
82
|
+
declare type State = StateMachine.State<MachineContext, MachineState>;
|
|
83
|
+
declare type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
84
|
+
|
|
85
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
86
|
+
portalled: boolean;
|
|
87
|
+
isOpen: boolean;
|
|
88
|
+
open(): void;
|
|
89
|
+
close(): void;
|
|
90
|
+
arrowProps: T["element"];
|
|
91
|
+
innerArrowProps: T["element"];
|
|
92
|
+
anchorProps: T["element"];
|
|
93
|
+
triggerProps: T["button"];
|
|
94
|
+
positionerProps: T["element"];
|
|
95
|
+
contentProps: T["element"];
|
|
96
|
+
titleProps: T["element"];
|
|
97
|
+
descriptionProps: T["element"];
|
|
98
|
+
closeButtonProps: T["button"];
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
declare function machine(ctx: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
102
|
+
|
|
103
|
+
export { UserDefinedContext as Context, connect, machine };
|