@lidofinance/lido-ui 3.0.0-next.13 → 3.0.0-next.14

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.
@@ -6,15 +6,25 @@ Object.defineProperty(exports, "setThemeCookie", {
6
6
  enumerable: true,
7
7
  get: ()=>setThemeCookie
8
8
  });
9
+ const _uaParserJs = require("ua-parser-js");
9
10
  const _utils = require("../../utils/index");
10
11
  const _constants = require("../constants");
11
12
  const setThemeCookie = (theme)=>{
13
+ var ref, ref1;
12
14
  const cookie = `${_constants.themeCookieKey}=${theme};expires=${_constants.themeCookieExpire};path=/;domain=${(0, _utils.getTopLevelDomain)()};samesite=None;`;
13
15
  // 1. we want this cookie to be available on HTTP websites too.
14
16
  // 2. there is a bug on localhost which causes Chrome to ignore cookies set without Secure,
15
17
  // and Safari when cookies are set with Secure, so we're forcing cookie into both
16
- document.cookie = cookie;
17
- document.cookie = `${cookie}Secure;`;
18
+ const parser = new _uaParserJs.UAParser();
19
+ if (((ref = parser.getBrowser()) === null || ref === void 0 ? void 0 : (ref1 = ref.name) === null || ref1 === void 0 ? void 0 : ref1.toLowerCase()) === 'safari') {
20
+ if (window.location.protocol === 'https:') {
21
+ document.cookie = `${cookie}Secure;`;
22
+ } else {
23
+ document.cookie = cookie;
24
+ }
25
+ } else {
26
+ document.cookie = `${cookie}Secure;`;
27
+ }
18
28
  };
19
29
 
20
30
  //# sourceMappingURL=set-theme-cookie.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/theme/utils/set-theme-cookie.ts"],"sourcesContent":["import { getTopLevelDomain } from '@lidofinance/utils'\nimport { themeCookieExpire, themeCookieKey, ThemeName } from '../constants'\n\nexport const setThemeCookie = (theme: ThemeName) => {\n const cookie = `${themeCookieKey}=${theme};expires=${themeCookieExpire};path=/;domain=${getTopLevelDomain()};samesite=None;`\n // 1. we want this cookie to be available on HTTP websites too.\n // 2. there is a bug on localhost which causes Chrome to ignore cookies set without Secure,\n // and Safari when cookies are set with Secure, so we're forcing cookie into both\n document.cookie = cookie\n document.cookie = `${cookie}Secure;`\n}\n"],"names":["setThemeCookie","theme","cookie","themeCookieKey","themeCookieExpire","getTopLevelDomain","document"],"mappings":"AAAA;;;;+BAGaA,gBAAc;;aAAdA,cAAc;;uBAHO,mBAAoB;2BACO,cAAc;AAEpE,MAAMA,cAAc,GAAG,CAACC,KAAgB,GAAK;IAClD,MAAMC,MAAM,GAAG,CAAC,EAAEC,UAAc,eAAA,CAAC,CAAC,EAAEF,KAAK,CAAC,SAAS,EAAEG,UAAiB,kBAAA,CAAC,eAAe,EAAEC,IAAAA,MAAiB,kBAAA,GAAE,CAAC,eAAe,CAAC;IAC5H,+DAA+D;IAC/D,2FAA2F;IAC3F,iFAAiF;IACjFC,QAAQ,CAACJ,MAAM,GAAGA,MAAM;IACxBI,QAAQ,CAACJ,MAAM,GAAG,CAAC,EAAEA,MAAM,CAAC,OAAO,CAAC;AACtC,CAAC"}
