@bluemarble/bm-components 1.13.4 → 1.15.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
@@ -240,18 +240,20 @@ interface UseGridProps$1<T> {
240
240
  }
241
241
  declare function useGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions, defaultData: externalDefaultData, defaultCurrentPage, defaultSortedBy }: UseGridProps$1<T>): {
242
242
  data: T[];
243
- set: (data: T[]) => void;
244
- onSortBy: (prop: string) => void;
245
243
  sortedBy: SortedByProps$1[];
246
244
  defaultData: T[];
247
245
  columns: ColumnsProps<_mui_material.Theme>[];
248
246
  currentPage: number;
249
247
  totalNumberOfPages: number;
250
- onPageChange: (pageNumber: number) => void;
251
- setRowsPerPage: (rows: number) => void;
252
248
  rowsPerPageOptions: number[];
253
249
  rowsPerPage: number;
250
+ set: (data: T[]) => void;
251
+ onSortBy: (prop: string) => void;
252
+ onPageChange: (pageNumber: number) => void;
253
+ setRowsPerPage: (rows: number) => void;
254
+ appendSort: (prop: string, direction: 'desc' | 'asc') => void;
254
255
  setSort: (prop: string, direction: 'desc' | 'asc') => void;
256
+ clearSort: () => void;
255
257
  };
256
258
 
257
259
  interface ColumnsProps<T extends object = Theme> {
@@ -390,7 +392,7 @@ interface ConstructorProps {
390
392
  scope: string;
391
393
  tenant_id: string;
392
394
  client_secret: string;
393
- onCreateUser: (fields: {
395
+ onCreateUser?: (fields: {
394
396
  email: string;
395
397
  fullname: string;
396
398
  }) => Promise<void>;
@@ -437,7 +439,7 @@ declare class AuthHelper {
437
439
  props?: undefined;
438
440
  } | {
439
441
  props: {
440
- destination: string;
442
+ error: string;
441
443
  };
442
444
  redirect?: undefined;
443
445
  }>;
package/dist/index.d.ts CHANGED
@@ -240,18 +240,20 @@ interface UseGridProps$1<T> {
240
240
  }
241
241
  declare function useGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions, defaultData: externalDefaultData, defaultCurrentPage, defaultSortedBy }: UseGridProps$1<T>): {
242
242
  data: T[];
243
- set: (data: T[]) => void;
244
- onSortBy: (prop: string) => void;
245
243
  sortedBy: SortedByProps$1[];
246
244
  defaultData: T[];
247
245
  columns: ColumnsProps<_mui_material.Theme>[];
248
246
  currentPage: number;
249
247
  totalNumberOfPages: number;
250
- onPageChange: (pageNumber: number) => void;
251
- setRowsPerPage: (rows: number) => void;
252
248
  rowsPerPageOptions: number[];
253
249
  rowsPerPage: number;
250
+ set: (data: T[]) => void;
251
+ onSortBy: (prop: string) => void;
252
+ onPageChange: (pageNumber: number) => void;
253
+ setRowsPerPage: (rows: number) => void;
254
+ appendSort: (prop: string, direction: 'desc' | 'asc') => void;
254
255
  setSort: (prop: string, direction: 'desc' | 'asc') => void;
256
+ clearSort: () => void;
255
257
  };
256
258
 
257
259
  interface ColumnsProps<T extends object = Theme> {
@@ -390,7 +392,7 @@ interface ConstructorProps {
390
392
  scope: string;
391
393
  tenant_id: string;
392
394
  client_secret: string;
393
- onCreateUser: (fields: {
395
+ onCreateUser?: (fields: {
394
396
  email: string;
395
397
  fullname: string;
396
398
  }) => Promise<void>;
@@ -437,7 +439,7 @@ declare class AuthHelper {
437
439
  props?: undefined;
438
440
  } | {
439
441
  props: {
440
- destination: string;
442
+ error: string;
441
443
  };
442
444
  redirect?: undefined;
443
445
  }>;
package/dist/index.js CHANGED
@@ -4427,7 +4427,7 @@ function decodeSessionToken({
4427
4427
  try {
4428
4428
  const decoded = jwtDecode(token);
4429
4429
  req.user = decoded.sub;
4430
- } catch (error) {
4430
+ } catch (_) {
4431
4431
  res.status(401).json({ error: "Token inv\xE1lido", code: "token.expired" });
4432
4432
  return true;
4433
4433
  }
@@ -4637,7 +4637,9 @@ var AuthHelper = class {
4637
4637
  try {
4638
4638
  const { fullName, email } = yield this.oauthSignInCallback(code);
4639
4639
  const userExists = yield this.onGetUserData(email);
4640
- if (!userExists && this.oauth) {
4640
+ if (!userExists && !this.oauth.onCreateUser)
4641
+ throw new Error("User does not exists");
4642
+ if (!userExists && this.oauth.onCreateUser) {
4641
4643
  yield this.oauth.onCreateUser({ fullname: fullName, email });
4642
4644
  }
4643
4645
  const { token, refreshToken } = yield this.generateJwtAndRefreshToken(
@@ -4664,10 +4666,9 @@ var AuthHelper = class {
4664
4666
  }
4665
4667
  };
4666
4668
  } catch (error) {
4667
- console.log(error);
4668
4669
  return {
4669
4670
  props: {
4670
- destination: onFailedDestination || "/"
4671
+ error: JSON.stringify(error)
4671
4672
  }
4672
4673
  };
4673
4674
  }
@@ -4800,9 +4801,15 @@ function useGrid({
4800
4801
  },
4801
4802
  []
4802
4803
  );
4803
- const setSort = _react.useCallback.call(void 0, (prop, direction) => {
4804
+ const clearSort = _react.useCallback.call(void 0, () => {
4805
+ setSortedBy([]);
4806
+ }, []);
4807
+ const appendSort = _react.useCallback.call(void 0, (prop, direction) => {
4804
4808
  setSortedBy((prev) => [...prev, { prop, direction }]);
4805
4809
  }, []);
4810
+ const setSort = _react.useCallback.call(void 0, (prop, direction) => {
4811
+ setSortedBy([{ prop, direction }]);
4812
+ }, []);
4806
4813
  const onSortBy = _react.useCallback.call(void 0,
4807
4814
  (prop) => {
4808
4815
  if (!prop)
@@ -4890,18 +4897,20 @@ function useGrid({
4890
4897
  }, [externalDefaultData]);
4891
4898
  return {
4892
4899
  data: displayData,
4893
- set,
4894
- onSortBy,
4895
4900
  sortedBy,
4896
4901
  defaultData,
4897
4902
  columns,
4898
4903
  currentPage,
4899
4904
  totalNumberOfPages: totalNumberOfPages < 0 ? 0 : totalNumberOfPages,
4900
- onPageChange,
4901
- setRowsPerPage: onChangeRowsPerPage,
4902
4905
  rowsPerPageOptions,
4903
4906
  rowsPerPage,
4904
- setSort
4907
+ set,
4908
+ onSortBy,
4909
+ onPageChange,
4910
+ setRowsPerPage: onChangeRowsPerPage,
4911
+ appendSort,
4912
+ setSort,
4913
+ clearSort
4905
4914
  };
4906
4915
  }
4907
4916
  function searchKeysForValue(row, compare) {