dynamic-formik-form 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -97,16 +97,25 @@ var defaultAdapter = {
97
97
  )
98
98
  };
99
99
  var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, FormHelperText, IconButton, MenuItem, Paper, Popover, Radio, RadioGroup, Switch, TextField2, Typography, DatePicker, DateTimePicker) => {
100
+ const filterMUIProps = (props) => {
101
+ const filtered = { ...props };
102
+ delete filtered.error;
103
+ delete filtered.fullWidth;
104
+ delete filtered.select;
105
+ delete filtered.multiline;
106
+ delete filtered.variant;
107
+ return filtered;
108
+ };
100
109
  return {
101
110
  Input: ({ className, disabled, error, type, ...props }) => {
102
- const { error: _, ...restProps } = props;
111
+ const filteredProps = filterMUIProps(props);
103
112
  return /* @__PURE__ */ jsxRuntime.jsx(
104
113
  TextField2,
105
114
  {
106
- ...restProps,
115
+ ...filteredProps,
107
116
  type,
108
117
  disabled,
109
- error: !!error,
118
+ ...error ? { error: true } : {},
110
119
  className,
111
120
  fullWidth: true,
112
121
  variant: "outlined"
@@ -114,15 +123,15 @@ var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, Fo
114
123
  );
115
124
  },
116
125
  Textarea: ({ className, disabled, error, rows, ...props }) => {
117
- const { error: _, ...restProps } = props;
126
+ const filteredProps = filterMUIProps(props);
118
127
  return /* @__PURE__ */ jsxRuntime.jsx(
119
128
  TextField2,
120
129
  {
121
- ...restProps,
130
+ ...filteredProps,
122
131
  multiline: true,
123
132
  rows: rows || 4,
124
133
  disabled,
125
- error: !!error,
134
+ ...error ? { error: true } : {},
126
135
  className,
127
136
  fullWidth: true,
128
137
  variant: "outlined"
@@ -130,14 +139,14 @@ var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, Fo
130
139
  );
131
140
  },
132
141
  Select: ({ className, disabled, error, children, ...props }) => {
133
- const { error: _, ...restProps } = props;
142
+ const filteredProps = filterMUIProps(props);
134
143
  return /* @__PURE__ */ jsxRuntime.jsx(
135
144
  TextField2,
136
145
  {
137
- ...restProps,
146
+ ...filteredProps,
138
147
  select: true,
139
148
  disabled,
140
- error: !!error,
149
+ ...error ? { error: true } : {},
141
150
  className,
142
151
  fullWidth: true,
143
152
  variant: "outlined",
@@ -200,7 +209,7 @@ var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, Fo
200
209
  {
201
210
  className,
202
211
  required,
203
- error: !!error,
212
+ ...error ? { error: true } : {},
204
213
  fullWidth: true,
205
214
  children
206
215
  }
@@ -263,7 +272,7 @@ var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, Fo
263
272
  }
264
273
  ) : void 0,
265
274
  TextField: TextField2 ? ({ inputRef, inputProps, label, id, error, helperText, ...props }) => {
266
- const { error: _, ...restProps } = props;
275
+ const filteredProps = filterMUIProps(props);
267
276
  return /* @__PURE__ */ jsxRuntime.jsx(
268
277
  TextField2,
269
278
  {
@@ -271,9 +280,9 @@ var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, Fo
271
280
  inputProps,
272
281
  label,
273
282
  id,
274
- error: !!error,
283
+ ...error ? { error: true } : {},
275
284
  helperText,
276
- ...restProps,
285
+ ...filteredProps,
277
286
  fullWidth: true,
278
287
  variant: "outlined"
279
288
  }
@@ -353,7 +362,7 @@ var createBootstrapAdapter = (Form, FormControl, FormLabel, FormText, FormCheck,
353
362
  children
354
363
  }
355
364
  ),
356
- FormControl: ({ className, required, error, children }) => /* @__PURE__ */ jsxRuntime.jsx(Form, { className, children }),
365
+ FormControl: ({ className, required, error, children }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${className || ""} ${error ? "is-invalid" : ""}`, children }),
357
366
  FormHelperText: ({ className, children }) => /* @__PURE__ */ jsxRuntime.jsx(FormText, { className, children }),
358
367
  Label: ({ className, htmlFor, children }) => /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { htmlFor, className, children }),
359
368
  Box: ({ className, children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className, ...props, children }),