@destyler/popover 0.2.6 → 0.2.7
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.mts +16 -16
- package/dist/index.mjs +6 -5
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as _destyler_anatomy0 from "@destyler/anatomy";
|
|
2
1
|
import { Placement, PositioningOptions } from "@destyler/popper";
|
|
3
2
|
import { DismissableElementHandlers, FocusOutsideEvent, InteractOutsideEvent, PersistentElementOptions, PointerDownOutsideEvent } from "@destyler/dismissable";
|
|
4
3
|
import * as _destyler_xstate0 from "@destyler/xstate";
|
|
@@ -6,7 +5,7 @@ import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
|
|
|
6
5
|
import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
|
|
7
6
|
|
|
8
7
|
//#region src/anatomy.d.ts
|
|
9
|
-
declare const anatomy:
|
|
8
|
+
declare const anatomy: any;
|
|
10
9
|
//#endregion
|
|
11
10
|
//#region src/types.d.ts
|
|
12
11
|
interface OpenChangeDetails {
|
|
@@ -26,7 +25,7 @@ interface PublicContext extends CommonProperties, DirectionProperty, Dismissable
|
|
|
26
25
|
/**
|
|
27
26
|
* The ids of the elements in the popover. Useful for composition.
|
|
28
27
|
*/
|
|
29
|
-
|
|
28
|
+
ids?: ElementIds | undefined;
|
|
30
29
|
/**
|
|
31
30
|
* Whether the popover should be modal. When set to `true`:
|
|
32
31
|
* - interaction with outside elements will be disabled
|
|
@@ -36,51 +35,52 @@ interface PublicContext extends CommonProperties, DirectionProperty, Dismissable
|
|
|
36
35
|
*
|
|
37
36
|
* @default false
|
|
38
37
|
*/
|
|
39
|
-
|
|
38
|
+
modal?: boolean | undefined;
|
|
40
39
|
/**
|
|
41
40
|
* Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position
|
|
42
41
|
* of the popover content.
|
|
43
42
|
*
|
|
44
43
|
* @default true
|
|
45
44
|
*/
|
|
46
|
-
|
|
45
|
+
portalled?: boolean | undefined;
|
|
47
46
|
/**
|
|
48
47
|
* Whether to automatically set focus on the first focusable
|
|
49
48
|
* content within the popover when opened.
|
|
50
49
|
*
|
|
51
50
|
* @default true
|
|
52
51
|
*/
|
|
53
|
-
|
|
52
|
+
autoFocus?: boolean | undefined;
|
|
54
53
|
/**
|
|
55
54
|
* The element to focus on when the popover is opened.
|
|
56
55
|
*/
|
|
57
|
-
|
|
56
|
+
initialFocusEl?: (() => HTMLElement | null) | undefined;
|
|
58
57
|
/**
|
|
59
58
|
* Whether to close the popover when the user clicks outside of the popover.
|
|
60
59
|
* @default true
|
|
61
60
|
*/
|
|
62
|
-
|
|
61
|
+
closeOnInteractOutside?: boolean | undefined;
|
|
63
62
|
/**
|
|
64
63
|
* Whether to close the popover when the escape key is pressed.
|
|
65
64
|
* @default true
|
|
66
65
|
*/
|
|
67
|
-
|
|
66
|
+
closeOnEscape?: boolean | undefined;
|
|
68
67
|
/**
|
|
69
68
|
* Function invoked when the popover opens or closes
|
|
70
69
|
*/
|
|
71
|
-
|
|
70
|
+
onOpenChange?: ((details: OpenChangeDetails) => void) | undefined;
|
|
72
71
|
/**
|
|
73
72
|
* The user provided options used to position the popover content
|
|
74
73
|
*/
|
|
75
|
-
|
|
74
|
+
positioning: PositioningOptions;
|
|
76
75
|
/**
|
|
77
76
|
* Whether the popover is open
|
|
78
77
|
*/
|
|
79
|
-
|
|
78
|
+
open?: boolean | undefined;
|
|
80
79
|
/**
|
|
81
|
-
*
|
|
80
|
+
* The initial open state of the popover when it is not controlled.
|
|
81
|
+
* Prefer this over seeding with `open` for uncontrolled usage.
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
defaultOpen?: boolean | undefined;
|
|
84
84
|
}
|
|
85
85
|
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
86
86
|
type ComputedContext = Readonly<{
|
|
@@ -148,7 +148,7 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
148
148
|
declare function machine(userContext: UserDefinedContext): _destyler_xstate0.Machine<MachineContext, MachineState, _destyler_xstate0.AnyEventObject>;
|
|
149
149
|
//#endregion
|
|
150
150
|
//#region src/props.d.ts
|
|
151
|
-
declare const props: ("open" | "
|
|
152
|
-
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "
|
|
151
|
+
declare const props: ("open" | "ids" | "modal" | "portalled" | "autoFocus" | "initialFocusEl" | "closeOnInteractOutside" | "closeOnEscape" | "onOpenChange" | "positioning" | "defaultOpen" | "id" | "getRootNode" | "dir" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements")[];
|
|
152
|
+
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "ids" | "modal" | "portalled" | "autoFocus" | "initialFocusEl" | "closeOnInteractOutside" | "closeOnEscape" | "onOpenChange" | "positioning" | "defaultOpen" | "id" | "getRootNode" | "dir" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "persistentElements">];
|
|
153
153
|
//#endregion
|
|
154
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { ariaHidden } from "@destyler/aria-hidden";
|
|
|
5
5
|
import { trackDismissableElement } from "@destyler/dismissable";
|
|
6
6
|
import { trapFocus } from "@destyler/focus-trap";
|
|
7
7
|
import { preventBodyScroll } from "@destyler/remove-scroll";
|
|
8
|
-
import { compact, createSplitProps } from "@destyler/utils";
|
|
8
|
+
import { compact, createSplitProps, isControlled, resolveControllableOpen, withControllableProvided } from "@destyler/utils";
|
|
9
9
|
import { createMachine } from "@destyler/xstate";
|
|
10
10
|
import { createProps } from "@destyler/types";
|
|
11
11
|
|
|
@@ -169,10 +169,11 @@ function connect(state, send, normalize) {
|
|
|
169
169
|
//#endregion
|
|
170
170
|
//#region src/machine.ts
|
|
171
171
|
function machine(userContext) {
|
|
172
|
-
const ctx = compact(userContext);
|
|
172
|
+
const ctx = compact(withControllableProvided(userContext, ["open"]));
|
|
173
|
+
const { initialOpen } = resolveControllableOpen(ctx);
|
|
173
174
|
return createMachine({
|
|
174
175
|
id: "popover",
|
|
175
|
-
initial:
|
|
176
|
+
initial: initialOpen ? "open" : "closed",
|
|
176
177
|
context: {
|
|
177
178
|
closeOnInteractOutside: true,
|
|
178
179
|
closeOnEscape: true,
|
|
@@ -247,7 +248,7 @@ function machine(userContext) {
|
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
250
|
}, {
|
|
250
|
-
guards: { isOpenControlled: (ctx$1) =>
|
|
251
|
+
guards: { isOpenControlled: (ctx$1) => isControlled(ctx$1, "open") },
|
|
251
252
|
activities: {
|
|
252
253
|
trackPositioning(ctx$1) {
|
|
253
254
|
ctx$1.currentPlacement = ctx$1.positioning.placement;
|
|
@@ -393,8 +394,8 @@ const props = createProps()([
|
|
|
393
394
|
"onInteractOutside",
|
|
394
395
|
"onOpenChange",
|
|
395
396
|
"onPointerDownOutside",
|
|
396
|
-
"open.controlled",
|
|
397
397
|
"open",
|
|
398
|
+
"defaultOpen",
|
|
398
399
|
"persistentElements",
|
|
399
400
|
"portalled",
|
|
400
401
|
"positioning"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/popover",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"description": "displays rich content in a portal, triggered by a button.",
|
|
6
6
|
"author": "Elone Hoo <elonehoo@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@destyler/
|
|
26
|
-
"@destyler/
|
|
27
|
-
"@destyler/
|
|
28
|
-
"@destyler/
|
|
29
|
-
"@destyler/
|
|
30
|
-
"@destyler/
|
|
31
|
-
"@destyler/
|
|
32
|
-
"@destyler/
|
|
33
|
-
"@destyler/xstate": "0.2.
|
|
34
|
-
"@destyler/
|
|
25
|
+
"@destyler/aria-hidden": "0.2.7",
|
|
26
|
+
"@destyler/dismissable": "0.2.7",
|
|
27
|
+
"@destyler/anatomy": "0.2.7",
|
|
28
|
+
"@destyler/focus-trap": "0.2.7",
|
|
29
|
+
"@destyler/popper": "0.2.7",
|
|
30
|
+
"@destyler/dom": "0.2.7",
|
|
31
|
+
"@destyler/types": "0.2.7",
|
|
32
|
+
"@destyler/utils": "0.2.7",
|
|
33
|
+
"@destyler/xstate": "0.2.7",
|
|
34
|
+
"@destyler/remove-scroll": "0.2.7"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|