@huin-core/react-hover-card 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +90 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.js +329 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +297 -0
- package/dist/index.mjs.map +7 -0
- package/package.json +1 -1
package/dist/index.d.mts
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
import * as React$1 from 'react';
|
2
|
+
import React__default from 'react';
|
3
|
+
import { Primitive } from '@huin-core/react-primitive';
|
4
|
+
import { Portal } from '@huin-core/react-portal';
|
5
|
+
import * as PopperPrimitive from '@huin-core/react-popper';
|
6
|
+
import { DismissableLayer } from '@huin-core/react-dismissable-layer';
|
7
|
+
|
8
|
+
type Scope<C = any> = {
|
9
|
+
[scopeName: string]: React$1.Context<C>[];
|
10
|
+
} | undefined;
|
11
|
+
type ScopeHook = (scope: Scope) => {
|
12
|
+
[__scopeProp: string]: Scope;
|
13
|
+
};
|
14
|
+
interface CreateScope {
|
15
|
+
scopeName: string;
|
16
|
+
(): ScopeHook;
|
17
|
+
}
|
18
|
+
|
19
|
+
declare const createHoverCardScope: CreateScope;
|
20
|
+
interface HoverCardProps {
|
21
|
+
children?: React$1.ReactNode;
|
22
|
+
open?: boolean;
|
23
|
+
defaultOpen?: boolean;
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
25
|
+
openDelay?: number;
|
26
|
+
closeDelay?: number;
|
27
|
+
}
|
28
|
+
declare const HoverCard: React$1.FC<HoverCardProps>;
|
29
|
+
declare const Root: React$1.FC<HoverCardProps>;
|
30
|
+
|
31
|
+
type PrimitiveLinkProps = React__default.ComponentPropsWithoutRef<typeof Primitive.a>;
|
32
|
+
interface HoverCardTriggerProps extends PrimitiveLinkProps {
|
33
|
+
}
|
34
|
+
declare const HoverCardTrigger: React__default.ForwardRefExoticComponent<HoverCardTriggerProps & React__default.RefAttributes<HTMLAnchorElement>>;
|
35
|
+
|
36
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
|
37
|
+
interface HoverCardPortalProps {
|
38
|
+
children?: React.ReactNode;
|
39
|
+
/**
|
40
|
+
* Specify a container element to portal the content into.
|
41
|
+
*/
|
42
|
+
container?: PortalProps["container"];
|
43
|
+
/**
|
44
|
+
* Used to force mounting when more control is needed. Useful when
|
45
|
+
* controlling animation with React animation libraries.
|
46
|
+
*/
|
47
|
+
forceMount?: true;
|
48
|
+
}
|
49
|
+
declare const HoverCardPortal: React.FC<HoverCardPortalProps>;
|
50
|
+
|
51
|
+
interface HoverCardContentProps extends HoverCardContentImplProps {
|
52
|
+
/**
|
53
|
+
* Used to force mounting when more control is needed. Useful when
|
54
|
+
* controlling animation with React animation libraries.
|
55
|
+
*/
|
56
|
+
forceMount?: true;
|
57
|
+
}
|
58
|
+
declare const HoverCardContent: React__default.ForwardRefExoticComponent<HoverCardContentProps & React__default.RefAttributes<HTMLDivElement>>;
|
59
|
+
type DismissableLayerProps = React__default.ComponentPropsWithoutRef<typeof DismissableLayer>;
|
60
|
+
type PopperContentProps = React__default.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;
|
61
|
+
interface HoverCardContentImplProps extends Omit<PopperContentProps, "onPlaced"> {
|
62
|
+
/**
|
63
|
+
* Event handler called when the escape key is down.
|
64
|
+
* Can be prevented.
|
65
|
+
*/
|
66
|
+
onEscapeKeyDown?: DismissableLayerProps["onEscapeKeyDown"];
|
67
|
+
/**
|
68
|
+
* Event handler called when the a `pointerdown` event happens outside of the `HoverCard`.
|
69
|
+
* Can be prevented.
|
70
|
+
*/
|
71
|
+
onPointerDownOutside?: DismissableLayerProps["onPointerDownOutside"];
|
72
|
+
/**
|
73
|
+
* Event handler called when the focus moves outside of the `HoverCard`.
|
74
|
+
* Can be prevented.
|
75
|
+
*/
|
76
|
+
onFocusOutside?: DismissableLayerProps["onFocusOutside"];
|
77
|
+
/**
|
78
|
+
* Event handler called when an interaction happens outside the `HoverCard`.
|
79
|
+
* Specifically, when a `pointerdown` event happens outside or focus moves outside of it.
|
80
|
+
* Can be prevented.
|
81
|
+
*/
|
82
|
+
onInteractOutside?: DismissableLayerProps["onInteractOutside"];
|
83
|
+
}
|
84
|
+
|
85
|
+
type PopperArrowProps = React__default.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;
|
86
|
+
interface HoverCardArrowProps extends PopperArrowProps {
|
87
|
+
}
|
88
|
+
declare const HoverCardArrow: React__default.ForwardRefExoticComponent<HoverCardArrowProps & React__default.RefAttributes<SVGSVGElement>>;
|
89
|
+
|
90
|
+
export { HoverCard, HoverCardArrow, type HoverCardArrowProps, HoverCardContent, type HoverCardContentProps, HoverCardPortal, type HoverCardPortalProps, type HoverCardProps, HoverCardTrigger, type HoverCardTriggerProps, Root, createHoverCardScope };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
import * as React$1 from 'react';
|
2
|
+
import React__default from 'react';
|
3
|
+
import { Primitive } from '@huin-core/react-primitive';
|
4
|
+
import { Portal } from '@huin-core/react-portal';
|
5
|
+
import * as PopperPrimitive from '@huin-core/react-popper';
|
6
|
+
import { DismissableLayer } from '@huin-core/react-dismissable-layer';
|
7
|
+
|
8
|
+
type Scope<C = any> = {
|
9
|
+
[scopeName: string]: React$1.Context<C>[];
|
10
|
+
} | undefined;
|
11
|
+
type ScopeHook = (scope: Scope) => {
|
12
|
+
[__scopeProp: string]: Scope;
|
13
|
+
};
|
14
|
+
interface CreateScope {
|
15
|
+
scopeName: string;
|
16
|
+
(): ScopeHook;
|
17
|
+
}
|
18
|
+
|
19
|
+
declare const createHoverCardScope: CreateScope;
|
20
|
+
interface HoverCardProps {
|
21
|
+
children?: React$1.ReactNode;
|
22
|
+
open?: boolean;
|
23
|
+
defaultOpen?: boolean;
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
25
|
+
openDelay?: number;
|
26
|
+
closeDelay?: number;
|
27
|
+
}
|
28
|
+
declare const HoverCard: React$1.FC<HoverCardProps>;
|
29
|
+
declare const Root: React$1.FC<HoverCardProps>;
|
30
|
+
|
31
|
+
type PrimitiveLinkProps = React__default.ComponentPropsWithoutRef<typeof Primitive.a>;
|
32
|
+
interface HoverCardTriggerProps extends PrimitiveLinkProps {
|
33
|
+
}
|
34
|
+
declare const HoverCardTrigger: React__default.ForwardRefExoticComponent<HoverCardTriggerProps & React__default.RefAttributes<HTMLAnchorElement>>;
|
35
|
+
|
36
|
+
type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
|
37
|
+
interface HoverCardPortalProps {
|
38
|
+
children?: React.ReactNode;
|
39
|
+
/**
|
40
|
+
* Specify a container element to portal the content into.
|
41
|
+
*/
|
42
|
+
container?: PortalProps["container"];
|
43
|
+
/**
|
44
|
+
* Used to force mounting when more control is needed. Useful when
|
45
|
+
* controlling animation with React animation libraries.
|
46
|
+
*/
|
47
|
+
forceMount?: true;
|
48
|
+
}
|
49
|
+
declare const HoverCardPortal: React.FC<HoverCardPortalProps>;
|
50
|
+
|
51
|
+
interface HoverCardContentProps extends HoverCardContentImplProps {
|
52
|
+
/**
|
53
|
+
* Used to force mounting when more control is needed. Useful when
|
54
|
+
* controlling animation with React animation libraries.
|
55
|
+
*/
|
56
|
+
forceMount?: true;
|
57
|
+
}
|
58
|
+
declare const HoverCardContent: React__default.ForwardRefExoticComponent<HoverCardContentProps & React__default.RefAttributes<HTMLDivElement>>;
|
59
|
+
type DismissableLayerProps = React__default.ComponentPropsWithoutRef<typeof DismissableLayer>;
|
60
|
+
type PopperContentProps = React__default.ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;
|
61
|
+
interface HoverCardContentImplProps extends Omit<PopperContentProps, "onPlaced"> {
|
62
|
+
/**
|
63
|
+
* Event handler called when the escape key is down.
|
64
|
+
* Can be prevented.
|
65
|
+
*/
|
66
|
+
onEscapeKeyDown?: DismissableLayerProps["onEscapeKeyDown"];
|
67
|
+
/**
|
68
|
+
* Event handler called when the a `pointerdown` event happens outside of the `HoverCard`.
|
69
|
+
* Can be prevented.
|
70
|
+
*/
|
71
|
+
onPointerDownOutside?: DismissableLayerProps["onPointerDownOutside"];
|
72
|
+
/**
|
73
|
+
* Event handler called when the focus moves outside of the `HoverCard`.
|
74
|
+
* Can be prevented.
|
75
|
+
*/
|
76
|
+
onFocusOutside?: DismissableLayerProps["onFocusOutside"];
|
77
|
+
/**
|
78
|
+
* Event handler called when an interaction happens outside the `HoverCard`.
|
79
|
+
* Specifically, when a `pointerdown` event happens outside or focus moves outside of it.
|
80
|
+
* Can be prevented.
|
81
|
+
*/
|
82
|
+
onInteractOutside?: DismissableLayerProps["onInteractOutside"];
|
83
|
+
}
|
84
|
+
|
85
|
+
type PopperArrowProps = React__default.ComponentPropsWithoutRef<typeof PopperPrimitive.Arrow>;
|
86
|
+
interface HoverCardArrowProps extends PopperArrowProps {
|
87
|
+
}
|
88
|
+
declare const HoverCardArrow: React__default.ForwardRefExoticComponent<HoverCardArrowProps & React__default.RefAttributes<SVGSVGElement>>;
|
89
|
+
|
90
|
+
export { HoverCard, HoverCardArrow, type HoverCardArrowProps, HoverCardContent, type HoverCardContentProps, HoverCardPortal, type HoverCardPortalProps, type HoverCardProps, HoverCardTrigger, type HoverCardTriggerProps, Root, createHoverCardScope };
|
package/dist/index.js
ADDED
@@ -0,0 +1,329 @@
|
|
1
|
+
"use strict";
|
2
|
+
"use client";
|
3
|
+
var __create = Object.create;
|
4
|
+
var __defProp = Object.defineProperty;
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
9
|
+
var __export = (target, all) => {
|
10
|
+
for (var name in all)
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
12
|
+
};
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
15
|
+
for (let key of __getOwnPropNames(from))
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
|
+
}
|
19
|
+
return to;
|
20
|
+
};
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
27
|
+
mod
|
28
|
+
));
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
|
+
|
31
|
+
// packages/react/hover-card/src/index.ts
|
32
|
+
var src_exports = {};
|
33
|
+
__export(src_exports, {
|
34
|
+
HoverCard: () => HoverCard,
|
35
|
+
HoverCardArrow: () => HoverCardArrow,
|
36
|
+
HoverCardContent: () => HoverCardContent,
|
37
|
+
HoverCardPortal: () => HoverCardPortal,
|
38
|
+
HoverCardTrigger: () => HoverCardTrigger,
|
39
|
+
Root: () => Root2,
|
40
|
+
createHoverCardScope: () => createHoverCardScope
|
41
|
+
});
|
42
|
+
module.exports = __toCommonJS(src_exports);
|
43
|
+
|
44
|
+
// packages/react/hover-card/src/HoverCard.tsx
|
45
|
+
var React = __toESM(require("react"));
|
46
|
+
var import_react_context = require("@huin-core/react-context");
|
47
|
+
var import_react_use_controllable_state = require("@huin-core/react-use-controllable-state");
|
48
|
+
var PopperPrimitive = __toESM(require("@huin-core/react-popper"));
|
49
|
+
var import_react_popper = require("@huin-core/react-popper");
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
51
|
+
var HOVERCARD_NAME = "HoverCard";
|
52
|
+
var [createHoverCardContext, createHoverCardScope] = (0, import_react_context.createContextScope)(HOVERCARD_NAME, [import_react_popper.createPopperScope]);
|
53
|
+
var usePopperScope = (0, import_react_popper.createPopperScope)();
|
54
|
+
var [HoverCardProvider, useHoverCardContext] = createHoverCardContext(HOVERCARD_NAME);
|
55
|
+
var HoverCard = (props) => {
|
56
|
+
const {
|
57
|
+
__scopeHoverCard,
|
58
|
+
children,
|
59
|
+
open: openProp,
|
60
|
+
defaultOpen,
|
61
|
+
onOpenChange,
|
62
|
+
openDelay = 700,
|
63
|
+
closeDelay = 300
|
64
|
+
} = props;
|
65
|
+
const popperScope = usePopperScope(__scopeHoverCard);
|
66
|
+
const openTimerRef = React.useRef(0);
|
67
|
+
const closeTimerRef = React.useRef(0);
|
68
|
+
const hasSelectionRef = React.useRef(false);
|
69
|
+
const isPointerDownOnContentRef = React.useRef(false);
|
70
|
+
const [open = false, setOpen] = (0, import_react_use_controllable_state.useControllableState)({
|
71
|
+
prop: openProp,
|
72
|
+
defaultProp: defaultOpen,
|
73
|
+
onChange: onOpenChange
|
74
|
+
});
|
75
|
+
const handleOpen = React.useCallback(() => {
|
76
|
+
clearTimeout(closeTimerRef.current);
|
77
|
+
openTimerRef.current = window.setTimeout(() => setOpen(true), openDelay);
|
78
|
+
}, [openDelay, setOpen]);
|
79
|
+
const handleClose = React.useCallback(() => {
|
80
|
+
clearTimeout(openTimerRef.current);
|
81
|
+
if (!hasSelectionRef.current && !isPointerDownOnContentRef.current) {
|
82
|
+
closeTimerRef.current = window.setTimeout(
|
83
|
+
() => setOpen(false),
|
84
|
+
closeDelay
|
85
|
+
);
|
86
|
+
}
|
87
|
+
}, [closeDelay, setOpen]);
|
88
|
+
const handleDismiss = React.useCallback(() => setOpen(false), [setOpen]);
|
89
|
+
React.useEffect(() => {
|
90
|
+
return () => {
|
91
|
+
clearTimeout(openTimerRef.current);
|
92
|
+
clearTimeout(closeTimerRef.current);
|
93
|
+
};
|
94
|
+
}, []);
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
96
|
+
HoverCardProvider,
|
97
|
+
{
|
98
|
+
scope: __scopeHoverCard,
|
99
|
+
open,
|
100
|
+
onOpenChange: setOpen,
|
101
|
+
onOpen: handleOpen,
|
102
|
+
onClose: handleClose,
|
103
|
+
onDismiss: handleDismiss,
|
104
|
+
hasSelectionRef,
|
105
|
+
isPointerDownOnContentRef,
|
106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopperPrimitive.Root, { ...popperScope, children })
|
107
|
+
}
|
108
|
+
);
|
109
|
+
};
|
110
|
+
HoverCard.displayName = HOVERCARD_NAME;
|
111
|
+
function excludeTouch(eventHandler) {
|
112
|
+
return (event) => event.pointerType === "touch" ? void 0 : eventHandler();
|
113
|
+
}
|
114
|
+
var Root2 = HoverCard;
|
115
|
+
|
116
|
+
// packages/react/hover-card/src/HoverCardTrigger.tsx
|
117
|
+
var import_react = __toESM(require("react"));
|
118
|
+
var import_react_primitive = require("@huin-core/react-primitive");
|
119
|
+
var PopperPrimitive2 = __toESM(require("@huin-core/react-popper"));
|
120
|
+
var import_primitive = require("@huin-core/primitive");
|
121
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
122
|
+
var TRIGGER_NAME = "HoverCardTrigger";
|
123
|
+
var HoverCardTrigger = import_react.default.forwardRef((props, forwardedRef) => {
|
124
|
+
const { __scopeHoverCard, ...triggerProps } = props;
|
125
|
+
const context = useHoverCardContext(TRIGGER_NAME, __scopeHoverCard);
|
126
|
+
const popperScope = usePopperScope(__scopeHoverCard);
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PopperPrimitive2.Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
128
|
+
import_react_primitive.Primitive.a,
|
129
|
+
{
|
130
|
+
"data-state": context.open ? "open" : "closed",
|
131
|
+
...triggerProps,
|
132
|
+
ref: forwardedRef,
|
133
|
+
onPointerEnter: (0, import_primitive.composeEventHandlers)(
|
134
|
+
props.onPointerEnter,
|
135
|
+
excludeTouch(context.onOpen)
|
136
|
+
),
|
137
|
+
onPointerLeave: (0, import_primitive.composeEventHandlers)(
|
138
|
+
props.onPointerLeave,
|
139
|
+
excludeTouch(context.onClose)
|
140
|
+
),
|
141
|
+
onFocus: (0, import_primitive.composeEventHandlers)(props.onFocus, context.onOpen),
|
142
|
+
onBlur: (0, import_primitive.composeEventHandlers)(props.onBlur, context.onClose),
|
143
|
+
onTouchStart: (0, import_primitive.composeEventHandlers)(
|
144
|
+
props.onTouchStart,
|
145
|
+
(event) => event.preventDefault()
|
146
|
+
)
|
147
|
+
}
|
148
|
+
) });
|
149
|
+
});
|
150
|
+
HoverCardTrigger.displayName = TRIGGER_NAME;
|
151
|
+
|
152
|
+
// packages/react/hover-card/src/HoverCardPortal.tsx
|
153
|
+
var import_react_presence = require("@huin-core/react-presence");
|
154
|
+
var import_react_portal = require("@huin-core/react-portal");
|
155
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
156
|
+
var PORTAL_NAME = "HoverCardPortal";
|
157
|
+
var [PortalProvider, usePortalContext] = createHoverCardContext(PORTAL_NAME, {
|
158
|
+
forceMount: void 0
|
159
|
+
});
|
160
|
+
var HoverCardPortal = (props) => {
|
161
|
+
const { __scopeHoverCard, forceMount, children, container } = props;
|
162
|
+
const context = useHoverCardContext(PORTAL_NAME, __scopeHoverCard);
|
163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PortalProvider, { scope: __scopeHoverCard, forceMount, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_presence.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_portal.Portal, { asChild: true, container, children }) }) });
|
164
|
+
};
|
165
|
+
HoverCardPortal.displayName = PORTAL_NAME;
|
166
|
+
|
167
|
+
// packages/react/hover-card/src/HoverCardContent.tsx
|
168
|
+
var import_react2 = __toESM(require("react"));
|
169
|
+
var import_react_presence2 = require("@huin-core/react-presence");
|
170
|
+
var import_primitive2 = require("@huin-core/primitive");
|
171
|
+
var PopperPrimitive3 = __toESM(require("@huin-core/react-popper"));
|
172
|
+
var import_react_dismissable_layer = require("@huin-core/react-dismissable-layer");
|
173
|
+
var import_react_compose_refs = require("@huin-core/react-compose-refs");
|
174
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
175
|
+
var originalBodyUserSelect;
|
176
|
+
var CONTENT_NAME = "HoverCardContent";
|
177
|
+
var HoverCardContent = import_react2.default.forwardRef((props, forwardedRef) => {
|
178
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeHoverCard);
|
179
|
+
const {
|
180
|
+
forceMount = portalContext.forceMount,
|
181
|
+
align = "center",
|
182
|
+
...contentProps
|
183
|
+
} = props;
|
184
|
+
const context = useHoverCardContext(CONTENT_NAME, props.__scopeHoverCard);
|
185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_presence2.Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
186
|
+
HoverCardContentImpl,
|
187
|
+
{
|
188
|
+
"data-state": context.open ? "open" : "closed",
|
189
|
+
...contentProps,
|
190
|
+
onPointerEnter: (0, import_primitive2.composeEventHandlers)(
|
191
|
+
props.onPointerEnter,
|
192
|
+
excludeTouch(context.onOpen)
|
193
|
+
),
|
194
|
+
onPointerLeave: (0, import_primitive2.composeEventHandlers)(
|
195
|
+
props.onPointerLeave,
|
196
|
+
excludeTouch(context.onClose)
|
197
|
+
),
|
198
|
+
ref: forwardedRef
|
199
|
+
}
|
200
|
+
) });
|
201
|
+
});
|
202
|
+
HoverCardContent.displayName = CONTENT_NAME;
|
203
|
+
var HoverCardContentImpl = import_react2.default.forwardRef((props, forwardedRef) => {
|
204
|
+
const {
|
205
|
+
__scopeHoverCard,
|
206
|
+
onEscapeKeyDown,
|
207
|
+
onPointerDownOutside,
|
208
|
+
onFocusOutside,
|
209
|
+
onInteractOutside,
|
210
|
+
...contentProps
|
211
|
+
} = props;
|
212
|
+
const context = useHoverCardContext(CONTENT_NAME, __scopeHoverCard);
|
213
|
+
const popperScope = usePopperScope(__scopeHoverCard);
|
214
|
+
const ref = import_react2.default.useRef(null);
|
215
|
+
const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
|
216
|
+
const [containSelection, setContainSelection] = import_react2.default.useState(false);
|
217
|
+
import_react2.default.useEffect(() => {
|
218
|
+
if (containSelection) {
|
219
|
+
const body = document.body;
|
220
|
+
originalBodyUserSelect = body.style.userSelect || body.style.webkitUserSelect;
|
221
|
+
body.style.userSelect = "none";
|
222
|
+
body.style.webkitUserSelect = "none";
|
223
|
+
return () => {
|
224
|
+
body.style.userSelect = originalBodyUserSelect;
|
225
|
+
body.style.webkitUserSelect = originalBodyUserSelect;
|
226
|
+
};
|
227
|
+
}
|
228
|
+
}, [containSelection]);
|
229
|
+
import_react2.default.useEffect(() => {
|
230
|
+
if (ref.current) {
|
231
|
+
const handlePointerUp = () => {
|
232
|
+
setContainSelection(false);
|
233
|
+
context.isPointerDownOnContentRef.current = false;
|
234
|
+
setTimeout(() => {
|
235
|
+
const hasSelection = document.getSelection()?.toString() !== "";
|
236
|
+
if (hasSelection) context.hasSelectionRef.current = true;
|
237
|
+
});
|
238
|
+
};
|
239
|
+
document.addEventListener("pointerup", handlePointerUp);
|
240
|
+
return () => {
|
241
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
242
|
+
context.hasSelectionRef.current = false;
|
243
|
+
context.isPointerDownOnContentRef.current = false;
|
244
|
+
};
|
245
|
+
}
|
246
|
+
}, [context.isPointerDownOnContentRef, context.hasSelectionRef]);
|
247
|
+
import_react2.default.useEffect(() => {
|
248
|
+
if (ref.current) {
|
249
|
+
const tabbables = getTabbableNodes(ref.current);
|
250
|
+
tabbables.forEach((tabbable) => tabbable.setAttribute("tabindex", "-1"));
|
251
|
+
}
|
252
|
+
});
|
253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
254
|
+
import_react_dismissable_layer.DismissableLayer,
|
255
|
+
{
|
256
|
+
asChild: true,
|
257
|
+
disableOutsidePointerEvents: false,
|
258
|
+
onInteractOutside,
|
259
|
+
onEscapeKeyDown,
|
260
|
+
onPointerDownOutside,
|
261
|
+
onFocusOutside: (0, import_primitive2.composeEventHandlers)(onFocusOutside, (event) => {
|
262
|
+
event.preventDefault();
|
263
|
+
}),
|
264
|
+
onDismiss: context.onDismiss,
|
265
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
266
|
+
PopperPrimitive3.Content,
|
267
|
+
{
|
268
|
+
...popperScope,
|
269
|
+
...contentProps,
|
270
|
+
onPointerDown: (0, import_primitive2.composeEventHandlers)(
|
271
|
+
contentProps.onPointerDown,
|
272
|
+
(event) => {
|
273
|
+
if (event.currentTarget.contains(event.target)) {
|
274
|
+
setContainSelection(true);
|
275
|
+
}
|
276
|
+
context.hasSelectionRef.current = false;
|
277
|
+
context.isPointerDownOnContentRef.current = true;
|
278
|
+
}
|
279
|
+
),
|
280
|
+
ref: composedRefs,
|
281
|
+
style: {
|
282
|
+
...contentProps.style,
|
283
|
+
userSelect: containSelection ? "text" : void 0,
|
284
|
+
// Safari requires prefix
|
285
|
+
WebkitUserSelect: containSelection ? "text" : void 0,
|
286
|
+
// re-namespace exposed content custom properties
|
287
|
+
...{
|
288
|
+
"--huin-core-hover-card-content-transform-origin": "var(--huin-core-popper-transform-origin)",
|
289
|
+
"--huin-core-hover-card-content-available-width": "var(--huin-core-popper-available-width)",
|
290
|
+
"--huin-core-hover-card-content-available-height": "var(--huin-core-popper-available-height)",
|
291
|
+
"--huin-core-hover-card-trigger-width": "var(--huin-core-popper-anchor-width)",
|
292
|
+
"--huin-core-hover-card-trigger-height": "var(--huin-core-popper-anchor-height)"
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
296
|
+
)
|
297
|
+
}
|
298
|
+
);
|
299
|
+
});
|
300
|
+
function getTabbableNodes(container) {
|
301
|
+
const nodes = [];
|
302
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
303
|
+
acceptNode: (node) => {
|
304
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
305
|
+
}
|
306
|
+
});
|
307
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
308
|
+
return nodes;
|
309
|
+
}
|
310
|
+
|
311
|
+
// packages/react/hover-card/src/HoverCardArrow.tsx
|
312
|
+
var PopperPrimitive4 = __toESM(require("@huin-core/react-popper"));
|
313
|
+
var import_react3 = __toESM(require("react"));
|
314
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
315
|
+
var ARROW_NAME = "HoverCardArrow";
|
316
|
+
var HoverCardArrow = import_react3.default.forwardRef((props, forwardedRef) => {
|
317
|
+
const { __scopeHoverCard, ...arrowProps } = props;
|
318
|
+
const popperScope = usePopperScope(__scopeHoverCard);
|
319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
320
|
+
PopperPrimitive4.Arrow,
|
321
|
+
{
|
322
|
+
...popperScope,
|
323
|
+
...arrowProps,
|
324
|
+
ref: forwardedRef
|
325
|
+
}
|
326
|
+
);
|
327
|
+
});
|
328
|
+
HoverCardArrow.displayName = ARROW_NAME;
|
329
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../src/index.ts", "../src/HoverCard.tsx", "../src/HoverCardTrigger.tsx", "../src/HoverCardPortal.tsx", "../src/HoverCardContent.tsx", "../src/HoverCardArrow.tsx"],
|
4
|
+
"sourcesContent": ["\"use client\";\nexport { createHoverCardScope, HoverCard, Root } from \"./HoverCard\";\nexport { HoverCardTrigger } from \"./HoverCardTrigger\";\nexport { HoverCardPortal } from \"./HoverCardPortal\";\nexport { HoverCardContent } from \"./HoverCardContent\";\nexport { HoverCardArrow } from \"./HoverCardArrow\";\n\nexport type { HoverCardProps } from \"./HoverCard\";\nexport type { HoverCardTriggerProps } from \"./HoverCardTrigger\";\nexport type { HoverCardPortalProps } from \"./HoverCardPortal\";\nexport type { HoverCardContentProps } from \"./HoverCardContent\";\nexport type { HoverCardArrowProps } from \"./HoverCardArrow\";\n", "import * as React from \"react\";\nimport { createContextScope } from \"@huin-core/react-context\";\nimport { useControllableState } from \"@huin-core/react-use-controllable-state\";\nimport * as PopperPrimitive from \"@huin-core/react-popper\";\nimport { createPopperScope } from \"@huin-core/react-popper\";\nimport type { Scope } from \"@huin-core/react-context\";\n\n/* -------------------------------------------------------------------------------------------------\n * HoverCard\n * -----------------------------------------------------------------------------------------------*/\n\nconst HOVERCARD_NAME = \"HoverCard\";\n\nexport type ScopedProps<P> = P & { __scopeHoverCard?: Scope };\nexport const [createHoverCardContext, createHoverCardScope] =\n createContextScope(HOVERCARD_NAME, [createPopperScope]);\nexport const usePopperScope = createPopperScope();\n\ntype HoverCardContextValue = {\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpen(): void;\n onClose(): void;\n onDismiss(): void;\n hasSelectionRef: React.MutableRefObject<boolean>;\n isPointerDownOnContentRef: React.MutableRefObject<boolean>;\n};\n\nexport const [HoverCardProvider, useHoverCardContext] =\n createHoverCardContext<HoverCardContextValue>(HOVERCARD_NAME);\n\ninterface HoverCardProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n openDelay?: number;\n closeDelay?: number;\n}\n\nconst HoverCard: React.FC<HoverCardProps> = (\n props: ScopedProps<HoverCardProps>\n) => {\n const {\n __scopeHoverCard,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n openDelay = 700,\n closeDelay = 300,\n } = props;\n const popperScope = usePopperScope(__scopeHoverCard);\n const openTimerRef = React.useRef(0);\n const closeTimerRef = React.useRef(0);\n const hasSelectionRef = React.useRef(false);\n const isPointerDownOnContentRef = React.useRef(false);\n\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const handleOpen = React.useCallback(() => {\n clearTimeout(closeTimerRef.current);\n openTimerRef.current = window.setTimeout(() => setOpen(true), openDelay);\n }, [openDelay, setOpen]);\n\n const handleClose = React.useCallback(() => {\n clearTimeout(openTimerRef.current);\n if (!hasSelectionRef.current && !isPointerDownOnContentRef.current) {\n closeTimerRef.current = window.setTimeout(\n () => setOpen(false),\n closeDelay\n );\n }\n }, [closeDelay, setOpen]);\n\n const handleDismiss = React.useCallback(() => setOpen(false), [setOpen]);\n\n // cleanup any queued state updates on unmount\n React.useEffect(() => {\n return () => {\n clearTimeout(openTimerRef.current);\n clearTimeout(closeTimerRef.current);\n };\n }, []);\n\n return (\n <HoverCardProvider\n scope={__scopeHoverCard}\n open={open}\n onOpenChange={setOpen}\n onOpen={handleOpen}\n onClose={handleClose}\n onDismiss={handleDismiss}\n hasSelectionRef={hasSelectionRef}\n isPointerDownOnContentRef={isPointerDownOnContentRef}\n >\n <PopperPrimitive.Root {...popperScope}>{children}</PopperPrimitive.Root>\n </HoverCardProvider>\n );\n};\n\nHoverCard.displayName = HOVERCARD_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport function excludeTouch<E>(eventHandler: () => void) {\n return (event: React.PointerEvent<E>) =>\n event.pointerType === \"touch\" ? undefined : eventHandler();\n}\n\nconst Root = HoverCard;\n\nexport { HoverCard, Root };\nexport type { HoverCardProps };\n", "import React from \"react\";\nimport {\n excludeTouch,\n ScopedProps,\n useHoverCardContext,\n usePopperScope,\n} from \"./HoverCard\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport * as PopperPrimitive from \"@huin-core/react-popper\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\n\nconst TRIGGER_NAME = \"HoverCardTrigger\";\n\ntype HoverCardTriggerElement = React.ElementRef<typeof Primitive.a>;\ntype PrimitiveLinkProps = React.ComponentPropsWithoutRef<typeof Primitive.a>;\ninterface HoverCardTriggerProps extends PrimitiveLinkProps {}\n\nconst HoverCardTrigger = React.forwardRef<\n HoverCardTriggerElement,\n HoverCardTriggerProps\n>((props: ScopedProps<HoverCardTriggerProps>, forwardedRef) => {\n const { __scopeHoverCard, ...triggerProps } = props;\n const context = useHoverCardContext(TRIGGER_NAME, __scopeHoverCard);\n const popperScope = usePopperScope(__scopeHoverCard);\n return (\n <PopperPrimitive.Anchor asChild {...popperScope}>\n <Primitive.a\n data-state={context.open ? \"open\" : \"closed\"}\n {...triggerProps}\n ref={forwardedRef}\n onPointerEnter={composeEventHandlers(\n props.onPointerEnter,\n excludeTouch(context.onOpen)\n )}\n onPointerLeave={composeEventHandlers(\n props.onPointerLeave,\n excludeTouch(context.onClose)\n )}\n onFocus={composeEventHandlers(props.onFocus, context.onOpen)}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n // prevent focus event on touch devices\n onTouchStart={composeEventHandlers(props.onTouchStart, (event) =>\n event.preventDefault()\n )}\n />\n </PopperPrimitive.Anchor>\n );\n});\n\nHoverCardTrigger.displayName = TRIGGER_NAME;\n\nexport { HoverCardTrigger };\nexport type { HoverCardTriggerProps };\n", "import { Presence } from \"@huin-core/react-presence\";\nimport {\n createHoverCardContext,\n ScopedProps,\n useHoverCardContext,\n} from \"./HoverCard\";\nimport { Portal as PortalPrimitive } from \"@huin-core/react-portal\";\n\nconst PORTAL_NAME = \"HoverCardPortal\";\n\ntype PortalContextValue = { forceMount?: true };\nexport const [PortalProvider, usePortalContext] =\n createHoverCardContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n });\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface HoverCardPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps[\"container\"];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst HoverCardPortal: React.FC<HoverCardPortalProps> = (\n props: ScopedProps<HoverCardPortalProps>\n) => {\n const { __scopeHoverCard, forceMount, children, container } = props;\n const context = useHoverCardContext(PORTAL_NAME, __scopeHoverCard);\n return (\n <PortalProvider scope={__scopeHoverCard} forceMount={forceMount}>\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {children}\n </PortalPrimitive>\n </Presence>\n </PortalProvider>\n );\n};\n\nHoverCardPortal.displayName = PORTAL_NAME;\n\nexport { HoverCardPortal };\nexport type { HoverCardPortalProps };\n", "import React from \"react\";\nimport {\n excludeTouch,\n ScopedProps,\n useHoverCardContext,\n usePopperScope,\n} from \"./HoverCard\";\nimport { Presence } from \"@huin-core/react-presence\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\nimport * as PopperPrimitive from \"@huin-core/react-popper\";\nimport { DismissableLayer } from \"@huin-core/react-dismissable-layer\";\nimport { useComposedRefs } from \"@huin-core/react-compose-refs\";\nimport { usePortalContext } from \"./HoverCardPortal\";\nlet originalBodyUserSelect: string;\n\nconst CONTENT_NAME = \"HoverCardContent\";\n\ntype HoverCardContentElement = HoverCardContentImplElement;\ninterface HoverCardContentProps extends HoverCardContentImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst HoverCardContent = React.forwardRef<\n HoverCardContentElement,\n HoverCardContentProps\n>((props: ScopedProps<HoverCardContentProps>, forwardedRef) => {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopeHoverCard);\n const {\n forceMount = portalContext.forceMount,\n align = \"center\",\n ...contentProps\n } = props;\n const context = useHoverCardContext(CONTENT_NAME, props.__scopeHoverCard);\n return (\n <Presence present={forceMount || context.open}>\n <HoverCardContentImpl\n data-state={context.open ? \"open\" : \"closed\"}\n {...contentProps}\n onPointerEnter={composeEventHandlers(\n props.onPointerEnter,\n excludeTouch(context.onOpen)\n )}\n onPointerLeave={composeEventHandlers(\n props.onPointerLeave,\n excludeTouch(context.onClose)\n )}\n ref={forwardedRef}\n />\n </Presence>\n );\n});\n\nHoverCardContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype HoverCardContentImplElement = React.ElementRef<\n typeof PopperPrimitive.Content\n>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<\n typeof DismissableLayer\n>;\ntype PopperContentProps = React.ComponentPropsWithoutRef<\n typeof PopperPrimitive.Content\n>;\ninterface HoverCardContentImplProps\n extends Omit<PopperContentProps, \"onPlaced\"> {\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: DismissableLayerProps[\"onEscapeKeyDown\"];\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `HoverCard`.\n * Can be prevented.\n */\n onPointerDownOutside?: DismissableLayerProps[\"onPointerDownOutside\"];\n /**\n * Event handler called when the focus moves outside of the `HoverCard`.\n * Can be prevented.\n */\n onFocusOutside?: DismissableLayerProps[\"onFocusOutside\"];\n /**\n * Event handler called when an interaction happens outside the `HoverCard`.\n * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: DismissableLayerProps[\"onInteractOutside\"];\n}\n\nconst HoverCardContentImpl = React.forwardRef<\n HoverCardContentImplElement,\n HoverCardContentImplProps\n>((props: ScopedProps<HoverCardContentImplProps>, forwardedRef) => {\n const {\n __scopeHoverCard,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props;\n const context = useHoverCardContext(CONTENT_NAME, __scopeHoverCard);\n const popperScope = usePopperScope(__scopeHoverCard);\n const ref = React.useRef<HoverCardContentImplElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const [containSelection, setContainSelection] = React.useState(false);\n\n React.useEffect(() => {\n if (containSelection) {\n const body = document.body;\n\n // Safari requires prefix\n originalBodyUserSelect =\n body.style.userSelect || body.style.webkitUserSelect;\n\n body.style.userSelect = \"none\";\n body.style.webkitUserSelect = \"none\";\n return () => {\n body.style.userSelect = originalBodyUserSelect;\n body.style.webkitUserSelect = originalBodyUserSelect;\n };\n }\n }, [containSelection]);\n\n React.useEffect(() => {\n if (ref.current) {\n const handlePointerUp = () => {\n setContainSelection(false);\n context.isPointerDownOnContentRef.current = false;\n\n // Delay a frame to ensure we always access the latest selection\n setTimeout(() => {\n const hasSelection = document.getSelection()?.toString() !== \"\";\n if (hasSelection) context.hasSelectionRef.current = true;\n });\n };\n\n document.addEventListener(\"pointerup\", handlePointerUp);\n return () => {\n document.removeEventListener(\"pointerup\", handlePointerUp);\n context.hasSelectionRef.current = false;\n context.isPointerDownOnContentRef.current = false;\n };\n }\n }, [context.isPointerDownOnContentRef, context.hasSelectionRef]);\n\n React.useEffect(() => {\n if (ref.current) {\n const tabbables = getTabbableNodes(ref.current);\n tabbables.forEach((tabbable) => tabbable.setAttribute(\"tabindex\", \"-1\"));\n }\n });\n\n return (\n <DismissableLayer\n asChild\n disableOutsidePointerEvents={false}\n onInteractOutside={onInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={onPointerDownOutside}\n onFocusOutside={composeEventHandlers(onFocusOutside, (event) => {\n event.preventDefault();\n })}\n onDismiss={context.onDismiss}\n >\n <PopperPrimitive.Content\n {...popperScope}\n {...contentProps}\n onPointerDown={composeEventHandlers(\n contentProps.onPointerDown,\n (event) => {\n // Contain selection to current layer\n if (event.currentTarget.contains(event.target as HTMLElement)) {\n setContainSelection(true);\n }\n context.hasSelectionRef.current = false;\n context.isPointerDownOnContentRef.current = true;\n }\n )}\n ref={composedRefs}\n style={{\n ...contentProps.style,\n userSelect: containSelection ? \"text\" : undefined,\n // Safari requires prefix\n WebkitUserSelect: containSelection ? \"text\" : undefined,\n // re-namespace exposed content custom properties\n ...{\n \"--huin-core-hover-card-content-transform-origin\":\n \"var(--huin-core-popper-transform-origin)\",\n \"--huin-core-hover-card-content-available-width\":\n \"var(--huin-core-popper-available-width)\",\n \"--huin-core-hover-card-content-available-height\":\n \"var(--huin-core-popper-available-height)\",\n \"--huin-core-hover-card-trigger-width\":\n \"var(--huin-core-popper-anchor-width)\",\n \"--huin-core-hover-card-trigger-height\":\n \"var(--huin-core-popper-anchor-height)\",\n },\n }}\n />\n </DismissableLayer>\n );\n});\n\n/**\n * Returns a list of nodes that can be in the tab sequence.\n * @see: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n */\nfunction getTabbableNodes(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: any) => {\n // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP;\n },\n });\n while (walker.nextNode()) nodes.push(walker.currentNode as HTMLElement);\n return nodes;\n}\n\nexport { HoverCardContent };\nexport type { HoverCardContentProps };\n", "import * as PopperPrimitive from \"@huin-core/react-popper\";\nimport React from \"react\";\nimport { ScopedProps, usePopperScope } from \"./HoverCard\";\n\nconst ARROW_NAME = \"HoverCardArrow\";\n\ntype HoverCardArrowElement = React.ElementRef<typeof PopperPrimitive.Arrow>;\ntype PopperArrowProps = React.ComponentPropsWithoutRef<\n typeof PopperPrimitive.Arrow\n>;\ninterface HoverCardArrowProps extends PopperArrowProps {}\n\nconst HoverCardArrow = React.forwardRef<\n HoverCardArrowElement,\n HoverCardArrowProps\n>((props: ScopedProps<HoverCardArrowProps>, forwardedRef) => {\n const { __scopeHoverCard, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopeHoverCard);\n return (\n <PopperPrimitive.Arrow\n {...popperScope}\n {...arrowProps}\n ref={forwardedRef}\n />\n );\n});\n\nHoverCardArrow.displayName = ARROW_NAME;\n\nexport { HoverCardArrow };\nexport type { HoverCardArrowProps };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;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cAAc;AAAA,IAC3E,YAAY,CAAC,SAAc;AAIzB,aAAO,KAAK,YAAY,IACpB,WAAW,gBACX,WAAW;AAAA,IACjB;AAAA,EACF,CAAC;AACD,SAAO,OAAO,SAAS,EAAG,OAAM,KAAK,OAAO,WAA0B;AACtE,SAAO;AACT;;;ACnOA,IAAAC,mBAAiC;AACjC,IAAAC,gBAAkB;AAkBd,IAAAC,sBAAA;AAfJ,IAAM,aAAa;AAQnB,IAAM,iBAAiB,cAAAC,QAAM,WAG3B,CAAC,OAAyC,iBAAiB;AAC3D,QAAM,EAAE,kBAAkB,GAAG,WAAW,IAAI;AAC5C,QAAM,cAAc,eAAe,gBAAgB;AACnD,SACE;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACJ,KAAK;AAAA;AAAA,EACP;AAEJ,CAAC;AAED,eAAe,cAAc;",
|
6
|
+
"names": ["Root", "Root", "PopperPrimitive", "import_jsx_runtime", "React", "import_jsx_runtime", "PortalPrimitive", "import_react", "import_react_presence", "import_primitive", "PopperPrimitive", "import_jsx_runtime", "React", "PopperPrimitive", "import_react", "import_jsx_runtime", "React"]
|
7
|
+
}
|
package/dist/index.mjs
ADDED
@@ -0,0 +1,297 @@
|
|
1
|
+
"use client";
|
2
|
+
|
3
|
+
// packages/react/hover-card/src/HoverCard.tsx
|
4
|
+
import * as React from "react";
|
5
|
+
import { createContextScope } from "@huin-core/react-context";
|
6
|
+
import { useControllableState } from "@huin-core/react-use-controllable-state";
|
7
|
+
import * as PopperPrimitive from "@huin-core/react-popper";
|
8
|
+
import { createPopperScope } from "@huin-core/react-popper";
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
10
|
+
var HOVERCARD_NAME = "HoverCard";
|
11
|
+
var [createHoverCardContext, createHoverCardScope] = createContextScope(HOVERCARD_NAME, [createPopperScope]);
|
12
|
+
var usePopperScope = createPopperScope();
|
13
|
+
var [HoverCardProvider, useHoverCardContext] = createHoverCardContext(HOVERCARD_NAME);
|
14
|
+
var HoverCard = (props) => {
|
15
|
+
const {
|
16
|
+
__scopeHoverCard,
|
17
|
+
children,
|
18
|
+
open: openProp,
|
19
|
+
defaultOpen,
|
20
|
+
onOpenChange,
|
21
|
+
openDelay = 700,
|
22
|
+
closeDelay = 300
|
23
|
+
} = props;
|
24
|
+
const popperScope = usePopperScope(__scopeHoverCard);
|
25
|
+
const openTimerRef = React.useRef(0);
|
26
|
+
const closeTimerRef = React.useRef(0);
|
27
|
+
const hasSelectionRef = React.useRef(false);
|
28
|
+
const isPointerDownOnContentRef = React.useRef(false);
|
29
|
+
const [open = false, setOpen] = useControllableState({
|
30
|
+
prop: openProp,
|
31
|
+
defaultProp: defaultOpen,
|
32
|
+
onChange: onOpenChange
|
33
|
+
});
|
34
|
+
const handleOpen = React.useCallback(() => {
|
35
|
+
clearTimeout(closeTimerRef.current);
|
36
|
+
openTimerRef.current = window.setTimeout(() => setOpen(true), openDelay);
|
37
|
+
}, [openDelay, setOpen]);
|
38
|
+
const handleClose = React.useCallback(() => {
|
39
|
+
clearTimeout(openTimerRef.current);
|
40
|
+
if (!hasSelectionRef.current && !isPointerDownOnContentRef.current) {
|
41
|
+
closeTimerRef.current = window.setTimeout(
|
42
|
+
() => setOpen(false),
|
43
|
+
closeDelay
|
44
|
+
);
|
45
|
+
}
|
46
|
+
}, [closeDelay, setOpen]);
|
47
|
+
const handleDismiss = React.useCallback(() => setOpen(false), [setOpen]);
|
48
|
+
React.useEffect(() => {
|
49
|
+
return () => {
|
50
|
+
clearTimeout(openTimerRef.current);
|
51
|
+
clearTimeout(closeTimerRef.current);
|
52
|
+
};
|
53
|
+
}, []);
|
54
|
+
return /* @__PURE__ */ jsx(
|
55
|
+
HoverCardProvider,
|
56
|
+
{
|
57
|
+
scope: __scopeHoverCard,
|
58
|
+
open,
|
59
|
+
onOpenChange: setOpen,
|
60
|
+
onOpen: handleOpen,
|
61
|
+
onClose: handleClose,
|
62
|
+
onDismiss: handleDismiss,
|
63
|
+
hasSelectionRef,
|
64
|
+
isPointerDownOnContentRef,
|
65
|
+
children: /* @__PURE__ */ jsx(PopperPrimitive.Root, { ...popperScope, children })
|
66
|
+
}
|
67
|
+
);
|
68
|
+
};
|
69
|
+
HoverCard.displayName = HOVERCARD_NAME;
|
70
|
+
function excludeTouch(eventHandler) {
|
71
|
+
return (event) => event.pointerType === "touch" ? void 0 : eventHandler();
|
72
|
+
}
|
73
|
+
var Root2 = HoverCard;
|
74
|
+
|
75
|
+
// packages/react/hover-card/src/HoverCardTrigger.tsx
|
76
|
+
import React2 from "react";
|
77
|
+
import { Primitive } from "@huin-core/react-primitive";
|
78
|
+
import * as PopperPrimitive2 from "@huin-core/react-popper";
|
79
|
+
import { composeEventHandlers } from "@huin-core/primitive";
|
80
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
81
|
+
var TRIGGER_NAME = "HoverCardTrigger";
|
82
|
+
var HoverCardTrigger = React2.forwardRef((props, forwardedRef) => {
|
83
|
+
const { __scopeHoverCard, ...triggerProps } = props;
|
84
|
+
const context = useHoverCardContext(TRIGGER_NAME, __scopeHoverCard);
|
85
|
+
const popperScope = usePopperScope(__scopeHoverCard);
|
86
|
+
return /* @__PURE__ */ jsx2(PopperPrimitive2.Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx2(
|
87
|
+
Primitive.a,
|
88
|
+
{
|
89
|
+
"data-state": context.open ? "open" : "closed",
|
90
|
+
...triggerProps,
|
91
|
+
ref: forwardedRef,
|
92
|
+
onPointerEnter: composeEventHandlers(
|
93
|
+
props.onPointerEnter,
|
94
|
+
excludeTouch(context.onOpen)
|
95
|
+
),
|
96
|
+
onPointerLeave: composeEventHandlers(
|
97
|
+
props.onPointerLeave,
|
98
|
+
excludeTouch(context.onClose)
|
99
|
+
),
|
100
|
+
onFocus: composeEventHandlers(props.onFocus, context.onOpen),
|
101
|
+
onBlur: composeEventHandlers(props.onBlur, context.onClose),
|
102
|
+
onTouchStart: composeEventHandlers(
|
103
|
+
props.onTouchStart,
|
104
|
+
(event) => event.preventDefault()
|
105
|
+
)
|
106
|
+
}
|
107
|
+
) });
|
108
|
+
});
|
109
|
+
HoverCardTrigger.displayName = TRIGGER_NAME;
|
110
|
+
|
111
|
+
// packages/react/hover-card/src/HoverCardPortal.tsx
|
112
|
+
import { Presence } from "@huin-core/react-presence";
|
113
|
+
import { Portal as PortalPrimitive } from "@huin-core/react-portal";
|
114
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
115
|
+
var PORTAL_NAME = "HoverCardPortal";
|
116
|
+
var [PortalProvider, usePortalContext] = createHoverCardContext(PORTAL_NAME, {
|
117
|
+
forceMount: void 0
|
118
|
+
});
|
119
|
+
var HoverCardPortal = (props) => {
|
120
|
+
const { __scopeHoverCard, forceMount, children, container } = props;
|
121
|
+
const context = useHoverCardContext(PORTAL_NAME, __scopeHoverCard);
|
122
|
+
return /* @__PURE__ */ jsx3(PortalProvider, { scope: __scopeHoverCard, forceMount, children: /* @__PURE__ */ jsx3(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx3(PortalPrimitive, { asChild: true, container, children }) }) });
|
123
|
+
};
|
124
|
+
HoverCardPortal.displayName = PORTAL_NAME;
|
125
|
+
|
126
|
+
// packages/react/hover-card/src/HoverCardContent.tsx
|
127
|
+
import React3 from "react";
|
128
|
+
import { Presence as Presence2 } from "@huin-core/react-presence";
|
129
|
+
import { composeEventHandlers as composeEventHandlers2 } from "@huin-core/primitive";
|
130
|
+
import * as PopperPrimitive3 from "@huin-core/react-popper";
|
131
|
+
import { DismissableLayer } from "@huin-core/react-dismissable-layer";
|
132
|
+
import { useComposedRefs } from "@huin-core/react-compose-refs";
|
133
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
134
|
+
var originalBodyUserSelect;
|
135
|
+
var CONTENT_NAME = "HoverCardContent";
|
136
|
+
var HoverCardContent = React3.forwardRef((props, forwardedRef) => {
|
137
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeHoverCard);
|
138
|
+
const {
|
139
|
+
forceMount = portalContext.forceMount,
|
140
|
+
align = "center",
|
141
|
+
...contentProps
|
142
|
+
} = props;
|
143
|
+
const context = useHoverCardContext(CONTENT_NAME, props.__scopeHoverCard);
|
144
|
+
return /* @__PURE__ */ jsx4(Presence2, { present: forceMount || context.open, children: /* @__PURE__ */ jsx4(
|
145
|
+
HoverCardContentImpl,
|
146
|
+
{
|
147
|
+
"data-state": context.open ? "open" : "closed",
|
148
|
+
...contentProps,
|
149
|
+
onPointerEnter: composeEventHandlers2(
|
150
|
+
props.onPointerEnter,
|
151
|
+
excludeTouch(context.onOpen)
|
152
|
+
),
|
153
|
+
onPointerLeave: composeEventHandlers2(
|
154
|
+
props.onPointerLeave,
|
155
|
+
excludeTouch(context.onClose)
|
156
|
+
),
|
157
|
+
ref: forwardedRef
|
158
|
+
}
|
159
|
+
) });
|
160
|
+
});
|
161
|
+
HoverCardContent.displayName = CONTENT_NAME;
|
162
|
+
var HoverCardContentImpl = React3.forwardRef((props, forwardedRef) => {
|
163
|
+
const {
|
164
|
+
__scopeHoverCard,
|
165
|
+
onEscapeKeyDown,
|
166
|
+
onPointerDownOutside,
|
167
|
+
onFocusOutside,
|
168
|
+
onInteractOutside,
|
169
|
+
...contentProps
|
170
|
+
} = props;
|
171
|
+
const context = useHoverCardContext(CONTENT_NAME, __scopeHoverCard);
|
172
|
+
const popperScope = usePopperScope(__scopeHoverCard);
|
173
|
+
const ref = React3.useRef(null);
|
174
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
175
|
+
const [containSelection, setContainSelection] = React3.useState(false);
|
176
|
+
React3.useEffect(() => {
|
177
|
+
if (containSelection) {
|
178
|
+
const body = document.body;
|
179
|
+
originalBodyUserSelect = body.style.userSelect || body.style.webkitUserSelect;
|
180
|
+
body.style.userSelect = "none";
|
181
|
+
body.style.webkitUserSelect = "none";
|
182
|
+
return () => {
|
183
|
+
body.style.userSelect = originalBodyUserSelect;
|
184
|
+
body.style.webkitUserSelect = originalBodyUserSelect;
|
185
|
+
};
|
186
|
+
}
|
187
|
+
}, [containSelection]);
|
188
|
+
React3.useEffect(() => {
|
189
|
+
if (ref.current) {
|
190
|
+
const handlePointerUp = () => {
|
191
|
+
setContainSelection(false);
|
192
|
+
context.isPointerDownOnContentRef.current = false;
|
193
|
+
setTimeout(() => {
|
194
|
+
const hasSelection = document.getSelection()?.toString() !== "";
|
195
|
+
if (hasSelection) context.hasSelectionRef.current = true;
|
196
|
+
});
|
197
|
+
};
|
198
|
+
document.addEventListener("pointerup", handlePointerUp);
|
199
|
+
return () => {
|
200
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
201
|
+
context.hasSelectionRef.current = false;
|
202
|
+
context.isPointerDownOnContentRef.current = false;
|
203
|
+
};
|
204
|
+
}
|
205
|
+
}, [context.isPointerDownOnContentRef, context.hasSelectionRef]);
|
206
|
+
React3.useEffect(() => {
|
207
|
+
if (ref.current) {
|
208
|
+
const tabbables = getTabbableNodes(ref.current);
|
209
|
+
tabbables.forEach((tabbable) => tabbable.setAttribute("tabindex", "-1"));
|
210
|
+
}
|
211
|
+
});
|
212
|
+
return /* @__PURE__ */ jsx4(
|
213
|
+
DismissableLayer,
|
214
|
+
{
|
215
|
+
asChild: true,
|
216
|
+
disableOutsidePointerEvents: false,
|
217
|
+
onInteractOutside,
|
218
|
+
onEscapeKeyDown,
|
219
|
+
onPointerDownOutside,
|
220
|
+
onFocusOutside: composeEventHandlers2(onFocusOutside, (event) => {
|
221
|
+
event.preventDefault();
|
222
|
+
}),
|
223
|
+
onDismiss: context.onDismiss,
|
224
|
+
children: /* @__PURE__ */ jsx4(
|
225
|
+
PopperPrimitive3.Content,
|
226
|
+
{
|
227
|
+
...popperScope,
|
228
|
+
...contentProps,
|
229
|
+
onPointerDown: composeEventHandlers2(
|
230
|
+
contentProps.onPointerDown,
|
231
|
+
(event) => {
|
232
|
+
if (event.currentTarget.contains(event.target)) {
|
233
|
+
setContainSelection(true);
|
234
|
+
}
|
235
|
+
context.hasSelectionRef.current = false;
|
236
|
+
context.isPointerDownOnContentRef.current = true;
|
237
|
+
}
|
238
|
+
),
|
239
|
+
ref: composedRefs,
|
240
|
+
style: {
|
241
|
+
...contentProps.style,
|
242
|
+
userSelect: containSelection ? "text" : void 0,
|
243
|
+
// Safari requires prefix
|
244
|
+
WebkitUserSelect: containSelection ? "text" : void 0,
|
245
|
+
// re-namespace exposed content custom properties
|
246
|
+
...{
|
247
|
+
"--huin-core-hover-card-content-transform-origin": "var(--huin-core-popper-transform-origin)",
|
248
|
+
"--huin-core-hover-card-content-available-width": "var(--huin-core-popper-available-width)",
|
249
|
+
"--huin-core-hover-card-content-available-height": "var(--huin-core-popper-available-height)",
|
250
|
+
"--huin-core-hover-card-trigger-width": "var(--huin-core-popper-anchor-width)",
|
251
|
+
"--huin-core-hover-card-trigger-height": "var(--huin-core-popper-anchor-height)"
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
)
|
256
|
+
}
|
257
|
+
);
|
258
|
+
});
|
259
|
+
function getTabbableNodes(container) {
|
260
|
+
const nodes = [];
|
261
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
262
|
+
acceptNode: (node) => {
|
263
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
264
|
+
}
|
265
|
+
});
|
266
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
267
|
+
return nodes;
|
268
|
+
}
|
269
|
+
|
270
|
+
// packages/react/hover-card/src/HoverCardArrow.tsx
|
271
|
+
import * as PopperPrimitive4 from "@huin-core/react-popper";
|
272
|
+
import React4 from "react";
|
273
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
274
|
+
var ARROW_NAME = "HoverCardArrow";
|
275
|
+
var HoverCardArrow = React4.forwardRef((props, forwardedRef) => {
|
276
|
+
const { __scopeHoverCard, ...arrowProps } = props;
|
277
|
+
const popperScope = usePopperScope(__scopeHoverCard);
|
278
|
+
return /* @__PURE__ */ jsx5(
|
279
|
+
PopperPrimitive4.Arrow,
|
280
|
+
{
|
281
|
+
...popperScope,
|
282
|
+
...arrowProps,
|
283
|
+
ref: forwardedRef
|
284
|
+
}
|
285
|
+
);
|
286
|
+
});
|
287
|
+
HoverCardArrow.displayName = ARROW_NAME;
|
288
|
+
export {
|
289
|
+
HoverCard,
|
290
|
+
HoverCardArrow,
|
291
|
+
HoverCardContent,
|
292
|
+
HoverCardPortal,
|
293
|
+
HoverCardTrigger,
|
294
|
+
Root2 as Root,
|
295
|
+
createHoverCardScope
|
296
|
+
};
|
297
|
+
//# sourceMappingURL=index.mjs.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../src/HoverCard.tsx", "../src/HoverCardTrigger.tsx", "../src/HoverCardPortal.tsx", "../src/HoverCardContent.tsx", "../src/HoverCardArrow.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from \"react\";\nimport { createContextScope } from \"@huin-core/react-context\";\nimport { useControllableState } from \"@huin-core/react-use-controllable-state\";\nimport * as PopperPrimitive from \"@huin-core/react-popper\";\nimport { createPopperScope } from \"@huin-core/react-popper\";\nimport type { Scope } from \"@huin-core/react-context\";\n\n/* -------------------------------------------------------------------------------------------------\n * HoverCard\n * -----------------------------------------------------------------------------------------------*/\n\nconst HOVERCARD_NAME = \"HoverCard\";\n\nexport type ScopedProps<P> = P & { __scopeHoverCard?: Scope };\nexport const [createHoverCardContext, createHoverCardScope] =\n createContextScope(HOVERCARD_NAME, [createPopperScope]);\nexport const usePopperScope = createPopperScope();\n\ntype HoverCardContextValue = {\n open: boolean;\n onOpenChange(open: boolean): void;\n onOpen(): void;\n onClose(): void;\n onDismiss(): void;\n hasSelectionRef: React.MutableRefObject<boolean>;\n isPointerDownOnContentRef: React.MutableRefObject<boolean>;\n};\n\nexport const [HoverCardProvider, useHoverCardContext] =\n createHoverCardContext<HoverCardContextValue>(HOVERCARD_NAME);\n\ninterface HoverCardProps {\n children?: React.ReactNode;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n openDelay?: number;\n closeDelay?: number;\n}\n\nconst HoverCard: React.FC<HoverCardProps> = (\n props: ScopedProps<HoverCardProps>\n) => {\n const {\n __scopeHoverCard,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n openDelay = 700,\n closeDelay = 300,\n } = props;\n const popperScope = usePopperScope(__scopeHoverCard);\n const openTimerRef = React.useRef(0);\n const closeTimerRef = React.useRef(0);\n const hasSelectionRef = React.useRef(false);\n const isPointerDownOnContentRef = React.useRef(false);\n\n const [open = false, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const handleOpen = React.useCallback(() => {\n clearTimeout(closeTimerRef.current);\n openTimerRef.current = window.setTimeout(() => setOpen(true), openDelay);\n }, [openDelay, setOpen]);\n\n const handleClose = React.useCallback(() => {\n clearTimeout(openTimerRef.current);\n if (!hasSelectionRef.current && !isPointerDownOnContentRef.current) {\n closeTimerRef.current = window.setTimeout(\n () => setOpen(false),\n closeDelay\n );\n }\n }, [closeDelay, setOpen]);\n\n const handleDismiss = React.useCallback(() => setOpen(false), [setOpen]);\n\n // cleanup any queued state updates on unmount\n React.useEffect(() => {\n return () => {\n clearTimeout(openTimerRef.current);\n clearTimeout(closeTimerRef.current);\n };\n }, []);\n\n return (\n <HoverCardProvider\n scope={__scopeHoverCard}\n open={open}\n onOpenChange={setOpen}\n onOpen={handleOpen}\n onClose={handleClose}\n onDismiss={handleDismiss}\n hasSelectionRef={hasSelectionRef}\n isPointerDownOnContentRef={isPointerDownOnContentRef}\n >\n <PopperPrimitive.Root {...popperScope}>{children}</PopperPrimitive.Root>\n </HoverCardProvider>\n );\n};\n\nHoverCard.displayName = HOVERCARD_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport function excludeTouch<E>(eventHandler: () => void) {\n return (event: React.PointerEvent<E>) =>\n event.pointerType === \"touch\" ? undefined : eventHandler();\n}\n\nconst Root = HoverCard;\n\nexport { HoverCard, Root };\nexport type { HoverCardProps };\n", "import React from \"react\";\nimport {\n excludeTouch,\n ScopedProps,\n useHoverCardContext,\n usePopperScope,\n} from \"./HoverCard\";\nimport { Primitive } from \"@huin-core/react-primitive\";\nimport * as PopperPrimitive from \"@huin-core/react-popper\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\n\nconst TRIGGER_NAME = \"HoverCardTrigger\";\n\ntype HoverCardTriggerElement = React.ElementRef<typeof Primitive.a>;\ntype PrimitiveLinkProps = React.ComponentPropsWithoutRef<typeof Primitive.a>;\ninterface HoverCardTriggerProps extends PrimitiveLinkProps {}\n\nconst HoverCardTrigger = React.forwardRef<\n HoverCardTriggerElement,\n HoverCardTriggerProps\n>((props: ScopedProps<HoverCardTriggerProps>, forwardedRef) => {\n const { __scopeHoverCard, ...triggerProps } = props;\n const context = useHoverCardContext(TRIGGER_NAME, __scopeHoverCard);\n const popperScope = usePopperScope(__scopeHoverCard);\n return (\n <PopperPrimitive.Anchor asChild {...popperScope}>\n <Primitive.a\n data-state={context.open ? \"open\" : \"closed\"}\n {...triggerProps}\n ref={forwardedRef}\n onPointerEnter={composeEventHandlers(\n props.onPointerEnter,\n excludeTouch(context.onOpen)\n )}\n onPointerLeave={composeEventHandlers(\n props.onPointerLeave,\n excludeTouch(context.onClose)\n )}\n onFocus={composeEventHandlers(props.onFocus, context.onOpen)}\n onBlur={composeEventHandlers(props.onBlur, context.onClose)}\n // prevent focus event on touch devices\n onTouchStart={composeEventHandlers(props.onTouchStart, (event) =>\n event.preventDefault()\n )}\n />\n </PopperPrimitive.Anchor>\n );\n});\n\nHoverCardTrigger.displayName = TRIGGER_NAME;\n\nexport { HoverCardTrigger };\nexport type { HoverCardTriggerProps };\n", "import { Presence } from \"@huin-core/react-presence\";\nimport {\n createHoverCardContext,\n ScopedProps,\n useHoverCardContext,\n} from \"./HoverCard\";\nimport { Portal as PortalPrimitive } from \"@huin-core/react-portal\";\n\nconst PORTAL_NAME = \"HoverCardPortal\";\n\ntype PortalContextValue = { forceMount?: true };\nexport const [PortalProvider, usePortalContext] =\n createHoverCardContext<PortalContextValue>(PORTAL_NAME, {\n forceMount: undefined,\n });\n\ntype PortalProps = React.ComponentPropsWithoutRef<typeof PortalPrimitive>;\ninterface HoverCardPortalProps {\n children?: React.ReactNode;\n /**\n * Specify a container element to portal the content into.\n */\n container?: PortalProps[\"container\"];\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst HoverCardPortal: React.FC<HoverCardPortalProps> = (\n props: ScopedProps<HoverCardPortalProps>\n) => {\n const { __scopeHoverCard, forceMount, children, container } = props;\n const context = useHoverCardContext(PORTAL_NAME, __scopeHoverCard);\n return (\n <PortalProvider scope={__scopeHoverCard} forceMount={forceMount}>\n <Presence present={forceMount || context.open}>\n <PortalPrimitive asChild container={container}>\n {children}\n </PortalPrimitive>\n </Presence>\n </PortalProvider>\n );\n};\n\nHoverCardPortal.displayName = PORTAL_NAME;\n\nexport { HoverCardPortal };\nexport type { HoverCardPortalProps };\n", "import React from \"react\";\nimport {\n excludeTouch,\n ScopedProps,\n useHoverCardContext,\n usePopperScope,\n} from \"./HoverCard\";\nimport { Presence } from \"@huin-core/react-presence\";\nimport { composeEventHandlers } from \"@huin-core/primitive\";\nimport * as PopperPrimitive from \"@huin-core/react-popper\";\nimport { DismissableLayer } from \"@huin-core/react-dismissable-layer\";\nimport { useComposedRefs } from \"@huin-core/react-compose-refs\";\nimport { usePortalContext } from \"./HoverCardPortal\";\nlet originalBodyUserSelect: string;\n\nconst CONTENT_NAME = \"HoverCardContent\";\n\ntype HoverCardContentElement = HoverCardContentImplElement;\ninterface HoverCardContentProps extends HoverCardContentImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with React animation libraries.\n */\n forceMount?: true;\n}\n\nconst HoverCardContent = React.forwardRef<\n HoverCardContentElement,\n HoverCardContentProps\n>((props: ScopedProps<HoverCardContentProps>, forwardedRef) => {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopeHoverCard);\n const {\n forceMount = portalContext.forceMount,\n align = \"center\",\n ...contentProps\n } = props;\n const context = useHoverCardContext(CONTENT_NAME, props.__scopeHoverCard);\n return (\n <Presence present={forceMount || context.open}>\n <HoverCardContentImpl\n data-state={context.open ? \"open\" : \"closed\"}\n {...contentProps}\n onPointerEnter={composeEventHandlers(\n props.onPointerEnter,\n excludeTouch(context.onOpen)\n )}\n onPointerLeave={composeEventHandlers(\n props.onPointerLeave,\n excludeTouch(context.onClose)\n )}\n ref={forwardedRef}\n />\n </Presence>\n );\n});\n\nHoverCardContent.displayName = CONTENT_NAME;\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype HoverCardContentImplElement = React.ElementRef<\n typeof PopperPrimitive.Content\n>;\ntype DismissableLayerProps = React.ComponentPropsWithoutRef<\n typeof DismissableLayer\n>;\ntype PopperContentProps = React.ComponentPropsWithoutRef<\n typeof PopperPrimitive.Content\n>;\ninterface HoverCardContentImplProps\n extends Omit<PopperContentProps, \"onPlaced\"> {\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: DismissableLayerProps[\"onEscapeKeyDown\"];\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `HoverCard`.\n * Can be prevented.\n */\n onPointerDownOutside?: DismissableLayerProps[\"onPointerDownOutside\"];\n /**\n * Event handler called when the focus moves outside of the `HoverCard`.\n * Can be prevented.\n */\n onFocusOutside?: DismissableLayerProps[\"onFocusOutside\"];\n /**\n * Event handler called when an interaction happens outside the `HoverCard`.\n * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: DismissableLayerProps[\"onInteractOutside\"];\n}\n\nconst HoverCardContentImpl = React.forwardRef<\n HoverCardContentImplElement,\n HoverCardContentImplProps\n>((props: ScopedProps<HoverCardContentImplProps>, forwardedRef) => {\n const {\n __scopeHoverCard,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props;\n const context = useHoverCardContext(CONTENT_NAME, __scopeHoverCard);\n const popperScope = usePopperScope(__scopeHoverCard);\n const ref = React.useRef<HoverCardContentImplElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n const [containSelection, setContainSelection] = React.useState(false);\n\n React.useEffect(() => {\n if (containSelection) {\n const body = document.body;\n\n // Safari requires prefix\n originalBodyUserSelect =\n body.style.userSelect || body.style.webkitUserSelect;\n\n body.style.userSelect = \"none\";\n body.style.webkitUserSelect = \"none\";\n return () => {\n body.style.userSelect = originalBodyUserSelect;\n body.style.webkitUserSelect = originalBodyUserSelect;\n };\n }\n }, [containSelection]);\n\n React.useEffect(() => {\n if (ref.current) {\n const handlePointerUp = () => {\n setContainSelection(false);\n context.isPointerDownOnContentRef.current = false;\n\n // Delay a frame to ensure we always access the latest selection\n setTimeout(() => {\n const hasSelection = document.getSelection()?.toString() !== \"\";\n if (hasSelection) context.hasSelectionRef.current = true;\n });\n };\n\n document.addEventListener(\"pointerup\", handlePointerUp);\n return () => {\n document.removeEventListener(\"pointerup\", handlePointerUp);\n context.hasSelectionRef.current = false;\n context.isPointerDownOnContentRef.current = false;\n };\n }\n }, [context.isPointerDownOnContentRef, context.hasSelectionRef]);\n\n React.useEffect(() => {\n if (ref.current) {\n const tabbables = getTabbableNodes(ref.current);\n tabbables.forEach((tabbable) => tabbable.setAttribute(\"tabindex\", \"-1\"));\n }\n });\n\n return (\n <DismissableLayer\n asChild\n disableOutsidePointerEvents={false}\n onInteractOutside={onInteractOutside}\n onEscapeKeyDown={onEscapeKeyDown}\n onPointerDownOutside={onPointerDownOutside}\n onFocusOutside={composeEventHandlers(onFocusOutside, (event) => {\n event.preventDefault();\n })}\n onDismiss={context.onDismiss}\n >\n <PopperPrimitive.Content\n {...popperScope}\n {...contentProps}\n onPointerDown={composeEventHandlers(\n contentProps.onPointerDown,\n (event) => {\n // Contain selection to current layer\n if (event.currentTarget.contains(event.target as HTMLElement)) {\n setContainSelection(true);\n }\n context.hasSelectionRef.current = false;\n context.isPointerDownOnContentRef.current = true;\n }\n )}\n ref={composedRefs}\n style={{\n ...contentProps.style,\n userSelect: containSelection ? \"text\" : undefined,\n // Safari requires prefix\n WebkitUserSelect: containSelection ? \"text\" : undefined,\n // re-namespace exposed content custom properties\n ...{\n \"--huin-core-hover-card-content-transform-origin\":\n \"var(--huin-core-popper-transform-origin)\",\n \"--huin-core-hover-card-content-available-width\":\n \"var(--huin-core-popper-available-width)\",\n \"--huin-core-hover-card-content-available-height\":\n \"var(--huin-core-popper-available-height)\",\n \"--huin-core-hover-card-trigger-width\":\n \"var(--huin-core-popper-anchor-width)\",\n \"--huin-core-hover-card-trigger-height\":\n \"var(--huin-core-popper-anchor-height)\",\n },\n }}\n />\n </DismissableLayer>\n );\n});\n\n/**\n * Returns a list of nodes that can be in the tab sequence.\n * @see: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker\n */\nfunction getTabbableNodes(container: HTMLElement) {\n const nodes: HTMLElement[] = [];\n const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: any) => {\n // `.tabIndex` is not the same as the `tabindex` attribute. It works on the\n // runtime's understanding of tabbability, so this automatically accounts\n // for any kind of element that could be tabbed to.\n return node.tabIndex >= 0\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP;\n },\n });\n while (walker.nextNode()) nodes.push(walker.currentNode as HTMLElement);\n return nodes;\n}\n\nexport { HoverCardContent };\nexport type { HoverCardContentProps };\n", "import * as PopperPrimitive from \"@huin-core/react-popper\";\nimport React from \"react\";\nimport { ScopedProps, usePopperScope } from \"./HoverCard\";\n\nconst ARROW_NAME = \"HoverCardArrow\";\n\ntype HoverCardArrowElement = React.ElementRef<typeof PopperPrimitive.Arrow>;\ntype PopperArrowProps = React.ComponentPropsWithoutRef<\n typeof PopperPrimitive.Arrow\n>;\ninterface HoverCardArrowProps extends PopperArrowProps {}\n\nconst HoverCardArrow = React.forwardRef<\n HoverCardArrowElement,\n HoverCardArrowProps\n>((props: ScopedProps<HoverCardArrowProps>, forwardedRef) => {\n const { __scopeHoverCard, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopeHoverCard);\n return (\n <PopperPrimitive.Arrow\n {...popperScope}\n {...arrowProps}\n ref={forwardedRef}\n />\n );\n});\n\nHoverCardArrow.displayName = ARROW_NAME;\n\nexport { HoverCardArrow };\nexport type { HoverCardArrowProps };\n"],
|
5
|
+
"mappings": ";;;AAAA,YAAY,WAAW;AACvB,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,YAAY,qBAAqB;AACjC,SAAS,yBAAyB;AAgG5B;AAzFN,IAAM,iBAAiB;AAGhB,IAAM,CAAC,wBAAwB,oBAAoB,IACxD,mBAAmB,gBAAgB,CAAC,iBAAiB,CAAC;AACjD,IAAM,iBAAiB,kBAAkB;AAYzC,IAAM,CAAC,mBAAmB,mBAAmB,IAClD,uBAA8C,cAAc;AAW9D,IAAM,YAAsC,CAC1C,UACG;AACH,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,aAAa;AAAA,EACf,IAAI;AACJ,QAAM,cAAc,eAAe,gBAAgB;AACnD,QAAM,eAAqB,aAAO,CAAC;AACnC,QAAM,gBAAsB,aAAO,CAAC;AACpC,QAAM,kBAAwB,aAAO,KAAK;AAC1C,QAAM,4BAAkC,aAAO,KAAK;AAEpD,QAAM,CAAC,OAAO,OAAO,OAAO,IAAI,qBAAqB;AAAA,IACnD,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,EACZ,CAAC;AAED,QAAM,aAAmB,kBAAY,MAAM;AACzC,iBAAa,cAAc,OAAO;AAClC,iBAAa,UAAU,OAAO,WAAW,MAAM,QAAQ,IAAI,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;AAAA,UACA,KAAK;AAAA,UACL,OAAO;AAAA,YACL,GAAG,aAAa;AAAA,YAChB,YAAY,mBAAmB,SAAS;AAAA;AAAA,YAExC,kBAAkB,mBAAmB,SAAS;AAAA;AAAA,YAE9C,GAAG;AAAA,cACD,mDACE;AAAA,cACF,kDACE;AAAA,cACF,mDACE;AAAA,cACF,wCACE;AAAA,cACF,yCACE;AAAA,YACJ;AAAA,UACF;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ,CAAC;AAMD,SAAS,iBAAiB,WAAwB;AAChD,QAAM,QAAuB,CAAC;AAC9B,QAAM,SAAS,SAAS,iBAAiB,WAAW,WAAW,cAAc;AAAA,IAC3E,YAAY,CAAC,SAAc;AAIzB,aAAO,KAAK,YAAY,IACpB,WAAW,gBACX,WAAW;AAAA,IACjB;AAAA,EACF,CAAC;AACD,SAAO,OAAO,SAAS,EAAG,OAAM,KAAK,OAAO,WAA0B;AACtE,SAAO;AACT;;;ACnOA,YAAYC,sBAAqB;AACjC,OAAOC,YAAW;AAkBd,gBAAAC,YAAA;AAfJ,IAAM,aAAa;AAQnB,IAAM,iBAAiBC,OAAM,WAG3B,CAAC,OAAyC,iBAAiB;AAC3D,QAAM,EAAE,kBAAkB,GAAG,WAAW,IAAI;AAC5C,QAAM,cAAc,eAAe,gBAAgB;AACnD,SACE,gBAAAD;AAAA,IAAiB;AAAA,IAAhB;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACJ,KAAK;AAAA;AAAA,EACP;AAEJ,CAAC;AAED,eAAe,cAAc;",
|
6
|
+
"names": ["Root", "React", "PopperPrimitive", "jsx", "React", "jsx", "React", "Presence", "composeEventHandlers", "PopperPrimitive", "jsx", "React", "Presence", "composeEventHandlers", "PopperPrimitive", "React", "jsx", "React"]
|
7
|
+
}
|