2024-06-15 00:55:43 +03:00

68 lines
3.0 KiB
JavaScript

"use client";
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/popover-trigger.tsx
var popover_trigger_exports = {};
__export(popover_trigger_exports, {
default: () => popover_trigger_default
});
module.exports = __toCommonJS(popover_trigger_exports);
var import_react = require("react");
var import_system = require("@nextui-org/system");
var import_react_utils2 = require("@nextui-org/react-utils");
var import_use_aria_button = require("@nextui-org/use-aria-button");
var import_button = require("@nextui-org/button");
var import_utils = require("@react-aria/utils");
// src/popover-context.ts
var import_react_utils = require("@nextui-org/react-utils");
var [PopoverProvider, usePopoverContext] = (0, import_react_utils.createContext)({
name: "PopoverContext",
errorMessage: "usePopoverContext: `context` is undefined. Seems you forgot to wrap all popover components within `<Popover />`"
});
// src/popover-trigger.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var PopoverTrigger = (0, import_system.forwardRef)((props, _) => {
const { triggerRef, getTriggerProps } = usePopoverContext();
const { children, ...otherProps } = props;
const child = (0, import_react.useMemo)(() => {
if (typeof children === "string")
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children });
return import_react.Children.only(children);
}, [children]);
const { onPress, isDisabled, ...restProps } = (0, import_react.useMemo)(() => {
return getTriggerProps((0, import_utils.mergeProps)(otherProps, child.props), child.ref);
}, [getTriggerProps, child.props, otherProps, child.ref]);
const [, triggerChildren] = (0, import_react_utils2.pickChildren)(children, import_button.Button);
const { buttonProps } = (0, import_use_aria_button.useAriaButton)({ onPress, isDisabled }, triggerRef);
const hasNextUIButton = (0, import_react.useMemo)(() => {
return (triggerChildren == null ? void 0 : triggerChildren[0]) !== void 0;
}, [triggerChildren]);
return (0, import_react.cloneElement)(
child,
(0, import_utils.mergeProps)(restProps, hasNextUIButton ? { onPress, isDisabled } : buttonProps)
);
});
PopoverTrigger.displayName = "NextUI.PopoverTrigger";
var popover_trigger_default = PopoverTrigger;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {});