@hellocoop/react 3.0.2 → 3.1.3
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/auth.d.ts +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/buttons.d.ts +3 -3
- package/dist/buttons.d.ts.map +1 -1
- package/dist/buttons.js +12 -13
- package/dist/login-status.js +2 -3
- package/dist/logout.d.ts.map +1 -1
- package/dist/logout.js +2 -2
- package/package.json +4 -6
package/dist/auth.d.ts
CHANGED
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAelD,MAAM,MAAM,SAAS,GAAG;IACpB,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,GAAG,SAAS,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,OAAO,QAAO,SAS1B,CAAA"}
|
package/dist/buttons.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ProviderHint, Scope } from '@hellocoop/
|
|
3
|
-
import { Button } from '@hellocoop/
|
|
2
|
+
import type { ProviderHint, Scope } from '@hellocoop/definitions';
|
|
3
|
+
import { Button } from '@hellocoop/definitions';
|
|
4
4
|
interface CommonButtonProps {
|
|
5
5
|
label?: string;
|
|
6
6
|
onClick?: any;
|
|
@@ -15,7 +15,7 @@ interface CommonButtonProps {
|
|
|
15
15
|
promptLogin?: boolean;
|
|
16
16
|
promptConsent?: boolean;
|
|
17
17
|
loginHint?: string;
|
|
18
|
-
|
|
18
|
+
domainHint?: string;
|
|
19
19
|
}
|
|
20
20
|
export interface BaseButtonProps extends CommonButtonProps {
|
|
21
21
|
scope?: Scope[] | string;
|
package/dist/buttons.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buttons.d.ts","sourceRoot":"","sources":["../src/buttons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"buttons.d.ts","sourceRoot":"","sources":["../src/buttons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAM/C,UAAU,iBAAiB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,GAAG,CAAA;IACb,KAAK,CAAC,EAAE,GAAG,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACtD,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACvD,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IACxD,MAAM,CAAC,EAAE,OAAO,CAAA;CACnB;AAwFD,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,qBAErD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,qBAElD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,qBAE3D"}
|
package/dist/buttons.js
CHANGED
|
@@ -23,25 +23,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.ContinueButton = ContinueButton;
|
|
27
|
+
exports.LoginButton = LoginButton;
|
|
28
|
+
exports.UpdateProfileButton = UpdateProfileButton;
|
|
27
29
|
const react_1 = __importStar(require("react"));
|
|
28
|
-
const
|
|
30
|
+
const definitions_1 = require("@hellocoop/definitions");
|
|
29
31
|
const provider_1 = require("./provider");
|
|
30
32
|
let checkedForStylesheet = false;
|
|
31
|
-
function BaseButton({ scope, update = false, targetURI, providerHint, label, style, color = "black", theme = "ignore-light", hover = "pop", showLoader = false, disabled = false, promptLogin = false, promptConsent = false, loginHint,
|
|
33
|
+
function BaseButton({ scope, update = false, targetURI, providerHint, label, style, color = "black", theme = "ignore-light", hover = "pop", showLoader = false, disabled = false, promptLogin = false, promptConsent = false, loginHint, domainHint }) {
|
|
32
34
|
var _a;
|
|
33
35
|
//check if dev has added Hellō stylesheet to pages with Hellō buttons
|
|
34
36
|
if (typeof window != 'undefined' && !checkedForStylesheet) {
|
|
35
37
|
const hasStylesheet = Array.from(document.head.getElementsByTagName('link')).find((element) => {
|
|
36
38
|
var _a;
|
|
37
39
|
return element.getAttribute('rel') === 'stylesheet' &&
|
|
38
|
-
((_a = element.getAttribute('href')) === null || _a === void 0 ? void 0 : _a.startsWith(
|
|
40
|
+
((_a = element.getAttribute('href')) === null || _a === void 0 ? void 0 : _a.startsWith(definitions_1.Button.STYLES_URL));
|
|
39
41
|
});
|
|
40
42
|
if (!hasStylesheet)
|
|
41
43
|
console.warn('Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info.');
|
|
42
44
|
checkedForStylesheet = true;
|
|
43
45
|
}
|
|
44
|
-
const helloBtnClass = (_a =
|
|
46
|
+
const helloBtnClass = (_a = definitions_1.Button.CLASS_MAPPING[color]) === null || _a === void 0 ? void 0 : _a[theme];
|
|
45
47
|
const [clicked, setClicked] = (0, react_1.useState)(false);
|
|
46
48
|
const loginRoute = new URL(provider_1.routeConfig.login, "https://example.com"); // hack so we can use URL()
|
|
47
49
|
if (scope) {
|
|
@@ -55,6 +57,10 @@ function BaseButton({ scope, update = false, targetURI, providerHint, label, sty
|
|
|
55
57
|
loginRoute.searchParams.set("target_uri", targetURI);
|
|
56
58
|
if (update)
|
|
57
59
|
loginRoute.searchParams.set("prompt", "consent");
|
|
60
|
+
if (loginHint)
|
|
61
|
+
loginRoute.searchParams.set("login_hint", loginHint);
|
|
62
|
+
if (domainHint)
|
|
63
|
+
loginRoute.searchParams.set("domain_hint", domainHint);
|
|
58
64
|
if (providerHint) {
|
|
59
65
|
if (typeof providerHint == 'string')
|
|
60
66
|
loginRoute.searchParams.set("provider_hint", providerHint);
|
|
@@ -70,26 +76,19 @@ function BaseButton({ scope, update = false, targetURI, providerHint, label, sty
|
|
|
70
76
|
else if (promptConsent) {
|
|
71
77
|
loginRoute.searchParams.set("prompt", "consent");
|
|
72
78
|
}
|
|
73
|
-
if (loginHint)
|
|
74
|
-
loginRoute.searchParams.set("login_hint", loginHint);
|
|
75
|
-
if (account)
|
|
76
|
-
loginRoute.searchParams.set("account", account);
|
|
77
79
|
const onClickHandler = () => {
|
|
78
80
|
setClicked(true);
|
|
79
81
|
if (typeof window !== 'undefined')
|
|
80
82
|
window.location.href = loginRoute.pathname + loginRoute.search;
|
|
81
83
|
};
|
|
82
|
-
return (react_1.default.createElement("button", { onClick: onClickHandler, disabled: disabled || clicked, style: style, className: `hello-btn ${helloBtnClass} ${
|
|
84
|
+
return (react_1.default.createElement("button", { onClick: onClickHandler, disabled: disabled || clicked, style: style, className: `hello-btn ${helloBtnClass} ${definitions_1.Button.HOVER_MAPPING[hover]} ${(showLoader || clicked) ? 'hello-btn-loader' : ''}` }, label));
|
|
83
85
|
}
|
|
84
86
|
function ContinueButton(props) {
|
|
85
87
|
return react_1.default.createElement(BaseButton, { label: "\u014D\u00A0\u00A0\u00A0Continue with Hell\u014D", ...props });
|
|
86
88
|
}
|
|
87
|
-
exports.ContinueButton = ContinueButton;
|
|
88
89
|
function LoginButton(props) {
|
|
89
90
|
return react_1.default.createElement(BaseButton, { label: "\u014D\u00A0\u00A0\u00A0Log in with Hell\u014D", ...props });
|
|
90
91
|
}
|
|
91
|
-
exports.LoginButton = LoginButton;
|
|
92
92
|
function UpdateProfileButton(props) {
|
|
93
93
|
return react_1.default.createElement(BaseButton, { label: "\u014D\u00A0\u00A0\u00A0Update Profile with Hell\u014D", ...props, update: true });
|
|
94
94
|
}
|
|
95
|
-
exports.UpdateProfileButton = UpdateProfileButton;
|
package/dist/login-status.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LoggedIn = LoggedIn;
|
|
4
|
+
exports.LoggedOut = LoggedOut;
|
|
4
5
|
const auth_1 = require("./auth");
|
|
5
6
|
const isLoggedIn = () => { var _a; return ((_a = (0, auth_1.useAuth)()) === null || _a === void 0 ? void 0 : _a.isLoggedIn) || false; };
|
|
6
7
|
function LoggedIn({ children }) {
|
|
7
8
|
if (isLoggedIn())
|
|
8
9
|
return children;
|
|
9
10
|
}
|
|
10
|
-
exports.LoggedIn = LoggedIn;
|
|
11
11
|
function LoggedOut({ children }) {
|
|
12
12
|
if (!isLoggedIn())
|
|
13
13
|
return children;
|
|
14
14
|
}
|
|
15
|
-
exports.LoggedOut = LoggedOut;
|
package/dist/logout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../src/logout.tsx"],"names":[],"mappings":"AAeA,eAAO,MAAM,cAAc,WAAW,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../src/logout.tsx"],"names":[],"mappings":"AAeA,eAAO,MAAM,cAAc,WAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,WAA4B,CAAA;AAErF,wBAAgB,MAAM,CAAC,MAAM,EAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAEhD"}
|
package/dist/logout.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getLogOutRoute = void 0;
|
|
4
|
+
exports.logOut = logOut;
|
|
4
5
|
const provider_1 = require("./provider");
|
|
5
6
|
const makeLogoutRoute = (params) => {
|
|
6
7
|
if (!params || !Object.keys(params).length)
|
|
@@ -18,4 +19,3 @@ function logOut(params) {
|
|
|
18
19
|
if (typeof window !== 'undefined')
|
|
19
20
|
window.location.href = makeLogoutRoute(params);
|
|
20
21
|
}
|
|
21
|
-
exports.logOut = logOut;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hellocoop/react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "React SDK for Hellō https://hello.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,16 +32,14 @@
|
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"watch": "tsc --watch --declaration",
|
|
35
|
-
"
|
|
36
|
-
"build
|
|
37
|
-
"build:src": "tsc --declaration"
|
|
35
|
+
"prebuild": "rimraf dist/",
|
|
36
|
+
"build": "tsc --declaration"
|
|
38
37
|
},
|
|
39
38
|
"peerDependencies": {
|
|
40
39
|
"react": ">=17",
|
|
41
40
|
"react-dom": ">=17"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"@hellocoop/types": "~1.1.6",
|
|
45
43
|
"@types/react": "^18.2.21",
|
|
46
44
|
"react": "^18.2.0",
|
|
47
45
|
"react-dom": "^18.2.0",
|
|
@@ -52,7 +50,7 @@
|
|
|
52
50
|
"node": ">=18"
|
|
53
51
|
},
|
|
54
52
|
"dependencies": {
|
|
55
|
-
"@hellocoop/
|
|
53
|
+
"@hellocoop/definitions": "^1.0.3",
|
|
56
54
|
"swr": "^2.2.2"
|
|
57
55
|
}
|
|
58
56
|
}
|