@availity/mui-controlled-form 2.0.0 → 2.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 +7 -0
- package/dist/index.js +6 -4
- package/dist/index.mjs +6 -4
- package/package.json +1 -1
- package/src/lib/AsyncAutocomplete.tsx +3 -2
- package/src/lib/Autocomplete.tsx +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [2.0.1](https://github.com/Availity/element/compare/@availity/mui-controlled-form@2.0.0...@availity/mui-controlled-form@2.0.1) (2025-11-21)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **mui-controlled-form:** update empty value for multi-select controlled autocomplete ([f67f483](https://github.com/Availity/element/commit/f67f483489a1bf2a7a5c6b8182db6382dac80c1c))
|
|
11
|
+
|
|
5
12
|
## [2.0.0](https://github.com/Availity/element/compare/@availity/mui-controlled-form@1.4.4...@availity/mui-controlled-form@2.0.0) (2025-11-17)
|
|
6
13
|
|
|
7
14
|
### Dependency Updates
|
package/dist/index.js
CHANGED
|
@@ -115,6 +115,7 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
115
115
|
"transform"
|
|
116
116
|
]);
|
|
117
117
|
const { setValue } = (0, import_react_hook_form.useFormContext)();
|
|
118
|
+
const emptyValue = (rest == null ? void 0 : rest.multiple) ? [] : null;
|
|
118
119
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
119
120
|
import_react_hook_form.Controller,
|
|
120
121
|
{
|
|
@@ -141,12 +142,12 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
141
142
|
onChange: (event, value3, reason) => {
|
|
142
143
|
var _a3, _b3, _c2, _d;
|
|
143
144
|
if (reason === "clear") {
|
|
144
|
-
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 :
|
|
145
|
+
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 : emptyValue);
|
|
145
146
|
}
|
|
146
147
|
onChange2((_d = (_c2 = transform == null ? void 0 : transform.output) == null ? void 0 : _c2.call(transform, value3)) != null ? _d : value3);
|
|
147
148
|
},
|
|
148
149
|
onBlur: onBlur2,
|
|
149
|
-
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c :
|
|
150
|
+
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c : emptyValue,
|
|
150
151
|
loadOptions: (offset, limit, inputValue) => __async(null, null, function* () {
|
|
151
152
|
const { options, hasMore, offset: returnedOffsetValue } = yield rest.loadOptions(offset, limit, inputValue);
|
|
152
153
|
if (defaultToFirstOption && offset === 0) {
|
|
@@ -190,6 +191,7 @@ var ControlledAutocomplete = (_a) => {
|
|
|
190
191
|
"value",
|
|
191
192
|
"transform"
|
|
192
193
|
]);
|
|
194
|
+
const emptyValue = (rest == null ? void 0 : rest.multiple) ? [] : null;
|
|
193
195
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
194
196
|
import_react_hook_form2.Controller,
|
|
195
197
|
{
|
|
@@ -221,12 +223,12 @@ var ControlledAutocomplete = (_a) => {
|
|
|
221
223
|
onChange: (event, value3, reason) => {
|
|
222
224
|
var _a3, _b3, _c2, _d;
|
|
223
225
|
if (reason === "clear") {
|
|
224
|
-
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 :
|
|
226
|
+
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 : emptyValue);
|
|
225
227
|
}
|
|
226
228
|
onChange2((_d = (_c2 = transform == null ? void 0 : transform.output) == null ? void 0 : _c2.call(transform, value3)) != null ? _d : value3);
|
|
227
229
|
},
|
|
228
230
|
onBlur: onBlur2,
|
|
229
|
-
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c :
|
|
231
|
+
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c : emptyValue
|
|
230
232
|
})
|
|
231
233
|
);
|
|
232
234
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -79,6 +79,7 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
79
79
|
"transform"
|
|
80
80
|
]);
|
|
81
81
|
const { setValue } = useFormContext();
|
|
82
|
+
const emptyValue = (rest == null ? void 0 : rest.multiple) ? [] : null;
|
|
82
83
|
return /* @__PURE__ */ jsx(
|
|
83
84
|
Controller,
|
|
84
85
|
{
|
|
@@ -105,12 +106,12 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
105
106
|
onChange: (event, value3, reason) => {
|
|
106
107
|
var _a3, _b3, _c2, _d;
|
|
107
108
|
if (reason === "clear") {
|
|
108
|
-
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 :
|
|
109
|
+
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 : emptyValue);
|
|
109
110
|
}
|
|
110
111
|
onChange2((_d = (_c2 = transform == null ? void 0 : transform.output) == null ? void 0 : _c2.call(transform, value3)) != null ? _d : value3);
|
|
111
112
|
},
|
|
112
113
|
onBlur: onBlur2,
|
|
113
|
-
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c :
|
|
114
|
+
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c : emptyValue,
|
|
114
115
|
loadOptions: (offset, limit, inputValue) => __async(null, null, function* () {
|
|
115
116
|
const { options, hasMore, offset: returnedOffsetValue } = yield rest.loadOptions(offset, limit, inputValue);
|
|
116
117
|
if (defaultToFirstOption && offset === 0) {
|
|
@@ -154,6 +155,7 @@ var ControlledAutocomplete = (_a) => {
|
|
|
154
155
|
"value",
|
|
155
156
|
"transform"
|
|
156
157
|
]);
|
|
158
|
+
const emptyValue = (rest == null ? void 0 : rest.multiple) ? [] : null;
|
|
157
159
|
return /* @__PURE__ */ jsx2(
|
|
158
160
|
Controller2,
|
|
159
161
|
{
|
|
@@ -185,12 +187,12 @@ var ControlledAutocomplete = (_a) => {
|
|
|
185
187
|
onChange: (event, value3, reason) => {
|
|
186
188
|
var _a3, _b3, _c2, _d;
|
|
187
189
|
if (reason === "clear") {
|
|
188
|
-
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 :
|
|
190
|
+
onChange2((_b3 = (_a3 = transform == null ? void 0 : transform.output) == null ? void 0 : _a3.call(transform, null)) != null ? _b3 : emptyValue);
|
|
189
191
|
}
|
|
190
192
|
onChange2((_d = (_c2 = transform == null ? void 0 : transform.output) == null ? void 0 : _c2.call(transform, value3)) != null ? _d : value3);
|
|
191
193
|
},
|
|
192
194
|
onBlur: onBlur2,
|
|
193
|
-
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c :
|
|
195
|
+
value: (_c = (_b2 = (_a2 = transform == null ? void 0 : transform.input) == null ? void 0 : _a2.call(transform, value2)) != null ? _b2 : value2) != null ? _c : emptyValue
|
|
194
196
|
})
|
|
195
197
|
);
|
|
196
198
|
}
|
package/package.json
CHANGED
|
@@ -42,6 +42,7 @@ export const ControlledAsyncAutocomplete = <
|
|
|
42
42
|
...rest
|
|
43
43
|
}: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent, Output>) => {
|
|
44
44
|
const { setValue } = useFormContext();
|
|
45
|
+
const emptyValue = rest?.multiple ? [] : null;
|
|
45
46
|
return (
|
|
46
47
|
<Controller
|
|
47
48
|
name={name}
|
|
@@ -68,12 +69,12 @@ export const ControlledAsyncAutocomplete = <
|
|
|
68
69
|
}}
|
|
69
70
|
onChange={(event, value, reason) => {
|
|
70
71
|
if (reason === 'clear') {
|
|
71
|
-
onChange(transform?.output?.(null) ??
|
|
72
|
+
onChange(transform?.output?.(null) ?? emptyValue);
|
|
72
73
|
}
|
|
73
74
|
onChange(transform?.output?.(value) ?? value);
|
|
74
75
|
}}
|
|
75
76
|
onBlur={onBlur}
|
|
76
|
-
value={transform?.input?.(value) ?? value ??
|
|
77
|
+
value={transform?.input?.(value) ?? value ?? emptyValue}
|
|
77
78
|
loadOptions={async (offset, limit, inputValue) => {
|
|
78
79
|
const { options, hasMore, offset: returnedOffsetValue } = await rest.loadOptions(offset, limit, inputValue);
|
|
79
80
|
|
package/src/lib/Autocomplete.tsx
CHANGED
|
@@ -37,6 +37,7 @@ export const ControlledAutocomplete = <
|
|
|
37
37
|
transform,
|
|
38
38
|
...rest
|
|
39
39
|
}: ControlledAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent, Output>) => {
|
|
40
|
+
const emptyValue = rest?.multiple ? [] : null;
|
|
40
41
|
return (
|
|
41
42
|
<Controller
|
|
42
43
|
name={name}
|
|
@@ -69,12 +70,12 @@ export const ControlledAutocomplete = <
|
|
|
69
70
|
}}
|
|
70
71
|
onChange={(event, value, reason) => {
|
|
71
72
|
if (reason === 'clear') {
|
|
72
|
-
onChange(transform?.output?.(null) ??
|
|
73
|
+
onChange(transform?.output?.(null) ?? emptyValue);
|
|
73
74
|
}
|
|
74
75
|
onChange(transform?.output?.(value) ?? value);
|
|
75
76
|
}}
|
|
76
77
|
onBlur={onBlur}
|
|
77
|
-
value={transform?.input?.(value) ?? value ??
|
|
78
|
+
value={transform?.input?.(value) ?? value ?? emptyValue}
|
|
78
79
|
/>
|
|
79
80
|
)}
|
|
80
81
|
/>
|