80 lines
3.8 KiB
JavaScript
80 lines
3.8 KiB
JavaScript
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
const require_CopilotChatConfigurationProvider = require('../../providers/CopilotChatConfigurationProvider.cjs');
|
|
const require_utils = require('../../lib/utils.cjs');
|
|
const require_slots = require('../../lib/slots.cjs');
|
|
let react = require("react");
|
|
react = require_runtime.__toESM(react);
|
|
let lucide_react = require("lucide-react");
|
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
|
//#region src/components/chat/CopilotModalHeader.tsx
|
|
function CopilotModalHeader({ title, titleContent, closeButton, children, className, ...rest }) {
|
|
const configuration = require_CopilotChatConfigurationProvider.useCopilotChatConfiguration();
|
|
const fallbackTitle = configuration?.labels.modalHeaderTitle ?? require_CopilotChatConfigurationProvider.CopilotChatDefaultLabels.modalHeaderTitle;
|
|
const resolvedTitle = title ?? fallbackTitle;
|
|
const handleClose = (0, react.useCallback)(() => {
|
|
configuration?.setModalOpen?.(false);
|
|
}, [configuration]);
|
|
const BoundTitle = require_slots.renderSlot(titleContent, CopilotModalHeader.Title, { children: resolvedTitle });
|
|
const BoundCloseButton = require_slots.renderSlot(closeButton, CopilotModalHeader.CloseButton, { onClick: handleClose });
|
|
if (children) return children({
|
|
titleContent: BoundTitle,
|
|
closeButton: BoundCloseButton,
|
|
title: resolvedTitle,
|
|
...rest
|
|
});
|
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
"data-testid": "copilot-modal-header",
|
|
"data-slot": "copilot-modal-header",
|
|
className: require_utils.cn("copilotKitHeader", "cpk:flex cpk:items-center cpk:justify-between cpk:border-b cpk:border-border cpk:px-4 cpk:py-4", "cpk:bg-background/95 cpk:backdrop-blur cpk:supports-[backdrop-filter]:bg-background/80", className),
|
|
...rest,
|
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
className: "cpk:flex cpk:w-full cpk:items-center cpk:gap-2",
|
|
children: [
|
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
className: "cpk:flex-1",
|
|
"aria-hidden": "true"
|
|
}),
|
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
className: "cpk:flex cpk:flex-1 cpk:justify-center cpk:text-center",
|
|
children: BoundTitle
|
|
}),
|
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
className: "cpk:flex cpk:flex-1 cpk:justify-end",
|
|
children: BoundCloseButton
|
|
})
|
|
]
|
|
})
|
|
});
|
|
}
|
|
CopilotModalHeader.displayName = "CopilotModalHeader";
|
|
(function(_CopilotModalHeader) {
|
|
_CopilotModalHeader.Title = ({ children, className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
"data-testid": "copilot-header-title",
|
|
className: require_utils.cn("cpk:w-full cpk:text-base cpk:font-medium cpk:leading-none cpk:tracking-tight cpk:text-foreground", className),
|
|
...props,
|
|
children
|
|
});
|
|
_CopilotModalHeader.CloseButton = ({ className, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
type: "button",
|
|
"data-testid": "copilot-close-button",
|
|
className: require_utils.cn("cpk:inline-flex cpk:size-8 cpk:items-center cpk:justify-center cpk:rounded-full cpk:text-muted-foreground cpk:transition cpk:cursor-pointer", "cpk:hover:bg-muted cpk:hover:text-foreground cpk:focus-visible:outline-none cpk:focus-visible:ring-2 cpk:focus-visible:ring-ring", className),
|
|
"aria-label": "Close",
|
|
...props,
|
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
|
|
className: "cpk:h-4 cpk:w-4",
|
|
"aria-hidden": "true"
|
|
})
|
|
});
|
|
})(CopilotModalHeader || (CopilotModalHeader = {}));
|
|
CopilotModalHeader.Title.displayName = "CopilotModalHeader.Title";
|
|
CopilotModalHeader.CloseButton.displayName = "CopilotModalHeader.CloseButton";
|
|
|
|
//#endregion
|
|
Object.defineProperty(exports, 'CopilotModalHeader', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return CopilotModalHeader;
|
|
}
|
|
});
|
|
//# sourceMappingURL=CopilotModalHeader.cjs.map
|