@yamada-ui/popover 1.4.5-next-20241127012228 → 1.4.6-dev-20241201045027
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/{chunk-DM7BMTAI.mjs → chunk-3CIQ6HR5.mjs} +2 -2
- package/dist/{chunk-MAIEILC4.mjs → chunk-5T2J7HCS.mjs} +2 -2
- package/dist/{chunk-DSIIS6RK.mjs → chunk-FMZMQMLR.mjs} +44 -31
- package/dist/chunk-FMZMQMLR.mjs.map +1 -0
- package/dist/{chunk-454CM6LT.mjs → chunk-FZV2OLZC.mjs} +2 -2
- package/dist/{chunk-ZWCBPNYU.mjs → chunk-JO4HZF7S.mjs} +2 -2
- package/dist/{chunk-5XOZKPK7.mjs → chunk-M7G3RCAM.mjs} +8 -6
- package/dist/chunk-M7G3RCAM.mjs.map +1 -0
- package/dist/{chunk-7QWRXZGF.mjs → chunk-NS7I3VTN.mjs} +2 -2
- package/dist/{chunk-62XMD3XG.mjs → chunk-S4GMR5U7.mjs} +2 -2
- package/dist/index.js +48 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/popover-anchor.js +43 -30
- package/dist/popover-anchor.js.map +1 -1
- package/dist/popover-anchor.mjs +2 -2
- package/dist/popover-body.js +43 -30
- package/dist/popover-body.js.map +1 -1
- package/dist/popover-body.mjs +2 -2
- package/dist/popover-close-button.js +43 -30
- package/dist/popover-close-button.js.map +1 -1
- package/dist/popover-close-button.mjs +2 -2
- package/dist/popover-content.js +48 -33
- package/dist/popover-content.js.map +1 -1
- package/dist/popover-content.mjs +3 -3
- package/dist/popover-footer.js +43 -30
- package/dist/popover-footer.js.map +1 -1
- package/dist/popover-footer.mjs +2 -2
- package/dist/popover-header.js +43 -30
- package/dist/popover-header.js.map +1 -1
- package/dist/popover-header.mjs +2 -2
- package/dist/popover-trigger.js +43 -30
- package/dist/popover-trigger.js.map +1 -1
- package/dist/popover-trigger.mjs +2 -2
- package/dist/popover.d.mts +23 -3
- package/dist/popover.d.ts +23 -3
- package/dist/popover.js +43 -30
- package/dist/popover.js.map +1 -1
- package/dist/popover.mjs +1 -1
- package/package.json +10 -10
- package/dist/chunk-5XOZKPK7.mjs.map +0 -1
- package/dist/chunk-DSIIS6RK.mjs.map +0 -1
- /package/dist/{chunk-DM7BMTAI.mjs.map → chunk-3CIQ6HR5.mjs.map} +0 -0
- /package/dist/{chunk-MAIEILC4.mjs.map → chunk-5T2J7HCS.mjs.map} +0 -0
- /package/dist/{chunk-454CM6LT.mjs.map → chunk-FZV2OLZC.mjs.map} +0 -0
- /package/dist/{chunk-ZWCBPNYU.mjs.map → chunk-JO4HZF7S.mjs.map} +0 -0
- /package/dist/{chunk-7QWRXZGF.mjs.map → chunk-NS7I3VTN.mjs.map} +0 -0
- /package/dist/{chunk-62XMD3XG.mjs.map → chunk-S4GMR5U7.mjs.map} +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
usePopover
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-FMZMQMLR.mjs";
|
5
5
|
|
6
6
|
// src/popover-body.tsx
|
7
7
|
import { forwardRef, ui } from "@yamada-ui/core";
|
@@ -33,4 +33,4 @@ PopoverBody.__ui__ = "PopoverBody";
|
|
33
33
|
export {
|
34
34
|
PopoverBody
|
35
35
|
};
|
36
|
-
//# sourceMappingURL=chunk-
|
36
|
+
//# sourceMappingURL=chunk-3CIQ6HR5.mjs.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
usePopover
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-FMZMQMLR.mjs";
|
5
5
|
|
6
6
|
// src/popover-footer.tsx
|
7
7
|
import { forwardRef, ui } from "@yamada-ui/core";
|
@@ -33,4 +33,4 @@ PopoverFooter.__ui__ = "PopoverFooter";
|
|
33
33
|
export {
|
34
34
|
PopoverFooter
|
35
35
|
};
|
36
|
-
//# sourceMappingURL=chunk-
|
36
|
+
//# sourceMappingURL=chunk-5T2J7HCS.mjs.map
|
@@ -22,7 +22,9 @@ import { useCallback, useEffect, useId, useRef } from "react";
|
|
22
22
|
import { jsx } from "react/jsx-runtime";
|
23
23
|
var popoverProperties = [
|
24
24
|
...popperProperties,
|
25
|
+
"open",
|
25
26
|
"isOpen",
|
27
|
+
"defaultOpen",
|
26
28
|
"defaultIsOpen",
|
27
29
|
"onOpen",
|
28
30
|
"onClose",
|
@@ -35,6 +37,7 @@ var popoverProperties = [
|
|
35
37
|
"trigger",
|
36
38
|
"openDelay",
|
37
39
|
"closeDelay",
|
40
|
+
"Lazy",
|
38
41
|
"isLazy",
|
39
42
|
"lazyBehavior",
|
40
43
|
"animation",
|
@@ -46,7 +49,7 @@ var [PopoverProvider, usePopover] = createContext({
|
|
46
49
|
});
|
47
50
|
var Popover = (props) => {
|
48
51
|
const [styles, mergedProps] = useComponentMultiStyle("Popover", props);
|
49
|
-
|
52
|
+
let {
|
50
53
|
animation = "scale",
|
51
54
|
autoFocus = true,
|
52
55
|
children,
|
@@ -57,15 +60,25 @@ var Popover = (props) => {
|
|
57
60
|
duration,
|
58
61
|
initialFocusRef,
|
59
62
|
isLazy,
|
63
|
+
isOpen: isOpenProp,
|
64
|
+
lazy,
|
60
65
|
lazyBehavior = "unmount",
|
66
|
+
open: openProp,
|
61
67
|
openDelay = 200,
|
62
68
|
relatedRef,
|
63
69
|
restoreFocus = true,
|
64
70
|
trigger = "click",
|
65
71
|
...rest
|
66
72
|
} = omitThemeProps(mergedProps);
|
73
|
+
lazy != null ? lazy : lazy = isLazy;
|
74
|
+
openProp != null ? openProp : openProp = isOpenProp;
|
67
75
|
const id = useId();
|
68
|
-
const {
|
76
|
+
const {
|
77
|
+
isOpen: open,
|
78
|
+
onClose,
|
79
|
+
onOpen,
|
80
|
+
onToggle
|
81
|
+
} = useDisclosure({ ...mergedProps, isOpen: openProp });
|
69
82
|
const anchorRef = useRef(null);
|
70
83
|
const triggerRef = useRef(null);
|
71
84
|
const headerRef = useRef(null);
|
@@ -73,17 +86,17 @@ var Popover = (props) => {
|
|
73
86
|
const popoverRef = useRef(null);
|
74
87
|
const { present, onAnimationComplete } = useAnimationObserver({
|
75
88
|
ref: popoverRef,
|
76
|
-
isOpen
|
89
|
+
isOpen: open
|
77
90
|
});
|
78
91
|
const openTimeout = useRef(void 0);
|
79
92
|
const closeTimeout = useRef(void 0);
|
80
|
-
const
|
93
|
+
const hoveringRef = useRef(false);
|
81
94
|
const hasBeenOpened = useRef(false);
|
82
95
|
const { forceUpdate, referenceRef, transformOrigin, getPopperProps } = usePopper({
|
83
96
|
...rest,
|
84
|
-
enabled:
|
97
|
+
enabled: open
|
85
98
|
});
|
86
|
-
if (
|
99
|
+
if (open) hasBeenOpened.current = true;
|
87
100
|
useEffect(() => {
|
88
101
|
return () => {
|
89
102
|
if (openTimeout.current) clearTimeout(openTimeout.current);
|
@@ -92,20 +105,20 @@ var Popover = (props) => {
|
|
92
105
|
}, []);
|
93
106
|
useFocusOnPointerDown({
|
94
107
|
ref: triggerRef,
|
95
|
-
enabled:
|
108
|
+
enabled: open
|
96
109
|
});
|
97
110
|
useFocusOnHide(popoverRef, {
|
98
111
|
focusRef: triggerRef,
|
99
112
|
shouldFocus: restoreFocus && (trigger === "click" || trigger === "contextmenu"),
|
100
|
-
visible:
|
113
|
+
visible: open
|
101
114
|
});
|
102
115
|
useFocusOnShow(popoverRef, {
|
103
116
|
focusRef: initialFocusRef,
|
104
117
|
shouldFocus: autoFocus && (trigger === "click" || trigger === "contextmenu"),
|
105
|
-
visible:
|
118
|
+
visible: open
|
106
119
|
});
|
107
120
|
const shouldRenderChildren = useLazyDisclosure({
|
108
|
-
enabled:
|
121
|
+
enabled: lazy,
|
109
122
|
isSelected: present,
|
110
123
|
mode: lazyBehavior,
|
111
124
|
wasSelected: hasBeenOpened.current
|
@@ -116,7 +129,7 @@ var Popover = (props) => {
|
|
116
129
|
const popoverProps = {
|
117
130
|
id,
|
118
131
|
"aria-describedby": (_a = bodyRef.current) == null ? void 0 : _a.id,
|
119
|
-
"aria-hidden": !
|
132
|
+
"aria-hidden": !open,
|
120
133
|
"aria-labelledby": (_b = headerRef.current) == null ? void 0 : _b.id,
|
121
134
|
role: "dialog",
|
122
135
|
...props2,
|
@@ -132,8 +145,8 @@ var Popover = (props) => {
|
|
132
145
|
const targetIsPopover = isContains(popoverRef.current, relatedTarget);
|
133
146
|
const targetIsTrigger = isContains(triggerRef.current, relatedTarget);
|
134
147
|
const targetIsRelated = (relatedRef == null ? void 0 : relatedRef.current) ? isContains(relatedRef.current, relatedTarget) : false;
|
135
|
-
const
|
136
|
-
if (
|
148
|
+
const validBlur = !targetIsPopover && !targetIsTrigger && !targetIsRelated;
|
149
|
+
if (open && closeOnBlur && validBlur) onClose();
|
137
150
|
}),
|
138
151
|
onKeyDown: handlerAll(props2.onKeyDown, (ev) => {
|
139
152
|
if (closeOnEsc && ev.key === "Escape") onClose();
|
@@ -141,11 +154,11 @@ var Popover = (props) => {
|
|
141
154
|
};
|
142
155
|
if (trigger === "hover") {
|
143
156
|
popoverProps.onMouseEnter = handlerAll(props2.onMouseEnter, () => {
|
144
|
-
|
157
|
+
hoveringRef.current = true;
|
145
158
|
});
|
146
159
|
popoverProps.onMouseLeave = handlerAll(props2.onMouseLeave, (ev) => {
|
147
160
|
if (ev.nativeEvent.relatedTarget === null) return;
|
148
|
-
|
161
|
+
hoveringRef.current = false;
|
149
162
|
if (closeOnBlur) setTimeout(onClose, closeDelay);
|
150
163
|
});
|
151
164
|
}
|
@@ -155,7 +168,7 @@ var Popover = (props) => {
|
|
155
168
|
closeDelay,
|
156
169
|
closeOnBlur,
|
157
170
|
closeOnEsc,
|
158
|
-
|
171
|
+
open,
|
159
172
|
onClose,
|
160
173
|
shouldRenderChildren,
|
161
174
|
transformOrigin,
|
@@ -173,8 +186,8 @@ var Popover = (props) => {
|
|
173
186
|
const getTriggerProps = useCallback(
|
174
187
|
(props2 = {}, ref = null) => {
|
175
188
|
const triggerProps = {
|
176
|
-
"aria-controls":
|
177
|
-
"aria-expanded":
|
189
|
+
"aria-controls": open ? id : void 0,
|
190
|
+
"aria-expanded": open,
|
178
191
|
role: "button",
|
179
192
|
...props2,
|
180
193
|
ref: mergeRefs(triggerRef, ref, maybeReferenceRef)
|
@@ -183,8 +196,8 @@ var Popover = (props) => {
|
|
183
196
|
triggerProps.onClick = handlerAll(props2.onClick, onToggle);
|
184
197
|
triggerProps.onBlur = handlerAll(props2.onBlur, (ev) => {
|
185
198
|
const relatedTarget = getEventRelatedTarget(ev);
|
186
|
-
const
|
187
|
-
if (
|
199
|
+
const validBlur = !isContains(popoverRef.current, relatedTarget);
|
200
|
+
if (open && closeOnBlur && validBlur) onClose();
|
188
201
|
});
|
189
202
|
}
|
190
203
|
if (trigger === "contextmenu") {
|
@@ -194,8 +207,8 @@ var Popover = (props) => {
|
|
194
207
|
});
|
195
208
|
triggerProps.onBlur = handlerAll(props2.onBlur, (ev) => {
|
196
209
|
const relatedTarget = getEventRelatedTarget(ev);
|
197
|
-
const
|
198
|
-
if (
|
210
|
+
const validBlur = !isContains(popoverRef.current, relatedTarget);
|
211
|
+
if (open && closeOnBlur && validBlur) onClose();
|
199
212
|
});
|
200
213
|
}
|
201
214
|
if (trigger === "hover") {
|
@@ -204,24 +217,24 @@ var Popover = (props) => {
|
|
204
217
|
});
|
205
218
|
triggerProps.onBlur = handlerAll(props2.onBlur, (ev) => {
|
206
219
|
const relatedTarget = getEventRelatedTarget(ev);
|
207
|
-
const
|
208
|
-
if (
|
220
|
+
const validBlur = !isContains(popoverRef.current, relatedTarget);
|
221
|
+
if (open && closeOnBlur && validBlur) onClose();
|
209
222
|
});
|
210
223
|
triggerProps.onKeyDown = handlerAll(props2.onKeyDown, (ev) => {
|
211
224
|
if (ev.key === "Escape") onClose();
|
212
225
|
});
|
213
226
|
triggerProps.onMouseEnter = handlerAll(props2.onMouseEnter, () => {
|
214
|
-
|
227
|
+
hoveringRef.current = true;
|
215
228
|
openTimeout.current = window.setTimeout(onOpen, openDelay);
|
216
229
|
});
|
217
230
|
triggerProps.onMouseLeave = handlerAll(props2.onMouseLeave, () => {
|
218
|
-
|
231
|
+
hoveringRef.current = false;
|
219
232
|
if (openTimeout.current) {
|
220
233
|
clearTimeout(openTimeout.current);
|
221
234
|
openTimeout.current = void 0;
|
222
235
|
}
|
223
236
|
closeTimeout.current = window.setTimeout(() => {
|
224
|
-
if (!
|
237
|
+
if (!hoveringRef.current) onClose();
|
225
238
|
}, closeDelay);
|
226
239
|
});
|
227
240
|
}
|
@@ -230,7 +243,7 @@ var Popover = (props) => {
|
|
230
243
|
[
|
231
244
|
closeDelay,
|
232
245
|
closeOnBlur,
|
233
|
-
|
246
|
+
open,
|
234
247
|
maybeReferenceRef,
|
235
248
|
onClose,
|
236
249
|
onOpen,
|
@@ -260,7 +273,7 @@ var Popover = (props) => {
|
|
260
273
|
duration,
|
261
274
|
forceUpdate,
|
262
275
|
headerRef,
|
263
|
-
|
276
|
+
open,
|
264
277
|
styles,
|
265
278
|
getAnchorProps,
|
266
279
|
getPopoverProps,
|
@@ -271,7 +284,7 @@ var Popover = (props) => {
|
|
271
284
|
},
|
272
285
|
children: runIfFunc(children, {
|
273
286
|
forceUpdate,
|
274
|
-
|
287
|
+
open,
|
275
288
|
onClose
|
276
289
|
})
|
277
290
|
}
|
@@ -285,4 +298,4 @@ export {
|
|
285
298
|
usePopover,
|
286
299
|
Popover
|
287
300
|
};
|
288
|
-
//# sourceMappingURL=chunk-
|
301
|
+
//# sourceMappingURL=chunk-FMZMQMLR.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/popover.tsx"],"sourcesContent":["import type {\n CSSUIObject,\n FC,\n HTMLUIPropsWithRef,\n PropGetter,\n ThemeProps,\n} from \"@yamada-ui/core\"\nimport type { MotionProps, MotionTransitionProps } from \"@yamada-ui/motion\"\nimport type { LazyMode } from \"@yamada-ui/use-disclosure\"\nimport type { UsePopperProps } from \"@yamada-ui/use-popper\"\nimport type {\n ComponentProps,\n PropsWithChildren,\n RefAttributes,\n RefObject,\n} from \"react\"\nimport { omitThemeProps, useComponentMultiStyle } from \"@yamada-ui/core\"\nimport { useAnimationObserver } from \"@yamada-ui/use-animation\"\nimport { useDisclosure, useLazyDisclosure } from \"@yamada-ui/use-disclosure\"\nimport {\n useFocusOnHide,\n useFocusOnPointerDown,\n useFocusOnShow,\n} from \"@yamada-ui/use-focus\"\nimport { popperProperties, usePopper } from \"@yamada-ui/use-popper\"\nimport {\n createContext,\n getEventRelatedTarget,\n handlerAll,\n isContains,\n mergeRefs,\n runIfFunc,\n} from \"@yamada-ui/utils\"\nimport { useCallback, useEffect, useId, useRef } from \"react\"\n\nexport type PopoverProperty = (typeof popoverProperties)[number]\n\nexport const popoverProperties = [\n ...popperProperties,\n \"open\",\n \"isOpen\",\n \"defaultOpen\",\n \"defaultIsOpen\",\n \"onOpen\",\n \"onClose\",\n \"initialFocusRef\",\n \"restoreFocus\",\n \"autoFocus\",\n \"closeOnBlur\",\n \"closeOnEsc\",\n \"closeOnButton\",\n \"trigger\",\n \"openDelay\",\n \"closeDelay\",\n \"Lazy\",\n \"isLazy\",\n \"lazyBehavior\",\n \"animation\",\n \"duration\",\n] as const\n\nexport interface ComboBoxProps\n extends Omit<\n PopoverOptions,\n | \"autoFocus\"\n | \"closeOnButton\"\n | \"initialFocusRef\"\n | \"relatedRef\"\n | \"restoreFocus\"\n | \"trigger\"\n >,\n Omit<UsePopperProps, \"enabled\"> {}\n\ninterface PopoverOptions {\n /**\n * The animation of the popover.\n *\n * @default 'scale'\n */\n animation?: \"bottom\" | \"left\" | \"none\" | \"right\" | \"scale\" | \"top\"\n /**\n * If `true`, focus will be transferred to the first interactive element when the popover opens.\n *\n * @default true\n */\n autoFocus?: boolean\n /**\n * The number of delay time to close.\n *\n * @default 200\n */\n closeDelay?: number\n /**\n * If `true`, the popover will close when you blur out it by clicking outside or tabbing out.\n *\n * @default true\n */\n closeOnBlur?: boolean\n /**\n * If `true`, display the popover close button.\n *\n * @default true\n */\n closeOnButton?: boolean\n /**\n * If `true`, the popover will close when you hit the `Esc` key.\n *\n * @default true\n */\n closeOnEsc?: boolean\n /**\n * If `true`, the popover will be initially opened.\n *\n * @deprecated Use `defaultOpen` instead\n */\n defaultIsOpen?: boolean\n /**\n * If `true`, the popover will be initially opened.\n */\n defaultOpen?: boolean\n /**\n * The animation duration.\n */\n duration?: MotionTransitionProps[\"duration\"]\n /**\n * The `ref` of the element that should receive focus when the popover opens.\n */\n initialFocusRef?: RefObject<{ focus(): void }>\n /**\n * If `true`, the PopoverContent rendering will be deferred until the popover is open.\n *\n * @default false\n *\n * @deprecated Use `lazy` instead\n */\n isLazy?: boolean\n /**\n * If `true`, the popover will be opened.\n *\n * @deprecated Use `open` instead\n */\n isOpen?: boolean\n /**\n * If `true`, the PopoverContent rendering will be deferred until the popover is open.\n *\n * @default false\n */\n lazy?: boolean\n /**\n * The lazy behavior of popover's content when not visible. Only works when `lazy={true}`\n *\n * - `unmount`: The popover's content is always unmounted when not open.\n * - `keepMounted`: The popover's content initially unmounted, but stays mounted when popover is open.\n *\n * @default 'unmount'\n */\n lazyBehavior?: LazyMode\n /**\n * If `true`, the popover will be opened.\n */\n open?: boolean\n /**\n * The number of delay time to open.\n *\n * @default 200\n */\n openDelay?: number\n /**\n * The `ref` of the element related to the popover.\n * This is used during the `onBlur` event.\n */\n relatedRef?: RefObject<HTMLElement>\n /**\n * If `true`, focus will be returned to the element that triggers the popover when it closes.\n *\n * @default true\n */\n restoreFocus?: boolean\n /**\n * The interaction that triggers the popover.\n *\n * - `hover`: means the popover will open when you hover with mouse or focus with keyboard on the popover trigger.\n * - `click`: means the popover will open on click or press `Enter` to `Space` on keyboard.\n *\n * @default 'click'\n */\n trigger?: \"click\" | \"contextmenu\" | \"hover\" | \"never\"\n /**\n * Callback fired when the popover closes.\n */\n onClose?: () => void\n /**\n * Callback fired when the popover opens.\n */\n onOpen?: () => void\n}\n\nexport interface PopoverProps\n extends ThemeProps<\"Popover\">,\n Omit<UsePopperProps, \"enabled\">,\n PropsWithChildren<PopoverOptions> {}\n\ninterface PopoverContext\n extends Pick<\n PopoverOptions,\n \"animation\" | \"closeOnButton\" | \"duration\" | \"isOpen\" | \"onClose\" | \"open\"\n > {\n id: string\n bodyRef: RefObject<HTMLElement>\n forceUpdate: () => undefined | void\n headerRef: RefObject<HTMLElement>\n styles: { [key: string]: CSSUIObject | undefined }\n getAnchorProps: PropGetter\n getPopoverProps: PropGetter<MotionProps<\"section\">, MotionProps<\"section\">>\n getPopperProps: PropGetter<ComponentProps<\"div\">>\n getTriggerProps: PropGetter\n onAnimationComplete: () => void\n}\n\nconst [PopoverProvider, usePopover] = createContext<PopoverContext>({\n name: \"PopoverContext\",\n errorMessage: `usePopoverContext returned is 'undefined'. Seems you forgot to wrap the components in \"<Popover />\"`,\n})\n\nexport { usePopover }\n\n/**\n * `Popover` is a component that floats around an element to display information.\n *\n * @see Docs https://yamada-ui.com/components/overlay/popover\n */\nexport const Popover: FC<PopoverProps> = (props) => {\n const [styles, mergedProps] = useComponentMultiStyle(\"Popover\", props)\n let {\n animation = \"scale\",\n autoFocus = true,\n children,\n closeDelay = 200,\n closeOnBlur = true,\n closeOnButton = true,\n closeOnEsc = true,\n duration,\n initialFocusRef,\n isLazy,\n isOpen: isOpenProp,\n lazy,\n lazyBehavior = \"unmount\",\n open: openProp,\n openDelay = 200,\n relatedRef,\n restoreFocus = true,\n trigger = \"click\",\n ...rest\n } = omitThemeProps(mergedProps)\n\n lazy ??= isLazy\n openProp ??= isOpenProp\n\n const id = useId()\n const {\n isOpen: open,\n onClose,\n onOpen,\n onToggle,\n } = useDisclosure({ ...mergedProps, isOpen: openProp })\n const anchorRef = useRef<HTMLElement>(null)\n const triggerRef = useRef<HTMLElement>(null)\n const headerRef = useRef<HTMLElement>(null)\n const bodyRef = useRef<HTMLElement>(null)\n const popoverRef = useRef<HTMLElement>(null)\n const { present, onAnimationComplete } = useAnimationObserver({\n ref: popoverRef,\n isOpen: open,\n })\n const openTimeout = useRef<number | undefined>(undefined)\n const closeTimeout = useRef<number | undefined>(undefined)\n const hoveringRef = useRef(false)\n const hasBeenOpened = useRef(false)\n const { forceUpdate, referenceRef, transformOrigin, getPopperProps } =\n usePopper({\n ...rest,\n enabled: open,\n })\n\n if (open) hasBeenOpened.current = true\n\n useEffect(() => {\n return () => {\n if (openTimeout.current) clearTimeout(openTimeout.current)\n\n if (closeTimeout.current) clearTimeout(closeTimeout.current)\n }\n }, [])\n\n useFocusOnPointerDown({\n ref: triggerRef,\n enabled: open,\n })\n\n useFocusOnHide(popoverRef, {\n focusRef: triggerRef,\n shouldFocus:\n restoreFocus && (trigger === \"click\" || trigger === \"contextmenu\"),\n visible: open,\n })\n\n useFocusOnShow(popoverRef, {\n focusRef: initialFocusRef,\n shouldFocus:\n autoFocus && (trigger === \"click\" || trigger === \"contextmenu\"),\n visible: open,\n })\n\n const shouldRenderChildren = useLazyDisclosure({\n enabled: lazy,\n isSelected: present,\n mode: lazyBehavior,\n wasSelected: hasBeenOpened.current,\n })\n\n const getPopoverProps: PropGetter<\n MotionProps<\"section\">,\n MotionProps<\"section\">\n > = useCallback(\n (props = {}, ref = null) => {\n const popoverProps: MotionProps & RefAttributes<any> = {\n id,\n \"aria-describedby\": bodyRef.current?.id,\n \"aria-hidden\": !open,\n \"aria-labelledby\": headerRef.current?.id,\n role: \"dialog\",\n ...props,\n ref: mergeRefs(popoverRef, ref),\n style: {\n ...props.style,\n transformOrigin,\n },\n children: shouldRenderChildren ? props.children : null,\n tabIndex: -1,\n onBlur: handlerAll(props.onBlur, (ev) => {\n const relatedTarget = getEventRelatedTarget(ev)\n const targetIsPopover = isContains(popoverRef.current, relatedTarget)\n const targetIsTrigger = isContains(triggerRef.current, relatedTarget)\n const targetIsRelated = relatedRef?.current\n ? isContains(relatedRef.current, relatedTarget)\n : false\n\n const validBlur =\n !targetIsPopover && !targetIsTrigger && !targetIsRelated\n\n if (open && closeOnBlur && validBlur) onClose()\n }),\n onKeyDown: handlerAll(props.onKeyDown, (ev) => {\n if (closeOnEsc && ev.key === \"Escape\") onClose()\n }),\n }\n\n if (trigger === \"hover\") {\n popoverProps.onMouseEnter = handlerAll(props.onMouseEnter, () => {\n hoveringRef.current = true\n })\n\n popoverProps.onMouseLeave = handlerAll(props.onMouseLeave, (ev) => {\n if (ev.nativeEvent.relatedTarget === null) return\n\n hoveringRef.current = false\n\n if (closeOnBlur) setTimeout(onClose, closeDelay)\n })\n }\n\n return popoverProps\n },\n [\n closeDelay,\n closeOnBlur,\n closeOnEsc,\n open,\n onClose,\n shouldRenderChildren,\n transformOrigin,\n trigger,\n relatedRef,\n id,\n ],\n )\n\n const maybeReferenceRef = useCallback(\n (node: Element) => {\n if (anchorRef.current == null) referenceRef(node)\n },\n [referenceRef],\n )\n\n const getTriggerProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n const triggerProps: HTMLUIPropsWithRef = {\n \"aria-controls\": open ? id : undefined,\n \"aria-expanded\": open,\n role: \"button\",\n ...props,\n ref: mergeRefs(triggerRef, ref, maybeReferenceRef),\n }\n\n if (trigger === \"click\") {\n triggerProps.onClick = handlerAll(props.onClick, onToggle)\n triggerProps.onBlur = handlerAll(props.onBlur, (ev) => {\n const relatedTarget = getEventRelatedTarget(ev)\n const validBlur = !isContains(popoverRef.current, relatedTarget)\n\n if (open && closeOnBlur && validBlur) onClose()\n })\n }\n\n if (trigger === \"contextmenu\") {\n triggerProps.onContextMenu = handlerAll(props.onContextMenu, (ev) => {\n ev.preventDefault()\n onOpen()\n })\n triggerProps.onBlur = handlerAll(props.onBlur, (ev) => {\n const relatedTarget = getEventRelatedTarget(ev)\n const validBlur = !isContains(popoverRef.current, relatedTarget)\n\n if (open && closeOnBlur && validBlur) onClose()\n })\n }\n\n if (trigger === \"hover\") {\n triggerProps.onFocus = handlerAll(props.onFocus, () => {\n if (openTimeout.current === undefined) onOpen()\n })\n\n triggerProps.onBlur = handlerAll(props.onBlur, (ev) => {\n const relatedTarget = getEventRelatedTarget(ev)\n const validBlur = !isContains(popoverRef.current, relatedTarget)\n\n if (open && closeOnBlur && validBlur) onClose()\n })\n\n triggerProps.onKeyDown = handlerAll(props.onKeyDown, (ev) => {\n if (ev.key === \"Escape\") onClose()\n })\n\n triggerProps.onMouseEnter = handlerAll(props.onMouseEnter, () => {\n hoveringRef.current = true\n openTimeout.current = window.setTimeout(onOpen, openDelay)\n })\n\n triggerProps.onMouseLeave = handlerAll(props.onMouseLeave, () => {\n hoveringRef.current = false\n\n if (openTimeout.current) {\n clearTimeout(openTimeout.current)\n openTimeout.current = undefined\n }\n\n closeTimeout.current = window.setTimeout(() => {\n if (!hoveringRef.current) onClose()\n }, closeDelay)\n })\n }\n\n return triggerProps\n },\n [\n closeDelay,\n closeOnBlur,\n open,\n maybeReferenceRef,\n onClose,\n onOpen,\n onToggle,\n openDelay,\n trigger,\n id,\n ],\n )\n\n const getAnchorProps: PropGetter = useCallback(\n (props = {}, ref = null) => {\n return {\n ...props,\n ref: mergeRefs(ref, anchorRef, referenceRef),\n }\n },\n [anchorRef, referenceRef],\n )\n\n return (\n <PopoverProvider\n value={{\n id,\n animation,\n bodyRef,\n closeOnButton,\n duration,\n forceUpdate,\n headerRef,\n open,\n styles,\n getAnchorProps,\n getPopoverProps,\n getPopperProps,\n getTriggerProps,\n onAnimationComplete,\n onClose,\n }}\n >\n {runIfFunc(children, {\n forceUpdate,\n open,\n onClose,\n })}\n </PopoverProvider>\n )\n}\n\nPopover.displayName = \"Popover\"\nPopover.__ui__ = \"Popover\"\n"],"mappings":";;;AAgBA,SAAS,gBAAgB,8BAA8B;AACvD,SAAS,4BAA4B;AACrC,SAAS,eAAe,yBAAyB;AACjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB,iBAAiB;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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O,WAAW,QAAQ,SAAS;AAAA,QAC3D,CAAC;AAED,qBAAa,eAAe,WAAWA,OAAM,cAAc,MAAM;AAC/D,sBAAY,UAAU;AAEtB,cAAI,YAAY,SAAS;AACvB,yBAAa,YAAY,OAAO;AAChC,wBAAY,UAAU;AAAA,UACxB;AAEA,uBAAa,UAAU,OAAO,WAAW,MAAM;AAC7C,gBAAI,CAAC,YAAY,QAAS,SAAQ;AAAA,UACpC,GAAG,UAAU;AAAA,QACf,CAAC;AAAA,MACH;AAEA,aAAO;AAAA,IACT;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAA6B;AAAA,IACjC,CAACA,SAAQ,CAAC,GAAG,MAAM,SAAS;AAC1B,aAAO;AAAA,QACL,GAAGA;AAAA,QACH,KAAK,UAAU,KAAK,WAAW,YAAY;AAAA,MAC7C;AAAA,IACF;AAAA,IACA,CAAC,WAAW,YAAY;AAAA,EAC1B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC,oBAAU,UAAU;AAAA,QACnB;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA;AAAA,EACH;AAEJ;AAEA,QAAQ,cAAc;AACtB,QAAQ,SAAS;","names":["props"]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
usePopover
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-FMZMQMLR.mjs";
|
5
5
|
|
6
6
|
// src/popover-trigger.tsx
|
7
7
|
import { Children, cloneElement } from "react";
|
@@ -16,4 +16,4 @@ PopoverTrigger.__ui__ = "PopoverTrigger";
|
|
16
16
|
export {
|
17
17
|
PopoverTrigger
|
18
18
|
};
|
19
|
-
//# sourceMappingURL=chunk-
|
19
|
+
//# sourceMappingURL=chunk-FZV2OLZC.mjs.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
usePopover
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-FMZMQMLR.mjs";
|
5
5
|
|
6
6
|
// src/popover-close-button.tsx
|
7
7
|
import { CloseButton } from "@yamada-ui/close-button";
|
@@ -39,4 +39,4 @@ PopoverCloseButton.__ui__ = "PopoverCloseButton";
|
|
39
39
|
export {
|
40
40
|
PopoverCloseButton
|
41
41
|
};
|
42
|
-
//# sourceMappingURL=chunk-
|
42
|
+
//# sourceMappingURL=chunk-JO4HZF7S.mjs.map
|
@@ -1,10 +1,10 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
PopoverCloseButton
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-JO4HZF7S.mjs";
|
5
5
|
import {
|
6
6
|
usePopover
|
7
|
-
} from "./chunk-
|
7
|
+
} from "./chunk-FMZMQMLR.mjs";
|
8
8
|
|
9
9
|
// src/popover-content.tsx
|
10
10
|
import { ui } from "@yamada-ui/core";
|
@@ -66,16 +66,18 @@ var PopoverContent = motionForwardRef(
|
|
66
66
|
...rest
|
67
67
|
}, ref) => {
|
68
68
|
var _a, _b, _c, _d, _e;
|
69
|
-
|
69
|
+
let {
|
70
70
|
animation,
|
71
71
|
closeOnButton,
|
72
72
|
duration,
|
73
73
|
isOpen,
|
74
|
+
open,
|
74
75
|
styles,
|
75
76
|
getPopoverProps,
|
76
77
|
getPopperProps,
|
77
78
|
onAnimationComplete
|
78
79
|
} = usePopover();
|
80
|
+
open != null ? open : open = isOpen;
|
79
81
|
const validChildren = getValidChildren(children);
|
80
82
|
const [customPopoverCloseButton, ...cloneChildren] = findChildren(
|
81
83
|
validChildren,
|
@@ -103,7 +105,7 @@ var PopoverContent = motionForwardRef(
|
|
103
105
|
ui.div,
|
104
106
|
{
|
105
107
|
...getPopperProps({
|
106
|
-
style: { visibility:
|
108
|
+
style: { visibility: open ? "visible" : "hidden" }
|
107
109
|
}),
|
108
110
|
className: "ui-popover",
|
109
111
|
maxWidth,
|
@@ -118,7 +120,7 @@ var PopoverContent = motionForwardRef(
|
|
118
120
|
className: cx("ui-popover__content", className),
|
119
121
|
...animation !== "none" ? getPopoverContentProps(animation, duration) : {},
|
120
122
|
...getPopoverProps(rest, ref),
|
121
|
-
animate:
|
123
|
+
animate: open ? "enter" : "exit",
|
122
124
|
exit: "exit",
|
123
125
|
initial: "exit",
|
124
126
|
onAnimationComplete: funcAll(
|
@@ -142,4 +144,4 @@ PopoverContent.__ui__ = "PopoverContent";
|
|
142
144
|
export {
|
143
145
|
PopoverContent
|
144
146
|
};
|
145
|
-
//# sourceMappingURL=chunk-
|
147
|
+
//# sourceMappingURL=chunk-M7G3RCAM.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/popover-content.tsx"],"sourcesContent":["import type { CSSUIObject, CSSUIProps, HTMLUIProps } from \"@yamada-ui/core\"\nimport type { MotionPropsWithoutChildren } from \"@yamada-ui/motion\"\nimport type { PropsWithChildren } from \"react\"\nimport type { PopoverProps } from \"./popover\"\nimport { ui } from \"@yamada-ui/core\"\nimport { motion, motionForwardRef } from \"@yamada-ui/motion\"\nimport { scaleFadeProps, slideFadeProps } from \"@yamada-ui/transitions\"\nimport { cx, findChildren, funcAll, getValidChildren } from \"@yamada-ui/utils\"\nimport { useMemo } from \"react\"\nimport { usePopover } from \"./popover\"\nimport { PopoverCloseButton } from \"./popover-close-button\"\n\nexport interface PopoverContentProps\n extends MotionPropsWithoutChildren<\"section\">,\n PropsWithChildren {\n /**\n * The props of the container element.\n */\n containerProps?: Omit<HTMLUIProps, \"children\">\n}\n\nconst getPopoverContentProps = (\n animation: PopoverProps[\"animation\"] = \"scale\",\n duration?: PopoverProps[\"duration\"],\n) => {\n const custom = {\n duration,\n enter: { visibility: \"visible\" },\n reverse: true,\n transitionEnd: { exit: { visibility: \"hidden\" } },\n }\n\n switch (animation) {\n case \"scale\":\n return {\n ...scaleFadeProps,\n custom: { ...custom, scale: 0.95 },\n }\n case \"top\":\n return {\n ...slideFadeProps,\n custom: { ...custom, offsetX: 0, offsetY: -16 },\n }\n case \"right\":\n return {\n ...slideFadeProps,\n custom: { ...custom, offsetX: 16, offsetY: 0 },\n }\n case \"left\":\n return {\n ...slideFadeProps,\n custom: { ...custom, offsetX: -16, offsetY: 0 },\n }\n case \"bottom\":\n return {\n ...slideFadeProps,\n custom: { ...custom, offsetX: 0, offsetY: 16 },\n }\n }\n}\n\nexport const PopoverContent = motionForwardRef<PopoverContentProps, \"section\">(\n (\n {\n as = \"section\",\n className,\n children,\n maxW,\n maxWidth,\n minW,\n minWidth,\n w,\n width,\n z,\n zIndex,\n containerProps,\n __css,\n ...rest\n },\n ref,\n ) => {\n let {\n animation,\n closeOnButton,\n duration,\n isOpen,\n open,\n styles,\n getPopoverProps,\n getPopperProps,\n onAnimationComplete,\n } = usePopover()\n\n open ??= isOpen\n\n const validChildren = getValidChildren(children)\n const [customPopoverCloseButton, ...cloneChildren] = findChildren(\n validChildren,\n PopoverCloseButton,\n )\n\n const Component = useMemo(() => motion(as), [as])\n\n const css = __css ?? styles.container ?? {}\n\n const computedCSS: CSSUIObject = {\n display: \"flex\",\n flexDirection: \"column\",\n outline: 0,\n position: \"relative\",\n w: \"100%\",\n ...css,\n }\n\n width ??= w\n width ??= (css.width ?? css.w) as CSSUIProps[\"width\"]\n minWidth ??= minW\n minWidth ??= (css.minWidth ?? css.minW) as CSSUIProps[\"minWidth\"]\n maxWidth ??= maxW\n maxWidth ??= (css.maxWidth ?? css.maxW) as CSSUIProps[\"maxWidth\"]\n\n zIndex ??= z\n zIndex ??= (css.zIndex ?? css.z) as CSSUIProps[\"zIndex\"]\n\n return (\n <ui.div\n {...getPopperProps({\n style: { visibility: open ? \"visible\" : \"hidden\" },\n })}\n className=\"ui-popover\"\n maxWidth={maxWidth}\n minWidth={minWidth}\n outline=\"none\"\n width={width}\n zIndex={zIndex}\n {...containerProps}\n >\n <Component\n className={cx(\"ui-popover__content\", className)}\n {...(animation !== \"none\"\n ? getPopoverContentProps(animation, duration)\n : {})}\n {...getPopoverProps(rest, ref)}\n animate={open ? \"enter\" : \"exit\"}\n exit=\"exit\"\n initial=\"exit\"\n onAnimationComplete={funcAll(\n onAnimationComplete,\n rest.onAnimationComplete,\n )}\n __css={computedCSS}\n >\n {customPopoverCloseButton ??\n (closeOnButton ? <PopoverCloseButton /> : null)}\n\n {cloneChildren}\n </Component>\n </ui.div>\n )\n },\n)\n\nPopoverContent.displayName = \"PopoverContent\"\nPopoverContent.__ui__ = \"PopoverContent\"\n"],"mappings":";;;;;;;;;AAIA,SAAS,UAAU;AACnB,SAAS,QAAQ,wBAAwB;AACzC,SAAS,gBAAgB,sBAAsB;AAC/C,SAAS,IAAI,cAAc,SAAS,wBAAwB;AAC5D,SAAS,eAAe;AAiIhB,SAgBqB,KAhBrB;AApHR,IAAM,yBAAyB,CAC7B,YAAuC,SACvC,aACG;AACH,QAAM,SAAS;AAAA,IACb;AAAA,IACA,OAAO,EAAE,YAAY,UAAU;AAAA,IAC/B,SAAS;AAAA,IACT,eAAe,EAAE,MAAM,EAAE,YAAY,SAAS,EAAE;AAAA,EAClD;AAEA,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,QAAQ,EAAE,GAAG,QAAQ,OAAO,KAAK;AAAA,MACnC;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,QAAQ,EAAE,GAAG,QAAQ,SAAS,GAAG,SAAS,IAAI;AAAA,MAChD;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AA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,uCAAW;AACX,wCAAY,SAAI,WAAJ,YAAc,IAAI;AAE9B,WACE;AAAA,MAAC,GAAG;AAAA,MAAH;AAAA,QACE,GAAG,eAAe;AAAA,UACjB,OAAO,EAAE,YAAY,OAAO,YAAY,SAAS;AAAA,QACnD,CAAC;AAAA,QACD,WAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA,SAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QAEJ;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,GAAG,uBAAuB,SAAS;AAAA,YAC7C,GAAI,cAAc,SACf,uBAAuB,WAAW,QAAQ,IAC1C,CAAC;AAAA,YACJ,GAAG,gBAAgB,MAAM,GAAG;AAAA,YAC7B,SAAS,OAAO,UAAU;AAAA,YAC1B,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,qBAAqB;AAAA,cACnB;AAAA,cACA,KAAK;AAAA,YACP;AAAA,YACA,OAAO;AAAA,YAEN;AAAA,4EACE,gBAAgB,oBAAC,sBAAmB,IAAK;AAAA,cAE3C;AAAA;AAAA;AAAA,QACH;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAC7B,eAAe,SAAS;","names":[]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
usePopover
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-FMZMQMLR.mjs";
|
5
5
|
|
6
6
|
// src/popover-anchor.tsx
|
7
7
|
import { Children, cloneElement } from "react";
|
@@ -16,4 +16,4 @@ PopoverAnchor.__ui__ = "PopoverAnchor";
|
|
16
16
|
export {
|
17
17
|
PopoverAnchor
|
18
18
|
};
|
19
|
-
//# sourceMappingURL=chunk-
|
19
|
+
//# sourceMappingURL=chunk-NS7I3VTN.mjs.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client"
|
2
2
|
import {
|
3
3
|
usePopover
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-FMZMQMLR.mjs";
|
5
5
|
|
6
6
|
// src/popover-header.tsx
|
7
7
|
import { forwardRef, ui } from "@yamada-ui/core";
|
@@ -33,4 +33,4 @@ PopoverHeader.__ui__ = "PopoverHeader";
|
|
33
33
|
export {
|
34
34
|
PopoverHeader
|
35
35
|
};
|
36
|
-
//# sourceMappingURL=chunk-
|
36
|
+
//# sourceMappingURL=chunk-S4GMR5U7.mjs.map
|