@destyler/hover-card 0.2.10 → 0.2.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/dist/index.d.mts +6 -9
- package/dist/index.mjs +29 -35
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import * as _destyler_anatomy0 from "@destyler/anatomy";
|
|
2
1
|
import { Placement, PositioningOptions } from "@destyler/popper";
|
|
3
|
-
import * as _destyler_xstate0 from "@destyler/xstate";
|
|
4
2
|
import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
|
|
5
3
|
import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
|
|
6
|
-
|
|
7
4
|
//#region src/anatomy.d.ts
|
|
8
|
-
declare const anatomy:
|
|
5
|
+
export declare const anatomy: import("@destyler/anatomy").AnatomyInstance<"arrow" | "arrowTip" | "trigger" | "positioner" | "content">;
|
|
9
6
|
//#endregion
|
|
10
7
|
//#region src/types.d.ts
|
|
11
8
|
interface OpenChangeDetails {
|
|
@@ -93,13 +90,13 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
93
90
|
}
|
|
94
91
|
//#endregion
|
|
95
92
|
//#region src/connect.d.ts
|
|
96
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
93
|
+
export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
97
94
|
//#endregion
|
|
98
95
|
//#region src/machine.d.ts
|
|
99
|
-
declare function machine(userContext: UserDefinedContext):
|
|
96
|
+
export declare function machine(userContext: UserDefinedContext): import("@destyler/xstate").Machine<MachineContext, MachineState, import("@destyler/xstate").AnyEventObject>;
|
|
100
97
|
//#endregion
|
|
101
98
|
//#region src/props.d.ts
|
|
102
|
-
declare const props: ("open" | "ids" | "onOpenChange" | "openDelay" | "closeDelay" | "defaultOpen" | "positioning" | "dir" | "id" | "getRootNode")[];
|
|
103
|
-
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "ids" | "onOpenChange" | "openDelay" | "closeDelay" | "defaultOpen" | "positioning" | "dir" | "id" | "getRootNode">];
|
|
99
|
+
export declare const props: ("open" | "ids" | "onOpenChange" | "openDelay" | "closeDelay" | "defaultOpen" | "positioning" | "dir" | "id" | "getRootNode")[];
|
|
100
|
+
export declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "ids" | "onOpenChange" | "openDelay" | "closeDelay" | "defaultOpen" | "positioning" | "dir" | "id" | "getRootNode">];
|
|
104
101
|
//#endregion
|
|
105
|
-
export {
|
|
102
|
+
export type { MachineApi as Api, UserDefinedContext as Context, ElementIds, OpenChangeDetails, Placement, PositioningOptions, Service };
|
package/dist/index.mjs
CHANGED
|
@@ -5,11 +5,9 @@ import { trackDismissableElement } from "@destyler/dismissable";
|
|
|
5
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
|
-
|
|
9
8
|
//#region src/anatomy.ts
|
|
10
9
|
const anatomy = createAnatomy("hoverCard").parts("arrow", "arrowTip", "trigger", "positioner", "content");
|
|
11
10
|
const parts = anatomy.build();
|
|
12
|
-
|
|
13
11
|
//#endregion
|
|
14
12
|
//#region src/dom.ts
|
|
15
13
|
const dom = createScope({
|
|
@@ -21,7 +19,6 @@ const dom = createScope({
|
|
|
21
19
|
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
22
20
|
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx))
|
|
23
21
|
});
|
|
24
|
-
|
|
25
22
|
//#endregion
|
|
26
23
|
//#region src/connect.ts
|
|
27
24
|
function connect(state, send, normalize) {
|
|
@@ -119,7 +116,6 @@ function connect(state, send, normalize) {
|
|
|
119
116
|
}
|
|
120
117
|
};
|
|
121
118
|
}
|
|
122
|
-
|
|
123
119
|
//#endregion
|
|
124
120
|
//#region src/machine.ts
|
|
125
121
|
const { not, and } = guards;
|
|
@@ -246,30 +242,30 @@ function machine(userContext) {
|
|
|
246
242
|
}
|
|
247
243
|
}, {
|
|
248
244
|
delays: {
|
|
249
|
-
OPEN_DELAY: (ctx
|
|
250
|
-
CLOSE_DELAY: (ctx
|
|
245
|
+
OPEN_DELAY: (ctx) => ctx.openDelay,
|
|
246
|
+
CLOSE_DELAY: (ctx) => ctx.closeDelay
|
|
251
247
|
},
|
|
252
248
|
guards: {
|
|
253
|
-
isPointer: (ctx
|
|
254
|
-
isOpenControlled: (ctx
|
|
249
|
+
isPointer: (ctx) => !!ctx.isPointer,
|
|
250
|
+
isOpenControlled: (ctx) => isControlled(ctx, "open")
|
|
255
251
|
},
|
|
256
252
|
activities: {
|
|
257
|
-
trackPositioning(ctx
|
|
258
|
-
ctx
|
|
259
|
-
const getPositionerEl = () => dom.getPositionerEl(ctx
|
|
260
|
-
return getPlacement(dom.getTriggerEl(ctx
|
|
261
|
-
...ctx
|
|
253
|
+
trackPositioning(ctx) {
|
|
254
|
+
ctx.currentPlacement ||= ctx.positioning.placement;
|
|
255
|
+
const getPositionerEl = () => dom.getPositionerEl(ctx);
|
|
256
|
+
return getPlacement(dom.getTriggerEl(ctx), getPositionerEl, {
|
|
257
|
+
...ctx.positioning,
|
|
262
258
|
defer: true,
|
|
263
259
|
onComplete(data) {
|
|
264
|
-
ctx
|
|
260
|
+
ctx.currentPlacement = data.placement;
|
|
265
261
|
}
|
|
266
262
|
});
|
|
267
263
|
},
|
|
268
|
-
trackDismissableElement(ctx
|
|
269
|
-
const getContentEl = () => dom.getContentEl(ctx
|
|
264
|
+
trackDismissableElement(ctx, _evt, { send }) {
|
|
265
|
+
const getContentEl = () => dom.getContentEl(ctx);
|
|
270
266
|
return trackDismissableElement(getContentEl, {
|
|
271
267
|
defer: true,
|
|
272
|
-
exclude: [dom.getTriggerEl(ctx
|
|
268
|
+
exclude: [dom.getTriggerEl(ctx)],
|
|
273
269
|
onDismiss() {
|
|
274
270
|
send({
|
|
275
271
|
type: "CLOSE",
|
|
@@ -283,34 +279,34 @@ function machine(userContext) {
|
|
|
283
279
|
}
|
|
284
280
|
},
|
|
285
281
|
actions: {
|
|
286
|
-
invokeOnClose(ctx
|
|
287
|
-
ctx
|
|
282
|
+
invokeOnClose(ctx) {
|
|
283
|
+
ctx.onOpenChange?.({ open: false });
|
|
288
284
|
},
|
|
289
|
-
invokeOnOpen(ctx
|
|
290
|
-
ctx
|
|
285
|
+
invokeOnOpen(ctx) {
|
|
286
|
+
ctx.onOpenChange?.({ open: true });
|
|
291
287
|
},
|
|
292
|
-
setIsPointer(ctx
|
|
293
|
-
ctx
|
|
288
|
+
setIsPointer(ctx) {
|
|
289
|
+
ctx.isPointer = true;
|
|
294
290
|
},
|
|
295
|
-
clearIsPointer(ctx
|
|
296
|
-
ctx
|
|
291
|
+
clearIsPointer(ctx) {
|
|
292
|
+
ctx.isPointer = false;
|
|
297
293
|
},
|
|
298
|
-
reposition(ctx
|
|
299
|
-
const getPositionerEl = () => dom.getPositionerEl(ctx
|
|
300
|
-
getPlacement(dom.getTriggerEl(ctx
|
|
301
|
-
...ctx
|
|
294
|
+
reposition(ctx, evt) {
|
|
295
|
+
const getPositionerEl = () => dom.getPositionerEl(ctx);
|
|
296
|
+
getPlacement(dom.getTriggerEl(ctx), getPositionerEl, {
|
|
297
|
+
...ctx.positioning,
|
|
302
298
|
...evt.options,
|
|
303
299
|
defer: true,
|
|
304
300
|
listeners: false,
|
|
305
301
|
onComplete(data) {
|
|
306
|
-
ctx
|
|
302
|
+
ctx.currentPlacement = data.placement;
|
|
307
303
|
}
|
|
308
304
|
});
|
|
309
305
|
},
|
|
310
|
-
toggleVisibility(ctx
|
|
306
|
+
toggleVisibility(ctx, evt, { send }) {
|
|
311
307
|
queueMicrotask(() => {
|
|
312
308
|
send({
|
|
313
|
-
type: ctx
|
|
309
|
+
type: ctx.open ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE",
|
|
314
310
|
previousEvent: evt
|
|
315
311
|
});
|
|
316
312
|
});
|
|
@@ -318,7 +314,6 @@ function machine(userContext) {
|
|
|
318
314
|
}
|
|
319
315
|
});
|
|
320
316
|
}
|
|
321
|
-
|
|
322
317
|
//#endregion
|
|
323
318
|
//#region src/props.ts
|
|
324
319
|
const props = createProps()([
|
|
@@ -334,6 +329,5 @@ const props = createProps()([
|
|
|
334
329
|
"positioning"
|
|
335
330
|
]);
|
|
336
331
|
const splitProps = createSplitProps(props);
|
|
337
|
-
|
|
338
332
|
//#endregion
|
|
339
|
-
export { anatomy, connect, machine, props, splitProps };
|
|
333
|
+
export { anatomy, connect, machine, props, splitProps };
|
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.12",
|
|
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/
|
|
27
|
-
"@destyler/
|
|
28
|
-
"@destyler/
|
|
29
|
-
"@destyler/
|
|
30
|
-
"@destyler/utils": "0.2.
|
|
31
|
-
"@destyler/xstate": "0.2.
|
|
25
|
+
"@destyler/anatomy": "0.2.12",
|
|
26
|
+
"@destyler/dismissable": "0.2.12",
|
|
27
|
+
"@destyler/dom": "0.2.12",
|
|
28
|
+
"@destyler/popper": "0.2.12",
|
|
29
|
+
"@destyler/types": "0.2.12",
|
|
30
|
+
"@destyler/utils": "0.2.12",
|
|
31
|
+
"@destyler/xstate": "0.2.12"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|