UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

131 lines (130 loc) 3.54 kB
import { jsx as e, jsxs as i, Fragment as m } from "react/jsx-runtime"; import { Button as h, Tabs as g, Tab as U, Box as b } from "@mui/material"; import { forwardRef as v, useState as s, useRef as C, useImperativeHandle as I } from "react"; import { DialogBase as M } from "../DialogBase.js"; import { displayToast as P } from "../ToastMessage/ToastMessage.js"; import { EntityUpload as O } from "./EntityUpload.js"; import { LinkToURL as V } from "./LinkToURL.js"; const w = v(function(y, k) { const { entityId: d, open: L, onClose: t, onUploadReady: x } = y, [n, r] = s( 0 /* UploadFile */ ), [l, E] = s("LOADING"), [F, R] = s(!1), c = C(null), u = C(null), a = l === "PROMPT_USER" || l === "UPLOADING", T = a || l === "COMPLETE", p = n === 0 ? l !== "COMPLETE" : !F; function f() { p || (n === 0 ? t() : c.current.submit()); } return I(k, () => ({ handleUploads: (o) => { r( 0 /* UploadFile */ ), u.current?.handleUploads(o); } })), /* @__PURE__ */ e( M, { DialogProps: { onKeyUp: (o) => { o.key === "Enter" && f(); }, // SWC-4693 - For drag-and-drop upload to be ready before the modal opens, the modal contents must be mounted keepMounted: !0 }, title: "Upload or Link to File", open: L, maxWidth: "md", fullWidth: !0, content: /* @__PURE__ */ i(m, { children: [ /* @__PURE__ */ i( g, { textColor: "secondary", indicatorColor: "secondary", value: n, onChange: (o, S) => r(S), sx: { mb: 2 }, children: [ /* @__PURE__ */ e(U, { label: "Upload File", value: 0 /* UploadFile */ }), /* @__PURE__ */ e(U, { label: "Link to URL", value: 1 /* LinkToURL */ }) ] } ), /* @__PURE__ */ e( b, { sx: { display: n === 0 ? "block" : "none" }, children: /* @__PURE__ */ e( O, { ref: u, entityId: d, onStateChange: E, onUploadReady: x } ) } ), /* @__PURE__ */ e( b, { sx: { display: n === 1 ? "block" : "none" }, children: /* @__PURE__ */ e( V, { ref: c, entityId: d, onIsValidChanged: R, onSuccess: (o) => { P(`Successfully created "${o.name}"`, "success"), t(); } } ) } ) ] }), onCancel: () => { a || t(); }, hasCloseButton: !a, actions: /* @__PURE__ */ i(m, { children: [ /* @__PURE__ */ e( h, { variant: "outlined", onClick: () => { t(); }, disabled: T, children: "Cancel" } ), /* @__PURE__ */ e( h, { variant: "contained", onClick: f, disabled: p, children: "Finish" } ) ] }) } ); }); export { w as EntityUploadModal, w as default }; //# sourceMappingURL=EntityUploadModal.js.map