@availity/mui-controlled-form 0.1.3 → 0.2.0
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/CHANGELOG.md +27 -0
- package/dist/index.d.mts +54 -2
- package/dist/index.d.ts +54 -2
- package/dist/index.js +821 -5
- package/dist/index.mjs +808 -3
- package/package.json +19 -11
- package/src/index.ts +11 -0
package/dist/index.js
CHANGED
|
@@ -49,23 +49,839 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
49
49
|
// src/index.ts
|
|
50
50
|
var src_exports = {};
|
|
51
51
|
__export(src_exports, {
|
|
52
|
-
|
|
52
|
+
ControlledAsyncAutocomplete: () => ControlledAsyncAutocomplete,
|
|
53
|
+
ControlledAutocomplete: () => ControlledAutocomplete,
|
|
54
|
+
ControlledCheckbox: () => ControlledCheckbox,
|
|
55
|
+
ControlledCodesAutocomplete: () => ControlledCodesAutocomplete,
|
|
56
|
+
ControlledDatepicker: () => ControlledDatepicker,
|
|
57
|
+
ControlledForm: () => ControlledForm,
|
|
58
|
+
ControlledInput: () => ControlledInput,
|
|
59
|
+
ControlledOrganizationAutocomplete: () => ControlledOrganizationAutocomplete,
|
|
60
|
+
ControlledProviderAutocomplete: () => ControlledProviderAutocomplete,
|
|
61
|
+
ControlledRadioGroup: () => ControlledRadioGroup,
|
|
62
|
+
ControlledSelect: () => ControlledSelect,
|
|
63
|
+
ControlledTextField: () => ControlledTextField
|
|
53
64
|
});
|
|
54
65
|
module.exports = __toCommonJS(src_exports);
|
|
55
66
|
|
|
56
|
-
// src/lib/
|
|
67
|
+
// src/lib/AsyncAutocomplete.tsx
|
|
68
|
+
var import_mui_autocomplete = require("@availity/mui-autocomplete");
|
|
57
69
|
var import_react_hook_form = require("react-hook-form");
|
|
58
70
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
71
|
+
var ControlledAsyncAutocomplete = (_a) => {
|
|
72
|
+
var _b = _a, {
|
|
73
|
+
name,
|
|
74
|
+
deps,
|
|
75
|
+
max,
|
|
76
|
+
maxLength,
|
|
77
|
+
min,
|
|
78
|
+
minLength,
|
|
79
|
+
onBlur,
|
|
80
|
+
onChange,
|
|
81
|
+
pattern,
|
|
82
|
+
required,
|
|
83
|
+
shouldUnregister,
|
|
84
|
+
validate,
|
|
85
|
+
value,
|
|
86
|
+
FieldProps
|
|
87
|
+
} = _b, rest = __objRest(_b, [
|
|
88
|
+
"name",
|
|
89
|
+
"deps",
|
|
90
|
+
"max",
|
|
91
|
+
"maxLength",
|
|
92
|
+
"min",
|
|
93
|
+
"minLength",
|
|
94
|
+
"onBlur",
|
|
95
|
+
"onChange",
|
|
96
|
+
"pattern",
|
|
97
|
+
"required",
|
|
98
|
+
"shouldUnregister",
|
|
99
|
+
"validate",
|
|
100
|
+
"value",
|
|
101
|
+
"FieldProps"
|
|
102
|
+
]);
|
|
103
|
+
var _a2;
|
|
104
|
+
const {
|
|
105
|
+
control,
|
|
106
|
+
formState: { errors }
|
|
107
|
+
} = (0, import_react_hook_form.useFormContext)();
|
|
108
|
+
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
|
+
import_react_hook_form.Controller,
|
|
111
|
+
{
|
|
112
|
+
name,
|
|
113
|
+
control,
|
|
114
|
+
defaultValue: rest.defaultValue,
|
|
115
|
+
rules: {
|
|
116
|
+
deps,
|
|
117
|
+
max,
|
|
118
|
+
maxLength,
|
|
119
|
+
min,
|
|
120
|
+
minLength,
|
|
121
|
+
onBlur,
|
|
122
|
+
onChange,
|
|
123
|
+
pattern,
|
|
124
|
+
required,
|
|
125
|
+
shouldUnregister,
|
|
126
|
+
validate,
|
|
127
|
+
value
|
|
128
|
+
},
|
|
129
|
+
shouldUnregister,
|
|
130
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
131
|
+
import_mui_autocomplete.AsyncAutocomplete,
|
|
132
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
133
|
+
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
134
|
+
error: !!errorMessage,
|
|
135
|
+
helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
136
|
+
errorMessage,
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
138
|
+
FieldProps == null ? void 0 : FieldProps.helperText
|
|
139
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
140
|
+
}),
|
|
141
|
+
onChange: (event, value3, reason) => {
|
|
142
|
+
if (reason === "clear") {
|
|
143
|
+
onChange2(null);
|
|
144
|
+
}
|
|
145
|
+
onChange2(value3);
|
|
146
|
+
},
|
|
147
|
+
onBlur: onBlur2,
|
|
148
|
+
value: value2 || null
|
|
149
|
+
})
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/lib/Autocomplete.tsx
|
|
156
|
+
var import_mui_autocomplete2 = require("@availity/mui-autocomplete");
|
|
157
|
+
var import_react_hook_form2 = require("react-hook-form");
|
|
158
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
159
|
+
var ControlledAutocomplete = (_a) => {
|
|
160
|
+
var _b = _a, {
|
|
161
|
+
name,
|
|
162
|
+
FieldProps,
|
|
163
|
+
defaultValue,
|
|
164
|
+
deps,
|
|
165
|
+
max,
|
|
166
|
+
maxLength,
|
|
167
|
+
min,
|
|
168
|
+
minLength,
|
|
169
|
+
onBlur,
|
|
170
|
+
onChange,
|
|
171
|
+
pattern,
|
|
172
|
+
required,
|
|
173
|
+
shouldUnregister,
|
|
174
|
+
validate,
|
|
175
|
+
value
|
|
176
|
+
} = _b, rest = __objRest(_b, [
|
|
177
|
+
"name",
|
|
178
|
+
"FieldProps",
|
|
179
|
+
"defaultValue",
|
|
180
|
+
"deps",
|
|
181
|
+
"max",
|
|
182
|
+
"maxLength",
|
|
183
|
+
"min",
|
|
184
|
+
"minLength",
|
|
185
|
+
"onBlur",
|
|
186
|
+
"onChange",
|
|
187
|
+
"pattern",
|
|
188
|
+
"required",
|
|
189
|
+
"shouldUnregister",
|
|
190
|
+
"validate",
|
|
191
|
+
"value"
|
|
192
|
+
]);
|
|
193
|
+
var _a2;
|
|
194
|
+
const {
|
|
195
|
+
control,
|
|
196
|
+
formState: { errors }
|
|
197
|
+
} = (0, import_react_hook_form2.useFormContext)();
|
|
198
|
+
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
200
|
+
import_react_hook_form2.Controller,
|
|
201
|
+
{
|
|
202
|
+
control,
|
|
203
|
+
name,
|
|
204
|
+
defaultValue,
|
|
205
|
+
rules: {
|
|
206
|
+
deps,
|
|
207
|
+
max,
|
|
208
|
+
maxLength,
|
|
209
|
+
min,
|
|
210
|
+
minLength,
|
|
211
|
+
onBlur,
|
|
212
|
+
onChange,
|
|
213
|
+
pattern,
|
|
214
|
+
required,
|
|
215
|
+
shouldUnregister,
|
|
216
|
+
validate,
|
|
217
|
+
value
|
|
218
|
+
},
|
|
219
|
+
shouldUnregister,
|
|
220
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
221
|
+
import_mui_autocomplete2.Autocomplete,
|
|
222
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
223
|
+
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
224
|
+
error: !!errorMessage,
|
|
225
|
+
helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
226
|
+
errorMessage,
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("br", {}),
|
|
228
|
+
FieldProps == null ? void 0 : FieldProps.helperText
|
|
229
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
230
|
+
}),
|
|
231
|
+
onChange: (event, value3, reason) => {
|
|
232
|
+
if (reason === "clear") {
|
|
233
|
+
onChange2(null);
|
|
234
|
+
}
|
|
235
|
+
onChange2(value3);
|
|
236
|
+
},
|
|
237
|
+
onBlur: onBlur2,
|
|
238
|
+
value: value2 || null
|
|
239
|
+
})
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/lib/Checkbox.tsx
|
|
246
|
+
var import_mui_checkbox = require("@availity/mui-checkbox");
|
|
247
|
+
var import_react_hook_form3 = require("react-hook-form");
|
|
248
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
249
|
+
var ControlledCheckbox = (_a) => {
|
|
250
|
+
var _b = _a, {
|
|
251
|
+
name,
|
|
252
|
+
setValueAs,
|
|
253
|
+
disabled,
|
|
254
|
+
onChange,
|
|
255
|
+
onBlur,
|
|
256
|
+
value,
|
|
257
|
+
shouldUnregister,
|
|
258
|
+
deps
|
|
259
|
+
} = _b, rest = __objRest(_b, [
|
|
260
|
+
"name",
|
|
261
|
+
"setValueAs",
|
|
262
|
+
"disabled",
|
|
263
|
+
"onChange",
|
|
264
|
+
"onBlur",
|
|
265
|
+
"value",
|
|
266
|
+
"shouldUnregister",
|
|
267
|
+
"deps"
|
|
268
|
+
]);
|
|
269
|
+
const { register } = (0, import_react_hook_form3.useFormContext)();
|
|
270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
271
|
+
import_mui_checkbox.Checkbox,
|
|
272
|
+
__spreadValues(__spreadValues({}, rest), register(name, {
|
|
273
|
+
setValueAs,
|
|
274
|
+
disabled,
|
|
275
|
+
onChange,
|
|
276
|
+
onBlur,
|
|
277
|
+
value,
|
|
278
|
+
shouldUnregister,
|
|
279
|
+
deps
|
|
280
|
+
}))
|
|
281
|
+
);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/lib/CodesAutocomplete.tsx
|
|
285
|
+
var import_mui_autocomplete3 = require("@availity/mui-autocomplete");
|
|
286
|
+
var import_react_hook_form4 = require("react-hook-form");
|
|
287
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
288
|
+
var ControlledCodesAutocomplete = (_a) => {
|
|
289
|
+
var _b = _a, {
|
|
290
|
+
name,
|
|
291
|
+
defaultValue,
|
|
292
|
+
deps,
|
|
293
|
+
max,
|
|
294
|
+
maxLength,
|
|
295
|
+
onBlur,
|
|
296
|
+
onChange,
|
|
297
|
+
pattern,
|
|
298
|
+
required,
|
|
299
|
+
shouldUnregister,
|
|
300
|
+
validate,
|
|
301
|
+
value,
|
|
302
|
+
FieldProps
|
|
303
|
+
} = _b, rest = __objRest(_b, [
|
|
304
|
+
"name",
|
|
305
|
+
"defaultValue",
|
|
306
|
+
"deps",
|
|
307
|
+
"max",
|
|
308
|
+
"maxLength",
|
|
309
|
+
"onBlur",
|
|
310
|
+
"onChange",
|
|
311
|
+
"pattern",
|
|
312
|
+
"required",
|
|
313
|
+
"shouldUnregister",
|
|
314
|
+
"validate",
|
|
315
|
+
"value",
|
|
316
|
+
"FieldProps"
|
|
317
|
+
]);
|
|
318
|
+
var _a2;
|
|
319
|
+
const {
|
|
320
|
+
control,
|
|
321
|
+
formState: { errors }
|
|
322
|
+
} = (0, import_react_hook_form4.useFormContext)();
|
|
323
|
+
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
325
|
+
import_react_hook_form4.Controller,
|
|
326
|
+
{
|
|
327
|
+
name,
|
|
328
|
+
control,
|
|
329
|
+
defaultValue,
|
|
330
|
+
rules: {
|
|
331
|
+
deps,
|
|
332
|
+
max,
|
|
333
|
+
maxLength,
|
|
334
|
+
onBlur,
|
|
335
|
+
onChange,
|
|
336
|
+
pattern,
|
|
337
|
+
required,
|
|
338
|
+
shouldUnregister,
|
|
339
|
+
validate,
|
|
340
|
+
value
|
|
341
|
+
},
|
|
342
|
+
shouldUnregister,
|
|
343
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
344
|
+
import_mui_autocomplete3.CodesAutocomplete,
|
|
345
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
346
|
+
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
347
|
+
error: !!errorMessage,
|
|
348
|
+
helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
349
|
+
errorMessage,
|
|
350
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {}),
|
|
351
|
+
FieldProps == null ? void 0 : FieldProps.helperText
|
|
352
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
353
|
+
}),
|
|
354
|
+
onChange: (event, value3, reason) => {
|
|
355
|
+
if (reason === "clear") {
|
|
356
|
+
onChange2(null);
|
|
357
|
+
}
|
|
358
|
+
onChange2(value3);
|
|
359
|
+
},
|
|
360
|
+
onBlur: onBlur2,
|
|
361
|
+
value: value2 || null
|
|
362
|
+
})
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// src/lib/ControlledForm.tsx
|
|
369
|
+
var import_react_hook_form5 = require("react-hook-form");
|
|
370
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
59
371
|
var ControlledForm = (_a) => {
|
|
60
372
|
var _b = _a, { onSubmit, values, schema, validationResolver } = _b, rest = __objRest(_b, ["onSubmit", "values", "schema", "validationResolver"]);
|
|
61
373
|
const useFormOptions = { values };
|
|
62
374
|
if (schema && validationResolver) {
|
|
63
375
|
useFormOptions.resolver = validationResolver(schema);
|
|
64
376
|
}
|
|
65
|
-
const methods = (0,
|
|
66
|
-
return /* @__PURE__ */ (0,
|
|
377
|
+
const methods = (0, import_react_hook_form5.useForm)(useFormOptions);
|
|
378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_hook_form5.FormProvider, __spreadProps(__spreadValues({}, methods), { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("form", __spreadValues({ onSubmit: methods.handleSubmit(onSubmit) }, rest)) }));
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
// src/lib/Datepicker.tsx
|
|
382
|
+
var import_mui_datepicker = require("@availity/mui-datepicker");
|
|
383
|
+
var import_react_hook_form6 = require("react-hook-form");
|
|
384
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
385
|
+
var ControlledDatepicker = (_a) => {
|
|
386
|
+
var _b = _a, {
|
|
387
|
+
name,
|
|
388
|
+
defaultValue,
|
|
389
|
+
deps,
|
|
390
|
+
max,
|
|
391
|
+
maxLength,
|
|
392
|
+
min,
|
|
393
|
+
minLength,
|
|
394
|
+
onBlur,
|
|
395
|
+
onChange,
|
|
396
|
+
pattern,
|
|
397
|
+
required,
|
|
398
|
+
shouldUnregister,
|
|
399
|
+
validate,
|
|
400
|
+
value
|
|
401
|
+
} = _b, rest = __objRest(_b, [
|
|
402
|
+
"name",
|
|
403
|
+
"defaultValue",
|
|
404
|
+
"deps",
|
|
405
|
+
"max",
|
|
406
|
+
"maxLength",
|
|
407
|
+
"min",
|
|
408
|
+
"minLength",
|
|
409
|
+
"onBlur",
|
|
410
|
+
"onChange",
|
|
411
|
+
"pattern",
|
|
412
|
+
"required",
|
|
413
|
+
"shouldUnregister",
|
|
414
|
+
"validate",
|
|
415
|
+
"value"
|
|
416
|
+
]);
|
|
417
|
+
const { control } = (0, import_react_hook_form6.useFormContext)();
|
|
418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
419
|
+
import_react_hook_form6.Controller,
|
|
420
|
+
{
|
|
421
|
+
name,
|
|
422
|
+
control,
|
|
423
|
+
defaultValue,
|
|
424
|
+
rules: {
|
|
425
|
+
deps,
|
|
426
|
+
max,
|
|
427
|
+
maxLength,
|
|
428
|
+
min,
|
|
429
|
+
minLength,
|
|
430
|
+
onBlur,
|
|
431
|
+
onChange,
|
|
432
|
+
pattern,
|
|
433
|
+
required,
|
|
434
|
+
shouldUnregister,
|
|
435
|
+
validate,
|
|
436
|
+
value
|
|
437
|
+
},
|
|
438
|
+
shouldUnregister,
|
|
439
|
+
render: ({ field: { onChange: onChange2, value: value2 } }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_mui_datepicker.Datepicker, __spreadProps(__spreadValues({}, rest), { onChange: onChange2, value: value2 || null }))
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
// src/lib/Input.tsx
|
|
445
|
+
var import_mui_form_utils = require("@availity/mui-form-utils");
|
|
446
|
+
var import_react_hook_form7 = require("react-hook-form");
|
|
447
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
448
|
+
var ControlledInput = (_a) => {
|
|
449
|
+
var _b = _a, {
|
|
450
|
+
name,
|
|
451
|
+
required,
|
|
452
|
+
maxLength,
|
|
453
|
+
minLength,
|
|
454
|
+
max,
|
|
455
|
+
min,
|
|
456
|
+
pattern,
|
|
457
|
+
validate,
|
|
458
|
+
setValueAs,
|
|
459
|
+
disabled,
|
|
460
|
+
onChange,
|
|
461
|
+
onBlur,
|
|
462
|
+
value,
|
|
463
|
+
shouldUnregister,
|
|
464
|
+
deps
|
|
465
|
+
} = _b, rest = __objRest(_b, [
|
|
466
|
+
"name",
|
|
467
|
+
"required",
|
|
468
|
+
"maxLength",
|
|
469
|
+
"minLength",
|
|
470
|
+
"max",
|
|
471
|
+
"min",
|
|
472
|
+
"pattern",
|
|
473
|
+
"validate",
|
|
474
|
+
"setValueAs",
|
|
475
|
+
"disabled",
|
|
476
|
+
"onChange",
|
|
477
|
+
"onBlur",
|
|
478
|
+
"value",
|
|
479
|
+
"shouldUnregister",
|
|
480
|
+
"deps"
|
|
481
|
+
]);
|
|
482
|
+
const {
|
|
483
|
+
register,
|
|
484
|
+
formState: { errors }
|
|
485
|
+
} = (0, import_react_hook_form7.useFormContext)();
|
|
486
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
487
|
+
import_mui_form_utils.Input,
|
|
488
|
+
__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
489
|
+
error: !!errors[name],
|
|
490
|
+
required: !!required
|
|
491
|
+
}), register(name, {
|
|
492
|
+
required,
|
|
493
|
+
maxLength,
|
|
494
|
+
minLength,
|
|
495
|
+
max,
|
|
496
|
+
min,
|
|
497
|
+
pattern,
|
|
498
|
+
validate,
|
|
499
|
+
setValueAs,
|
|
500
|
+
disabled,
|
|
501
|
+
onChange,
|
|
502
|
+
onBlur,
|
|
503
|
+
value,
|
|
504
|
+
shouldUnregister,
|
|
505
|
+
deps
|
|
506
|
+
}))
|
|
507
|
+
);
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/lib/OrganizationAutocomplete.tsx
|
|
511
|
+
var import_mui_autocomplete4 = require("@availity/mui-autocomplete");
|
|
512
|
+
var import_react_hook_form8 = require("react-hook-form");
|
|
513
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
514
|
+
var ControlledOrganizationAutocomplete = (_a) => {
|
|
515
|
+
var _b = _a, {
|
|
516
|
+
name,
|
|
517
|
+
defaultValue,
|
|
518
|
+
deps,
|
|
519
|
+
onBlur,
|
|
520
|
+
onChange,
|
|
521
|
+
pattern,
|
|
522
|
+
required,
|
|
523
|
+
shouldUnregister,
|
|
524
|
+
validate,
|
|
525
|
+
value,
|
|
526
|
+
FieldProps
|
|
527
|
+
} = _b, rest = __objRest(_b, [
|
|
528
|
+
"name",
|
|
529
|
+
"defaultValue",
|
|
530
|
+
"deps",
|
|
531
|
+
"onBlur",
|
|
532
|
+
"onChange",
|
|
533
|
+
"pattern",
|
|
534
|
+
"required",
|
|
535
|
+
"shouldUnregister",
|
|
536
|
+
"validate",
|
|
537
|
+
"value",
|
|
538
|
+
"FieldProps"
|
|
539
|
+
]);
|
|
540
|
+
var _a2;
|
|
541
|
+
const {
|
|
542
|
+
control,
|
|
543
|
+
formState: { errors }
|
|
544
|
+
} = (0, import_react_hook_form8.useFormContext)();
|
|
545
|
+
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
547
|
+
import_react_hook_form8.Controller,
|
|
548
|
+
{
|
|
549
|
+
name,
|
|
550
|
+
control,
|
|
551
|
+
defaultValue,
|
|
552
|
+
rules: {
|
|
553
|
+
deps,
|
|
554
|
+
onBlur,
|
|
555
|
+
onChange,
|
|
556
|
+
pattern,
|
|
557
|
+
required,
|
|
558
|
+
shouldUnregister,
|
|
559
|
+
validate,
|
|
560
|
+
value
|
|
561
|
+
},
|
|
562
|
+
shouldUnregister,
|
|
563
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
564
|
+
import_mui_autocomplete4.OrganizationAutocomplete,
|
|
565
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
566
|
+
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
567
|
+
error: !!errorMessage,
|
|
568
|
+
helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
569
|
+
errorMessage,
|
|
570
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("br", {}),
|
|
571
|
+
FieldProps == null ? void 0 : FieldProps.helperText
|
|
572
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
573
|
+
}),
|
|
574
|
+
onChange: (event, value3, reason) => {
|
|
575
|
+
if (reason === "clear") {
|
|
576
|
+
onChange2(null);
|
|
577
|
+
}
|
|
578
|
+
onChange2(value3);
|
|
579
|
+
},
|
|
580
|
+
onBlur: onBlur2,
|
|
581
|
+
value: value2 || null
|
|
582
|
+
})
|
|
583
|
+
)
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
// src/lib/ProviderAutocomplete.tsx
|
|
589
|
+
var import_mui_autocomplete5 = require("@availity/mui-autocomplete");
|
|
590
|
+
var import_react_hook_form9 = require("react-hook-form");
|
|
591
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
592
|
+
var ControlledProviderAutocomplete = (_a) => {
|
|
593
|
+
var _b = _a, {
|
|
594
|
+
name,
|
|
595
|
+
defaultValue,
|
|
596
|
+
deps,
|
|
597
|
+
max,
|
|
598
|
+
maxLength,
|
|
599
|
+
min,
|
|
600
|
+
minLength,
|
|
601
|
+
onBlur,
|
|
602
|
+
onChange,
|
|
603
|
+
pattern,
|
|
604
|
+
required,
|
|
605
|
+
shouldUnregister,
|
|
606
|
+
validate,
|
|
607
|
+
value,
|
|
608
|
+
FieldProps
|
|
609
|
+
} = _b, rest = __objRest(_b, [
|
|
610
|
+
"name",
|
|
611
|
+
"defaultValue",
|
|
612
|
+
"deps",
|
|
613
|
+
"max",
|
|
614
|
+
"maxLength",
|
|
615
|
+
"min",
|
|
616
|
+
"minLength",
|
|
617
|
+
"onBlur",
|
|
618
|
+
"onChange",
|
|
619
|
+
"pattern",
|
|
620
|
+
"required",
|
|
621
|
+
"shouldUnregister",
|
|
622
|
+
"validate",
|
|
623
|
+
"value",
|
|
624
|
+
"FieldProps"
|
|
625
|
+
]);
|
|
626
|
+
var _a2;
|
|
627
|
+
const {
|
|
628
|
+
control,
|
|
629
|
+
formState: { errors }
|
|
630
|
+
} = (0, import_react_hook_form9.useFormContext)();
|
|
631
|
+
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
633
|
+
import_react_hook_form9.Controller,
|
|
634
|
+
{
|
|
635
|
+
name,
|
|
636
|
+
control,
|
|
637
|
+
defaultValue,
|
|
638
|
+
rules: {
|
|
639
|
+
deps,
|
|
640
|
+
max,
|
|
641
|
+
maxLength,
|
|
642
|
+
min,
|
|
643
|
+
minLength,
|
|
644
|
+
onBlur,
|
|
645
|
+
onChange,
|
|
646
|
+
pattern,
|
|
647
|
+
required,
|
|
648
|
+
shouldUnregister,
|
|
649
|
+
validate,
|
|
650
|
+
value
|
|
651
|
+
},
|
|
652
|
+
shouldUnregister,
|
|
653
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
654
|
+
import_mui_autocomplete5.ProviderAutocomplete,
|
|
655
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
656
|
+
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
657
|
+
error: !!errorMessage,
|
|
658
|
+
helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
659
|
+
errorMessage,
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("br", {}),
|
|
661
|
+
FieldProps == null ? void 0 : FieldProps.helperText
|
|
662
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
663
|
+
}),
|
|
664
|
+
onChange: (event, value3, reason) => {
|
|
665
|
+
if (reason === "clear") {
|
|
666
|
+
onChange2(null);
|
|
667
|
+
}
|
|
668
|
+
onChange2(value3);
|
|
669
|
+
},
|
|
670
|
+
onBlur: onBlur2,
|
|
671
|
+
value: value2 || null
|
|
672
|
+
})
|
|
673
|
+
)
|
|
674
|
+
}
|
|
675
|
+
);
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
// src/lib/RadioGroup.tsx
|
|
679
|
+
var import_mui_form_utils2 = require("@availity/mui-form-utils");
|
|
680
|
+
var import_react_hook_form10 = require("react-hook-form");
|
|
681
|
+
var import_mui_form_utils3 = require("@availity/mui-form-utils");
|
|
682
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
683
|
+
var ControlledRadioGroup = (_a) => {
|
|
684
|
+
var _b = _a, {
|
|
685
|
+
name,
|
|
686
|
+
helperText,
|
|
687
|
+
label,
|
|
688
|
+
defaultValue,
|
|
689
|
+
deps,
|
|
690
|
+
onBlur,
|
|
691
|
+
onChange,
|
|
692
|
+
required,
|
|
693
|
+
shouldUnregister,
|
|
694
|
+
value
|
|
695
|
+
} = _b, rest = __objRest(_b, [
|
|
696
|
+
"name",
|
|
697
|
+
"helperText",
|
|
698
|
+
"label",
|
|
699
|
+
"defaultValue",
|
|
700
|
+
"deps",
|
|
701
|
+
"onBlur",
|
|
702
|
+
"onChange",
|
|
703
|
+
"required",
|
|
704
|
+
"shouldUnregister",
|
|
705
|
+
"value"
|
|
706
|
+
]);
|
|
707
|
+
var _a2;
|
|
708
|
+
const {
|
|
709
|
+
control,
|
|
710
|
+
formState: { errors }
|
|
711
|
+
} = (0, import_react_hook_form10.useFormContext)();
|
|
712
|
+
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
714
|
+
import_react_hook_form10.Controller,
|
|
715
|
+
{
|
|
716
|
+
control,
|
|
717
|
+
name,
|
|
718
|
+
defaultValue,
|
|
719
|
+
rules: { deps, onBlur, onChange, required, shouldUnregister, value },
|
|
720
|
+
shouldUnregister,
|
|
721
|
+
render: ({ field }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_mui_form_utils3.FormControl, { error: !!errorMessage, children: [
|
|
722
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_form_utils3.FormLabel, { children: label }),
|
|
723
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_form_utils2.RadioGroup, __spreadValues(__spreadValues({}, field), rest)),
|
|
724
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_form_utils3.FormHelperText, { children: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
725
|
+
errorMessage,
|
|
726
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("br", {}),
|
|
727
|
+
helperText
|
|
728
|
+
] }) : helperText })
|
|
729
|
+
] })
|
|
730
|
+
}
|
|
731
|
+
);
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
// src/lib/Select.tsx
|
|
735
|
+
var import_mui_form_utils4 = require("@availity/mui-form-utils");
|
|
736
|
+
var import_react_hook_form11 = require("react-hook-form");
|
|
737
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
738
|
+
var ControlledSelect = (_a) => {
|
|
739
|
+
var _b = _a, {
|
|
740
|
+
name,
|
|
741
|
+
required,
|
|
742
|
+
maxLength,
|
|
743
|
+
minLength,
|
|
744
|
+
max,
|
|
745
|
+
min,
|
|
746
|
+
pattern,
|
|
747
|
+
validate,
|
|
748
|
+
setValueAs,
|
|
749
|
+
disabled,
|
|
750
|
+
onChange,
|
|
751
|
+
onBlur,
|
|
752
|
+
value,
|
|
753
|
+
shouldUnregister,
|
|
754
|
+
deps
|
|
755
|
+
} = _b, rest = __objRest(_b, [
|
|
756
|
+
"name",
|
|
757
|
+
"required",
|
|
758
|
+
"maxLength",
|
|
759
|
+
"minLength",
|
|
760
|
+
"max",
|
|
761
|
+
"min",
|
|
762
|
+
"pattern",
|
|
763
|
+
"validate",
|
|
764
|
+
"setValueAs",
|
|
765
|
+
"disabled",
|
|
766
|
+
"onChange",
|
|
767
|
+
"onBlur",
|
|
768
|
+
"value",
|
|
769
|
+
"shouldUnregister",
|
|
770
|
+
"deps"
|
|
771
|
+
]);
|
|
772
|
+
const {
|
|
773
|
+
register,
|
|
774
|
+
formState: { errors }
|
|
775
|
+
} = (0, import_react_hook_form11.useFormContext)();
|
|
776
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
777
|
+
import_mui_form_utils4.Select,
|
|
778
|
+
__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
779
|
+
error: !!errors[name],
|
|
780
|
+
required: !!required
|
|
781
|
+
}), register(name, {
|
|
782
|
+
required,
|
|
783
|
+
maxLength,
|
|
784
|
+
minLength,
|
|
785
|
+
max,
|
|
786
|
+
min,
|
|
787
|
+
pattern,
|
|
788
|
+
validate,
|
|
789
|
+
setValueAs,
|
|
790
|
+
disabled,
|
|
791
|
+
onChange,
|
|
792
|
+
onBlur,
|
|
793
|
+
value,
|
|
794
|
+
shouldUnregister,
|
|
795
|
+
deps
|
|
796
|
+
}))
|
|
797
|
+
);
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
// src/lib/TextField.tsx
|
|
801
|
+
var import_mui_textfield = require("@availity/mui-textfield");
|
|
802
|
+
var import_react_hook_form12 = require("react-hook-form");
|
|
803
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
804
|
+
var ControlledTextField = (_a) => {
|
|
805
|
+
var _b = _a, {
|
|
806
|
+
name,
|
|
807
|
+
helperText,
|
|
808
|
+
required,
|
|
809
|
+
maxLength,
|
|
810
|
+
minLength,
|
|
811
|
+
max,
|
|
812
|
+
min,
|
|
813
|
+
pattern,
|
|
814
|
+
validate,
|
|
815
|
+
setValueAs,
|
|
816
|
+
disabled,
|
|
817
|
+
onChange,
|
|
818
|
+
onBlur,
|
|
819
|
+
value,
|
|
820
|
+
shouldUnregister,
|
|
821
|
+
deps
|
|
822
|
+
} = _b, rest = __objRest(_b, [
|
|
823
|
+
"name",
|
|
824
|
+
"helperText",
|
|
825
|
+
"required",
|
|
826
|
+
"maxLength",
|
|
827
|
+
"minLength",
|
|
828
|
+
"max",
|
|
829
|
+
"min",
|
|
830
|
+
"pattern",
|
|
831
|
+
"validate",
|
|
832
|
+
"setValueAs",
|
|
833
|
+
"disabled",
|
|
834
|
+
"onChange",
|
|
835
|
+
"onBlur",
|
|
836
|
+
"value",
|
|
837
|
+
"shouldUnregister",
|
|
838
|
+
"deps"
|
|
839
|
+
]);
|
|
840
|
+
var _a2;
|
|
841
|
+
const {
|
|
842
|
+
register,
|
|
843
|
+
formState: { errors }
|
|
844
|
+
} = (0, import_react_hook_form12.useFormContext)();
|
|
845
|
+
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
847
|
+
import_mui_textfield.TextField,
|
|
848
|
+
__spreadProps(__spreadValues(__spreadValues({}, rest), register(name, {
|
|
849
|
+
required,
|
|
850
|
+
maxLength,
|
|
851
|
+
minLength,
|
|
852
|
+
max,
|
|
853
|
+
min,
|
|
854
|
+
pattern,
|
|
855
|
+
validate,
|
|
856
|
+
setValueAs,
|
|
857
|
+
disabled,
|
|
858
|
+
onChange,
|
|
859
|
+
onBlur,
|
|
860
|
+
value,
|
|
861
|
+
shouldUnregister,
|
|
862
|
+
deps
|
|
863
|
+
})), {
|
|
864
|
+
error: !!errors[name],
|
|
865
|
+
helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
866
|
+
errorMessage,
|
|
867
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("br", {}),
|
|
868
|
+
helperText
|
|
869
|
+
] }) : helperText
|
|
870
|
+
})
|
|
871
|
+
);
|
|
67
872
|
};
|
|
68
873
|
// Annotate the CommonJS export names for ESM import in node:
|
|
69
874
|
0 && (module.exports = {
|
|
70
|
-
|
|
875
|
+
ControlledAsyncAutocomplete,
|
|
876
|
+
ControlledAutocomplete,
|
|
877
|
+
ControlledCheckbox,
|
|
878
|
+
ControlledCodesAutocomplete,
|
|
879
|
+
ControlledDatepicker,
|
|
880
|
+
ControlledForm,
|
|
881
|
+
ControlledInput,
|
|
882
|
+
ControlledOrganizationAutocomplete,
|
|
883
|
+
ControlledProviderAutocomplete,
|
|
884
|
+
ControlledRadioGroup,
|
|
885
|
+
ControlledSelect,
|
|
886
|
+
ControlledTextField
|
|
71
887
|
});
|