1
+ {"version":3,"sources":["../../../../packages/theme/utils/set-theme-cookie.ts"],"sourcesContent":["import { UAParser } from 'ua-parser-js'\nimport { getTopLevelDomain } from '@lidofinance/utils'\nimport { themeCookieExpire, themeCookieKey, ThemeName } from '../constants'\n\nexport const setThemeCookie = (theme: ThemeName) => {\n const cookie = `${themeCookieKey}=${theme};expires=${themeCookieExpire};path=/;domain=${getTopLevelDomain()};samesite=None;`\n // 1. we want this cookie to be available on HTTP websites too.\n // 2. there is a bug on localhost which causes Chrome to ignore cookies set without Secure,\n // and Safari when cookies are set with Secure, so we're forcing cookie into both\n const parser = new UAParser()\n if (parser.getBrowser()?.name?.toLowerCase() === 'safari') {\n if (window.location.protocol === 'https:') {\n document.cookie = `${cookie}Secure;`\n } else {\n document.cookie = cookie\n }\n } else {\n document.cookie = `${cookie}Secure;`\n }\n}\n"],"names":["setThemeCookie","theme","parser","cookie","themeCookieKey","themeCookieExpire","getTopLevelDomain","UAParser","getBrowser","name","toLowerCase","window","location","protocol","document"],"mappings":"AAAA;;;;+BAIaA,gBAAc;;aAAdA,cAAc;;4BAJF,cAAc;uBACL,mBAAoB;2BACO,cAAc;AAEpE,MAAMA,cAAc,GAAG,CAACC,KAAgB,GAAK;QAM9CC,GAAmB;IALvB,MAAMC,MAAM,GAAG,CAAC,EAAEC,UAAc,eAAA,CAAC,CAAC,EAAEH,KAAK,CAAC,SAAS,EAAEI,UAAiB,kBAAA,CAAC,eAAe,EAAEC,IAAAA,MAAiB,kBAAA,GAAE,CAAC,eAAe,CAAC;IAC5H,+DAA+D;IAC/D,2FAA2F;IAC3F,iFAAiF;IACjF,MAAMJ,MAAM,GAAG,IAAIK,WAAQ,SAAA,EAAE;IAC7B,IAAIL,CAAAA,CAAAA,GAAmB,GAAnBA,MAAM,CAACM,UAAU,EAAE,cAAnBN,GAAmB,WAAM,GAAzBA,KAAAA,CAAyB,GAAzBA,QAAAA,GAAmB,CAAEO,IAAI,6BAAA,GAAzBP,KAAAA,CAAyB,GAAzBA,KAA2BQ,WAAW,EAAE,MAAK,QAAQ,EAAE;QACzD,IAAIC,MAAM,CAACC,QAAQ,CAACC,QAAQ,KAAK,QAAQ,EAAE;YACzCC,QAAQ,CAACX,MAAM,GAAG,CAAC,EAAEA,MAAM,CAAC,OAAO,CAAC;QACtC,OAAO;YACLW,QAAQ,CAACX,MAAM,GAAGA,MAAM;QAC1B,CAAC;IACH,OAAO;QACLW,QAAQ,CAACX,MAAM,GAAG,CAAC,EAAEA,MAAM,CAAC,OAAO,CAAC;IACtC,CAAC;AACH,CAAC"}
@@ -1,12 +1,22 @@
1
+ import { UAParser } from "ua-parser-js";
1
2
  import { getTopLevelDomain } from "../../utils/index";
2
3
  import { themeCookieExpire, themeCookieKey } from "../constants";
3
4
  export const setThemeCookie = (theme)=>{
5
+ var ref, ref1;
4
6
  const cookie = `${themeCookieKey}=${theme};expires=${themeCookieExpire};path=/;domain=${getTopLevelDomain()};samesite=None;`;
5
7
  // 1. we want this cookie to be available on HTTP websites too.
6
8
  // 2. there is a bug on localhost which causes Chrome to ignore cookies set without Secure,
7
9
  // and Safari when cookies are set with Secure, so we're forcing cookie into both
8
- document.cookie = cookie;
9
- document.cookie = `${cookie}Secure;`;
10
+ const parser = new UAParser();
11
+ if (((ref = parser.getBrowser()) === null || ref === void 0 ? void 0 : (ref1 = ref.name) === null || ref1 === void 0 ? void 0 : ref1.toLowerCase()) === 'safari') {
12
+ if (window.location.protocol === 'https:') {
13
+ document.cookie = `${cookie}Secure;`;
14
+ } else {
15
+ document.cookie = cookie;
16
+ }
17
+ } else {
18
+ document.cookie = `${cookie}Secure;`;
19
+ }
10
20
  };
