@bluemarble/bm-components 1.1.0 → 1.3.0

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 CHANGED
@@ -259,7 +259,7 @@ declare class HttpError extends Error {
259
259
  constructor(status: number, message: any);
260
260
  }
261
261
 
262
- type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
262
+ type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'ALL';
263
263
  type HandlerProps<UserKeyType> = (req: NextApiRequest & {
264
264
  user?: UserKeyType;
265
265
  }, res: NextApiResponse) => Promise<any>;
@@ -267,7 +267,7 @@ type MethodProps<T> = Partial<Record<PossibleMethods, HandlerProps<T>>>;
267
267
  type MiddlewaresProps<T> = ((handler: HandlerProps<T>) => HandlerProps<T>)[];
268
268
  type ConstructorProps<T> = {
269
269
  middlewares?: MiddlewaresProps<T>;
270
- onFinally: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
270
+ onFinally?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
271
271
  onError?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
272
272
  };
273
273
  declare class ApiHelper<T> {
package/dist/index.d.ts CHANGED
@@ -259,7 +259,7 @@ declare class HttpError extends Error {
259
259
  constructor(status: number, message: any);
260
260
  }
261
261
 
262
- type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
262
+ type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'ALL';
263
263
  type HandlerProps<UserKeyType> = (req: NextApiRequest & {
264
264
  user?: UserKeyType;
265
265
  }, res: NextApiResponse) => Promise<any>;
@@ -267,7 +267,7 @@ type MethodProps<T> = Partial<Record<PossibleMethods, HandlerProps<T>>>;
267
267
  type MiddlewaresProps<T> = ((handler: HandlerProps<T>) => HandlerProps<T>)[];
268
268
  type ConstructorProps<T> = {
269
269
  middlewares?: MiddlewaresProps<T>;
270
- onFinally: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
270
+ onFinally?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
271
271
  onError?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
272
272
  };
273
273
  declare class ApiHelper<T> {
package/dist/index.js CHANGED
@@ -255,7 +255,7 @@ var require_react_is_development = __commonJS({
255
255
  var ContextProvider = REACT_PROVIDER_TYPE;
256
256
  var Element = REACT_ELEMENT_TYPE;
257
257
  var ForwardRef = REACT_FORWARD_REF_TYPE;
258
- var Fragment = REACT_FRAGMENT_TYPE;
258
+ var Fragment2 = REACT_FRAGMENT_TYPE;
259
259
  var Lazy = REACT_LAZY_TYPE;
260
260
  var Memo = REACT_MEMO_TYPE;
261
261
  var Portal = REACT_PORTAL_TYPE;
@@ -314,7 +314,7 @@ var require_react_is_development = __commonJS({
314
314
  exports.ContextProvider = ContextProvider;
315
315
  exports.Element = Element;
316
316
  exports.ForwardRef = ForwardRef;
317
- exports.Fragment = Fragment;
317
+ exports.Fragment = Fragment2;
318
318
  exports.Lazy = Lazy;
319
319
  exports.Memo = Memo;
320
320
  exports.Portal = Portal;
@@ -3352,6 +3352,7 @@ function FormikSelect(_a) {
3352
3352
 
3353
3353
 
3354
3354
 
3355
+
3355
3356
  function Autocomplete2(_a) {
3356
3357
  var _b = _a, {
3357
3358
  withFormik = true,
@@ -3436,6 +3437,9 @@ function FormikAutocomplete(_a) {
3436
3437
  error: Boolean(meta == null ? void 0 : meta.error),
3437
3438
  helperText: meta == null ? void 0 : meta.error
3438
3439
  }, params), field), {
3440
+ InputProps: __spreadProps(__spreadValues({}, params.InputProps), {
3441
+ endAdornment: /* @__PURE__ */ React2.default.createElement(_react.Fragment, null, props.loading ? /* @__PURE__ */ React2.default.createElement(_material.CircularProgress, { color: "inherit", size: 20 }) : null, params.InputProps.endAdornment)
3442
+ }),
3439
3443
  label: props.label
3440
3444
  })
3441
3445
  ),
@@ -3968,6 +3972,17 @@ var HttpError = class extends Error {
3968
3972
  };
3969
3973
 
3970
3974
  // src/helpers/apiHelper/index.ts
3975
+ var VALID_METHODS = [
3976
+ "GET",
3977
+ "HEAD",
3978
+ "POST",
3979
+ "PUT",
3980
+ "DELETE",
3981
+ "CONNECT",
3982
+ "OPTIONS",
3983
+ "TRACE",
3984
+ "PATCH"
3985
+ ];
3971
3986
  var ApiHelper = class _ApiHelper {
3972
3987
  onFinally(req, res) {
3973
3988
  return __async(this, null, function* () {
@@ -3979,9 +3994,9 @@ var ApiHelper = class _ApiHelper {
3979
3994
  }
3980
3995
  constructor(props) {
3981
3996
  this.middlewares = ((props == null ? void 0 : props.middlewares) || []).reverse();
3982
- this.onFinally = props.onFinally || (() => __async(this, null, function* () {
3997
+ this.onFinally = (props == null ? void 0 : props.onFinally) || (() => __async(this, null, function* () {
3983
3998
  }));
3984
- this.onError = props.onError || (() => __async(this, null, function* () {
3999
+ this.onError = (props == null ? void 0 : props.onError) || (() => __async(this, null, function* () {
3985
4000
  }));
3986
4001
  }
3987
4002
  setMiddlewares(middlewares) {
@@ -3990,12 +4005,14 @@ var ApiHelper = class _ApiHelper {
3990
4005
  }
3991
4006
  createMethods(methods) {
3992
4007
  return (req, res) => __async(this, null, function* () {
3993
- const currentMethod = methods[req.method];
4008
+ const currentMethod = methods[req.method] || methods.ALL;
3994
4009
  if (req.method === "OPTIONS")
3995
4010
  return res.status(200).end();
3996
4011
  try {
3997
- if (!currentMethod)
4012
+ if (!VALID_METHODS.includes(req.method))
3998
4013
  throw new HttpError(405, "M\xE9todo inv\xE1lido");
4014
+ if (!currentMethod)
4015
+ throw new HttpError(500, "M\xE9todo n\xE3o encontrado");
3999
4016
  const methodWithMiddlewares = this.middlewares.reduce(
4000
4017
  (acc, fn) => fn(acc),
4001
4018
  currentMethod