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

73 lines (72 loc) 2.01 kB
import { jsx as t, jsxs as m } from "react/jsx-runtime"; import { CloseTwoTone as p, AddBox as h } from "@mui/icons-material"; import { IconButton as l } from "@mui/material"; import { useCallback as u, useEffect as f, Fragment as g } from "react"; import { EvaluationRoundLimitOptions as L, LIMIT_TYPE_DISPLAY_NAME as x } from "./EvaluationRoundLimitOptions.js"; const c = Object.keys(x), y = (e) => c.find( (a) => !e.has(a) ); function S({ limitInputs: e, handleChange: a, handleDeleteLimit: d, onAddNewLimit: s }) { const n = new Set( e.map((o) => o.type) ), i = u(() => { s({ type: y(n), maxSubmissionString: "" }); }, [s, n]); return f(() => { e.length === 0 && i(); }, [e, i]), /* @__PURE__ */ t( "div", { "data-testid": "EvaluationRoundLimitOptionsList", className: "advanced-limits-grid", children: e.map((o, r) => /* @__PURE__ */ m(g, { children: [ /* @__PURE__ */ t( L, { limitInput: o, allSelectedTypes: n, onChange: a(r) } ), /* @__PURE__ */ t( l, { size: "small", color: "primary", "aria-label": "Remove", className: "remove-button", onClick: d(r), sx: { height: "40px", width: "40px" }, children: /* @__PURE__ */ t(p, {}) } ), // if last element r === e.length - 1 && // if the are unused limit types e.length < c.length && /* @__PURE__ */ t( l, { size: "small", color: "primary", "aria-label": "Add", onClick: i, className: "add-button", sx: { height: "40px", width: "40px" }, children: /* @__PURE__ */ t(h, {}) } ) ] }, o.type)) } ); } export { S as EvaluationRoundLimitOptionsList }; //# sourceMappingURL=EvaluationRoundLimitOptionsList.js.map