SettingsFromFields =
  (fieldsIn, opts = {}) =>
  () => {
    const fields = [...fieldsIn];
    if (opts.additionalFieldsOptionKey) {
      const options = React.useContext(optionsCtx);

      const addFields = options[opts.additionalFieldsOptionKey];
      fields.push(...(addFields || []));
    }
    const node = useNode((node) => {
      const ps = {};
      fields.forEach((f) => {
        ps[f.name] = node.data.props[f.name];
      });
      if (fields.some((f) => f.canBeFormula))
        ps.isFormula = node.data.props.isFormula;
      return ps;
    });
    const {
      actions: { setProp },
    } = node;
    const noop = () => {};
    return (
      <table className="w-100">
        <tbody>
          {fields.map((f, ix) => {
            if (f.showIf) {
              let noshow = false;
              Object.entries(f.showIf).forEach(([nm, value]) => {
                if (Array.isArray(value))
                  noshow = noshow || !value.includes(node[nm]);
                else noshow = noshow || value !== node[nm];
              });
              if (noshow) return null;
            }
            return (
              <SettingsRow
                field={f}
                key={ix}
                node={node}
                onChange={opts.onChange || noop}
                setProp={setProp}
              />
            );
          })}
        </tbody>
      </table>
    );
  }
@param {object[]} fields
@category saltcorn-builder
@subcategory components / elements / utils
@namespace
@returns {table}