11
21
 
12
22
  //# sourceMappingURL=set-theme-cookie.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/theme/utils/set-theme-cookie.ts"],"sourcesContent":["import { getTopLevelDomain } from '@lidofinance/utils'\nimport { themeCookieExpire, themeCookieKey, ThemeName } from '../constants'\n\nexport const setThemeCookie = (theme: ThemeName) => {\n const cookie = `${themeCookieKey}=${theme};expires=${themeCookieExpire};path=/;domain=${getTopLevelDomain()};samesite=None;`\n // 1. we want this cookie to be available on HTTP websites too.\n // 2. there is a bug on localhost which causes Chrome to ignore cookies set without Secure,\n // and Safari when cookies are set with Secure, so we're forcing cookie into both\n document.cookie = cookie\n document.cookie = `${cookie}Secure;`\n}\n"],"names":["getTopLevelDomain","themeCookieExpire","themeCookieKey","setThemeCookie","theme","cookie","document"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,mBAAoB,CAAA;AACtD,SAASC,iBAAiB,EAAEC,cAAc,QAAmB,cAAc,CAAA;AAE3E,OAAO,MAAMC,cAAc,GAAG,CAACC,KAAgB,GAAK;IAClD,MAAMC,MAAM,GAAG,CAAC,EAAEH,cAAc,CAAC,CAAC,EAAEE,KAAK,CAAC,SAAS,EAAEH,iBAAiB,CAAC,eAAe,EAAED,iBAAiB,EAAE,CAAC,eAAe,CAAC;IAC5H,+DAA+D;IAC/D,2FAA2F;IAC3F,iFAAiF;IACjFM,QAAQ,CAACD,MAAM,GAAGA,MAAM;IACxBC,QAAQ,CAACD,MAAM,GAAG,CAAC,EAAEA,MAAM,CAAC,OAAO,CAAC;AACtC,CAAC,CAAA"}
