@bluemarble/bm-components 1.9.4 → 1.10.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/dist/index.mjs CHANGED
@@ -2919,7 +2919,7 @@ import moment from "moment";
2919
2919
  var DefaultInput = (allProps) => {
2920
2920
  var _a;
2921
2921
  const {
2922
- TextFieldProps: TextFieldProps4,
2922
+ TextFieldProps: TextFieldProps3,
2923
2923
  onSave,
2924
2924
  name,
2925
2925
  onUpdateValue,
@@ -2973,7 +2973,7 @@ var DefaultInput = (allProps) => {
2973
2973
  defaultValue: formatDefaultValue(rowData == null ? void 0 : rowData[name]),
2974
2974
  sx: __spreadValues({
2975
2975
  width: fullWidth ? "100%" : "intial"
2976
- }, TextFieldProps4 == null ? void 0 : TextFieldProps4.sx),
2976
+ }, TextFieldProps3 == null ? void 0 : TextFieldProps3.sx),
2977
2977
  inputProps: {
2978
2978
  style: {
2979
2979
  paddingBottom: 6,
@@ -2981,13 +2981,13 @@ var DefaultInput = (allProps) => {
2981
2981
  },
2982
2982
  onKeyDown
2983
2983
  },
2984
- InputProps: __spreadProps(__spreadValues({}, TextFieldProps4 == null ? void 0 : TextFieldProps4.InputProps), {
2984
+ InputProps: __spreadProps(__spreadValues({}, TextFieldProps3 == null ? void 0 : TextFieldProps3.InputProps), {
2985
2985
  sx: __spreadValues({
2986
2986
  fontSize: 14,
2987
2987
  pl: 0.2
2988
- }, (_a = TextFieldProps4 == null ? void 0 : TextFieldProps4.InputProps) == null ? void 0 : _a.sx)
2988
+ }, (_a = TextFieldProps3 == null ? void 0 : TextFieldProps3.InputProps) == null ? void 0 : _a.sx)
2989
2989
  })
2990
- }, TextFieldProps4)
2990
+ }, TextFieldProps3)
2991
2991
  );
2992
2992
  };
2993
2993
 
@@ -2998,7 +2998,7 @@ import { TextField as TextField3 } from "@mui/material";
2998
2998
  var InputMask = (allProps) => {
2999
2999
  var _a;
3000
3000
  const {
3001
- TextFieldProps: TextFieldProps4,
3001
+ TextFieldProps: TextFieldProps3,
3002
3002
  onSave,
3003
3003
  name,
3004
3004
  rowData,
@@ -3045,7 +3045,7 @@ var InputMask = (allProps) => {
3045
3045
  size: "small",
3046
3046
  sx: __spreadValues({
3047
3047
  width: fullWidth ? "100%" : "intial"
3048
- }, TextFieldProps4 == null ? void 0 : TextFieldProps4.sx),
3048
+ }, TextFieldProps3 == null ? void 0 : TextFieldProps3.sx),
3049
3049
  inputProps: {
3050
3050
  style: {
3051
3051
  paddingBottom: 6,
@@ -3053,20 +3053,20 @@ var InputMask = (allProps) => {
3053
3053
  },
3054
3054
  onKeyDown
3055
3055
  },
3056
- InputProps: __spreadProps(__spreadValues({}, TextFieldProps4 == null ? void 0 : TextFieldProps4.InputProps), {
3056
+ InputProps: __spreadProps(__spreadValues({}, TextFieldProps3 == null ? void 0 : TextFieldProps3.InputProps), {
3057
3057
  sx: __spreadValues({
3058
3058
  fontSize: 14,
3059
3059
  pl: 0.2
3060
- }, (_a = TextFieldProps4 == null ? void 0 : TextFieldProps4.InputProps) == null ? void 0 : _a.sx)
3060
+ }, (_a = TextFieldProps3 == null ? void 0 : TextFieldProps3.InputProps) == null ? void 0 : _a.sx)
3061
3061
  })
3062
- }, TextFieldProps4)
3062
+ }, TextFieldProps3)
3063
3063
  );
3064
3064
  };
3065
3065
 
3066
3066
  // src/components/Grid/EditableTableCell/index.tsx
