UNPKG

@roochnetwork/rooch-sdk-kit

Version:
167 lines (152 loc) 7.41 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/components/ui/Modal.tsx var Modal_exports = {}; __export(Modal_exports, { Modal: () => Modal }); module.exports = __toCommonJS(Modal_exports); var import_react4 = require("react"); var Dialog = __toESM(require("@radix-ui/react-dialog"), 1); // src/components/ui/Modal.css.ts var closeButtonContainer = "Modal_closeButtonContainer__1c5z17f2"; var content = "Modal_content__1c5z17f1"; var overlay = "Modal_overlay__1c5z17f0"; // src/components/styling/StyleMarker.tsx var import_react_slot = require("@radix-ui/react-slot"); var import_react = require("react"); // src/constants/styleDataAttribute.ts var styleDataAttributeName = "data-sdk-kit"; var styleDataAttributeSelector = `[${styleDataAttributeName}]`; var styleDataAttribute = { [styleDataAttributeName]: "" }; // src/components/styling/StyleMarker.tsx var import_jsx_runtime = require("react/jsx-runtime"); var StyleMarker = (0, import_react.forwardRef)(({ children, ...props }, forwardedRef) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_slot.Slot, { ref: forwardedRef, ...props, ...styleDataAttribute, children })); StyleMarker.displayName = "StyleMarker"; // src/components/ProgressProvider.tsx var import_react2 = require("react"); // src/components/fauct-modal/views/FaucetView.css.ts var progressBar = "FaucetView_progressBar__1ff62y03"; // src/components/ui/Progress.tsx var import_jsx_runtime2 = require("react/jsx-runtime"); function Progress() { const { progress } = useProgress(); return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: progressBar, style: { width: `${progress}%` } }); } // src/components/ProgressProvider.tsx var import_jsx_runtime3 = require("react/jsx-runtime"); var ProgressProviderContext = (0, import_react2.createContext)(null); var ProgressProvider = ({ children }) => { const [progress, setProgress] = (0, import_react2.useState)(0); const [loading, setLoading] = (0, import_react2.useState)(false); const start = (0, import_react2.useCallback)(() => { setLoading(true); setProgress(0); const interval = setInterval(() => { setProgress((prev) => { const nextProgress = prev + 10; if (nextProgress >= 70) { clearInterval(interval); } return Math.min(nextProgress, 70); }); }, 100); }, []); const finish = (0, import_react2.useCallback)((callback) => { const interval = setInterval(() => { setProgress((prev) => { const nextProgress = prev + 5; if (nextProgress >= 100) { clearInterval(interval); setTimeout(() => { setLoading(false); if (callback) { callback(); } }, 300); } return Math.min(nextProgress, 100); }); }, 50); }, []); return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ProgressProviderContext.Provider, { value: { loading, progress, start, finish }, children: [ children, loading && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Progress, {}) ] }); }; var useProgress = () => { const ctx = (0, import_react2.useContext)(ProgressProviderContext); if (!ctx) { throw new Error("useSubscribeToError must be used within a GlobalProvider"); } return ctx; }; // src/components/ui/IconButton.tsx var import_react_slot2 = require("@radix-ui/react-slot"); var import_clsx = __toESM(require("clsx"), 1); var import_react3 = require("react"); // src/components/ui/IconButton.css.ts var container = "IconButton_container__5zr4fg0"; // src/components/ui/IconButton.tsx var import_jsx_runtime4 = require("react/jsx-runtime"); var IconButton = (0, import_react3.forwardRef)( ({ className, asChild = false, ...props }, forwardedRef) => { const Comp = asChild ? import_react_slot2.Slot : "button"; return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Comp, { ...props, className: (0, import_clsx.default)(container, className), ref: forwardedRef }); } ); IconButton.displayName = "Button"; // src/components/icons/CloseIcon.tsx var import_jsx_runtime5 = require("react/jsx-runtime"); function CloseIcon(props) { return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: 10, height: 10, fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)( "path", { d: "M9.708.292a.999.999 0 0 0-1.413 0l-3.289 3.29L1.717.291A.999.999 0 0 0 .305 1.705l3.289 3.289-3.29 3.289a.999.999 0 1 0 1.413 1.412l3.29-3.289 3.288 3.29a.999.999 0 0 0 1.413-1.413l-3.29-3.29 3.29-3.288a.999.999 0 0 0 0-1.413Z", fill: "currentColor" } ) }); } // src/components/ui/Modal.tsx var import_jsx_runtime6 = require("react/jsx-runtime"); function Modal({ trigger, children, open, defaultOpen, onOpenChange }) { const [isModalOpen, setModalOpen] = (0, import_react4.useState)(open ?? defaultOpen); const handleOpenChange = (open2) => { setModalOpen(open2); onOpenChange?.(open2); }; return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Dialog.Root, { open: open ?? isModalOpen, onOpenChange: handleOpenChange, children: [ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog.Trigger, { asChild: true, children: trigger }), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StyleMarker, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog.Overlay, { className: overlay, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Dialog.Content, { className: content, "aria-describedby": void 0, children: [ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProgressProvider, { children }), /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Dialog.Close, { className: closeButtonContainer, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(IconButton, { type: "button", "aria-label": "Close", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CloseIcon, {}) }) }) ] }) }) }) }) ] }); } //# sourceMappingURL=Modal.js.map