UNPKG

@payfit/unity-components

Version:

53 lines (52 loc) 1.62 kB
import { Button as e } from "../../button/Button.js"; import { InlineFieldGroupContext as t } from "../InlineFieldGroup.context.js"; import { useContext as n } from "react"; import { uyTv as r } from "@payfit/unity-themes"; import { jsx as i, jsxs as a } from "react/jsx-runtime"; import { useIntl as o } from "react-intl"; //#region src/components/inline-field-group/parts/InlineFieldGroupEditView.tsx var s = r({ slots: { fieldset: "uy:border-0 uy:p-0 uy:m-0", legend: "uy:sr-only", fieldsContainer: "uy:flex uy:flex-col uy:gap-250", hiddenButtons: "uy:sr-only" } }); function c({ children: r, className: c, legend: l }) { let u = o(), d = n(t); if (!d) throw Error("InlineFieldGroupEditView must be used within InlineFieldGroup"); let { mode: f, editViewId: p, isLoading: m, editViewRef: h } = d, g = f === "edit", { fieldset: _, legend: v, fieldsContainer: y, hiddenButtons: b } = s(), x = u.formatMessage({ id: "unity:component:inline-field-group:save", defaultMessage: "Save" }); return /* @__PURE__ */ a("fieldset", { ref: h, id: p, className: _({ className: c }), disabled: m, hidden: !g, "aria-hidden": !g, "aria-busy": m, ...!g && { inert: "" }, children: [ /* @__PURE__ */ i("legend", { className: v(), children: l }), /* @__PURE__ */ i("div", { className: y(), children: r }), /* @__PURE__ */ i("div", { className: b(), children: /* @__PURE__ */ i(e, { type: "submit", variant: "primary", children: x }) }) ] }); } c.displayName = "InlineFieldGroupEditView"; //#endregion export { c as InlineFieldGroupEditView };