@availity/mui-controlled-form 0.2.5 → 0.3.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 +14 -0
- package/README.md +2 -2
- package/dist/index.d.mts +122 -34
- package/dist/index.d.ts +122 -34
- package/dist/index.js +263 -225
- package/dist/index.mjs +279 -240
- package/package.json +2 -2
- package/src/index.ts +47 -0
- package/src/lib/AsyncAutocomplete.stories.tsx +21 -36
- package/src/lib/AsyncAutocomplete.test.tsx +17 -53
- package/src/lib/AsyncAutocomplete.tsx +23 -20
- package/src/lib/Autocomplete.stories.tsx +20 -33
- package/src/lib/Autocomplete.test.tsx +7 -37
- package/src/lib/Autocomplete.tsx +16 -15
- package/src/lib/Checkbox.stories.tsx +50 -43
- package/src/lib/Checkbox.test.tsx +14 -46
- package/src/lib/Checkbox.tsx +30 -15
- package/src/lib/CodesAutocomplete.stories.tsx +21 -35
- package/src/lib/CodesAutocomplete.test.tsx +20 -54
- package/src/lib/CodesAutocomplete.tsx +23 -20
- package/src/lib/ControlledForm.stories.tsx +1 -0
- package/src/lib/ControlledForm.tsx +8 -4
- package/src/lib/Datepicker.stories.tsx +19 -32
- package/src/lib/Datepicker.test.tsx +3 -35
- package/src/lib/Datepicker.tsx +18 -10
- package/src/lib/Input.stories.tsx +32 -33
- package/src/lib/Input.test.tsx +71 -7
- package/src/lib/Input.tsx +44 -24
- package/src/lib/OrganizationAutocomplete.stories.tsx +30 -35
- package/src/lib/OrganizationAutocomplete.test.tsx +23 -57
- package/src/lib/OrganizationAutocomplete.tsx +24 -23
- package/src/lib/ProviderAutocomplete.stories.tsx +20 -35
- package/src/lib/ProviderAutocomplete.test.tsx +29 -63
- package/src/lib/ProviderAutocomplete.tsx +22 -20
- package/src/lib/RadioGroup.stories.tsx +41 -36
- package/src/lib/RadioGroup.test.tsx +3 -35
- package/src/lib/RadioGroup.tsx +33 -25
- package/src/lib/Select.stories.tsx +78 -45
- package/src/lib/Select.test.tsx +8 -36
- package/src/lib/Select.tsx +44 -25
- package/src/lib/TextField.stories.tsx +26 -34
- package/src/lib/TextField.test.tsx +71 -5
- package/src/lib/TextField.tsx +55 -37
- package/src/lib/Types.tsx +2489 -0
- package/src/lib/UtilComponents.tsx +52 -0
- package/docs/propDefinitions.tsx +0 -31
package/dist/index.mjs
CHANGED
|
@@ -32,7 +32,7 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
|
|
33
33
|
// src/lib/AsyncAutocomplete.tsx
|
|
34
34
|
import { AsyncAutocomplete } from "@availity/mui-autocomplete";
|
|
35
|
-
import {
|
|
35
|
+
import { Controller } from "react-hook-form";
|
|
36
36
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
37
37
|
var ControlledAsyncAutocomplete = (_a) => {
|
|
38
38
|
var _b = _a, {
|
|
@@ -46,6 +46,7 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
46
46
|
onChange,
|
|
47
47
|
pattern,
|
|
48
48
|
required,
|
|
49
|
+
rules = {},
|
|
49
50
|
shouldUnregister,
|
|
50
51
|
validate,
|
|
51
52
|
value,
|
|
@@ -61,21 +62,18 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
61
62
|
"onChange",
|
|
62
63
|
"pattern",
|
|
63
64
|
"required",
|
|
65
|
+
"rules",
|
|
64
66
|
"shouldUnregister",
|
|
65
67
|
"validate",
|
|
66
68
|
"value",
|
|
67
69
|
"FieldProps"
|
|
68
70
|
]);
|
|
69
|
-
var _a2;
|
|
70
|
-
const { control, getFieldState } = useFormContext();
|
|
71
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
72
71
|
return /* @__PURE__ */ jsx(
|
|
73
72
|
Controller,
|
|
74
73
|
{
|
|
75
74
|
name,
|
|
76
|
-
control,
|
|
77
75
|
defaultValue: rest.defaultValue,
|
|
78
|
-
rules: {
|
|
76
|
+
rules: __spreadValues({
|
|
79
77
|
deps,
|
|
80
78
|
max,
|
|
81
79
|
maxLength,
|
|
@@ -88,19 +86,19 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
88
86
|
shouldUnregister,
|
|
89
87
|
validate,
|
|
90
88
|
value
|
|
91
|
-
},
|
|
89
|
+
}, rules),
|
|
92
90
|
shouldUnregister,
|
|
93
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx(
|
|
91
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => /* @__PURE__ */ jsx(
|
|
94
92
|
AsyncAutocomplete,
|
|
95
93
|
__spreadProps(__spreadValues({}, rest), {
|
|
96
94
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
97
|
-
|
|
98
|
-
error:
|
|
99
|
-
|
|
100
|
-
errorMessage,
|
|
95
|
+
error: !!error,
|
|
96
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
97
|
+
error.message,
|
|
101
98
|
/* @__PURE__ */ jsx("br", {}),
|
|
102
99
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
103
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
100
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
101
|
+
inputRef: ref
|
|
104
102
|
}),
|
|
105
103
|
onChange: (event, value3, reason) => {
|
|
106
104
|
if (reason === "clear") {
|
|
@@ -118,13 +116,14 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
118
116
|
|
|
119
117
|
// src/lib/Autocomplete.tsx
|
|
120
118
|
import { Autocomplete } from "@availity/mui-autocomplete";
|
|
121
|
-
import {
|
|
119
|
+
import { Controller as Controller2 } from "react-hook-form";
|
|
122
120
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
123
121
|
var ControlledAutocomplete = (_a) => {
|
|
124
122
|
var _b = _a, {
|
|
125
123
|
name,
|
|
126
124
|
FieldProps,
|
|
127
125
|
defaultValue,
|
|
126
|
+
rules = {},
|
|
128
127
|
deps,
|
|
129
128
|
max,
|
|
130
129
|
maxLength,
|
|
@@ -141,6 +140,7 @@ var ControlledAutocomplete = (_a) => {
|
|
|
141
140
|
"name",
|
|
142
141
|
"FieldProps",
|
|
143
142
|
"defaultValue",
|
|
143
|
+
"rules",
|
|
144
144
|
"deps",
|
|
145
145
|
"max",
|
|
146
146
|
"maxLength",
|
|
@@ -154,16 +154,12 @@ var ControlledAutocomplete = (_a) => {
|
|
|
154
154
|
"validate",
|
|
155
155
|
"value"
|
|
156
156
|
]);
|
|
157
|
-
var _a2;
|
|
158
|
-
const { control, getFieldState } = useFormContext2();
|
|
159
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
160
157
|
return /* @__PURE__ */ jsx2(
|
|
161
158
|
Controller2,
|
|
162
159
|
{
|
|
163
|
-
control,
|
|
164
160
|
name,
|
|
165
161
|
defaultValue,
|
|
166
|
-
rules: {
|
|
162
|
+
rules: __spreadValues({
|
|
167
163
|
deps,
|
|
168
164
|
max,
|
|
169
165
|
maxLength,
|
|
@@ -176,19 +172,19 @@ var ControlledAutocomplete = (_a) => {
|
|
|
176
172
|
shouldUnregister,
|
|
177
173
|
validate,
|
|
178
174
|
value
|
|
179
|
-
},
|
|
175
|
+
}, rules),
|
|
180
176
|
shouldUnregister,
|
|
181
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx2(
|
|
177
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => /* @__PURE__ */ jsx2(
|
|
182
178
|
Autocomplete,
|
|
183
179
|
__spreadProps(__spreadValues({}, rest), {
|
|
184
180
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
185
|
-
|
|
186
|
-
error:
|
|
187
|
-
|
|
188
|
-
errorMessage,
|
|
181
|
+
error: !!error,
|
|
182
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
183
|
+
error.message,
|
|
189
184
|
/* @__PURE__ */ jsx2("br", {}),
|
|
190
185
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
191
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
186
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
187
|
+
inputRef: ref
|
|
192
188
|
}),
|
|
193
189
|
onChange: (event, value3, reason) => {
|
|
194
190
|
if (reason === "clear") {
|
|
@@ -206,46 +202,55 @@ var ControlledAutocomplete = (_a) => {
|
|
|
206
202
|
|
|
207
203
|
// src/lib/Checkbox.tsx
|
|
208
204
|
import { Checkbox } from "@availity/mui-checkbox";
|
|
209
|
-
import {
|
|
205
|
+
import { Controller as Controller3 } from "react-hook-form";
|
|
210
206
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
211
207
|
var ControlledCheckbox = (_a) => {
|
|
212
208
|
var _b = _a, {
|
|
213
209
|
name,
|
|
214
|
-
setValueAs,
|
|
215
210
|
disabled,
|
|
216
211
|
onChange,
|
|
217
212
|
onBlur,
|
|
218
213
|
value,
|
|
214
|
+
defaultValue = false,
|
|
215
|
+
rules = {},
|
|
219
216
|
shouldUnregister,
|
|
220
|
-
deps
|
|
217
|
+
deps,
|
|
218
|
+
validate
|
|
221
219
|
} = _b, rest = __objRest(_b, [
|
|
222
220
|
"name",
|
|
223
|
-
"setValueAs",
|
|
224
221
|
"disabled",
|
|
225
222
|
"onChange",
|
|
226
223
|
"onBlur",
|
|
227
224
|
"value",
|
|
225
|
+
"defaultValue",
|
|
226
|
+
"rules",
|
|
228
227
|
"shouldUnregister",
|
|
229
|
-
"deps"
|
|
228
|
+
"deps",
|
|
229
|
+
"validate"
|
|
230
230
|
]);
|
|
231
|
-
const { register } = useFormContext3();
|
|
232
231
|
return /* @__PURE__ */ jsx3(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
Controller3,
|
|
233
|
+
{
|
|
234
|
+
name,
|
|
235
|
+
defaultValue,
|
|
236
236
|
disabled,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
rules: __spreadValues({
|
|
238
|
+
onChange,
|
|
239
|
+
onBlur,
|
|
240
|
+
value,
|
|
241
|
+
shouldUnregister,
|
|
242
|
+
deps,
|
|
243
|
+
validate
|
|
244
|
+
}, rules),
|
|
240
245
|
shouldUnregister,
|
|
241
|
-
|
|
242
|
-
}
|
|
246
|
+
render: ({ field }) => /* @__PURE__ */ jsx3(Checkbox, __spreadProps(__spreadValues(__spreadValues({}, rest), field), { checked: field.value, onChange: (e) => field.onChange(e.target.checked) }))
|
|
247
|
+
}
|
|
243
248
|
);
|
|
244
249
|
};
|
|
245
250
|
|
|
246
251
|
// src/lib/CodesAutocomplete.tsx
|
|
247
252
|
import { CodesAutocomplete } from "@availity/mui-autocomplete";
|
|
248
|
-
import {
|
|
253
|
+
import { Controller as Controller4 } from "react-hook-form";
|
|
249
254
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
250
255
|
var ControlledCodesAutocomplete = (_a) => {
|
|
251
256
|
var _b = _a, {
|
|
@@ -258,6 +263,7 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
258
263
|
onChange,
|
|
259
264
|
pattern,
|
|
260
265
|
required,
|
|
266
|
+
rules = {},
|
|
261
267
|
shouldUnregister,
|
|
262
268
|
validate,
|
|
263
269
|
value,
|
|
@@ -272,21 +278,18 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
272
278
|
"onChange",
|
|
273
279
|
"pattern",
|
|
274
280
|
"required",
|
|
281
|
+
"rules",
|
|
275
282
|
"shouldUnregister",
|
|
276
283
|
"validate",
|
|
277
284
|
"value",
|
|
278
285
|
"FieldProps"
|
|
279
286
|
]);
|
|
280
|
-
var _a2;
|
|
281
|
-
const { control, getFieldState } = useFormContext4();
|
|
282
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
283
287
|
return /* @__PURE__ */ jsx4(
|
|
284
|
-
|
|
288
|
+
Controller4,
|
|
285
289
|
{
|
|
286
290
|
name,
|
|
287
|
-
control,
|
|
288
291
|
defaultValue,
|
|
289
|
-
rules: {
|
|
292
|
+
rules: __spreadValues({
|
|
290
293
|
deps,
|
|
291
294
|
max,
|
|
292
295
|
maxLength,
|
|
@@ -297,19 +300,19 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
297
300
|
shouldUnregister,
|
|
298
301
|
validate,
|
|
299
302
|
value
|
|
300
|
-
},
|
|
303
|
+
}, rules),
|
|
301
304
|
shouldUnregister,
|
|
302
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx4(
|
|
305
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => /* @__PURE__ */ jsx4(
|
|
303
306
|
CodesAutocomplete,
|
|
304
307
|
__spreadProps(__spreadValues({}, rest), {
|
|
305
308
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
306
|
-
|
|
307
|
-
error:
|
|
308
|
-
|
|
309
|
-
errorMessage,
|
|
309
|
+
error: !!error,
|
|
310
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
311
|
+
error.message,
|
|
310
312
|
/* @__PURE__ */ jsx4("br", {}),
|
|
311
313
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
312
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
314
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
315
|
+
inputRef: ref
|
|
313
316
|
}),
|
|
314
317
|
onChange: (event, value3, reason) => {
|
|
315
318
|
if (reason === "clear") {
|
|
@@ -329,18 +332,18 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
329
332
|
import { useForm, FormProvider } from "react-hook-form";
|
|
330
333
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
331
334
|
var ControlledForm = (_a) => {
|
|
332
|
-
var _b = _a, { onSubmit, values, schema, validationResolver } = _b, rest = __objRest(_b, ["onSubmit", "values", "schema", "validationResolver"]);
|
|
333
|
-
const useFormOptions = { values };
|
|
335
|
+
var _b = _a, { onSubmit, values, schema, validationResolver, additionalUseFormOptions = { mode: "onBlur" } } = _b, rest = __objRest(_b, ["onSubmit", "values", "schema", "validationResolver", "additionalUseFormOptions"]);
|
|
336
|
+
const useFormOptions = __spreadValues({ values }, additionalUseFormOptions);
|
|
334
337
|
if (schema && validationResolver) {
|
|
335
338
|
useFormOptions.resolver = validationResolver(schema);
|
|
336
339
|
}
|
|
337
340
|
const methods = useForm(useFormOptions);
|
|
338
|
-
return /* @__PURE__ */ jsx5(FormProvider, __spreadProps(__spreadValues({}, methods), { children: /* @__PURE__ */ jsx5("form", __spreadValues({ onSubmit: methods.handleSubmit(onSubmit) }, rest)) }));
|
|
341
|
+
return /* @__PURE__ */ jsx5(FormProvider, __spreadProps(__spreadValues({}, methods), { children: /* @__PURE__ */ jsx5("form", __spreadValues({ onSubmit: methods.handleSubmit(onSubmit), noValidate: true }, rest)) }));
|
|
339
342
|
};
|
|
340
343
|
|
|
341
344
|
// src/lib/Datepicker.tsx
|
|
342
345
|
import { Datepicker } from "@availity/mui-datepicker";
|
|
343
|
-
import {
|
|
346
|
+
import { Controller as Controller5 } from "react-hook-form";
|
|
344
347
|
import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
345
348
|
var ControlledDatepicker = (_a) => {
|
|
346
349
|
var _b = _a, {
|
|
@@ -355,6 +358,7 @@ var ControlledDatepicker = (_a) => {
|
|
|
355
358
|
onChange,
|
|
356
359
|
pattern,
|
|
357
360
|
required,
|
|
361
|
+
rules = {},
|
|
358
362
|
shouldUnregister,
|
|
359
363
|
validate,
|
|
360
364
|
value,
|
|
@@ -371,19 +375,18 @@ var ControlledDatepicker = (_a) => {
|
|
|
371
375
|
"onChange",
|
|
372
376
|
"pattern",
|
|
373
377
|
"required",
|
|
378
|
+
"rules",
|
|
374
379
|
"shouldUnregister",
|
|
375
380
|
"validate",
|
|
376
381
|
"value",
|
|
377
382
|
"FieldProps"
|
|
378
383
|
]);
|
|
379
|
-
const { control } = useFormContext5();
|
|
380
384
|
return /* @__PURE__ */ jsx6(
|
|
381
|
-
|
|
385
|
+
Controller5,
|
|
382
386
|
{
|
|
383
387
|
name,
|
|
384
|
-
control,
|
|
385
388
|
defaultValue,
|
|
386
|
-
rules: {
|
|
389
|
+
rules: __spreadValues({
|
|
387
390
|
deps,
|
|
388
391
|
max,
|
|
389
392
|
maxLength,
|
|
@@ -396,19 +399,22 @@ var ControlledDatepicker = (_a) => {
|
|
|
396
399
|
shouldUnregister,
|
|
397
400
|
validate,
|
|
398
401
|
value
|
|
399
|
-
},
|
|
402
|
+
}, rules),
|
|
400
403
|
shouldUnregister,
|
|
401
|
-
render: ({ field: { onChange: onChange2, value: value2 }, fieldState: { error } }) => /* @__PURE__ */ jsx6(
|
|
404
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => /* @__PURE__ */ jsx6(
|
|
402
405
|
Datepicker,
|
|
403
406
|
__spreadProps(__spreadValues({}, rest), {
|
|
404
407
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
405
|
-
required: typeof required === "object" ? required.value : !!required,
|
|
406
408
|
error: !!error,
|
|
407
|
-
helperText:
|
|
408
|
-
error
|
|
409
|
+
helperText: error ? /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
410
|
+
error.message,
|
|
409
411
|
/* @__PURE__ */ jsx6("br", {}),
|
|
410
412
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
411
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
413
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
414
|
+
inputRef: ref,
|
|
415
|
+
inputProps: {
|
|
416
|
+
onBlur: onBlur2
|
|
417
|
+
}
|
|
412
418
|
}),
|
|
413
419
|
onChange: onChange2,
|
|
414
420
|
value: value2 || null
|
|
@@ -420,70 +426,79 @@ var ControlledDatepicker = (_a) => {
|
|
|
420
426
|
|
|
421
427
|
// src/lib/Input.tsx
|
|
422
428
|
import { Input } from "@availity/mui-form-utils";
|
|
423
|
-
import {
|
|
429
|
+
import { Controller as Controller6 } from "react-hook-form";
|
|
424
430
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
425
431
|
var ControlledInput = (_a) => {
|
|
426
432
|
var _b = _a, {
|
|
427
433
|
name,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
434
|
+
defaultValue,
|
|
435
|
+
deps,
|
|
436
|
+
disabled,
|
|
431
437
|
max,
|
|
438
|
+
maxLength,
|
|
432
439
|
min,
|
|
433
|
-
|
|
434
|
-
validate,
|
|
435
|
-
setValueAs,
|
|
436
|
-
disabled,
|
|
437
|
-
onChange,
|
|
440
|
+
minLength,
|
|
438
441
|
onBlur,
|
|
439
|
-
|
|
442
|
+
onChange,
|
|
443
|
+
pattern,
|
|
444
|
+
required,
|
|
445
|
+
rules = {},
|
|
440
446
|
shouldUnregister,
|
|
441
|
-
|
|
447
|
+
validate,
|
|
448
|
+
value
|
|
442
449
|
} = _b, rest = __objRest(_b, [
|
|
443
450
|
"name",
|
|
444
|
-
"
|
|
445
|
-
"
|
|
446
|
-
"
|
|
451
|
+
"defaultValue",
|
|
452
|
+
"deps",
|
|
453
|
+
"disabled",
|
|
447
454
|
"max",
|
|
455
|
+
"maxLength",
|
|
448
456
|
"min",
|
|
449
|
-
"
|
|
450
|
-
"validate",
|
|
451
|
-
"setValueAs",
|
|
452
|
-
"disabled",
|
|
453
|
-
"onChange",
|
|
457
|
+
"minLength",
|
|
454
458
|
"onBlur",
|
|
455
|
-
"
|
|
459
|
+
"onChange",
|
|
460
|
+
"pattern",
|
|
461
|
+
"required",
|
|
462
|
+
"rules",
|
|
456
463
|
"shouldUnregister",
|
|
457
|
-
"
|
|
464
|
+
"validate",
|
|
465
|
+
"value"
|
|
458
466
|
]);
|
|
459
|
-
const { register, getFieldState } = useFormContext6();
|
|
460
467
|
return /* @__PURE__ */ jsx7(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}), register(name, {
|
|
466
|
-
required,
|
|
467
|
-
maxLength,
|
|
468
|
-
minLength,
|
|
469
|
-
max,
|
|
470
|
-
min,
|
|
471
|
-
pattern,
|
|
472
|
-
validate,
|
|
473
|
-
setValueAs,
|
|
468
|
+
Controller6,
|
|
469
|
+
{
|
|
470
|
+
name,
|
|
471
|
+
defaultValue,
|
|
474
472
|
disabled,
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
473
|
+
rules: __spreadValues({
|
|
474
|
+
required: typeof required === "boolean" ? void 0 : required,
|
|
475
|
+
maxLength,
|
|
476
|
+
minLength,
|
|
477
|
+
max,
|
|
478
|
+
min,
|
|
479
|
+
pattern,
|
|
480
|
+
validate,
|
|
481
|
+
onChange,
|
|
482
|
+
onBlur,
|
|
483
|
+
value,
|
|
484
|
+
shouldUnregister,
|
|
485
|
+
deps
|
|
486
|
+
}, rules),
|
|
478
487
|
shouldUnregister,
|
|
479
|
-
|
|
480
|
-
|
|
488
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx7(
|
|
489
|
+
Input,
|
|
490
|
+
__spreadProps(__spreadValues(__spreadValues({}, rest), field), {
|
|
491
|
+
error: !!error,
|
|
492
|
+
required: !!required
|
|
493
|
+
})
|
|
494
|
+
)
|
|
495
|
+
}
|
|
481
496
|
);
|
|
482
497
|
};
|
|
483
498
|
|
|
484
499
|
// src/lib/OrganizationAutocomplete.tsx
|
|
485
500
|
import { OrganizationAutocomplete } from "@availity/mui-autocomplete";
|
|
486
|
-
import {
|
|
501
|
+
import { Controller as Controller7 } from "react-hook-form";
|
|
487
502
|
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
488
503
|
var ControlledOrganizationAutocomplete = (_a) => {
|
|
489
504
|
var _b = _a, {
|
|
@@ -494,6 +509,7 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
494
509
|
onChange,
|
|
495
510
|
pattern,
|
|
496
511
|
required,
|
|
512
|
+
rules = {},
|
|
497
513
|
shouldUnregister,
|
|
498
514
|
validate,
|
|
499
515
|
value,
|
|
@@ -506,21 +522,18 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
506
522
|
"onChange",
|
|
507
523
|
"pattern",
|
|
508
524
|
"required",
|
|
525
|
+
"rules",
|
|
509
526
|
"shouldUnregister",
|
|
510
527
|
"validate",
|
|
511
528
|
"value",
|
|
512
529
|
"FieldProps"
|
|
513
530
|
]);
|
|
514
|
-
var _a2;
|
|
515
|
-
const { control, getFieldState } = useFormContext7();
|
|
516
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
517
531
|
return /* @__PURE__ */ jsx8(
|
|
518
|
-
|
|
532
|
+
Controller7,
|
|
519
533
|
{
|
|
520
534
|
name,
|
|
521
|
-
control,
|
|
522
535
|
defaultValue,
|
|
523
|
-
rules: {
|
|
536
|
+
rules: __spreadValues({
|
|
524
537
|
deps,
|
|
525
538
|
onBlur,
|
|
526
539
|
onChange,
|
|
@@ -529,19 +542,19 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
529
542
|
shouldUnregister,
|
|
530
543
|
validate,
|
|
531
544
|
value
|
|
532
|
-
},
|
|
545
|
+
}, rules),
|
|
533
546
|
shouldUnregister,
|
|
534
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx8(
|
|
547
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => /* @__PURE__ */ jsx8(
|
|
535
548
|
OrganizationAutocomplete,
|
|
536
549
|
__spreadProps(__spreadValues({}, rest), {
|
|
537
550
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
538
|
-
|
|
539
|
-
error:
|
|
540
|
-
|
|
541
|
-
errorMessage,
|
|
551
|
+
error: !!error,
|
|
552
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
553
|
+
error.message,
|
|
542
554
|
/* @__PURE__ */ jsx8("br", {}),
|
|
543
555
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
544
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
556
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
557
|
+
inputRef: ref
|
|
545
558
|
}),
|
|
546
559
|
onChange: (event, value3, reason) => {
|
|
547
560
|
if (reason === "clear") {
|
|
@@ -559,7 +572,7 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
559
572
|
|
|
560
573
|
// src/lib/ProviderAutocomplete.tsx
|
|
561
574
|
import { ProviderAutocomplete } from "@availity/mui-autocomplete";
|
|
562
|
-
import {
|
|
575
|
+
import { Controller as Controller8 } from "react-hook-form";
|
|
563
576
|
import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
564
577
|
var ControlledProviderAutocomplete = (_a) => {
|
|
565
578
|
var _b = _a, {
|
|
@@ -574,6 +587,7 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
574
587
|
onChange,
|
|
575
588
|
pattern,
|
|
576
589
|
required,
|
|
590
|
+
rules = {},
|
|
577
591
|
shouldUnregister,
|
|
578
592
|
validate,
|
|
579
593
|
value,
|
|
@@ -590,21 +604,18 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
590
604
|
"onChange",
|
|
591
605
|
"pattern",
|
|
592
606
|
"required",
|
|
607
|
+
"rules",
|
|
593
608
|
"shouldUnregister",
|
|
594
609
|
"validate",
|
|
595
610
|
"value",
|
|
596
611
|
"FieldProps"
|
|
597
612
|
]);
|
|
598
|
-
var _a2;
|
|
599
|
-
const { control, getFieldState } = useFormContext8();
|
|
600
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
601
613
|
return /* @__PURE__ */ jsx9(
|
|
602
|
-
|
|
614
|
+
Controller8,
|
|
603
615
|
{
|
|
604
616
|
name,
|
|
605
|
-
control,
|
|
606
617
|
defaultValue,
|
|
607
|
-
rules: {
|
|
618
|
+
rules: __spreadValues({
|
|
608
619
|
deps,
|
|
609
620
|
max,
|
|
610
621
|
maxLength,
|
|
@@ -617,16 +628,15 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
617
628
|
shouldUnregister,
|
|
618
629
|
validate,
|
|
619
630
|
value
|
|
620
|
-
},
|
|
631
|
+
}, rules),
|
|
621
632
|
shouldUnregister,
|
|
622
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx9(
|
|
633
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx9(
|
|
623
634
|
ProviderAutocomplete,
|
|
624
635
|
__spreadProps(__spreadValues({}, rest), {
|
|
625
636
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
626
|
-
|
|
627
|
-
error:
|
|
628
|
-
|
|
629
|
-
errorMessage,
|
|
637
|
+
error: !!error,
|
|
638
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
639
|
+
error.message,
|
|
630
640
|
/* @__PURE__ */ jsx9("br", {}),
|
|
631
641
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
632
642
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -647,7 +657,7 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
647
657
|
|
|
648
658
|
// src/lib/RadioGroup.tsx
|
|
649
659
|
import { RadioGroup } from "@availity/mui-form-utils";
|
|
650
|
-
import {
|
|
660
|
+
import { Controller as Controller9 } from "react-hook-form";
|
|
651
661
|
import { FormControl, FormLabel, FormHelperText } from "@availity/mui-form-utils";
|
|
652
662
|
import { Fragment as Fragment7, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
653
663
|
var ControlledRadioGroup = (_a) => {
|
|
@@ -660,6 +670,7 @@ var ControlledRadioGroup = (_a) => {
|
|
|
660
670
|
onBlur,
|
|
661
671
|
onChange,
|
|
662
672
|
required,
|
|
673
|
+
rules = {},
|
|
663
674
|
shouldUnregister,
|
|
664
675
|
value
|
|
665
676
|
} = _b, rest = __objRest(_b, [
|
|
@@ -671,168 +682,193 @@ var ControlledRadioGroup = (_a) => {
|
|
|
671
682
|
"onBlur",
|
|
672
683
|
"onChange",
|
|
673
684
|
"required",
|
|
685
|
+
"rules",
|
|
674
686
|
"shouldUnregister",
|
|
675
687
|
"value"
|
|
676
688
|
]);
|
|
677
|
-
var _a2;
|
|
678
|
-
const { control, getFieldState } = useFormContext9();
|
|
679
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
680
689
|
return /* @__PURE__ */ jsx10(
|
|
681
|
-
|
|
690
|
+
Controller9,
|
|
682
691
|
{
|
|
683
|
-
control,
|
|
684
692
|
name,
|
|
685
693
|
defaultValue,
|
|
686
|
-
rules: { deps, onBlur, onChange, required, shouldUnregister, value },
|
|
694
|
+
rules: __spreadValues({ deps, onBlur, onChange, required: typeof required === "boolean" ? void 0 : required, shouldUnregister, value }, rules),
|
|
687
695
|
shouldUnregister,
|
|
688
|
-
render: (
|
|
689
|
-
|
|
690
|
-
/* @__PURE__ */
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
/* @__PURE__ */ jsx10(
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
696
|
+
render: (_a2) => {
|
|
697
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { disabled } = _d, field = __objRest(_d, ["disabled"]), { fieldState: { error } } = _b2;
|
|
698
|
+
return /* @__PURE__ */ jsxs7(FormControl, { error: !!error, disabled, required: !!required, children: [
|
|
699
|
+
/* @__PURE__ */ jsx10(FormLabel, { children: label }),
|
|
700
|
+
/* @__PURE__ */ jsx10(RadioGroup, __spreadValues(__spreadValues({}, field), rest)),
|
|
701
|
+
/* @__PURE__ */ jsx10(FormHelperText, { children: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs7(Fragment7, { children: [
|
|
702
|
+
error.message,
|
|
703
|
+
/* @__PURE__ */ jsx10("br", {}),
|
|
704
|
+
helperText
|
|
705
|
+
] }) : helperText })
|
|
706
|
+
] });
|
|
707
|
+
}
|
|
697
708
|
}
|
|
698
709
|
);
|
|
699
710
|
};
|
|
700
711
|
|
|
701
712
|
// src/lib/Select.tsx
|
|
702
713
|
import { Select } from "@availity/mui-form-utils";
|
|
703
|
-
import {
|
|
714
|
+
import { Controller as Controller10 } from "react-hook-form";
|
|
704
715
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
705
716
|
var ControlledSelect = (_a) => {
|
|
706
717
|
var _b = _a, {
|
|
707
718
|
name,
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
719
|
+
defaultValue,
|
|
720
|
+
deps,
|
|
721
|
+
disabled,
|
|
711
722
|
max,
|
|
723
|
+
maxLength,
|
|
712
724
|
min,
|
|
713
|
-
|
|
714
|
-
validate,
|
|
715
|
-
setValueAs,
|
|
716
|
-
disabled,
|
|
717
|
-
onChange,
|
|
725
|
+
minLength,
|
|
718
726
|
onBlur,
|
|
719
|
-
|
|
727
|
+
onChange,
|
|
728
|
+
pattern,
|
|
729
|
+
required,
|
|
730
|
+
rules = {},
|
|
720
731
|
shouldUnregister,
|
|
721
|
-
|
|
732
|
+
validate,
|
|
733
|
+
value
|
|
722
734
|
} = _b, rest = __objRest(_b, [
|
|
723
735
|
"name",
|
|
724
|
-
"
|
|
725
|
-
"
|
|
726
|
-
"
|
|
736
|
+
"defaultValue",
|
|
737
|
+
"deps",
|
|
738
|
+
"disabled",
|
|
727
739
|
"max",
|
|
740
|
+
"maxLength",
|
|
728
741
|
"min",
|
|
729
|
-
"
|
|
730
|
-
"validate",
|
|
731
|
-
"setValueAs",
|
|
732
|
-
"disabled",
|
|
733
|
-
"onChange",
|
|
742
|
+
"minLength",
|
|
734
743
|
"onBlur",
|
|
735
|
-
"
|
|
744
|
+
"onChange",
|
|
745
|
+
"pattern",
|
|
746
|
+
"required",
|
|
747
|
+
"rules",
|
|
736
748
|
"shouldUnregister",
|
|
737
|
-
"
|
|
749
|
+
"validate",
|
|
750
|
+
"value"
|
|
738
751
|
]);
|
|
739
|
-
const { register, getFieldState } = useFormContext10();
|
|
740
752
|
return /* @__PURE__ */ jsx11(
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}), register(name, {
|
|
746
|
-
required,
|
|
747
|
-
maxLength,
|
|
748
|
-
minLength,
|
|
749
|
-
max,
|
|
750
|
-
min,
|
|
751
|
-
pattern,
|
|
752
|
-
validate,
|
|
753
|
-
setValueAs,
|
|
753
|
+
Controller10,
|
|
754
|
+
{
|
|
755
|
+
name,
|
|
756
|
+
defaultValue,
|
|
754
757
|
disabled,
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
+
rules: __spreadValues({
|
|
759
|
+
required: typeof required === "boolean" ? void 0 : required,
|
|
760
|
+
maxLength,
|
|
761
|
+
minLength,
|
|
762
|
+
max,
|
|
763
|
+
min,
|
|
764
|
+
pattern,
|
|
765
|
+
validate,
|
|
766
|
+
onChange,
|
|
767
|
+
onBlur,
|
|
768
|
+
value,
|
|
769
|
+
shouldUnregister,
|
|
770
|
+
deps
|
|
771
|
+
}, rules),
|
|
758
772
|
shouldUnregister,
|
|
759
|
-
|
|
760
|
-
|
|
773
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx11(
|
|
774
|
+
Select,
|
|
775
|
+
__spreadProps(__spreadValues(__spreadValues({}, rest), field), {
|
|
776
|
+
error: !!error,
|
|
777
|
+
required: !!required
|
|
778
|
+
})
|
|
779
|
+
)
|
|
780
|
+
}
|
|
761
781
|
);
|
|
762
782
|
};
|
|
763
783
|
|
|
764
784
|
// src/lib/TextField.tsx
|
|
765
785
|
import { TextField } from "@availity/mui-textfield";
|
|
766
|
-
import {
|
|
786
|
+
import { Controller as Controller11 } from "react-hook-form";
|
|
767
787
|
import { Fragment as Fragment8, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
768
788
|
var ControlledTextField = (_a) => {
|
|
769
789
|
var _b = _a, {
|
|
770
790
|
name,
|
|
791
|
+
defaultValue,
|
|
792
|
+
deps,
|
|
793
|
+
disabled,
|
|
771
794
|
helperText,
|
|
772
|
-
required,
|
|
773
|
-
maxLength,
|
|
774
|
-
minLength,
|
|
775
795
|
max,
|
|
796
|
+
maxLength,
|
|
776
797
|
min,
|
|
777
|
-
|
|
778
|
-
validate,
|
|
779
|
-
setValueAs,
|
|
780
|
-
disabled,
|
|
781
|
-
onChange,
|
|
798
|
+
minLength,
|
|
782
799
|
onBlur,
|
|
783
|
-
|
|
800
|
+
onChange,
|
|
801
|
+
pattern,
|
|
802
|
+
required,
|
|
803
|
+
rules = {},
|
|
784
804
|
shouldUnregister,
|
|
785
|
-
|
|
805
|
+
validate,
|
|
806
|
+
value
|
|
786
807
|
} = _b, rest = __objRest(_b, [
|
|
787
808
|
"name",
|
|
809
|
+
"defaultValue",
|
|
810
|
+
"deps",
|
|
811
|
+
"disabled",
|
|
788
812
|
"helperText",
|
|
789
|
-
"required",
|
|
790
|
-
"maxLength",
|
|
791
|
-
"minLength",
|
|
792
813
|
"max",
|
|
814
|
+
"maxLength",
|
|
793
815
|
"min",
|
|
794
|
-
"
|
|
795
|
-
"validate",
|
|
796
|
-
"setValueAs",
|
|
797
|
-
"disabled",
|
|
798
|
-
"onChange",
|
|
816
|
+
"minLength",
|
|
799
817
|
"onBlur",
|
|
800
|
-
"
|
|
818
|
+
"onChange",
|
|
819
|
+
"pattern",
|
|
820
|
+
"required",
|
|
821
|
+
"rules",
|
|
801
822
|
"shouldUnregister",
|
|
802
|
-
"
|
|
823
|
+
"validate",
|
|
824
|
+
"value"
|
|
803
825
|
]);
|
|
804
|
-
var _a2;
|
|
805
|
-
const { register, getFieldState } = useFormContext11();
|
|
806
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
807
826
|
return /* @__PURE__ */ jsx12(
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
required,
|
|
813
|
-
maxLength,
|
|
814
|
-
minLength,
|
|
815
|
-
max,
|
|
816
|
-
min,
|
|
817
|
-
pattern,
|
|
818
|
-
validate,
|
|
819
|
-
setValueAs,
|
|
827
|
+
Controller11,
|
|
828
|
+
{
|
|
829
|
+
name,
|
|
830
|
+
defaultValue,
|
|
820
831
|
disabled,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
832
|
+
rules: __spreadValues({
|
|
833
|
+
required: typeof required === "boolean" ? void 0 : required,
|
|
834
|
+
maxLength,
|
|
835
|
+
minLength,
|
|
836
|
+
max,
|
|
837
|
+
min,
|
|
838
|
+
pattern,
|
|
839
|
+
validate,
|
|
840
|
+
onChange,
|
|
841
|
+
onBlur,
|
|
842
|
+
value,
|
|
843
|
+
shouldUnregister,
|
|
844
|
+
deps
|
|
845
|
+
}, rules),
|
|
824
846
|
shouldUnregister,
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
847
|
+
render: (_a2) => {
|
|
848
|
+
var _b2 = _a2, { field: _c } = _b2, _d = _c, { ref } = _d, field = __objRest(_d, ["ref"]), { fieldState: { error } } = _b2;
|
|
849
|
+
return /* @__PURE__ */ jsx12(
|
|
850
|
+
TextField,
|
|
851
|
+
__spreadProps(__spreadValues(__spreadValues({}, field), rest), {
|
|
852
|
+
inputRef: ref,
|
|
853
|
+
error: !!error,
|
|
854
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs8(Fragment8, { children: [
|
|
855
|
+
error.message,
|
|
856
|
+
/* @__PURE__ */ jsx12("br", {}),
|
|
857
|
+
helperText
|
|
858
|
+
] }) : helperText
|
|
859
|
+
})
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
834
863
|
);
|
|
835
864
|
};
|
|
865
|
+
|
|
866
|
+
// src/index.ts
|
|
867
|
+
import {
|
|
868
|
+
FormProvider as FormProvider2,
|
|
869
|
+
useForm as useForm2,
|
|
870
|
+
useFormContext
|
|
871
|
+
} from "react-hook-form";
|
|
836
872
|
export {
|
|
837
873
|
ControlledAsyncAutocomplete,
|
|
838
874
|
ControlledAutocomplete,
|
|
@@ -845,5 +881,8 @@ export {
|
|
|
845
881
|
ControlledProviderAutocomplete,
|
|
846
882
|
ControlledRadioGroup,
|
|
847
883
|
ControlledSelect,
|
|
848
|
-
ControlledTextField
|
|
884
|
+
ControlledTextField,
|
|
885
|
+
FormProvider2 as FormProvider,
|
|
886
|
+
useForm2 as useForm,
|
|
887
|
+
useFormContext
|
|
849
888
|
};
|