1
+ {"version":3,"sources":["../../../../packages/theme/utils/set-theme-cookie.ts"],"sourcesContent":["import { UAParser } from 'ua-parser-js'\nimport { getTopLevelDomain } from '@lidofinance/utils'\nimport { themeCookieExpire, themeCookieKey, ThemeName } from '../constants'\n\nexport const setThemeCookie = (theme: ThemeName) => {\n const cookie = `${themeCookieKey}=${theme};expires=${themeCookieExpire};path=/;domain=${getTopLevelDomain()};samesite=None;`\n // 1. we want this cookie to be available on HTTP websites too.\n // 2. there is a bug on localhost which causes Chrome to ignore cookies set without Secure,\n // and Safari when cookies are set with Secure, so we're forcing cookie into both\n const parser = new UAParser()\n if (parser.getBrowser()?.name?.toLowerCase() === 'safari') {\n if (window.location.protocol === 'https:') {\n document.cookie = `${cookie}Secure;`\n } else {\n document.cookie = cookie\n }\n } else {\n document.cookie = `${cookie}Secure;`\n }\n}\n"],"names":["UAParser","getTopLevelDomain","themeCookieExpire","themeCookieKey","setThemeCookie","theme","parser","cookie","getBrowser","name","toLowerCase","window","location","protocol","document"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc,CAAA;AACvC,SAASC,iBAAiB,QAAQ,mBAAoB,CAAA;AACtD,SAASC,iBAAiB,EAAEC,cAAc,QAAmB,cAAc,CAAA;AAE3E,OAAO,MAAMC,cAAc,GAAG,CAACC,KAAgB,GAAK;QAM9CC,GAAmB;IALvB,MAAMC,MAAM,GAAG,CAAC,EAAEJ,cAAc,CAAC,CAAC,EAAEE,KAAK,CAAC,SAAS,EAAEH,iBAAiB,CAAC,eAAe,EAAED,iBAAiB,EAAE,CAAC,eAAe,CAAC;IAC5H,+DAA+D;IAC/D,2FAA2F;IAC3F,iFAAiF;IACjF,MAAMK,MAAM,GAAG,IAAIN,QAAQ,EAAE;IAC7B,IAAIM,CAAAA,CAAAA,GAAmB,GAAnBA,MAAM,CAACE,UAAU,EAAE,cAAnBF,GAAmB,WAAM,GAAzBA,KAAAA,CAAyB,GAAzBA,QAAAA,GAAmB,CAAEG,IAAI,6BAAA,GAAzBH,KAAAA,CAAyB,GAAzBA,KAA2BI,WAAW,EAAE,MAAK,QAAQ,EAAE;QACzD,IAAIC,MAAM,CAACC,QAAQ,CAACC,QAAQ,KAAK,QAAQ,EAAE;YACzCC,QAAQ,CAACP,MAAM,GAAG,CAAC,EAAEA,MAAM,CAAC,OAAO,CAAC;QACtC,OAAO;YACLO,QAAQ,CAACP,MAAM,GAAGA,MAAM;QAC1B,CAAC;IACH,OAAO;QACLO,QAAQ,CAACP,MAAM,GAAG,CAAC,EAAEA,MAAM,CAAC,OAAO,CAAC;IACtC,CAAC;AACH,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"set-theme-cookie.d.ts","sourceRoot":"","sources":["../../../../packages/theme/utils/set-theme-cookie.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,SAAS,EAAE,MAAM,cAAc,CAAA;AAE3E,eAAO,MAAM,cAAc,UAAW,SAAS,SAO9C,CAAA"}
1
+ {"version":3,"file":"set-theme-cookie.d.ts","sourceRoot":"","sources":["../../../../packages/theme/utils/set-theme-cookie.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqC,SAAS,EAAE,MAAM,cAAc,CAAA;AAE3E,eAAO,MAAM,cAAc,UAAW,SAAS,SAe9C,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lidofinance/lido-ui",
3
- "version": "3.0.0-next.13",
3
+ "version": "3.0.0-next.14",
4
4
  "homepage": "https://github.com/lidofinance/ui",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,6 +45,7 @@
45
45
  "react-toastify": "7.0.4",
46
46
  "react-transition-group": "4",
47
47
  "styled-system": "5.1.5",
48
+ "ua-parser-js": "^1.0.2",
48
49
  "use-callback-ref": "1.2.5"
49
50
  },
50
51
  "devDependencies": {
@@ -62,6 +63,10 @@
62
63
  "@storybook/react": "^6.5.10",
63
64
  "@storybook/storybook-deployer": "^2.8.12",
64
65
  "@storybook/theming": "^6.5.10",
66
+ "@svgr/core": "5.5.0",
67
+ "@svgr/plugin-jsx": "5.5.0",
68
+ "@svgr/plugin-prettier": "5.5.0",
69
+ "@svgr/plugin-svgo": "5.5.0",
65
70
  "@swc/cli": "^0.1.57",
66
71
  "@swc/core": "^1.2.245",
67
72
  "@swc/jest": "^0.2.22",
@@ -74,6 +79,7 @@
74
79
  "@types/styled-components": "^5.1.26",
75
80
  "@types/styled-system": "^5.1.15",
76
81
  "@types/styled-system__should-forward-prop": "^5.1.2",
82
+ "@types/ua-parser-js": "^0.7.36",
77
83
  "@typescript-eslint/eslint-plugin": "^5.36.1",
78
84
  "@typescript-eslint/parser": "^5.36.1",
79
85
  "browserslist": "^4.21.3",
@@ -103,10 +109,6 @@
103
109
  "styled-components": "^5.3.5",
104
110
  "tslib": "2.3.1",
105
111
  "typescript": "4.8",
106
- "zx": "^7.0.8",
107
- "@svgr/core": "5.5.0",
108
- "@svgr/plugin-jsx": "5.5.0",
109
- "@svgr/plugin-prettier": "5.5.0",
110
- "@svgr/plugin-svgo": "5.5.0"
112
+ "zx": "^7.0.8"
111
113
  }
112
114
  }