@yamada-ui/popover 0.1.0
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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/chunk-DQEXAU5O.mjs +229 -0
- package/dist/chunk-O75PU3DP.mjs +216 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +458 -0
- package/dist/index.mjs +24 -0
- package/dist/popover-anchor.d.ts +5 -0
- package/dist/popover-anchor.js +51 -0
- package/dist/popover-anchor.mjs +7 -0
- package/dist/popover-body.d.ts +7 -0
- package/dist/popover-body.js +58 -0
- package/dist/popover-body.mjs +7 -0
- package/dist/popover-close-button.d.ts +7 -0
- package/dist/popover-close-button.js +72 -0
- package/dist/popover-close-button.mjs +7 -0
- package/dist/popover-content.d.ts +8 -0
- package/dist/popover-content.js +173 -0
- package/dist/popover-content.mjs +7 -0
- package/dist/popover-footer.d.ts +7 -0
- package/dist/popover-footer.js +60 -0
- package/dist/popover-footer.mjs +7 -0
- package/dist/popover-header.d.ts +7 -0
- package/dist/popover-header.js +60 -0
- package/dist/popover-header.mjs +7 -0
- package/dist/popover-trigger.d.ts +5 -0
- package/dist/popover-trigger.js +51 -0
- package/dist/popover-trigger.mjs +7 -0
- package/dist/popover.d.ts +45 -0
- package/dist/popover.js +247 -0
- package/dist/popover.mjs +8 -0
- package/package.json +82 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Popover: () => Popover,
|
|
24
|
+
PopoverAnchor: () => PopoverAnchor,
|
|
25
|
+
PopoverBody: () => PopoverBody,
|
|
26
|
+
PopoverCloseButton: () => PopoverCloseButton,
|
|
27
|
+
PopoverContent: () => PopoverContent,
|
|
28
|
+
PopoverFooter: () => PopoverFooter,
|
|
29
|
+
PopoverHeader: () => PopoverHeader,
|
|
30
|
+
PopoverTrigger: () => PopoverTrigger,
|
|
31
|
+
usePopover: () => usePopover
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(src_exports);
|
|
34
|
+
|
|
35
|
+
// src/popover.tsx
|
|
36
|
+
var import_core = require("@yamada-ui/core");
|
|
37
|
+
var import_use_animation = require("@yamada-ui/use-animation");
|
|
38
|
+
var import_use_disclosure = require("@yamada-ui/use-disclosure");
|
|
39
|
+
var import_use_focus = require("@yamada-ui/use-focus");
|
|
40
|
+
var import_use_popper = require("@yamada-ui/use-popper");
|
|
41
|
+
var import_utils = require("@yamada-ui/utils");
|
|
42
|
+
var import_react = require("react");
|
|
43
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
+
var [PopoverProvider, usePopover] = (0, import_utils.createContext)({
|
|
45
|
+
strict: false,
|
|
46
|
+
name: "PopoverContext"
|
|
47
|
+
});
|
|
48
|
+
var Popover = (props) => {
|
|
49
|
+
const [styles, mergedProps] = (0, import_core.useMultiComponentStyle)("Popover", props);
|
|
50
|
+
const {
|
|
51
|
+
children,
|
|
52
|
+
initialFocusRef,
|
|
53
|
+
restoreFocus = true,
|
|
54
|
+
autoFocus = true,
|
|
55
|
+
closeOnBlur = true,
|
|
56
|
+
closeOnEsc = true,
|
|
57
|
+
closeOnButton = true,
|
|
58
|
+
trigger = "click",
|
|
59
|
+
openDelay = 200,
|
|
60
|
+
closeDelay = 200,
|
|
61
|
+
isLazy,
|
|
62
|
+
lazyBehavior = "unmount",
|
|
63
|
+
animation = "scale",
|
|
64
|
+
duration,
|
|
65
|
+
...rest
|
|
66
|
+
} = (0, import_core.omitThemeProps)(mergedProps);
|
|
67
|
+
const [isOpen, onOpen, onClose, onToggle] = (0, import_use_disclosure.useDisclosure)(mergedProps);
|
|
68
|
+
const anchorRef = (0, import_react.useRef)(null);
|
|
69
|
+
const triggerRef = (0, import_react.useRef)(null);
|
|
70
|
+
const popoverRef = (0, import_react.useRef)(null);
|
|
71
|
+
const { present, onAnimationComplete } = (0, import_use_animation.useAnimationObserver)({ isOpen, ref: popoverRef });
|
|
72
|
+
const openTimeout = (0, import_react.useRef)(void 0);
|
|
73
|
+
const closeTimeout = (0, import_react.useRef)(void 0);
|
|
74
|
+
const isHoveringRef = (0, import_react.useRef)(false);
|
|
75
|
+
const hasBeenOpened = (0, import_react.useRef)(false);
|
|
76
|
+
if (isOpen)
|
|
77
|
+
hasBeenOpened.current = true;
|
|
78
|
+
const { referenceRef, getPopperProps, forceUpdate, transformOrigin } = (0, import_use_popper.usePopper)({
|
|
79
|
+
...rest,
|
|
80
|
+
enabled: isOpen
|
|
81
|
+
});
|
|
82
|
+
(0, import_react.useEffect)(() => {
|
|
83
|
+
return () => {
|
|
84
|
+
if (openTimeout.current)
|
|
85
|
+
clearTimeout(openTimeout.current);
|
|
86
|
+
if (closeTimeout.current)
|
|
87
|
+
clearTimeout(closeTimeout.current);
|
|
88
|
+
};
|
|
89
|
+
}, []);
|
|
90
|
+
(0, import_use_focus.useFocusOnPointerDown)({
|
|
91
|
+
enabled: isOpen,
|
|
92
|
+
ref: triggerRef
|
|
93
|
+
});
|
|
94
|
+
(0, import_use_focus.useFocusOnHide)(popoverRef, {
|
|
95
|
+
focusRef: triggerRef,
|
|
96
|
+
visible: isOpen,
|
|
97
|
+
shouldFocus: restoreFocus && trigger === "click"
|
|
98
|
+
});
|
|
99
|
+
(0, import_use_focus.useFocusOnShow)(popoverRef, {
|
|
100
|
+
focusRef: initialFocusRef,
|
|
101
|
+
visible: isOpen,
|
|
102
|
+
shouldFocus: autoFocus && trigger === "click"
|
|
103
|
+
});
|
|
104
|
+
const shouldRenderChildren = (0, import_use_disclosure.useLazyDisclosure)({
|
|
105
|
+
wasSelected: hasBeenOpened.current,
|
|
106
|
+
enabled: isLazy,
|
|
107
|
+
mode: lazyBehavior,
|
|
108
|
+
isSelected: present
|
|
109
|
+
});
|
|
110
|
+
const getPopoverProps = (0, import_react.useCallback)(
|
|
111
|
+
(props2 = {}, ref = null) => {
|
|
112
|
+
const popoverProps = {
|
|
113
|
+
...props2,
|
|
114
|
+
style: {
|
|
115
|
+
...props2.style,
|
|
116
|
+
transformOrigin
|
|
117
|
+
},
|
|
118
|
+
ref: (0, import_utils.mergeRefs)(popoverRef, ref),
|
|
119
|
+
children: shouldRenderChildren ? props2.children : null,
|
|
120
|
+
tabIndex: -1,
|
|
121
|
+
onKeyDown: (0, import_utils.handlerAll)(props2.onKeyDown, (event) => {
|
|
122
|
+
if (closeOnEsc && event.key === "Escape")
|
|
123
|
+
onClose();
|
|
124
|
+
}),
|
|
125
|
+
onBlur: (0, import_utils.handlerAll)(props2.onBlur, (event) => {
|
|
126
|
+
const relatedTarget = (0, import_utils.getEventRelatedTarget)(event);
|
|
127
|
+
const targetIsPopover = (0, import_utils.isContains)(popoverRef.current, relatedTarget);
|
|
128
|
+
const targetIsTrigger = (0, import_utils.isContains)(triggerRef.current, relatedTarget);
|
|
129
|
+
const isValidBlur = !targetIsPopover && !targetIsTrigger;
|
|
130
|
+
if (isOpen && closeOnBlur && isValidBlur)
|
|
131
|
+
onClose();
|
|
132
|
+
})
|
|
133
|
+
};
|
|
134
|
+
if (trigger === "hover") {
|
|
135
|
+
popoverProps.onMouseEnter = (0, import_utils.handlerAll)(props2.onMouseEnter, () => {
|
|
136
|
+
isHoveringRef.current = true;
|
|
137
|
+
});
|
|
138
|
+
popoverProps.onMouseLeave = (0, import_utils.handlerAll)(props2.onMouseLeave, (event) => {
|
|
139
|
+
if (event.nativeEvent.relatedTarget === null)
|
|
140
|
+
return;
|
|
141
|
+
isHoveringRef.current = false;
|
|
142
|
+
setTimeout(onClose, closeDelay);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return popoverProps;
|
|
146
|
+
},
|
|
147
|
+
[
|
|
148
|
+
closeDelay,
|
|
149
|
+
closeOnBlur,
|
|
150
|
+
closeOnEsc,
|
|
151
|
+
isOpen,
|
|
152
|
+
onClose,
|
|
153
|
+
shouldRenderChildren,
|
|
154
|
+
transformOrigin,
|
|
155
|
+
trigger
|
|
156
|
+
]
|
|
157
|
+
);
|
|
158
|
+
const maybeReferenceRef = (0, import_react.useCallback)(
|
|
159
|
+
(node) => {
|
|
160
|
+
if (anchorRef.current == null)
|
|
161
|
+
referenceRef(node);
|
|
162
|
+
},
|
|
163
|
+
[referenceRef]
|
|
164
|
+
);
|
|
165
|
+
const getTriggerProps = (0, import_react.useCallback)(
|
|
166
|
+
(props2 = {}, ref = null) => {
|
|
167
|
+
const triggerProps = {
|
|
168
|
+
...props2,
|
|
169
|
+
ref: (0, import_utils.mergeRefs)(triggerRef, ref, maybeReferenceRef)
|
|
170
|
+
};
|
|
171
|
+
if (trigger === "click")
|
|
172
|
+
triggerProps.onClick = (0, import_utils.handlerAll)(props2.onClick, onToggle);
|
|
173
|
+
if (trigger === "hover") {
|
|
174
|
+
triggerProps.onFocus = (0, import_utils.handlerAll)(props2.onFocus, () => {
|
|
175
|
+
if (openTimeout.current === void 0)
|
|
176
|
+
onOpen();
|
|
177
|
+
});
|
|
178
|
+
triggerProps.onBlur = (0, import_utils.handlerAll)(props2.onBlur, (event) => {
|
|
179
|
+
const relatedTarget = (0, import_utils.getEventRelatedTarget)(event);
|
|
180
|
+
const isValidBlur = !(0, import_utils.isContains)(popoverRef.current, relatedTarget);
|
|
181
|
+
if (isOpen && closeOnBlur && isValidBlur)
|
|
182
|
+
onClose();
|
|
183
|
+
});
|
|
184
|
+
triggerProps.onKeyDown = (0, import_utils.handlerAll)(props2.onKeyDown, (event) => {
|
|
185
|
+
if (event.key === "Escape")
|
|
186
|
+
onClose();
|
|
187
|
+
});
|
|
188
|
+
triggerProps.onMouseEnter = (0, import_utils.handlerAll)(props2.onMouseEnter, () => {
|
|
189
|
+
isHoveringRef.current = true;
|
|
190
|
+
openTimeout.current = window.setTimeout(onOpen, openDelay);
|
|
191
|
+
});
|
|
192
|
+
triggerProps.onMouseLeave = (0, import_utils.handlerAll)(props2.onMouseLeave, () => {
|
|
193
|
+
isHoveringRef.current = false;
|
|
194
|
+
if (openTimeout.current) {
|
|
195
|
+
clearTimeout(openTimeout.current);
|
|
196
|
+
openTimeout.current = void 0;
|
|
197
|
+
}
|
|
198
|
+
closeTimeout.current = window.setTimeout(() => {
|
|
199
|
+
if (isHoveringRef.current === false)
|
|
200
|
+
onClose();
|
|
201
|
+
}, closeDelay);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return triggerProps;
|
|
205
|
+
},
|
|
206
|
+
[
|
|
207
|
+
closeDelay,
|
|
208
|
+
closeOnBlur,
|
|
209
|
+
isOpen,
|
|
210
|
+
maybeReferenceRef,
|
|
211
|
+
onClose,
|
|
212
|
+
onOpen,
|
|
213
|
+
onToggle,
|
|
214
|
+
openDelay,
|
|
215
|
+
trigger
|
|
216
|
+
]
|
|
217
|
+
);
|
|
218
|
+
const getAnchorProps = (0, import_react.useCallback)(
|
|
219
|
+
(props2 = {}, ref = null) => {
|
|
220
|
+
return {
|
|
221
|
+
...props2,
|
|
222
|
+
ref: (0, import_utils.mergeRefs)(ref, anchorRef, referenceRef)
|
|
223
|
+
};
|
|
224
|
+
},
|
|
225
|
+
[anchorRef, referenceRef]
|
|
226
|
+
);
|
|
227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
228
|
+
PopoverProvider,
|
|
229
|
+
{
|
|
230
|
+
value: {
|
|
231
|
+
isOpen,
|
|
232
|
+
onClose,
|
|
233
|
+
closeOnButton,
|
|
234
|
+
onAnimationComplete,
|
|
235
|
+
forceUpdate,
|
|
236
|
+
getTriggerProps,
|
|
237
|
+
getAnchorProps,
|
|
238
|
+
getPopperProps,
|
|
239
|
+
getPopoverProps,
|
|
240
|
+
animation,
|
|
241
|
+
duration,
|
|
242
|
+
styles
|
|
243
|
+
},
|
|
244
|
+
children: (0, import_utils.runIfFunc)(children, {
|
|
245
|
+
isOpen,
|
|
246
|
+
onClose,
|
|
247
|
+
forceUpdate
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// src/popover-trigger.tsx
|
|
254
|
+
var import_react2 = require("react");
|
|
255
|
+
var PopoverTrigger = ({ children }) => {
|
|
256
|
+
const child = import_react2.Children.only(children);
|
|
257
|
+
const { getTriggerProps } = usePopover();
|
|
258
|
+
return (0, import_react2.cloneElement)(child, getTriggerProps(child.props, child.ref));
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
// src/popover-anchor.tsx
|
|
262
|
+
var import_react3 = require("react");
|
|
263
|
+
var PopoverAnchor = ({ children }) => {
|
|
264
|
+
const child = import_react3.Children.only(children);
|
|
265
|
+
const { getAnchorProps } = usePopover();
|
|
266
|
+
return (0, import_react3.cloneElement)(child, getAnchorProps(child.props, child.ref));
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// src/popover-close-button.tsx
|
|
270
|
+
var import_close_button = require("@yamada-ui/close-button");
|
|
271
|
+
var import_core2 = require("@yamada-ui/core");
|
|
272
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
273
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
274
|
+
var PopoverCloseButton = (0, import_core2.forwardRef)(
|
|
275
|
+
({ onClick, ...rest }, ref) => {
|
|
276
|
+
const { styles, onClose } = usePopover();
|
|
277
|
+
const css = {
|
|
278
|
+
position: "absolute",
|
|
279
|
+
...styles.closeButton
|
|
280
|
+
};
|
|
281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
282
|
+
import_close_button.CloseButton,
|
|
283
|
+
{
|
|
284
|
+
ref,
|
|
285
|
+
className: (0, import_utils2.cx)("ui-popover-close-button"),
|
|
286
|
+
__css: css,
|
|
287
|
+
onClick: (0, import_utils2.handlerAll)(onClick, (event) => {
|
|
288
|
+
event.stopPropagation();
|
|
289
|
+
onClose == null ? void 0 : onClose();
|
|
290
|
+
}),
|
|
291
|
+
size: "sm",
|
|
292
|
+
...rest
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
// src/popover-content.tsx
|
|
299
|
+
var import_core3 = require("@yamada-ui/core");
|
|
300
|
+
var import_motion = require("@yamada-ui/motion");
|
|
301
|
+
var import_transitions = require("@yamada-ui/transitions");
|
|
302
|
+
var import_utils3 = require("@yamada-ui/utils");
|
|
303
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
304
|
+
var getPopoverContentProps = (animation = "scale", duration) => {
|
|
305
|
+
const custom = {
|
|
306
|
+
reverse: true,
|
|
307
|
+
duration,
|
|
308
|
+
enter: { visibility: "visible" },
|
|
309
|
+
transitionEnd: { exit: { visibility: "hidden" } }
|
|
310
|
+
};
|
|
311
|
+
switch (animation) {
|
|
312
|
+
case "scale":
|
|
313
|
+
return {
|
|
314
|
+
...import_transitions.scaleFadeProps,
|
|
315
|
+
custom: { ...custom, scale: 0.95 }
|
|
316
|
+
};
|
|
317
|
+
case "top":
|
|
318
|
+
return {
|
|
319
|
+
...import_transitions.slideFadeProps,
|
|
320
|
+
custom: { ...custom, offsetX: 0, offsetY: -16 }
|
|
321
|
+
};
|
|
322
|
+
case "right":
|
|
323
|
+
return {
|
|
324
|
+
...import_transitions.slideFadeProps,
|
|
325
|
+
custom: { ...custom, offsetX: 16, offsetY: 0 }
|
|
326
|
+
};
|
|
327
|
+
case "left":
|
|
328
|
+
return {
|
|
329
|
+
...import_transitions.slideFadeProps,
|
|
330
|
+
custom: { ...custom, offsetX: -16, offsetY: 0 }
|
|
331
|
+
};
|
|
332
|
+
case "bottom":
|
|
333
|
+
return {
|
|
334
|
+
...import_transitions.slideFadeProps,
|
|
335
|
+
custom: { ...custom, offsetX: 0, offsetY: 16 }
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
var PopoverContent = (0, import_core3.forwardRef)(
|
|
340
|
+
({ as = "section", className, children, w, width, minW, minWidth, zIndex, __css, ...rest }, ref) => {
|
|
341
|
+
var _a, _b, _c, _d;
|
|
342
|
+
const {
|
|
343
|
+
isOpen,
|
|
344
|
+
closeOnButton,
|
|
345
|
+
getPopperProps,
|
|
346
|
+
getPopoverProps,
|
|
347
|
+
onAnimationComplete,
|
|
348
|
+
animation,
|
|
349
|
+
duration,
|
|
350
|
+
styles
|
|
351
|
+
} = usePopover();
|
|
352
|
+
const validChildren = (0, import_utils3.getValidChildren)(children);
|
|
353
|
+
const [customPopoverCloseButton, ...cloneChildren] = (0, import_utils3.findChildren)(
|
|
354
|
+
validChildren,
|
|
355
|
+
PopoverCloseButton
|
|
356
|
+
);
|
|
357
|
+
const css = {
|
|
358
|
+
position: "relative",
|
|
359
|
+
w: "100%",
|
|
360
|
+
display: "flex",
|
|
361
|
+
flexDirection: "column",
|
|
362
|
+
outline: 0,
|
|
363
|
+
...(0, import_utils3.omitObject)(__css != null ? __css : styles.container, ["zIndex"])
|
|
364
|
+
};
|
|
365
|
+
w = (_b = w != null ? w : width) != null ? _b : (_a = styles.container.w) != null ? _a : styles.container.width;
|
|
366
|
+
minW = (_d = minW != null ? minW : minWidth) != null ? _d : (_c = styles.container.minW) != null ? _c : styles.container.minWidth;
|
|
367
|
+
zIndex = zIndex != null ? zIndex : styles.container.zIndex;
|
|
368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
369
|
+
import_core3.ui.div,
|
|
370
|
+
{
|
|
371
|
+
...getPopperProps({ style: { visibility: isOpen ? "visible" : "hidden" } }),
|
|
372
|
+
className: "ui-popover",
|
|
373
|
+
w,
|
|
374
|
+
minW,
|
|
375
|
+
zIndex,
|
|
376
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
377
|
+
import_core3.ui.section,
|
|
378
|
+
{
|
|
379
|
+
as: import_motion.motion[as],
|
|
380
|
+
className: (0, import_utils3.cx)("ui-popover-content", className),
|
|
381
|
+
...animation !== "none" ? getPopoverContentProps(animation, duration) : {},
|
|
382
|
+
...getPopoverProps(rest, ref),
|
|
383
|
+
initial: "exit",
|
|
384
|
+
animate: isOpen ? "enter" : "exit",
|
|
385
|
+
exit: "exit",
|
|
386
|
+
onAnimationComplete: (0, import_utils3.funcAll)(onAnimationComplete, rest.onAnimationComplete),
|
|
387
|
+
__css: css,
|
|
388
|
+
children: [
|
|
389
|
+
customPopoverCloseButton != null ? customPopoverCloseButton : closeOnButton ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PopoverCloseButton, {}) : null,
|
|
390
|
+
cloneChildren
|
|
391
|
+
]
|
|
392
|
+
}
|
|
393
|
+
)
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
// src/popover-header.tsx
|
|
400
|
+
var import_core4 = require("@yamada-ui/core");
|
|
401
|
+
var import_utils4 = require("@yamada-ui/utils");
|
|
402
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
403
|
+
var PopoverHeader = (0, import_core4.forwardRef)(
|
|
404
|
+
({ className, ...rest }, ref) => {
|
|
405
|
+
const { styles } = usePopover();
|
|
406
|
+
const css = {
|
|
407
|
+
display: "flex",
|
|
408
|
+
alignItems: "center",
|
|
409
|
+
justifyContent: "flex-start",
|
|
410
|
+
...styles.header
|
|
411
|
+
};
|
|
412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.ui.header, { ref, className: (0, import_utils4.cx)("ui-popover-header", className), __css: css, ...rest });
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
// src/popover-body.tsx
|
|
417
|
+
var import_core5 = require("@yamada-ui/core");
|
|
418
|
+
var import_utils5 = require("@yamada-ui/utils");
|
|
419
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
420
|
+
var PopoverBody = (0, import_core5.forwardRef)(({ className, ...rest }, ref) => {
|
|
421
|
+
const { styles } = usePopover();
|
|
422
|
+
const css = {
|
|
423
|
+
display: "flex",
|
|
424
|
+
flexDirection: "column",
|
|
425
|
+
alignItems: "flex-start",
|
|
426
|
+
...styles.body
|
|
427
|
+
};
|
|
428
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_core5.ui.main, { ref, className: (0, import_utils5.cx)("ui-popover-body", className), __css: css, ...rest });
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
// src/popover-footer.tsx
|
|
432
|
+
var import_core6 = require("@yamada-ui/core");
|
|
433
|
+
var import_utils6 = require("@yamada-ui/utils");
|
|
434
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
435
|
+
var PopoverFooter = (0, import_core6.forwardRef)(
|
|
436
|
+
({ className, ...rest }, ref) => {
|
|
437
|
+
const { styles } = usePopover();
|
|
438
|
+
const css = {
|
|
439
|
+
display: "flex",
|
|
440
|
+
alignItems: "center",
|
|
441
|
+
justifyContent: "flex-start",
|
|
442
|
+
...styles.footer
|
|
443
|
+
};
|
|
444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core6.ui.footer, { ref, className: (0, import_utils6.cx)("ui-popover-footer", className), __css: css, ...rest });
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
448
|
+
0 && (module.exports = {
|
|
449
|
+
Popover,
|
|
450
|
+
PopoverAnchor,
|
|
451
|
+
PopoverBody,
|
|
452
|
+
PopoverCloseButton,
|
|
453
|
+
PopoverContent,
|
|
454
|
+
PopoverFooter,
|
|
455
|
+
PopoverHeader,
|
|
456
|
+
PopoverTrigger,
|
|
457
|
+
usePopover
|
|
458
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PopoverAnchor,
|
|
3
|
+
PopoverBody,
|
|
4
|
+
PopoverCloseButton,
|
|
5
|
+
PopoverContent,
|
|
6
|
+
PopoverFooter,
|
|
7
|
+
PopoverHeader,
|
|
8
|
+
PopoverTrigger
|
|
9
|
+
} from "./chunk-O75PU3DP.mjs";
|
|
10
|
+
import {
|
|
11
|
+
Popover,
|
|
12
|
+
usePopover
|
|
13
|
+
} from "./chunk-DQEXAU5O.mjs";
|
|
14
|
+
export {
|
|
15
|
+
Popover,
|
|
16
|
+
PopoverAnchor,
|
|
17
|
+
PopoverBody,
|
|
18
|
+
PopoverCloseButton,
|
|
19
|
+
PopoverContent,
|
|
20
|
+
PopoverFooter,
|
|
21
|
+
PopoverHeader,
|
|
22
|
+
PopoverTrigger,
|
|
23
|
+
usePopover
|
|
24
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/popover-anchor.tsx
|
|
21
|
+
var popover_anchor_exports = {};
|
|
22
|
+
__export(popover_anchor_exports, {
|
|
23
|
+
PopoverAnchor: () => PopoverAnchor
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(popover_anchor_exports);
|
|
26
|
+
var import_react2 = require("react");
|
|
27
|
+
|
|
28
|
+
// src/popover.tsx
|
|
29
|
+
var import_core = require("@yamada-ui/core");
|
|
30
|
+
var import_use_animation = require("@yamada-ui/use-animation");
|
|
31
|
+
var import_use_disclosure = require("@yamada-ui/use-disclosure");
|
|
32
|
+
var import_use_focus = require("@yamada-ui/use-focus");
|
|
33
|
+
var import_use_popper = require("@yamada-ui/use-popper");
|
|
34
|
+
var import_utils = require("@yamada-ui/utils");
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var [PopoverProvider, usePopover] = (0, import_utils.createContext)({
|
|
38
|
+
strict: false,
|
|
39
|
+
name: "PopoverContext"
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// src/popover-anchor.tsx
|
|
43
|
+
var PopoverAnchor = ({ children }) => {
|
|
44
|
+
const child = import_react2.Children.only(children);
|
|
45
|
+
const { getAnchorProps } = usePopover();
|
|
46
|
+
return (0, import_react2.cloneElement)(child, getAnchorProps(child.props, child.ref));
|
|
47
|
+
};
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
PopoverAnchor
|
|
51
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { HTMLUIProps } from '@yamada-ui/core';
|
|
3
|
+
|
|
4
|
+
type PopoverBodyProps = HTMLUIProps<'main'>;
|
|
5
|
+
declare const PopoverBody: _yamada_ui_core.Component<"main", PopoverBodyProps>;
|
|
6
|
+
|
|
7
|
+
export { PopoverBody, PopoverBodyProps };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/popover-body.tsx
|
|
21
|
+
var popover_body_exports = {};
|
|
22
|
+
__export(popover_body_exports, {
|
|
23
|
+
PopoverBody: () => PopoverBody
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(popover_body_exports);
|
|
26
|
+
var import_core2 = require("@yamada-ui/core");
|
|
27
|
+
var import_utils2 = require("@yamada-ui/utils");
|
|
28
|
+
|
|
29
|
+
// src/popover.tsx
|
|
30
|
+
var import_core = require("@yamada-ui/core");
|
|
31
|
+
var import_use_animation = require("@yamada-ui/use-animation");
|
|
32
|
+
var import_use_disclosure = require("@yamada-ui/use-disclosure");
|
|
33
|
+
var import_use_focus = require("@yamada-ui/use-focus");
|
|
34
|
+
var import_use_popper = require("@yamada-ui/use-popper");
|
|
35
|
+
var import_utils = require("@yamada-ui/utils");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
var [PopoverProvider, usePopover] = (0, import_utils.createContext)({
|
|
39
|
+
strict: false,
|
|
40
|
+
name: "PopoverContext"
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/popover-body.tsx
|
|
44
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
45
|
+
var PopoverBody = (0, import_core2.forwardRef)(({ className, ...rest }, ref) => {
|
|
46
|
+
const { styles } = usePopover();
|
|
47
|
+
const css = {
|
|
48
|
+
display: "flex",
|
|
49
|
+
flexDirection: "column",
|
|
50
|
+
alignItems: "flex-start",
|
|
51
|
+
...styles.body
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.ui.main, { ref, className: (0, import_utils2.cx)("ui-popover-body", className), __css: css, ...rest });
|
|
54
|
+
});
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
PopoverBody
|
|
58
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as _yamada_ui_core from '@yamada-ui/core';
|
|
2
|
+
import { CloseButtonProps } from '@yamada-ui/close-button';
|
|
3
|
+
|
|
4
|
+
type PopoverCloseButtonProps = CloseButtonProps;
|
|
5
|
+
declare const PopoverCloseButton: _yamada_ui_core.Component<"button", CloseButtonProps>;
|
|
6
|
+
|
|
7
|
+
export { PopoverCloseButton, PopoverCloseButtonProps };
|