@destyler/popover 0.0.7-beta.5 → 0.0.7-beta.9
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 +137 -135
- package/dist/index.js +407 -0
- package/package.json +16 -20
- package/dist/index.cjs +0 -443
- package/dist/index.d.cts +0 -152
- package/dist/index.d.mts +0 -152
- package/dist/index.mjs +0 -437
package/dist/index.d.ts
CHANGED
|
@@ -1,152 +1,154 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { PositioningOptions, Placement } from '@zag-js/popper';
|
|
8
|
-
export { Placement, PositioningOptions } from '@zag-js/popper';
|
|
9
|
-
|
|
10
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"arrow" | "arrowTip" | "anchor" | "trigger" | "indicator" | "positioner" | "content" | "title" | "description" | "closeTrigger">;
|
|
1
|
+
import * as _destyler_anatomy0 from "@destyler/anatomy";
|
|
2
|
+
import { Placement, PositioningOptions } from "@destyler/popper";
|
|
3
|
+
import { DismissableElementHandlers, FocusOutsideEvent, InteractOutsideEvent, PersistentElementOptions, PointerDownOutsideEvent } from "@destyler/dismissable";
|
|
4
|
+
import * as _destyler_xstate0 from "@destyler/xstate";
|
|
5
|
+
import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
|
|
6
|
+
import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
|
|
11
7
|
|
|
8
|
+
//#region src/anatomy.d.ts
|
|
9
|
+
declare const anatomy: _destyler_anatomy0.AnatomyInstance<"anchor" | "trigger" | "content" | "title" | "description" | "closeTrigger" | "positioner" | "arrow" | "arrowTip" | "indicator">;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/types.d.ts
|
|
12
12
|
interface OpenChangeDetails {
|
|
13
|
-
|
|
13
|
+
open: boolean;
|
|
14
14
|
}
|
|
15
15
|
type ElementIds = Partial<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
anchor: string;
|
|
17
|
+
trigger: string;
|
|
18
|
+
content: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
closeTrigger: string;
|
|
22
|
+
positioner: string;
|
|
23
|
+
arrow: string;
|
|
24
24
|
}>;
|
|
25
25
|
interface PublicContext extends CommonProperties, DirectionProperty, DismissableElementHandlers, PersistentElementOptions {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The ids of the elements in the popover. Useful for composition.
|
|
28
|
+
*/
|
|
29
|
+
'ids'?: ElementIds | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the popover should be modal. When set to `true`:
|
|
32
|
+
* - interaction with outside elements will be disabled
|
|
33
|
+
* - only popover content will be visible to screen readers
|
|
34
|
+
* - scrolling is blocked
|
|
35
|
+
* - focus is trapped within the popover
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
'modal'?: boolean | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position
|
|
42
|
+
* of the popover content.
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
'portalled'?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to automatically set focus on the first focusable
|
|
49
|
+
* content within the popover when opened.
|
|
50
|
+
*
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
'autoFocus'?: boolean | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The element to focus on when the popover is opened.
|
|
56
|
+
*/
|
|
57
|
+
'initialFocusEl'?: (() => HTMLElement | null) | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to close the popover when the user clicks outside of the popover.
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
'closeOnInteractOutside'?: boolean | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Whether to close the popover when the escape key is pressed.
|
|
65
|
+
* @default true
|
|
66
|
+
*/
|
|
67
|
+
'closeOnEscape'?: boolean | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Function invoked when the popover opens or closes
|
|
70
|
+
*/
|
|
71
|
+
'onOpenChange'?: ((details: OpenChangeDetails) => void) | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The user provided options used to position the popover content
|
|
74
|
+
*/
|
|
75
|
+
'positioning': PositioningOptions;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the popover is open
|
|
78
|
+
*/
|
|
79
|
+
'open'?: boolean | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the popover is controlled by the user
|
|
82
|
+
*/
|
|
83
|
+
'open.controlled'?: boolean | undefined;
|
|
84
84
|
}
|
|
85
85
|
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
86
86
|
type ComputedContext = Readonly<{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
/**
|
|
88
|
+
* @computed
|
|
89
|
+
* The computed value of `portalled`
|
|
90
|
+
*/
|
|
91
|
+
currentPortalled: boolean;
|
|
92
92
|
}>;
|
|
93
93
|
interface PrivateContext {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
|
|
94
|
+
/**
|
|
95
|
+
* @internal
|
|
96
|
+
* The elements that are rendered on mount
|
|
97
|
+
*/
|
|
98
|
+
renderedElements: {
|
|
99
|
+
title: boolean;
|
|
100
|
+
description: boolean;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
* The computed placement (maybe different from initial placement)
|
|
105
|
+
*/
|
|
106
|
+
currentPlacement?: Placement | undefined;
|
|
109
107
|
}
|
|
108
|
+
interface MachineContext extends PublicContext, ComputedContext, PrivateContext {}
|
|
110
109
|
interface MachineState {
|
|
111
|
-
|
|
110
|
+
value: 'open' | 'closed';
|
|
112
111
|
}
|
|
113
|
-
type State =
|
|
114
|
-
type Send =
|
|
115
|
-
type Service = Machine<MachineContext, MachineState,
|
|
112
|
+
type State = XState<MachineContext, MachineState>;
|
|
113
|
+
type Send = XSend<AnyEventObject>;
|
|
114
|
+
type Service = Machine<MachineContext, MachineState, AnyEventObject>;
|
|
116
115
|
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Whether the popover is portalled.
|
|
118
|
+
*/
|
|
119
|
+
portalled: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Whether the popover is open
|
|
122
|
+
*/
|
|
123
|
+
open: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Function to open or close the popover
|
|
126
|
+
*/
|
|
127
|
+
setOpen: (open: boolean) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Function to reposition the popover
|
|
130
|
+
*/
|
|
131
|
+
reposition: (options?: Partial<PositioningOptions>) => void;
|
|
132
|
+
getArrowProps: () => T['element'];
|
|
133
|
+
getArrowTipProps: () => T['element'];
|
|
134
|
+
getAnchorProps: () => T['element'];
|
|
135
|
+
getTriggerProps: () => T['button'];
|
|
136
|
+
getIndicatorProps: () => T['element'];
|
|
137
|
+
getPositionerProps: () => T['element'];
|
|
138
|
+
getContentProps: () => T['element'];
|
|
139
|
+
getTitleProps: () => T['element'];
|
|
140
|
+
getDescriptionProps: () => T['element'];
|
|
141
|
+
getCloseTriggerProps: () => T['button'];
|
|
143
142
|
}
|
|
144
|
-
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/connect.d.ts
|
|
145
145
|
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/machine.d.ts
|
|
148
|
+
declare function machine(userContext: UserDefinedContext): _destyler_xstate0.Machine<MachineContext, MachineState, _destyler_xstate0.AnyEventObject>;
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/props.d.ts
|
|
151
|
+
declare const props: ("open" | "id" | "ids" | "modal" | "portalled" | "autoFocus" | "initialFocusEl" | "closeOnInteractOutside" | "closeOnEscape" | "onOpenChange" | "positioning" | "open.controlled" | "getRootNode" | "dir" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements")[];
|
|
152
|
+
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "id" | "ids" | "modal" | "portalled" | "autoFocus" | "initialFocusEl" | "closeOnInteractOutside" | "closeOnEscape" | "onOpenChange" | "positioning" | "open.controlled" | "getRootNode" | "dir" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements">];
|
|
153
|
+
//#endregion
|
|
154
|
+
export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type FocusOutsideEvent, type InteractOutsideEvent, type OpenChangeDetails, type Placement, type PointerDownOutsideEvent, type PositioningOptions, type Service, anatomy, connect, machine, props, splitProps };
|