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

83 lines (82 loc) 2.24 kB
import { jsxs as q, Fragment as w, jsx as a } from "react/jsx-runtime"; import H from "@mui/material/TextField"; import { getInputProps as N, examplesId as u, ariaDescribedByIds as O, labelValue as k } from "@rjsf/utils"; const J = ["date", "datetime-local", "file", "time"]; function X(p) { const { id: t, name: K, // remove this from textFieldProps placeholder: l, required: R, readonly: c, disabled: m, type: s, label: h, hideLabel: Y, hideError: z, value: o, onChange: f, onChangeOverride: b, onBlur: x, onFocus: g, autofocus: v, options: n, schema: e, uiSchema: G, rawErrors: P = [], formContext: M, registry: y, InputLabelProps: i, ...F } = p, I = !0, L = N(e, s, n), { step: _, min: B, max: C, ...A } = L, E = { inputProps: { step: _, min: B, max: C, ...e.examples ? { list: u(t) } : void 0 }, ...A }, T = ({ target: { value: r } }) => f(r === "" ? n.emptyValue : r), S = ({ target: { value: r } }) => x(t, r), D = ({ target: { value: r } }) => g(t, r), V = J.includes(s) ? { ...i, shrink: !0 } : i; let d; (e.default || e.const) && (d = JSON.stringify(e.default || e.const) + " (derived)"); const j = y.formContext.showDerivedAnnotationPlaceholder && d || l; return /* @__PURE__ */ q(w, { children: [ /* @__PURE__ */ a( H, { id: t, name: t, placeholder: j, label: k(h || void 0, I, !1), autoFocus: v, required: !1, disabled: m || c, ...E, value: o || o === 0 ? o : "", error: P.length > 0, onChange: b || T, onBlur: S, onFocus: D, ...F, "aria-describedby": O(t, !!e.examples), slotProps: { htmlInput: { "aria-label": t }, inputLabel: V } } ), Array.isArray(e.examples) && /* @__PURE__ */ a("datalist", { id: u(t), children: e.examples.concat( e.default && !e.examples.includes(e.default) ? [e.default] : [] ).map((r) => /* @__PURE__ */ a("option", { value: r }, r)) }) ] }); } export { X as default }; //# sourceMappingURL=BaseInputTemplate.js.map