@bluemarble/bm-components 1.7.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3346,7 +3346,10 @@ function FormikSelect(_a) {
|
|
|
3346
3346
|
}
|
|
3347
3347
|
|
|
3348
3348
|
// src/components/Autocomplete/index.tsx
|
|
3349
|
-
import React13, {
|
|
3349
|
+
import React13, {
|
|
3350
|
+
Fragment,
|
|
3351
|
+
useMemo as useMemo2
|
|
3352
|
+
} from "react";
|
|
3350
3353
|
import { useField as useField2 } from "formik";
|
|
3351
3354
|
import {
|
|
3352
3355
|
Autocomplete as MuiAutocomplete,
|
|
@@ -3371,8 +3374,8 @@ function Autocomplete2(_a) {
|
|
|
3371
3374
|
getOptionValue
|
|
3372
3375
|
}, rest)
|
|
3373
3376
|
);
|
|
3374
|
-
}
|
|
3375
|
-
|
|
3377
|
+
}
|
|
3378
|
+
return /* @__PURE__ */ React13.createElement(BaseInput2, __spreadValues({}, rest));
|
|
3376
3379
|
}
|
|
3377
3380
|
function BaseInput2(props) {
|
|
3378
3381
|
return /* @__PURE__ */ React13.createElement(
|
|
@@ -3395,14 +3398,15 @@ function FormikAutocomplete(_a) {
|
|
|
3395
3398
|
name: props.name
|
|
3396
3399
|
}), _c = _a2, { value: defaultValue } = _c, field = __objRest(_c, ["value"]), [meta, { setValue }] = _b2;
|
|
3397
3400
|
const defaultOption = useMemo2(() => {
|
|
3401
|
+
if (!option)
|
|
3402
|
+
return defaultValue;
|
|
3398
3403
|
const key = option == null ? void 0 : option.key;
|
|
3399
3404
|
if (key)
|
|
3400
3405
|
return props.options.find((option2) => option2[key] === defaultValue);
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
}, []);
|
|
3406
|
+
return props.options.find(
|
|
3407
|
+
(option2) => Object.values(option2)[0] === defaultValue
|
|
3408
|
+
);
|
|
3409
|
+
}, [defaultValue, option, props.options.find]);
|
|
3406
3410
|
const onChange = (_, newValue) => {
|
|
3407
3411
|
const value = option == null ? void 0 : option.value;
|
|
3408
3412
|
if (getOptionValue) {
|
|
@@ -3415,7 +3419,7 @@ function FormikAutocomplete(_a) {
|
|
|
3415
3419
|
const getOptionLabel = (item) => {
|
|
3416
3420
|
if (props == null ? void 0 : props.getOptionLabel)
|
|
3417
3421
|
return props.getOptionLabel(item);
|
|
3418
|
-
|
|
3422
|
+
if (option == null ? void 0 : option.label)
|
|
3419
3423
|
return String(item[option.label]);
|
|
3420
3424
|
return "[getOptionLabel] error";
|
|
3421
3425
|
};
|
|
@@ -3423,7 +3427,7 @@ function FormikAutocomplete(_a) {
|
|
|
3423
3427
|
const key = option == null ? void 0 : option.key;
|
|
3424
3428
|
if (props == null ? void 0 : props.isOptionEqualToValue)
|
|
3425
3429
|
return props.isOptionEqualToValue(a, b);
|
|
3426
|
-
|
|
3430
|
+
if (key)
|
|
3427
3431
|
return a[key] === b[key];
|
|
3428
3432
|
return Object.values(a)[0] === Object.values(b)[0];
|
|
3429
3433
|
};
|