@bluemarble/bm-components 1.10.1 → 1.10.3

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.js CHANGED
@@ -3356,6 +3356,7 @@ function FormikSelect(_a) {
3356
3356
 
3357
3357
 
3358
3358
 
3359
+
3359
3360
  var _styles = require('@mui/material/styles');
3360
3361
  function Autocomplete2(_a) {
3361
3362
  var _b = _a, {
@@ -3368,8 +3369,22 @@ function Autocomplete2(_a) {
3368
3369
  "getOptionValue"
3369
3370
  ]);
3370
3371
  if (withFormik) {
3372
+ const theme = _styles.useTheme.call(void 0, );
3373
+ const isLegacyBehaviorDisabledTheme = _react.useMemo.call(void 0, () => {
3374
+ var _a2, _b2, _c;
3375
+ return ((_c = (_b2 = (_a2 = theme.components) == null ? void 0 : _a2.MuiAutocomplete) == null ? void 0 : _b2.defaultProps) == null ? void 0 : _c["data-legacy-behavior"]) === "disabled";
3376
+ }, [theme]);
3377
+ const isLegacyBehaviorDisabled = typeof (rest == null ? void 0 : rest["data-legacy-behavior"]) !== "undefined" ? rest["data-legacy-behavior"] === "disabled" : isLegacyBehaviorDisabledTheme;
3378
+ if (isLegacyBehaviorDisabled)
3379
+ return /* @__PURE__ */ React2.default.createElement(
3380
+ FormikAutocomplete,
3381
+ __spreadValues({
3382
+ name,
3383
+ getOptionValue
3384
+ }, rest)
3385
+ );
3371
3386
  return /* @__PURE__ */ React2.default.createElement(
3372
- FormikAutocomplete,
3387
+ FormikAutocompleteLegacy,
3373
3388
  __spreadValues({
3374
3389
  name,
3375
3390
  getOptionValue
@@ -3387,7 +3402,7 @@ function BaseInput2(props) {
3387
3402
  }, props)
3388
3403
  );
3389
3404
  }
3390
- function FormikAutocomplete(_a) {
3405
+ function FormikAutocompleteLegacy(_a) {
3391
3406
  var _b = _a, {
3392
3407
  getOptionValue,
3393
3408
  option
@@ -3398,22 +3413,14 @@ function FormikAutocomplete(_a) {
3398
3413
  const [_a2, ..._b2] = _formik.useField.call(void 0, {
3399
3414
  name: props.name
3400
3415
  }), _c = _a2, { value } = _c, field = __objRest(_c, ["value"]), [meta, { setValue }] = _b2;
3401
- const theme = _styles.useTheme.call(void 0, );
3402
- const isLegacyBehaviorDisabledTheme = _react.useMemo.call(void 0, () => {
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;
3407
3416
  const defaultOption = _react.useMemo.call(void 0, () => {
3408
- if (!option && isLegacyBehaviorDisabled)
3409
- return value;
3410
3417
  const key = option == null ? void 0 : option.key;
3411
3418
  if (key)
3412
3419
  return props.options.find((option2) => option2[key] === value);
3413
3420
  return props.options.find(
3414
3421
  (option2) => Object.values(option2)[0] === value
3415
3422
  );
3416
- }, [value, option, props.options.find, isLegacyBehaviorDisabled]);
3423
+ }, [value, option, props.options.find]);
3417
3424
  const onChange = (_, newValue) => {
3418
3425
  const value2 = option == null ? void 0 : option.value;
3419
3426
  if (getOptionValue) {
@@ -3462,6 +3469,49 @@ function FormikAutocomplete(_a) {
3462
3469
  }, props)
3463
3470
  );
3464
3471
  }
3472
+ function FormikAutocomplete(_a) {
3473
+ var _b = _a, {
3474
+ getOptionValue,
3475
+ option
3476
+ } = _b, props = __objRest(_b, [
3477
+ "getOptionValue",
3478
+ "option"
3479
+ ]);
3480
+ const [_a2, ..._b2] = _formik.useField.call(void 0, {
3481
+ name: props.name
3482
+ }), _c = _a2, { value } = _c, field = __objRest(_c, ["value"]), [meta, { setValue }] = _b2;
3483
+ const [defaultValue] = _react.useState.call(void 0, value);
3484
+ const onChange = (_, newValue) => {
3485
+ const value2 = option == null ? void 0 : option.value;
3486
+ if (getOptionValue) {
3487
+ setValue(getOptionValue(newValue));
3488
+ } else if (value2) {
3489
+ setValue(newValue[value2]);
3490
+ } else
3491
+ setValue(newValue);
3492
+ };
3493
+ return /* @__PURE__ */ React2.default.createElement(
3494
+ _material.Autocomplete,
3495
+ __spreadValues({
3496
+ renderInput: (params) => /* @__PURE__ */ React2.default.createElement(
3497
+ _material.TextField,
3498
+ __spreadValues(__spreadProps(__spreadValues(__spreadValues({
3499
+ error: Boolean(meta == null ? void 0 : meta.error),
3500
+ helperText: meta == null ? void 0 : meta.error
3501
+ }, params), field), {
3502
+ InputProps: __spreadProps(__spreadValues({}, params.InputProps), {
3503
+ endAdornment: /* @__PURE__ */ React2.default.createElement(_react.Fragment, null, props.loading ? /* @__PURE__ */ React2.default.createElement(_material.CircularProgress, { color: "inherit", size: 20 }) : null, params.InputProps.endAdornment)
3504
+ }),
3505
+ label: props.label,
3506
+ required: props.required,
3507
+ autoFocus: props.autoFocus
3508
+ }), props.textFieldProps)
3509
+ ),
3510
+ defaultValue,
3511
+ onChange
3512
+ }, props)
3513
+ );
3514
+ }
3465
3515
 
3466
3516
  // src/components/Checkbox/index.tsx
3467
3517
 
@@ -5084,6 +5134,7 @@ function CreateAuthProvider({
5084
5134
  const { createAlert } = useAlert();
5085
5135
  const signIn = _react.useCallback.call(void 0,
5086
5136
  (_0) => __async(this, [_0], function* ({ email, password }) {
5137
+ var _a, _b;
5087
5138
  setStatus("loading");
5088
5139
  try {
5089
5140
  const response = yield api.post("/auth/login", {
@@ -5097,7 +5148,7 @@ function CreateAuthProvider({
5097
5148
  setStatus("autenticated");
5098
5149
  return true;
5099
5150
  } catch (error) {
5100
- createAlert(error.response.data.error, "error");
5151
+ createAlert((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error, "error");
5101
5152
  setStatus("unauthenticated");
5102
5153
  throw error;
5103
5154
  }