@bluemarble/bm-components 2.1.2 → 2.1.4

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
@@ -4305,7 +4305,7 @@ var DialogConfirm = (props) => {
4305
4305
  onClick: model.onCancel,
4306
4306
  color: "inherit"
4307
4307
  },
4308
- props.cancelButtonText || "Confirmar"
4308
+ props.cancelButtonText || "Cancelar"
4309
4309
  ))))));
4310
4310
  };
4311
4311
 
@@ -4753,10 +4753,111 @@ function useFormHelper() {
4753
4753
  }
4754
4754
 
4755
4755
  // src/helpers/authHelper.ts
4756
- import { serialize } from "cookie";
4757
- import { parseCookies, setCookie } from "nookies";
4756
+ import { serialize as serialize2 } from "cookie";
4758
4757
  import { v4 as uuid } from "uuid";
4759
4758
  import jwt from "jsonwebtoken";
4759
+
4760
+ // packages/nookies/index.ts
4761
+ import * as cookie from "cookie";
4762
+ import * as setCookieParser from "set-cookie-parser";
4763
+
4764
+ // packages/nookies/util.ts
4765
+ function isBrowser() {
4766
+ return typeof window !== "undefined";
4767
+ }
4768
+ function createCookie(name, value, options) {
4769
+ let sameSite = options.sameSite;
4770
+ if (sameSite === true) {
4771
+ sameSite = "strict";
4772
+ }
4773
+ if (sameSite === void 0 || sameSite === false) {
4774
+ sameSite = "lax";
4775
+ }
4776
+ const cookieToSet = { ...options, sameSite };
4777
+ delete cookieToSet.encode;
4778
+ return {
4779
+ name,
4780
+ value,
4781
+ ...cookieToSet
4782
+ };
4783
+ }
4784
+ function hasSameProperties(a, b) {
4785
+ const aProps = Object.getOwnPropertyNames(a);
4786
+ const bProps = Object.getOwnPropertyNames(b);
4787
+ if (aProps.length !== bProps.length) {
4788
+ return false;
4789
+ }
4790
+ for (let i = 0; i < aProps.length; i++) {
4791
+ const propName = aProps[i];
4792
+ if (a[propName] !== b[propName]) {
4793
+ return false;
4794
+ }
4795
+ }
4796
+ return true;
4797
+ }
4798
+ function areCookiesEqual(a, b) {
4799
+ let sameSiteSame = a.sameSite === b.sameSite;
4800
+ if (typeof a.sameSite === "string" && typeof b.sameSite === "string") {
4801
+ sameSiteSame = a.sameSite.toLowerCase() === b.sameSite.toLowerCase();
4802
+ }
4803
+ return hasSameProperties(
4804
+ { ...a, sameSite: void 0 },
4805
+ { ...b, sameSite: void 0 }
4806
+ ) && sameSiteSame;
4807
+ }
4808
+
4809
+ // packages/nookies/index.ts
4810
+ function parseCookies(ctx, options) {
4811
+ if (ctx?.req?.headers?.cookie) {
4812
+ return cookie.parse(ctx.req.headers.cookie, options);
4813
+ }
4814
+ if (isBrowser()) {
4815
+ return cookie.parse(document.cookie, options);
4816
+ }
4817
+ return {};
4818
+ }
4819
+ function setCookie(ctx, name, value, options = {}) {
4820
+ if (ctx?.res?.getHeader && ctx.res.setHeader) {
4821
+ if (ctx?.res?.finished) {
4822
+ console.warn(`Not setting "${name}" cookie. Response has finished.`);
4823
+ console.warn(`You should set cookie before res.send()`);
4824
+ return {};
4825
+ }
4826
+ let cookies = ctx.res.getHeader("Set-Cookie") || [];
4827
+ if (typeof cookies === "string") cookies = [cookies];
4828
+ if (typeof cookies === "number") cookies = [];
4829
+ const parsedCookies = setCookieParser.parse(cookies, {
4830
+ decodeValues: false
4831
+ });
4832
+ const newCookie = createCookie(name, value, options);
4833
+ let cookiesToSet = [];
4834
+ parsedCookies.forEach((parsedCookie) => {
4835
+ if (!areCookiesEqual(parsedCookie, newCookie)) {
4836
+ const serializedCookie = cookie.serialize(
4837
+ parsedCookie.name,
4838
+ parsedCookie.value,
4839
+ {
4840
+ // we prevent reencoding by default, but you might override it
4841
+ encode: (val) => val,
4842
+ ...parsedCookie
4843
+ }
4844
+ );
4845
+ cookiesToSet.push(serializedCookie);
4846
+ }
4847
+ });
4848
+ cookiesToSet.push(cookie.serialize(name, value, options));
4849
+ ctx.res.setHeader("Set-Cookie", cookiesToSet);
4850
+ }
4851
+ if (isBrowser()) {
4852
+ if (options && options.httpOnly) {
4853
+ throw new Error("Can not set a httpOnly cookie in the browser.");
4854
+ }
4855
+ document.cookie = cookie.serialize(name, value, options);
4856
+ }
4857
+ return {};
4858
+ }
4859
+
4860
+ // src/helpers/authHelper.ts
4760
4861
  function decodeSessionToken({
4761
4862
  req,
4762
4863
  res,
@@ -4808,11 +4909,11 @@ var AuthHelper = class {
4808
4909
  };
4809
4910
  this.invalidateCookies = (res) => {
4810
4911
  return res.setHeader("Set-Cookie", [
4811
- serialize(this.cookies.sessionToken, "", {
4912
+ serialize2(this.cookies.sessionToken, "", {
4812
4913
  maxAge: -1,
4813
4914
  path: "/"
4814
4915
  }),
4815
- serialize(this.cookies.refreshToken, "", {
4916
+ serialize2(this.cookies.refreshToken, "", {
4816
4917
  maxAge: -1,
4817
4918
  path: "/"
4818
4919
  })
@@ -5114,8 +5215,26 @@ function createFilter(filters) {
5114
5215
  };
5115
5216
  }
5116
5217
 
5218
+ // src/helpers/sortHelper.ts
5219
+ function SortHelper(...fields) {
5220
+ return (a, b) => {
5221
+ for (const field of fields) {
5222
+ let direction = 1;
5223
+ let key = field;
5224
+ if (field.startsWith("-")) {
5225
+ direction = -1;
5226
+ key = field.slice(1);
5227
+ }
5228
+ const aVal = a[key];
5229
+ const bVal = b[key];
5230
+ if (aVal > bVal) return direction;
5231
+ if (aVal < bVal) return -direction;
5232
+ }
5233
+ return 0;
5234
+ };
5235
+ }
5236
+
5117
5237
  // src/hooks/useGrid.ts
5118
- import sortBy from "sort-by";
5119
5238
  function useGrid({
5120
5239
  columns,
5121
5240
  filters,
@@ -5185,7 +5304,7 @@ function useGrid({
5185
5304
  const formattedKeys = sortedBy.map(
5186
5305
  ({ prop, direction }) => `${symbolDir[direction]}${prop}`
5187
5306
  );
5188
- return data.sort(sortBy(...formattedKeys));
5307
+ return data.sort(SortHelper(...formattedKeys));
5189
5308
  } else return data;
5190
5309
  },
5191
5310
  [sortedBy]
@@ -5486,7 +5605,6 @@ import {
5486
5605
  useEffect as useEffect8,
5487
5606
  useState as useState11
5488
5607
  } from "react";
5489
- import { parseCookies as parseCookies2 } from "nookies";
5490
5608
  function createAuthContext() {
5491
5609
  return createContext5({});
5492
5610
  }
@@ -5526,7 +5644,7 @@ function CreateAuthProvider({
5526
5644
  setUser(void 0);
5527
5645
  }, [api]);
5528
5646
  useEffect8(() => {
5529
- const token = parseCookies2()[sessionTokenName];
5647
+ const token = parseCookies()[sessionTokenName];
5530
5648
  if (token) {
5531
5649
  setStatus("loading");
5532
5650
  api.get("/auth/me").then((response) => {