UNPKG

fastapi-rtk

Version:

A React component library for FastAPI in combination with FastAPI React Toolkit backend, built with Mantine, JsonForms, and Zustand.

38 lines (37 loc) 1.81 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const jsxRuntime = require("react/jsx-runtime"); const constants = require("fastapi-rtk/constants"); const hooks$1 = require("fastapi-rtk/hooks"); const core = require("@mantine/core"); const hooks = require("@mantine/hooks"); const React = require("react"); const useApi = require("../../hooks/api/useApi.cjs"); const useForms = require("../../hooks/api/useForms.cjs"); require("../../Wrappers/Provider/Contexts/LangContext.cjs"); const useTranslation = require("../../../../.external/cjs/react-i18next@15.7.3_i18next@25.5.2_react-dom@18.3.1_react@18.3.1_typescript@5.9.2/react-i18next/dist/es/useTranslation.cjs"); const IconEye = require("../../../../.external/cjs/@tabler_icons-react@3.18.0_react@18.3.1/@tabler/icons-react/dist/esm/icons/IconEye.cjs"); const View = React.memo(({ id, ...props }) => { const { getEntry } = useApi.useApi(); const { t } = useTranslation.useTranslation(); const { setOpened, setItem } = useForms.useForms("view"); const [loading, setLoading] = hooks.useDebouncedState(false, constants.DEBOUNCE_LOADING_DELAY); const actionIconProps = hooks$1.useActionIcon({ onClick: () => { setLoading(true); getEntry(id).then((entry) => { if (entry) { setItem(entry); setOpened(true); } }).catch(() => { }).finally(() => setLoading(false)); }, size: "sm", loading, ...props }); return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(core.Tooltip, { label: t("View"), children: /* @__PURE__ */ jsxRuntime.jsx(core.ActionIcon, { ...actionIconProps, children: /* @__PURE__ */ jsxRuntime.jsx(IconEye, {}) }) }) }); }); View.displayName = "View"; exports.View = View;