dynamic-formik-form 1.0.2 → 1.0.4

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.mjs CHANGED
@@ -91,45 +91,63 @@ var defaultAdapter = {
91
91
  )
92
92
  };
93
93
  var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, FormHelperText, IconButton, MenuItem, Paper, Popover, Radio, RadioGroup, Switch, TextField2, Typography, DatePicker, DateTimePicker) => {
94
+ const filterMUIProps = (props) => {
95
+ const filtered = { ...props };
96
+ delete filtered.error;
97
+ delete filtered.fullWidth;
98
+ delete filtered.select;
99
+ delete filtered.multiline;
100
+ delete filtered.variant;
101
+ return filtered;
102
+ };
94
103
  return {
95
- Input: ({ className, disabled, error, type, ...props }) => /* @__PURE__ */ jsx(
96
- TextField2,
97
- {
98
- ...props,
99
- type,
100
- disabled,
101
- error: !!error,
102
- className,
103
- fullWidth: true,
104
- variant: "outlined"
105
- }
106
- ),
107
- Textarea: ({ className, disabled, error, rows, ...props }) => /* @__PURE__ */ jsx(
108
- TextField2,
109
- {
110
- ...props,
111
- multiline: true,
112
- rows: rows || 4,
113
- disabled,
114
- error: !!error,
115
- className,
116
- fullWidth: true,
117
- variant: "outlined"
118
- }
119
- ),
120
- Select: ({ className, disabled, error, children, ...props }) => /* @__PURE__ */ jsx(
121
- TextField2,
122
- {
123
- ...props,
124
- select: true,
125
- disabled,
126
- error: !!error,
127
- className,
128
- fullWidth: true,
129
- variant: "outlined",
130
- children
131
- }
132
- ),
104
+ Input: ({ className, disabled, error, type, ...props }) => {
105
+ const filteredProps = filterMUIProps(props);
106
+ return /* @__PURE__ */ jsx(
107
+ TextField2,
108
+ {
109
+ ...filteredProps,
110
+ type,
111
+ disabled,
112
+ ...error ? { error: true } : {},
113
+ className,
114
+ fullWidth: true,
115
+ variant: "outlined"
116
+ }
117
+ );
118
+ },
119
+ Textarea: ({ className, disabled, error, rows, ...props }) => {
120
+ const filteredProps = filterMUIProps(props);
121
+ return /* @__PURE__ */ jsx(
122
+ TextField2,
123
+ {
124
+ ...filteredProps,
125
+ multiline: true,
126
+ rows: rows || 4,
127
+ disabled,
128
+ ...error ? { error: true } : {},
129
+ className,
130
+ fullWidth: true,
131
+ variant: "outlined"
132
+ }
133
+ );
134
+ },
135
+ Select: ({ className, disabled, error, children, ...props }) => {
136
+ const filteredProps = filterMUIProps(props);
137
+ return /* @__PURE__ */ jsx(
138
+ TextField2,
139
+ {
140
+ ...filteredProps,
141
+ select: true,
142
+ disabled,
143
+ ...error ? { error: true } : {},
144
+ className,
145
+ fullWidth: true,
146
+ variant: "outlined",
147
+ children
148
+ }
149
+ );
150
+ },
133
151
  Checkbox: ({ className, disabled, label, ...props }) => /* @__PURE__ */ jsx(
134
152
  FormControlLabel,
135
153
  {
@@ -185,7 +203,7 @@ var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, Fo
185
203
  {
186
204
  className,
187
205
  required,
188
- error: !!error,
206
+ ...error ? { error: true } : {},
189
207
  fullWidth: true,
190
208
  children
191
209
  }
@@ -247,20 +265,23 @@ var createMUIAdapter = (Box, Button, Checkbox, FormControl, FormControlLabel, Fo
247
265
  ...props
248
266
  }
249
267
  ) : void 0,
250
- TextField: TextField2 ? ({ inputRef, inputProps, label, id, error, helperText, ...props }) => /* @__PURE__ */ jsx(
251
- TextField2,
252
- {
253
- inputRef,
254
- inputProps,
255
- label,
256
- id,
257
- error: !!error,
258
- helperText,
259
- ...props,
260
- fullWidth: true,
261
- variant: "outlined"
262
- }
263
- ) : void 0
268
+ TextField: TextField2 ? ({ inputRef, inputProps, label, id, error, helperText, ...props }) => {
269
+ const filteredProps = filterMUIProps(props);
270
+ return /* @__PURE__ */ jsx(
271
+ TextField2,
272
+ {
273
+ inputRef,
274
+ inputProps,
275
+ label,
276
+ id,
277
+ ...error ? { error: true } : {},
278
+ helperText,
279
+ ...filteredProps,
280
+ fullWidth: true,
281
+ variant: "outlined"
282
+ }
283
+ );
284
+ } : void 0
264
285
  };
265
286
  };
266
287
  var createBootstrapAdapter = (Form, FormControl, FormLabel, FormText, FormCheck, FormSelect, ButtonComponent, InputGroup, OverlayTrigger, Popover, ListGroup, ListGroupItem) => {