@availity/mui-controlled-form 2.3.1 → 3.0.1
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 +40 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +468 -706
- package/package.json +30 -30
- package/project.json +5 -6
- package/src/index.ts +1 -1
- package/src/lib/AsyncAutocomplete.test.tsx +2 -2
- package/src/lib/Autocomplete.test.tsx +2 -2
- package/src/lib/Checkbox.test.tsx +1 -1
- package/src/lib/Checkbox.tsx +1 -3
- package/src/lib/CodesAutocomplete.test.tsx +2 -2
- package/src/lib/Datepicker.test.tsx +1 -1
- package/src/lib/Datepicker.tsx +3 -5
- package/src/lib/Input.test.tsx +1 -1
- package/src/lib/Input.tsx +1 -3
- package/src/lib/OrganizationAutocomplete.test.tsx +2 -2
- package/src/lib/ProviderAutocomplete.test.tsx +2 -2
- package/src/lib/ProviderAutocomplete.tsx +1 -1
- package/src/lib/RadioGroup.test.tsx +1 -1
- package/src/lib/RadioGroup.tsx +2 -5
- package/src/lib/Select.test.tsx +2 -6
- package/src/lib/Select.tsx +1 -3
- package/src/lib/TextField.test.tsx +1 -1
- package/src/lib/TextField.tsx +1 -3
- package/src/lib/Timepicker.test.tsx +1 -1
- package/src/lib/Timepicker.tsx +3 -5
- package/src/lib/Types.tsx +1 -1
- package/dist/index.d.mts +0 -103
- package/dist/index.mjs +0 -777
- package/jest.config.js +0 -7
- package/tsconfig.spec.json +0 -10
package/dist/index.mjs
DELETED
|
@@ -1,777 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
var fulfilled = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.next(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var rejected = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.throw(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// src/lib/AsyncAutocomplete.tsx
|
|
54
|
-
import { AsyncAutocomplete } from "@availity/mui-autocomplete";
|
|
55
|
-
import { Controller, useFormContext } from "react-hook-form";
|
|
56
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
57
|
-
var ControlledAsyncAutocomplete = (_a) => {
|
|
58
|
-
var _b = _a, {
|
|
59
|
-
name,
|
|
60
|
-
onBlur,
|
|
61
|
-
onChange,
|
|
62
|
-
rules = {},
|
|
63
|
-
shouldUnregister,
|
|
64
|
-
value,
|
|
65
|
-
FieldProps,
|
|
66
|
-
defaultToFirstOption,
|
|
67
|
-
defaultToOnlyOption,
|
|
68
|
-
transform
|
|
69
|
-
} = _b, rest = __objRest(_b, [
|
|
70
|
-
"name",
|
|
71
|
-
"onBlur",
|
|
72
|
-
"onChange",
|
|
73
|
-
"rules",
|
|
74
|
-
"shouldUnregister",
|
|
75
|
-
"value",
|
|
76
|
-
"FieldProps",
|
|
77
|
-
"defaultToFirstOption",
|
|
78
|
-
"defaultToOnlyOption",
|
|
79
|
-
"transform"
|
|
80
|
-
]);
|
|
81
|
-
const { setValue } = useFormContext();
|
|
82
|
-
const emptyValue = (rest == null ? void 0 : rest.multiple) ? [] : null;
|
|
83
|
-
return /* @__PURE__ */ jsx(
|
|
84
|
-
Controller,
|
|
85
|
-
{
|
|
86
|
-
name,
|
|
87
|
-
defaultValue: rest.defaultValue,
|
|
88
|
-
rules: __spreadValues({ onBlur, onChange, shouldUnregister, value }, rules),
|
|
89
|
-
shouldUnregister,
|
|
90
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => {
|
|
91
|
-
var _a2, _b2, _c;
|
|
92
|
-
return /* @__PURE__ */ jsx(
|
|
93
|
-
AsyncAutocomplete,
|
|
94
|
-
__spreadProps(__spreadValues({}, rest), {
|
|
95
|
-
FieldProps: __spreadProps(__spreadValues({
|
|
96
|
-
required: typeof rules.required === "object" ? rules.required.value : !!rules.required
|
|
97
|
-
}, FieldProps), {
|
|
98
|
-
error: !!error,
|
|
99
|
-
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
100
|
-
error.message,
|
|
101
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
102
|
-
FieldProps == null ? void 0 : FieldProps.helperText
|
|
103
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
104
|
-
inputRef: ref
|
|
105
|
-
}),
|
|
106
|
-
onChange: (event, value3, reason) => {
|
|
107
|
-
var _a3, _b3, _c2, _d;
|
|
108
|
-
if (reason === "clear") {
|
|
109
|
-
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 : emptyValue);
|
|
110
|
-
}
|
|
111
|
-
onChange2((_d = (_c2 = transform == null ? void 0 : transform.output) == null ? void 0 : _c2.call(transform, value3)) != null ? _d : value3);
|
|
112
|
-
},
|
|
113
|
-
onBlur: onBlur2,
|
|
114
|
-
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c : emptyValue,
|
|
115
|
-
loadOptions: (offset, limit, inputValue) => __async(null, null, function* () {
|
|
116
|
-
const { options, hasMore, offset: returnedOffsetValue } = yield rest.loadOptions(offset, limit, inputValue);
|
|
117
|
-
if (defaultToFirstOption && offset === 0) {
|
|
118
|
-
setValue(name, rest.multiple ? [options[0]] : options[0]);
|
|
119
|
-
}
|
|
120
|
-
if (defaultToOnlyOption && offset === 0 && options.length === 1) {
|
|
121
|
-
setValue(name, rest.multiple ? [options[0]] : options[0]);
|
|
122
|
-
}
|
|
123
|
-
return { options, hasMore, offset: returnedOffsetValue };
|
|
124
|
-
})
|
|
125
|
-
})
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// src/lib/Autocomplete.tsx
|
|
133
|
-
import { Autocomplete } from "@availity/mui-autocomplete";
|
|
134
|
-
import { Controller as Controller2 } from "react-hook-form";
|
|
135
|
-
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
136
|
-
var ControlledAutocomplete = (_a) => {
|
|
137
|
-
var _b = _a, {
|
|
138
|
-
name,
|
|
139
|
-
FieldProps,
|
|
140
|
-
defaultValue,
|
|
141
|
-
rules = {},
|
|
142
|
-
onBlur,
|
|
143
|
-
onChange,
|
|
144
|
-
shouldUnregister,
|
|
145
|
-
value,
|
|
146
|
-
transform
|
|
147
|
-
} = _b, rest = __objRest(_b, [
|
|
148
|
-
"name",
|
|
149
|
-
"FieldProps",
|
|
150
|
-
"defaultValue",
|
|
151
|
-
"rules",
|
|
152
|
-
"onBlur",
|
|
153
|
-
"onChange",
|
|
154
|
-
"shouldUnregister",
|
|
155
|
-
"value",
|
|
156
|
-
"transform"
|
|
157
|
-
]);
|
|
158
|
-
const emptyValue = (rest == null ? void 0 : rest.multiple) ? [] : null;
|
|
159
|
-
return /* @__PURE__ */ jsx2(
|
|
160
|
-
Controller2,
|
|
161
|
-
{
|
|
162
|
-
name,
|
|
163
|
-
defaultValue,
|
|
164
|
-
rules: __spreadValues({
|
|
165
|
-
onBlur,
|
|
166
|
-
onChange,
|
|
167
|
-
shouldUnregister,
|
|
168
|
-
value
|
|
169
|
-
}, rules),
|
|
170
|
-
shouldUnregister,
|
|
171
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => {
|
|
172
|
-
var _a2, _b2, _c;
|
|
173
|
-
return /* @__PURE__ */ jsx2(
|
|
174
|
-
Autocomplete,
|
|
175
|
-
__spreadProps(__spreadValues({}, rest), {
|
|
176
|
-
FieldProps: __spreadProps(__spreadValues({
|
|
177
|
-
required: typeof rules.required === "object" ? rules.required.value : !!rules.required
|
|
178
|
-
}, FieldProps), {
|
|
179
|
-
error: !!error,
|
|
180
|
-
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
181
|
-
error.message,
|
|
182
|
-
/* @__PURE__ */ jsx2("br", {}),
|
|
183
|
-
FieldProps == null ? void 0 : FieldProps.helperText
|
|
184
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
185
|
-
inputRef: ref
|
|
186
|
-
}),
|
|
187
|
-
onChange: (event, value3, reason) => {
|
|
188
|
-
var _a3, _b3, _c2, _d;
|
|
189
|
-
if (reason === "clear") {
|
|
190
|
-
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 : emptyValue);
|
|
191
|
-
}
|
|
192
|
-
onChange2((_d = (_c2 = transform == null ? void 0 : transform.output) == null ? void 0 : _c2.call(transform, value3)) != null ? _d : value3);
|
|
193
|
-
},
|
|
194
|
-
onBlur: onBlur2,
|
|
195
|
-
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c : emptyValue
|
|
196
|
-
})
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
);
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
// src/lib/Checkbox.tsx
|
|
204
|
-
import { Checkbox } from "@availity/mui-checkbox";
|
|
205
|
-
import { Controller as Controller3 } from "react-hook-form";
|
|
206
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
207
|
-
var ControlledCheckbox = (_a) => {
|
|
208
|
-
var _b = _a, {
|
|
209
|
-
name,
|
|
210
|
-
disabled,
|
|
211
|
-
onChange,
|
|
212
|
-
onBlur,
|
|
213
|
-
value,
|
|
214
|
-
defaultValue = false,
|
|
215
|
-
rules = {},
|
|
216
|
-
shouldUnregister,
|
|
217
|
-
transform
|
|
218
|
-
} = _b, rest = __objRest(_b, [
|
|
219
|
-
"name",
|
|
220
|
-
"disabled",
|
|
221
|
-
"onChange",
|
|
222
|
-
"onBlur",
|
|
223
|
-
"value",
|
|
224
|
-
"defaultValue",
|
|
225
|
-
"rules",
|
|
226
|
-
"shouldUnregister",
|
|
227
|
-
"transform"
|
|
228
|
-
]);
|
|
229
|
-
return /* @__PURE__ */ jsx3(
|
|
230
|
-
Controller3,
|
|
231
|
-
{
|
|
232
|
-
name,
|
|
233
|
-
defaultValue,
|
|
234
|
-
disabled,
|
|
235
|
-
rules: __spreadValues({
|
|
236
|
-
onChange,
|
|
237
|
-
onBlur,
|
|
238
|
-
value,
|
|
239
|
-
shouldUnregister
|
|
240
|
-
}, rules),
|
|
241
|
-
shouldUnregister,
|
|
242
|
-
render: ({ field }) => {
|
|
243
|
-
var _a2, _b2;
|
|
244
|
-
return /* @__PURE__ */ jsx3(
|
|
245
|
-
Checkbox,
|
|
246
|
-
__spreadProps(__spreadValues(__spreadValues({
|
|
247
|
-
required: typeof rules.required === "object" ? rules.required.value : !!rules.required
|
|
248
|
-
}, rest), field), {
|
|
249
|
-
checked: (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, field.value)) != null ? _b2 : field.value,
|
|
250
|
-
onChange: (e) => {
|
|
251
|
-
var _a3, _b3;
|
|
252
|
-
return field.onChange((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, e.target.checked)) != null ? _b3 : e.target.checked);
|
|
253
|
-
}
|
|
254
|
-
})
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
// src/lib/CodesAutocomplete.tsx
|
|
262
|
-
import { fetchCodes, handleGetCodesOptionLabel } from "@availity/mui-autocomplete";
|
|
263
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
264
|
-
var ControlledCodesAutocomplete = (_a) => {
|
|
265
|
-
var _b = _a, {
|
|
266
|
-
apiConfig = {},
|
|
267
|
-
queryOptions,
|
|
268
|
-
queryKey = "codes-autocomplete",
|
|
269
|
-
list,
|
|
270
|
-
watchParams
|
|
271
|
-
} = _b, rest = __objRest(_b, [
|
|
272
|
-
"apiConfig",
|
|
273
|
-
"queryOptions",
|
|
274
|
-
"queryKey",
|
|
275
|
-
"list",
|
|
276
|
-
"watchParams"
|
|
277
|
-
]);
|
|
278
|
-
const handleLoadOptions = (offset, limit, inputValue) => __async(null, null, function* () {
|
|
279
|
-
const resp = yield fetchCodes(__spreadProps(__spreadValues({}, apiConfig), {
|
|
280
|
-
params: __spreadProps(__spreadValues({}, apiConfig.params), { list, offset, limit, q: inputValue })
|
|
281
|
-
}));
|
|
282
|
-
return resp;
|
|
283
|
-
});
|
|
284
|
-
return /* @__PURE__ */ jsx4(
|
|
285
|
-
ControlledAsyncAutocomplete,
|
|
286
|
-
__spreadProps(__spreadValues({
|
|
287
|
-
getOptionLabel: handleGetCodesOptionLabel,
|
|
288
|
-
queryKey,
|
|
289
|
-
queryOptions: __spreadValues({ enabled: !!list }, queryOptions),
|
|
290
|
-
watchParams: __spreadValues({ list }, watchParams)
|
|
291
|
-
}, rest), {
|
|
292
|
-
loadOptions: handleLoadOptions
|
|
293
|
-
})
|
|
294
|
-
);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
// src/lib/Datepicker.tsx
|
|
298
|
-
import { Datepicker } from "@availity/mui-datepicker";
|
|
299
|
-
import { Controller as Controller4 } from "react-hook-form";
|
|
300
|
-
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
301
|
-
var ControlledDatepicker = (_a) => {
|
|
302
|
-
var _b = _a, {
|
|
303
|
-
name,
|
|
304
|
-
defaultValue,
|
|
305
|
-
onBlur,
|
|
306
|
-
onChange,
|
|
307
|
-
rules = {},
|
|
308
|
-
shouldUnregister,
|
|
309
|
-
value,
|
|
310
|
-
FieldProps,
|
|
311
|
-
transform
|
|
312
|
-
} = _b, rest = __objRest(_b, [
|
|
313
|
-
"name",
|
|
314
|
-
"defaultValue",
|
|
315
|
-
"onBlur",
|
|
316
|
-
"onChange",
|
|
317
|
-
"rules",
|
|
318
|
-
"shouldUnregister",
|
|
319
|
-
"value",
|
|
320
|
-
"FieldProps",
|
|
321
|
-
"transform"
|
|
322
|
-
]);
|
|
323
|
-
return /* @__PURE__ */ jsx5(
|
|
324
|
-
Controller4,
|
|
325
|
-
{
|
|
326
|
-
name,
|
|
327
|
-
defaultValue,
|
|
328
|
-
rules: __spreadValues({
|
|
329
|
-
onBlur,
|
|
330
|
-
onChange,
|
|
331
|
-
shouldUnregister,
|
|
332
|
-
value
|
|
333
|
-
}, rules),
|
|
334
|
-
shouldUnregister,
|
|
335
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => {
|
|
336
|
-
var _a2;
|
|
337
|
-
return /* @__PURE__ */ jsx5(
|
|
338
|
-
Datepicker,
|
|
339
|
-
__spreadProps(__spreadValues({}, rest), {
|
|
340
|
-
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
341
|
-
required: (typeof rules.required === "object" ? rules.required.value : !!rules.required) || (FieldProps == null ? void 0 : FieldProps.required),
|
|
342
|
-
error: !!error,
|
|
343
|
-
helperText: error ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
344
|
-
error.message,
|
|
345
|
-
/* @__PURE__ */ jsx5("br", {}),
|
|
346
|
-
FieldProps == null ? void 0 : FieldProps.helperText
|
|
347
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
348
|
-
inputRef: ref,
|
|
349
|
-
inputProps: {
|
|
350
|
-
onBlur: onBlur2
|
|
351
|
-
}
|
|
352
|
-
}),
|
|
353
|
-
onChange: (e) => {
|
|
354
|
-
var _a3, _b2;
|
|
355
|
-
return onChange2((_b2 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, e)) != null ? _b2 : e);
|
|
356
|
-
},
|
|
357
|
-
value: ((_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) || value2 || null
|
|
358
|
-
})
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
);
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
// src/lib/Input.tsx
|
|
366
|
-
import { Input } from "@availity/mui-form-utils";
|
|
367
|
-
import { Controller as Controller5 } from "react-hook-form";
|
|
368
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
369
|
-
var ControlledInput = (_a) => {
|
|
370
|
-
var _b = _a, {
|
|
371
|
-
name,
|
|
372
|
-
defaultValue,
|
|
373
|
-
disabled,
|
|
374
|
-
onBlur,
|
|
375
|
-
onChange,
|
|
376
|
-
rules = {},
|
|
377
|
-
shouldUnregister,
|
|
378
|
-
value,
|
|
379
|
-
transform
|
|
380
|
-
} = _b, rest = __objRest(_b, [
|
|
381
|
-
"name",
|
|
382
|
-
"defaultValue",
|
|
383
|
-
"disabled",
|
|
384
|
-
"onBlur",
|
|
385
|
-
"onChange",
|
|
386
|
-
"rules",
|
|
387
|
-
"shouldUnregister",
|
|
388
|
-
"value",
|
|
389
|
-
"transform"
|
|
390
|
-
]);
|
|
391
|
-
return /* @__PURE__ */ jsx6(
|
|
392
|
-
Controller5,
|
|
393
|
-
{
|
|
394
|
-
name,
|
|
395
|
-
defaultValue,
|
|
396
|
-
disabled,
|
|
397
|
-
rules: __spreadValues({
|
|
398
|
-
onChange,
|
|
399
|
-
onBlur,
|
|
400
|
-
value,
|
|
401
|
-
shouldUnregister
|
|
402
|
-
}, rules),
|
|
403
|
-
shouldUnregister,
|
|
404
|
-
render: ({ field, fieldState: { error } }) => {
|
|
405
|
-
var _a2, _b2, _c;
|
|
406
|
-
return /* @__PURE__ */ jsx6(
|
|
407
|
-
Input,
|
|
408
|
-
__spreadProps(__spreadValues(__spreadValues({
|
|
409
|
-
required: typeof rules.required === "object" ? rules.required.value : !!rules.required
|
|
410
|
-
}, rest), field), {
|
|
411
|
-
onChange: (e) => {
|
|
412
|
-
var _a3, _b3;
|
|
413
|
-
return field.onChange((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, e.target.value)) != null ? _b3 : e);
|
|
414
|
-
},
|
|
415
|
-
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, field.value)) != null ? _b2 : field.value) != null ? _c : "",
|
|
416
|
-
error: !!error
|
|
417
|
-
})
|
|
418
|
-
);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
);
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
// src/lib/OrganizationAutocomplete.tsx
|
|
425
|
-
import { handleGetOrgOptionLabel, fetchOrgs } from "@availity/mui-autocomplete";
|
|
426
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
427
|
-
var ControlledOrganizationAutocomplete = (_a) => {
|
|
428
|
-
var _b = _a, {
|
|
429
|
-
queryKey = "org-autocomplete",
|
|
430
|
-
apiConfig = {}
|
|
431
|
-
} = _b, rest = __objRest(_b, [
|
|
432
|
-
"queryKey",
|
|
433
|
-
"apiConfig"
|
|
434
|
-
]);
|
|
435
|
-
const handleLoadOptions = (offset, limit) => __async(null, null, function* () {
|
|
436
|
-
const resp = yield fetchOrgs(__spreadProps(__spreadValues({}, apiConfig), { params: __spreadProps(__spreadValues({ dropdown: true }, apiConfig.params), { offset, limit }) }));
|
|
437
|
-
return resp;
|
|
438
|
-
});
|
|
439
|
-
return /* @__PURE__ */ jsx7(
|
|
440
|
-
ControlledAsyncAutocomplete,
|
|
441
|
-
__spreadProps(__spreadValues({
|
|
442
|
-
getOptionLabel: handleGetOrgOptionLabel,
|
|
443
|
-
queryKey
|
|
444
|
-
}, rest), {
|
|
445
|
-
loadOptions: handleLoadOptions
|
|
446
|
-
})
|
|
447
|
-
);
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
// src/lib/ProviderAutocomplete.tsx
|
|
451
|
-
import { handleGetProviderOptionLabel, fetchProviders } from "@availity/mui-autocomplete";
|
|
452
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
453
|
-
var ControlledProviderAutocomplete = (_a) => {
|
|
454
|
-
var _b = _a, {
|
|
455
|
-
apiConfig = {},
|
|
456
|
-
customerId,
|
|
457
|
-
queryKey = "prov-autocomplete"
|
|
458
|
-
} = _b, rest = __objRest(_b, [
|
|
459
|
-
"apiConfig",
|
|
460
|
-
"customerId",
|
|
461
|
-
"queryKey"
|
|
462
|
-
]);
|
|
463
|
-
const handleLoadOptions = (offset, limit, inputValue) => __async(null, null, function* () {
|
|
464
|
-
const resp = yield fetchProviders(customerId, __spreadProps(__spreadValues({}, apiConfig), {
|
|
465
|
-
params: __spreadProps(__spreadValues({}, apiConfig.params), { offset, limit, q: inputValue })
|
|
466
|
-
}));
|
|
467
|
-
return resp;
|
|
468
|
-
});
|
|
469
|
-
return /* @__PURE__ */ jsx8(
|
|
470
|
-
ControlledAsyncAutocomplete,
|
|
471
|
-
__spreadProps(__spreadValues({
|
|
472
|
-
getOptionLabel: handleGetProviderOptionLabel,
|
|
473
|
-
queryOptions: { enabled: !!customerId },
|
|
474
|
-
queryKey,
|
|
475
|
-
watchParams: { customerId }
|
|
476
|
-
}, rest), {
|
|
477
|
-
loadOptions: handleLoadOptions
|
|
478
|
-
})
|
|
479
|
-
);
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
// src/lib/RadioGroup.tsx
|
|
483
|
-
import { RadioGroup } from "@availity/mui-form-utils";
|
|
484
|
-
import { Controller as Controller6 } from "react-hook-form";
|
|
485
|
-
import { FormControl, FormLabel, FormHelperText } from "@availity/mui-form-utils";
|
|
486
|
-
import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
487
|
-
var ControlledRadioGroup = (_a) => {
|
|
488
|
-
var _b = _a, {
|
|
489
|
-
name,
|
|
490
|
-
helperText,
|
|
491
|
-
label,
|
|
492
|
-
defaultValue,
|
|
493
|
-
onBlur,
|
|
494
|
-
onChange,
|
|
495
|
-
required,
|
|
496
|
-
rules = {},
|
|
497
|
-
shouldUnregister,
|
|
498
|
-
value,
|
|
499
|
-
transform
|
|
500
|
-
} = _b, rest = __objRest(_b, [
|
|
501
|
-
"name",
|
|
502
|
-
"helperText",
|
|
503
|
-
"label",
|
|
504
|
-
"defaultValue",
|
|
505
|
-
"onBlur",
|
|
506
|
-
"onChange",
|
|
507
|
-
"required",
|
|
508
|
-
"rules",
|
|
509
|
-
"shouldUnregister",
|
|
510
|
-
"value",
|
|
511
|
-
"transform"
|
|
512
|
-
]);
|
|
513
|
-
return /* @__PURE__ */ jsx9(
|
|
514
|
-
Controller6,
|
|
515
|
-
{
|
|
516
|
-
name,
|
|
517
|
-
defaultValue,
|
|
518
|
-
rules: __spreadValues({ onBlur, onChange, shouldUnregister, value }, rules),
|
|
519
|
-
shouldUnregister,
|
|
520
|
-
render: (_a2) => {
|
|
521
|
-
var _b2 = _a2, { field: _c } = _b2, _d = _c, { disabled } = _d, field = __objRest(_d, ["disabled"]), { fieldState: { error } } = _b2;
|
|
522
|
-
var _a3, _b3, _c2;
|
|
523
|
-
return /* @__PURE__ */ jsxs4(
|
|
524
|
-
FormControl,
|
|
525
|
-
{
|
|
526
|
-
error: !!error,
|
|
527
|
-
disabled,
|
|
528
|
-
required: !!required || (typeof rules.required === "object" ? rules.required.value : !!rules.required),
|
|
529
|
-
children: [
|
|
530
|
-
/* @__PURE__ */ jsx9(FormLabel, { children: label }),
|
|
531
|
-
/* @__PURE__ */ jsx9(
|
|
532
|
-
RadioGroup,
|
|
533
|
-
__spreadValues(__spreadProps(__spreadValues({}, field), {
|
|
534
|
-
onChange: (e) => {
|
|
535
|
-
var _a4, _b4;
|
|
536
|
-
return field.onChange((_b4 = (_a4 = transform == null ? void 0 : transform.output) == null ? void 0 : _a4.call(transform, e.target.value)) != null ? _b4 : e);
|
|
537
|
-
},
|
|
538
|
-
value: (_c2 = (_b3 = (_a3 = transform == null ? void 0 : transform.input) == null ? void 0 : _a3.call(transform, field.value)) != null ? _b3 : field.value) != null ? _c2 : ""
|
|
539
|
-
}), rest)
|
|
540
|
-
),
|
|
541
|
-
/* @__PURE__ */ jsx9(FormHelperText, { children: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
542
|
-
error.message,
|
|
543
|
-
/* @__PURE__ */ jsx9("br", {}),
|
|
544
|
-
helperText
|
|
545
|
-
] }) : helperText })
|
|
546
|
-
]
|
|
547
|
-
}
|
|
548
|
-
);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
);
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
// src/lib/Select.tsx
|
|
555
|
-
import { Select } from "@availity/mui-form-utils";
|
|
556
|
-
import { Controller as Controller7 } from "react-hook-form";
|
|
557
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
558
|
-
var ControlledSelect = (_a) => {
|
|
559
|
-
var _b = _a, {
|
|
560
|
-
name,
|
|
561
|
-
defaultValue,
|
|
562
|
-
disabled,
|
|
563
|
-
onBlur,
|
|
564
|
-
onChange,
|
|
565
|
-
rules = {},
|
|
566
|
-
shouldUnregister,
|
|
567
|
-
value,
|
|
568
|
-
transform
|
|
569
|
-
} = _b, rest = __objRest(_b, [
|
|
570
|
-
"name",
|
|
571
|
-
"defaultValue",
|
|
572
|
-
"disabled",
|
|
573
|
-
"onBlur",
|
|
574
|
-
"onChange",
|
|
575
|
-
"rules",
|
|
576
|
-
"shouldUnregister",
|
|
577
|
-
"value",
|
|
578
|
-
"transform"
|
|
579
|
-
]);
|
|
580
|
-
return /* @__PURE__ */ jsx10(
|
|
581
|
-
Controller7,
|
|
582
|
-
{
|
|
583
|
-
name,
|
|
584
|
-
defaultValue,
|
|
585
|
-
disabled,
|
|
586
|
-
rules: __spreadValues({
|
|
587
|
-
onChange,
|
|
588
|
-
onBlur,
|
|
589
|
-
value,
|
|
590
|
-
shouldUnregister
|
|
591
|
-
}, rules),
|
|
592
|
-
shouldUnregister,
|
|
593
|
-
render: ({ field, fieldState: { error } }) => {
|
|
594
|
-
var _a2, _b2, _c;
|
|
595
|
-
return /* @__PURE__ */ jsx10(
|
|
596
|
-
Select,
|
|
597
|
-
__spreadProps(__spreadValues(__spreadValues({
|
|
598
|
-
required: typeof rules.required === "object" ? rules.required.value : !!rules.required
|
|
599
|
-
}, rest), field), {
|
|
600
|
-
onChange: (e) => {
|
|
601
|
-
var _a3, _b3;
|
|
602
|
-
return field.onChange((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, e.target.value)) != null ? _b3 : e);
|
|
603
|
-
},
|
|
604
|
-
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, field.value)) != null ? _b2 : field.value) != null ? _c : "",
|
|
605
|
-
error: !!error
|
|
606
|
-
})
|
|
607
|
-
);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
);
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
// src/lib/TextField.tsx
|
|
614
|
-
import { TextField } from "@availity/mui-textfield";
|
|
615
|
-
import { Controller as Controller8 } from "react-hook-form";
|
|
616
|
-
import { Fragment as Fragment5, jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
617
|
-
var ControlledTextField = (_a) => {
|
|
618
|
-
var _b = _a, {
|
|
619
|
-
name,
|
|
620
|
-
defaultValue,
|
|
621
|
-
disabled,
|
|
622
|
-
helperText,
|
|
623
|
-
onBlur,
|
|
624
|
-
onChange,
|
|
625
|
-
rules = {},
|
|
626
|
-
shouldUnregister,
|
|
627
|
-
value,
|
|
628
|
-
transform
|
|
629
|
-
} = _b, rest = __objRest(_b, [
|
|
630
|
-
"name",
|
|
631
|
-
"defaultValue",
|
|
632
|
-
"disabled",
|
|
633
|
-
"helperText",
|
|
634
|
-
"onBlur",
|
|
635
|
-
"onChange",
|
|
636
|
-
"rules",
|
|
637
|
-
"shouldUnregister",
|
|
638
|
-
"value",
|
|
639
|
-
"transform"
|
|
640
|
-
]);
|
|
641
|
-
return /* @__PURE__ */ jsx11(
|
|
642
|
-
Controller8,
|
|
643
|
-
{
|
|
644
|
-
name,
|
|
645
|
-
defaultValue,
|
|
646
|
-
disabled,
|
|
647
|
-
rules: __spreadValues({
|
|
648
|
-
onChange,
|
|
649
|
-
onBlur,
|
|
650
|
-
value,
|
|
651
|
-
shouldUnregister
|
|
652
|
-
}, rules),
|
|
653
|
-
shouldUnregister,
|
|
654
|
-
render: (_a2) => {
|
|
655
|
-
var _b2 = _a2, { field: _c } = _b2, _d = _c, { ref } = _d, field = __objRest(_d, ["ref"]), { fieldState: { error } } = _b2;
|
|
656
|
-
var _a3, _b3, _c2, _d2;
|
|
657
|
-
return /* @__PURE__ */ jsx11(
|
|
658
|
-
TextField,
|
|
659
|
-
__spreadProps(__spreadValues(__spreadProps(__spreadValues({
|
|
660
|
-
required: typeof rules.required === "object" ? rules.required.value : !!rules.required
|
|
661
|
-
}, field), {
|
|
662
|
-
onChange: (e) => {
|
|
663
|
-
var _a4, _b4;
|
|
664
|
-
return field.onChange((_b4 = (_a4 = transform == null ? void 0 : transform.output) == null ? void 0 : _a4.call(transform, e.target.value)) != null ? _b4 : e);
|
|
665
|
-
},
|
|
666
|
-
value: (_c2 = (_b3 = (_a3 = transform == null ? void 0 : transform.input) == null ? void 0 : _a3.call(transform, field.value)) != null ? _b3 : field.value) != null ? _c2 : ""
|
|
667
|
-
}), rest), {
|
|
668
|
-
slotProps: __spreadProps(__spreadValues({}, rest.slotProps), {
|
|
669
|
-
htmlInput: __spreadValues({
|
|
670
|
-
maxLength: typeof rules.maxLength === "object" ? rules.maxLength.value : rules.maxLength
|
|
671
|
-
}, (_d2 = rest.slotProps) == null ? void 0 : _d2.htmlInput)
|
|
672
|
-
}),
|
|
673
|
-
inputRef: ref,
|
|
674
|
-
error: !!error,
|
|
675
|
-
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
676
|
-
error.message,
|
|
677
|
-
/* @__PURE__ */ jsx11("br", {}),
|
|
678
|
-
helperText
|
|
679
|
-
] }) : helperText
|
|
680
|
-
})
|
|
681
|
-
);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
);
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
// src/lib/Timepicker.tsx
|
|
688
|
-
import { Timepicker } from "@availity/mui-datepicker";
|
|
689
|
-
import { Controller as Controller9 } from "react-hook-form";
|
|
690
|
-
import { Fragment as Fragment6, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
691
|
-
var ControlledTimepicker = (_a) => {
|
|
692
|
-
var _b = _a, {
|
|
693
|
-
name,
|
|
694
|
-
defaultValue,
|
|
695
|
-
onBlur,
|
|
696
|
-
onChange,
|
|
697
|
-
rules = {},
|
|
698
|
-
shouldUnregister,
|
|
699
|
-
value,
|
|
700
|
-
FieldProps,
|
|
701
|
-
transform
|
|
702
|
-
} = _b, rest = __objRest(_b, [
|
|
703
|
-
"name",
|
|
704
|
-
"defaultValue",
|
|
705
|
-
"onBlur",
|
|
706
|
-
"onChange",
|
|
707
|
-
"rules",
|
|
708
|
-
"shouldUnregister",
|
|
709
|
-
"value",
|
|
710
|
-
"FieldProps",
|
|
711
|
-
"transform"
|
|
712
|
-
]);
|
|
713
|
-
return /* @__PURE__ */ jsx12(
|
|
714
|
-
Controller9,
|
|
715
|
-
{
|
|
716
|
-
name,
|
|
717
|
-
defaultValue,
|
|
718
|
-
rules: __spreadValues({
|
|
719
|
-
onBlur,
|
|
720
|
-
onChange,
|
|
721
|
-
shouldUnregister,
|
|
722
|
-
value
|
|
723
|
-
}, rules),
|
|
724
|
-
shouldUnregister,
|
|
725
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2, ref }, fieldState: { error } }) => {
|
|
726
|
-
var _a2;
|
|
727
|
-
return /* @__PURE__ */ jsx12(
|
|
728
|
-
Timepicker,
|
|
729
|
-
__spreadProps(__spreadValues({}, rest), {
|
|
730
|
-
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
731
|
-
required: (typeof rules.required === "object" ? rules.required.value : !!rules.required) || (FieldProps == null ? void 0 : FieldProps.required),
|
|
732
|
-
error: !!error,
|
|
733
|
-
helperText: error ? /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
734
|
-
error.message,
|
|
735
|
-
/* @__PURE__ */ jsx12("br", {}),
|
|
736
|
-
FieldProps == null ? void 0 : FieldProps.helperText
|
|
737
|
-
] }) : FieldProps == null ? void 0 : FieldProps.helperText,
|
|
738
|
-
inputRef: ref,
|
|
739
|
-
inputProps: {
|
|
740
|
-
onBlur: onBlur2
|
|
741
|
-
}
|
|
742
|
-
}),
|
|
743
|
-
onChange: (e) => {
|
|
744
|
-
var _a3, _b2;
|
|
745
|
-
return onChange2((_b2 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, e)) != null ? _b2 : e);
|
|
746
|
-
},
|
|
747
|
-
value: ((_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) || value2 || null
|
|
748
|
-
})
|
|
749
|
-
);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
);
|
|
753
|
-
};
|
|
754
|
-
|
|
755
|
-
// src/index.ts
|
|
756
|
-
import {
|
|
757
|
-
FormProvider,
|
|
758
|
-
useForm,
|
|
759
|
-
useFormContext as useFormContext2
|
|
760
|
-
} from "react-hook-form";
|
|
761
|
-
export {
|
|
762
|
-
ControlledAsyncAutocomplete,
|
|
763
|
-
ControlledAutocomplete,
|
|
764
|
-
ControlledCheckbox,
|
|
765
|
-
ControlledCodesAutocomplete,
|
|
766
|
-
ControlledDatepicker,
|
|
767
|
-
ControlledInput,
|
|
768
|
-
ControlledOrganizationAutocomplete,
|
|
769
|
-
ControlledProviderAutocomplete,
|
|
770
|
-
ControlledRadioGroup,
|
|
771
|
-
ControlledSelect,
|
|
772
|
-
ControlledTextField,
|
|
773
|
-
ControlledTimepicker,
|
|
774
|
-
FormProvider,
|
|
775
|
-
useForm,
|
|
776
|
-
useFormContext2 as useFormContext
|
|
777
|
-
};
|