@destyler/hover-card 0.2.6-beta.1 → 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 +12 -12
- package/dist/index.mjs +6 -5
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import * as _destyler_anatomy0 from "@destyler/anatomy";
|
|
2
1
|
import { Placement, PositioningOptions } from "@destyler/popper";
|
|
3
2
|
import * as _destyler_xstate0 from "@destyler/xstate";
|
|
4
3
|
import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
|
|
5
4
|
import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
|
|
6
5
|
|
|
7
6
|
//#region src/anatomy.d.ts
|
|
8
|
-
declare const anatomy:
|
|
7
|
+
declare const anatomy: any;
|
|
9
8
|
//#endregion
|
|
10
9
|
//#region src/types.d.ts
|
|
11
10
|
interface OpenChangeDetails {
|
|
@@ -21,33 +20,34 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
21
20
|
/**
|
|
22
21
|
* The ids of the elements in the popover. Useful for composition.
|
|
23
22
|
*/
|
|
24
|
-
|
|
23
|
+
ids?: ElementIds | undefined;
|
|
25
24
|
/**
|
|
26
25
|
* Function called when the hover card opens or closes.
|
|
27
26
|
*/
|
|
28
|
-
|
|
27
|
+
onOpenChange?: ((details: OpenChangeDetails) => void) | undefined;
|
|
29
28
|
/**
|
|
30
29
|
* The duration from when the mouse enters the trigger until the hover card opens.
|
|
31
30
|
* @default 700
|
|
32
31
|
*/
|
|
33
|
-
|
|
32
|
+
openDelay: number;
|
|
34
33
|
/**
|
|
35
34
|
* The duration from when the mouse leaves the trigger or content until the hover card closes.
|
|
36
35
|
* @default 300
|
|
37
36
|
*/
|
|
38
|
-
|
|
37
|
+
closeDelay: number;
|
|
39
38
|
/**
|
|
40
39
|
* Whether the hover card is open
|
|
41
40
|
*/
|
|
42
|
-
|
|
41
|
+
open?: boolean | undefined;
|
|
43
42
|
/**
|
|
44
|
-
*
|
|
43
|
+
* The initial open state of the hover card when it is not controlled.
|
|
44
|
+
* Prefer this over seeding with `open` for uncontrolled usage.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
defaultOpen?: boolean | undefined;
|
|
47
47
|
/**
|
|
48
48
|
* The user provided options used to position the popover content
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
positioning: PositioningOptions;
|
|
51
51
|
}
|
|
52
52
|
interface PrivateContext {
|
|
53
53
|
/**
|
|
@@ -98,7 +98,7 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
98
98
|
declare function machine(userContext: UserDefinedContext): _destyler_xstate0.Machine<MachineContext, MachineState, _destyler_xstate0.AnyEventObject>;
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/props.d.ts
|
|
101
|
-
declare const props: ("open" | "
|
|
102
|
-
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "
|
|
101
|
+
declare const props: ("open" | "ids" | "onOpenChange" | "openDelay" | "closeDelay" | "defaultOpen" | "positioning" | "dir" | "id" | "getRootNode")[];
|
|
102
|
+
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "ids" | "onOpenChange" | "openDelay" | "closeDelay" | "defaultOpen" | "positioning" | "dir" | "id" | "getRootNode">];
|
|
103
103
|
//#endregion
|
|
104
104
|
export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Placement, type PositioningOptions, type Service, anatomy, connect, machine, props, splitProps };
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createAnatomy } from "@destyler/anatomy";
|
|
|
2
2
|
import { getPlacement, getPlacementStyles } from "@destyler/popper";
|
|
3
3
|
import { createScope } from "@destyler/dom";
|
|
4
4
|
import { trackDismissableElement } from "@destyler/dismissable";
|
|
5
|
-
import { compact, createSplitProps } from "@destyler/utils";
|
|
5
|
+
import { compact, createSplitProps, isControlled, resolveControllableOpen, withControllableProvided } from "@destyler/utils";
|
|
6
6
|
import { createMachine, guards } from "@destyler/xstate";
|
|
7
7
|
import { createProps } from "@destyler/types";
|
|
8
8
|
|
|
@@ -125,10 +125,11 @@ function connect(state, send, normalize) {
|
|
|
125
125
|
//#region src/machine.ts
|
|
126
126
|
const { not, and } = guards;
|
|
127
127
|
function machine(userContext) {
|
|
128
|
-
const ctx = compact(userContext);
|
|
128
|
+
const ctx = compact(withControllableProvided(userContext, ["open"]));
|
|
129
|
+
const { initialOpen } = resolveControllableOpen(ctx);
|
|
129
130
|
return createMachine({
|
|
130
131
|
id: "hover-card",
|
|
131
|
-
initial:
|
|
132
|
+
initial: initialOpen ? "open" : "closed",
|
|
132
133
|
context: {
|
|
133
134
|
openDelay: 700,
|
|
134
135
|
closeDelay: 300,
|
|
@@ -242,7 +243,7 @@ function machine(userContext) {
|
|
|
242
243
|
},
|
|
243
244
|
guards: {
|
|
244
245
|
isPointer: (ctx$1) => !!ctx$1.isPointer,
|
|
245
|
-
isOpenControlled: (ctx$1) =>
|
|
246
|
+
isOpenControlled: (ctx$1) => isControlled(ctx$1, "open")
|
|
246
247
|
},
|
|
247
248
|
activities: {
|
|
248
249
|
trackPositioning(ctx$1) {
|
|
@@ -319,8 +320,8 @@ const props = createProps()([
|
|
|
319
320
|
"id",
|
|
320
321
|
"ids",
|
|
321
322
|
"onOpenChange",
|
|
322
|
-
"open.controlled",
|
|
323
323
|
"open",
|
|
324
|
+
"defaultOpen",
|
|
324
325
|
"openDelay",
|
|
325
326
|
"positioning"
|
|
326
327
|
]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/hover-card",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"description": "for sighted users to preview content available behind a link.",
|
|
6
6
|
"author": "Elone Hoo <elonehoo@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@destyler/anatomy": "0.2.
|
|
26
|
-
"@destyler/dismissable": "0.2.
|
|
27
|
-
"@destyler/
|
|
28
|
-
"@destyler/
|
|
29
|
-
"@destyler/
|
|
30
|
-
"@destyler/utils": "0.2.
|
|
31
|
-
"@destyler/xstate": "0.2.
|
|
25
|
+
"@destyler/anatomy": "0.2.7",
|
|
26
|
+
"@destyler/dismissable": "0.2.7",
|
|
27
|
+
"@destyler/types": "0.2.7",
|
|
28
|
+
"@destyler/dom": "0.2.7",
|
|
29
|
+
"@destyler/popper": "0.2.7",
|
|
30
|
+
"@destyler/utils": "0.2.7",
|
|
31
|
+
"@destyler/xstate": "0.2.7"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|