@hellocoop/react 1.0.0 → 1.0.2

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/buttons.js CHANGED
@@ -31,8 +31,8 @@ let checkedForStylesheet = false;
31
31
  function BaseButton({ scope, updateScope, targetURI, providerHint, label, style, color = "black", theme = "ignore-light", hover = "pop", showLoader = false, disabled = false }) {
32
32
  var _a;
33
33
  //check if dev has added Hellō stylesheet to pages with Hellō buttons
34
- if (!checkedForStylesheet) {
35
- const hasStylesheet = typeof document != 'undefined' && !Array.from(document.head.getElementsByTagName('link')).find((element) => {
34
+ if (typeof window != 'undefined' && !checkedForStylesheet) {
35
+ const hasStylesheet = !Array.from(document.head.getElementsByTagName('link')).find((element) => {
36
36
  var _a;
37
37
  return element.getAttribute('rel') === 'stylesheet' &&
38
38
  ((_a = element.getAttribute('href')) === null || _a === void 0 ? void 0 : _a.startsWith(types_1.Button.STYLES_URL));
@@ -43,7 +43,7 @@ function BaseButton({ scope, updateScope, targetURI, providerHint, label, style,
43
43
  }
44
44
  const helloBtnClass = (_a = types_1.Button.CLASS_MAPPING[color]) === null || _a === void 0 ? void 0 : _a[theme];
45
45
  const [clicked, setClicked] = (0, react_1.useState)(false);
46
- const loginRoute = new URL(provider_1.routeConfig.login, window.location.origin);
46
+ const loginRoute = new URL(provider_1.routeConfig.login, "https://example.com"); // hack so we can use URL()
47
47
  if (scope) {
48
48
  if (typeof scope == 'string')
49
49
  loginRoute.searchParams.set("scope", scope);
@@ -63,7 +63,8 @@ function BaseButton({ scope, updateScope, targetURI, providerHint, label, style,
63
63
  }
64
64
  const onClickHandler = () => {
65
65
  setClicked(true);
66
- window.location.href = loginRoute.href;
66
+ if (typeof window !== 'undefined')
67
+ window.location.href = loginRoute.pathname + loginRoute.search;
67
68
  };
68
69
  return (react_1.default.createElement("button", { onClick: onClickHandler, disabled: disabled || clicked, style: style, className: `hello-btn ${helloBtnClass} ${types_1.Button.HOVER_MAPPING[hover]} ${(showLoader || clicked) ? 'hello-btn-loader' : ''}` }, label));
69
70
  }
package/dist/logout.js CHANGED
@@ -5,6 +5,7 @@ const provider_1 = require("./provider");
5
5
  const getLogOutRoute = () => provider_1.routeConfig.logout;
6
6
  exports.getLogOutRoute = getLogOutRoute;
7
7
  function logOut() {
8
- window.location.href = provider_1.routeConfig.logout;
8
+ if (typeof window !== 'undefined')
9
+ window.location.href = provider_1.routeConfig.logout;
9
10
  }
10
11
  exports.logOut = logOut;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellocoop/react",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "React SDK for Hellō https://hello.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,6 +51,7 @@
51
51
  "node": ">=18"
52
52
  },
53
53
  "dependencies": {
54
+ "@hellocoop/types": "^1.0.0",
54
55
  "swr": "^2.2.2"
55
56
  }
56
57
  }