3067
3067
  var EditableTableCell = (allProps) => {
3068
3068
  const _a = allProps, {
3069
- TextFieldProps: TextFieldProps4,
3069
+ TextFieldProps: TextFieldProps3,
3070
3070
  onSave = () => {
3071
3071
  },
3072
3072
  onCancel,
@@ -3356,6 +3356,7 @@ import {
3356
3356
  TextField as TextField5,
3357
3357
  CircularProgress
3358
3358
  } from "@mui/material";
3359
+ import { useTheme as useTheme3 } from "@mui/material/styles";
3359
3360
  function Autocomplete2(_a) {
3360
3361
  var _b = _a, {
3361
3362
  withFormik = true,
@@ -3396,23 +3397,29 @@ function FormikAutocomplete(_a) {
3396
3397
  ]);
3397
3398
  const [_a2, ..._b2] = useField2({
3398
3399
  name: props.name
3399
- }), _c = _a2, { value: defaultValue } = _c, field = __objRest(_c, ["value"]), [meta, { setValue }] = _b2;
3400
+ }), _c = _a2, { value } = _c, field = __objRest(_c, ["value"]), [meta, { setValue }] = _b2;
3401
+ const theme = useTheme3();
3402
+ const isLegacyBehaviorDisabledTheme = useMemo2(() => {
3403
+ var _a3, _b3, _c2;
3404
+ return ((_c2 = (_b3 = (_a3 = theme.components) == null ? void 0 : _a3.MuiAutocomplete) == null ? void 0 : _b3.defaultProps) == null ? void 0 : _c2["data-legacy-behavior"]) === "disabled";
3405
+ }, [theme]);
3406
+ const isLegacyBehaviorDisabled = typeof (props == null ? void 0 : props["data-legacy-behavior"]) !== "undefined" ? props["data-legacy-behavior"] === "disabled" : isLegacyBehaviorDisabledTheme;
3400
3407
  const defaultOption = useMemo2(() => {
3401
- if (!option)
3402
- return defaultValue;
3408
+ if (!option && isLegacyBehaviorDisabled)
3409
+ return value;
3403
3410
  const key = option == null ? void 0 : option.key;
3404
3411
  if (key)
3405
- return props.options.find((option2) => option2[key] === defaultValue);
3412
+ return props.options.find((option2) => option2[key] === value);
3406
3413
  return props.options.find(
3407
- (option2) => Object.values(option2)[0] === defaultValue
3414
+ (option2) => Object.values(option2)[0] === value
3408
3415
  );
3409
- }, [defaultValue, option, props.options.find]);
3416
+ }, [value, option, props.options.find, isLegacyBehaviorDisabled]);
3410
3417
  const onChange = (_, newValue) => {
3411
- const value = option == null ? void 0 : option.value;
3418
+ const value2 = option == null ? void 0 : option.value;
3412
3419
  if (getOptionValue) {
3413
3420
  setValue(getOptionValue(newValue));
3414
- } else if (value) {
3415
- setValue(newValue[value]);
3421
+ } else if (value2) {
3422
+ setValue(newValue[value2]);
3416
3423
  } else
3417
3424
  setValue(newValue);
3418
3425
  };
@@ -3449,7 +3456,7 @@ function FormikAutocomplete(_a) {
3449
3456
  autoFocus: props.autoFocus
3450
3457
  }), props.textFieldProps)
3451
3458
  ),
3452
- defaultValue: defaultOption,
3459
+ value: defaultOption || null,
3453
3460
  onChange,
3454
3461
  isOptionEqualToValue
3455
3462
  }, props)
@@ -4010,6 +4017,15 @@ var HttpError = class extends Error {
4010
4017
  }
4011
4018
  };
4012
4019
 
4020
+ // src/errors/DomainError.ts
4021
+ var DomainError = class extends Error {
4022
+ constructor(message) {
4023
+ super(message);
4024
+ this.message = message;
4025
+ this.stack = `DomainError: ${message}`;
4026
+ }
4027
+ };
4028
+
4013
4029
  // src/helpers/apiHelper/index.ts
4014
4030
  var VALID_METHODS = [
4015
4031
  "GET",
@@ -4058,6 +4074,8 @@ var ApiHelper = class _ApiHelper {
4058
4074
  );
4059
4075
  yield methodWithMiddlewares(req, res);
4060
4076
  } catch (error) {
4077
+ if (error instanceof DomainError)
4078
+ return res.status(400).json(error.message);
4061
4079
  if (error instanceof HttpError)
4062
4080
  return res.status(error.status).json(error.message);
4063
4081
  if (process.env.NODE_ENV === "production") {
@@ -5126,6 +5144,7 @@ export {
5126
5144
  Checkbox,
5127
5145
  CreateAuthProvider,
5128
5146
  Dialog,
5147
+ DomainError,
5129
5148
  EditableTableCell,
5130
5149
  FormHelperContext,
5131
5150
  FormHelperProvider,