@hitachivantara/uikit-react-core
Version:
UI Kit Core React components.
41 lines (40 loc) • 1.37 kB
JavaScript
import { HvButton } from "../../Button/Button.js";
import { EyeIcon } from "../../Input/icons.js";
import { useClasses } from "./Preview.styles.js";
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
import { useEffect } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/FileUploader/Preview/Preview.tsx
/**
* The `HvFileUploaderPreview` component is available to facilitate the styling
* of the button (when clickable) and the detection of image unloading.
*/
var HvFileUploaderPreview = (props) => {
const { className, children, classes: classesProp, disableOverlay = false, onUnload, onClick, ...others } = useDefaultProps("HvFileUploaderPreview", props);
const { classes, cx, css } = useClasses(classesProp);
useEffect(() => {
return () => {
onUnload?.();
};
}, [onUnload]);
if (onClick) return /* @__PURE__ */ jsxs(HvButton, {
icon: true,
className: cx(classes.previewButton, className),
onClick,
...others,
children: [children, !disableOverlay && /* @__PURE__ */ jsx("div", {
className: classes.overlay,
"aria-hidden": "true",
children: /* @__PURE__ */ jsx(EyeIcon, { className: css({
position: "absolute",
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
display: "none"
}) })
})]
});
return children;
};
//#endregion
export { HvFileUploaderPreview };