@hellocoop/vue 1.0.0 → 1.0.1
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/BaseButton.vue.d.ts +2 -2
- package/dist/index.mjs +95 -86
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button, type ProviderHint, type Scope } from '../types';
|
|
2
|
-
|
|
2
|
+
type Props = {
|
|
3
3
|
label?: string;
|
|
4
4
|
style?: any;
|
|
5
5
|
color?: Button.Color;
|
|
@@ -11,7 +11,7 @@ interface Props {
|
|
|
11
11
|
providerHint?: ProviderHint[];
|
|
12
12
|
showLoader?: boolean;
|
|
13
13
|
disabled?: boolean;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
16
16
|
label: string;
|
|
17
17
|
color: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { provide as
|
|
2
|
-
const
|
|
1
|
+
import { provide as v, inject as H, defineComponent as a, onMounted as S, ref as B, openBlock as l, createElementBlock as p, normalizeClass as U, unref as g, normalizeStyle as k, createElementVNode as y, createBlock as i, renderSlot as f, createCommentVNode as b } from "vue";
|
|
2
|
+
const s = {
|
|
3
3
|
login: "/api/hellocoop?login=true",
|
|
4
4
|
auth: "/api/hellocoop?auth=true",
|
|
5
5
|
logout: "/api/hellocoop?logout=true"
|
|
6
|
-
},
|
|
6
|
+
}, m = "HelloAuth", P = () => H(m), G = {
|
|
7
7
|
props: ["auth", "config"],
|
|
8
|
-
setup(
|
|
9
|
-
var o,
|
|
10
|
-
(o =
|
|
8
|
+
setup(e) {
|
|
9
|
+
var o, t, n;
|
|
10
|
+
(o = e == null ? void 0 : e.config) != null && o.login && (s.login = e.config.login), (t = e == null ? void 0 : e.config) != null && t.auth && (s.auth = e.config.auth), (n = e == null ? void 0 : e.config) != null && n.logout && (s.logout = e.config.logout), v(m, e.auth);
|
|
11
11
|
},
|
|
12
12
|
render() {
|
|
13
13
|
return this.$slots.default();
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
var
|
|
17
|
-
((
|
|
18
|
-
|
|
16
|
+
var h;
|
|
17
|
+
((e) => {
|
|
18
|
+
e.STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css", e.HOVER_MAPPING = {
|
|
19
19
|
pop: "",
|
|
20
20
|
glow: "hello-btn-hover-glow",
|
|
21
21
|
flare: "hello-btn-hover-flare",
|
|
22
22
|
none: "hello-btn-hover-none"
|
|
23
|
-
},
|
|
23
|
+
}, e.CLASS_MAPPING = {
|
|
24
24
|
black: {
|
|
25
25
|
"ignore-light": "",
|
|
26
26
|
"ignore-dark": "hello-btn-black-on-dark",
|
|
@@ -34,8 +34,8 @@ var u;
|
|
|
34
34
|
"aware-static": "hello-btn-white-and-static"
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
})(
|
|
38
|
-
const
|
|
37
|
+
})(h || (h = {}));
|
|
38
|
+
const I = ["disabled"], $ = ["innerHTML"], r = /* @__PURE__ */ a({
|
|
39
39
|
__name: "BaseButton",
|
|
40
40
|
props: {
|
|
41
41
|
label: { default: "ō Continue with Hellō" },
|
|
@@ -50,137 +50,146 @@ const S = ["disabled"], k = ["innerHTML"], r = /* @__PURE__ */ n({
|
|
|
50
50
|
showLoader: { type: Boolean, default: !1 },
|
|
51
51
|
disabled: { type: Boolean, default: !1 }
|
|
52
52
|
},
|
|
53
|
-
setup(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
setup(e) {
|
|
54
|
+
let o = !1;
|
|
55
|
+
S(() => {
|
|
56
|
+
typeof window < "u" && !o && (Array.from(document.head.getElementsByTagName("link")).find(
|
|
57
|
+
(_) => {
|
|
58
|
+
var d;
|
|
59
|
+
return _.getAttribute("rel") === "stylesheet" && ((d = _.getAttribute("href")) == null ? void 0 : d.startsWith(h.STYLES_URL));
|
|
60
|
+
}
|
|
61
|
+
) || console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."), o = !0);
|
|
62
|
+
});
|
|
63
|
+
const t = B(!1), n = e, c = new URL(s.login, window.location.origin);
|
|
64
|
+
n.scope && c.searchParams.set("scope", n.scope.join(" ")), c.searchParams.set("target_uri", n.targetURI || window.location.pathname), n.updateScope && c.searchParams.set("scope", "profile_update " + n.updateScope), n.providerHint && c.searchParams.set("provider_hint", n.providerHint.join(" "));
|
|
65
|
+
const L = () => {
|
|
66
|
+
t.value = !0, window.location.href = c.href;
|
|
58
67
|
};
|
|
59
|
-
return (
|
|
60
|
-
var
|
|
61
|
-
return
|
|
62
|
-
onClick:
|
|
63
|
-
class:
|
|
64
|
-
disabled:
|
|
65
|
-
style:
|
|
68
|
+
return (u, _) => {
|
|
69
|
+
var d;
|
|
70
|
+
return l(), p("button", {
|
|
71
|
+
onClick: L,
|
|
72
|
+
class: U(["hello-btn", (d = g(h).CLASS_MAPPING[n.color]) == null ? void 0 : d[n.theme], g(h).HOVER_MAPPING[u.hover], (u.showLoader || t.value) && "hello-btn-loader"]),
|
|
73
|
+
disabled: n.disabled || t.value,
|
|
74
|
+
style: k(u.style)
|
|
66
75
|
}, [
|
|
67
|
-
|
|
68
|
-
], 14,
|
|
76
|
+
y("span", { innerHTML: u.label }, null, 8, $)
|
|
77
|
+
], 14, I);
|
|
69
78
|
};
|
|
70
79
|
}
|
|
71
|
-
}),
|
|
80
|
+
}), T = /* @__PURE__ */ a({
|
|
72
81
|
__name: "ContinueButton",
|
|
73
|
-
setup(
|
|
74
|
-
return (o,
|
|
82
|
+
setup(e) {
|
|
83
|
+
return (o, t) => (l(), i(r));
|
|
75
84
|
}
|
|
76
|
-
}),
|
|
85
|
+
}), x = /* @__PURE__ */ a({
|
|
77
86
|
__name: "LoginButton",
|
|
78
|
-
setup(
|
|
79
|
-
return (o,
|
|
87
|
+
setup(e) {
|
|
88
|
+
return (o, t) => (l(), i(r, { label: "ō Login with Hellō" }));
|
|
80
89
|
}
|
|
81
|
-
}),
|
|
90
|
+
}), M = /* @__PURE__ */ a({
|
|
82
91
|
__name: "UpdateEmailButton",
|
|
83
|
-
setup(
|
|
84
|
-
return (o,
|
|
92
|
+
setup(e) {
|
|
93
|
+
return (o, t) => (l(), i(r, {
|
|
85
94
|
label: "ō Update Email with Hellō",
|
|
86
95
|
updateScope: "email"
|
|
87
96
|
}));
|
|
88
97
|
}
|
|
89
|
-
}),
|
|
98
|
+
}), N = /* @__PURE__ */ a({
|
|
90
99
|
__name: "UpdatePictureButton",
|
|
91
|
-
setup(
|
|
92
|
-
return (o,
|
|
100
|
+
setup(e) {
|
|
101
|
+
return (o, t) => (l(), i(r, {
|
|
93
102
|
label: "ō Update Picture with Hellō",
|
|
94
103
|
updateScope: "picture"
|
|
95
104
|
}));
|
|
96
105
|
}
|
|
97
|
-
}),
|
|
106
|
+
}), O = /* @__PURE__ */ a({
|
|
98
107
|
__name: "UpdateTwitterButton",
|
|
99
|
-
setup(
|
|
100
|
-
return (o,
|
|
108
|
+
setup(e) {
|
|
109
|
+
return (o, t) => (l(), i(r, {
|
|
101
110
|
label: "ō Update Twitter with Hellō",
|
|
102
111
|
updateScope: "twitter"
|
|
103
112
|
}));
|
|
104
113
|
}
|
|
105
|
-
}),
|
|
114
|
+
}), V = /* @__PURE__ */ a({
|
|
106
115
|
__name: "UpdateDiscordButton",
|
|
107
|
-
setup(
|
|
108
|
-
return (o,
|
|
116
|
+
setup(e) {
|
|
117
|
+
return (o, t) => (l(), i(r, {
|
|
109
118
|
label: "ō Update Discord with Hellō",
|
|
110
119
|
updateScope: "discord"
|
|
111
120
|
}));
|
|
112
121
|
}
|
|
113
|
-
}),
|
|
122
|
+
}), j = /* @__PURE__ */ a({
|
|
114
123
|
__name: "UpdateGitHubButton",
|
|
115
|
-
setup(
|
|
116
|
-
return (o,
|
|
124
|
+
setup(e) {
|
|
125
|
+
return (o, t) => (l(), i(r, {
|
|
117
126
|
label: "ō Update GitHub with Hellō",
|
|
118
127
|
updateScope: "github"
|
|
119
128
|
}));
|
|
120
129
|
}
|
|
121
|
-
}),
|
|
130
|
+
}), D = /* @__PURE__ */ a({
|
|
122
131
|
__name: "UpdateGitLabButton",
|
|
123
|
-
setup(
|
|
124
|
-
return (o,
|
|
132
|
+
setup(e) {
|
|
133
|
+
return (o, t) => (l(), i(r, {
|
|
125
134
|
label: "ō Update GitLab with Hellō",
|
|
126
135
|
updateScope: "gitlab"
|
|
127
136
|
}));
|
|
128
137
|
}
|
|
129
|
-
}),
|
|
138
|
+
}), C = async (e) => {
|
|
130
139
|
try {
|
|
131
|
-
return await (await fetch(
|
|
140
|
+
return await (await fetch(e)).json();
|
|
132
141
|
} catch (o) {
|
|
133
142
|
console.error(o);
|
|
134
143
|
return;
|
|
135
144
|
}
|
|
136
|
-
},
|
|
137
|
-
const
|
|
145
|
+
}, w = () => {
|
|
146
|
+
const e = P(), { data: o = e, isValidating: t } = useSWR(s.auth, C);
|
|
138
147
|
return {
|
|
139
148
|
auth: o || {},
|
|
140
|
-
isLoading:
|
|
149
|
+
isLoading: t,
|
|
141
150
|
isLoggedIn: o == null ? void 0 : o.isLoggedIn
|
|
142
151
|
};
|
|
143
|
-
},
|
|
152
|
+
}, A = { key: 0 }, Y = /* @__PURE__ */ a({
|
|
144
153
|
__name: "LoggedIn",
|
|
145
|
-
setup(
|
|
154
|
+
setup(e) {
|
|
146
155
|
const o = () => {
|
|
147
|
-
var
|
|
148
|
-
return ((
|
|
156
|
+
var t;
|
|
157
|
+
return ((t = w()) == null ? void 0 : t.isLoggedIn) || !1;
|
|
149
158
|
};
|
|
150
|
-
return (
|
|
151
|
-
|
|
152
|
-
])) :
|
|
159
|
+
return (t, n) => o() ? (l(), p("div", A, [
|
|
160
|
+
f(t.$slots, "default")
|
|
161
|
+
])) : b("", !0);
|
|
153
162
|
}
|
|
154
|
-
}),
|
|
163
|
+
}), E = { key: 0 }, z = /* @__PURE__ */ a({
|
|
155
164
|
__name: "LoggedOut",
|
|
156
|
-
setup(
|
|
165
|
+
setup(e) {
|
|
157
166
|
const o = () => {
|
|
158
|
-
var
|
|
159
|
-
return ((
|
|
167
|
+
var t;
|
|
168
|
+
return ((t = w()) == null ? void 0 : t.isLoggedIn) || !1;
|
|
160
169
|
};
|
|
161
|
-
return (
|
|
162
|
-
|
|
170
|
+
return (t, n) => o() ? b("", !0) : (l(), p("div", E, [
|
|
171
|
+
f(t.$slots, "default")
|
|
163
172
|
]));
|
|
164
173
|
}
|
|
165
|
-
}),
|
|
166
|
-
function
|
|
167
|
-
window.location.href =
|
|
174
|
+
}), W = () => s.logout;
|
|
175
|
+
function F() {
|
|
176
|
+
window.location.href = s.logout;
|
|
168
177
|
}
|
|
169
178
|
export {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
T as ContinueButton,
|
|
180
|
+
G as HelloProvider,
|
|
181
|
+
Y as LoggedIn,
|
|
182
|
+
z as LoggedOut,
|
|
183
|
+
x as LoginButton,
|
|
184
|
+
V as UpdateDiscordButton,
|
|
185
|
+
M as UpdateEmailButton,
|
|
186
|
+
j as UpdateGitHubButton,
|
|
187
|
+
D as UpdateGitLabButton,
|
|
188
|
+
N as UpdatePictureButton,
|
|
189
|
+
O as UpdateTwitterButton,
|
|
190
|
+
W as getLogOutRoute,
|
|
191
|
+
F as logOut,
|
|
192
|
+
s as routeConfig,
|
|
193
|
+
w as useAuth,
|
|
185
194
|
P as useHelloProviderContext
|
|
186
195
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(l=typeof globalThis<"u"?globalThis:l||self,e(l["@hellocoop/vue"]={},l.Vue))})(this,function(l,e){"use strict";const i={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},p="HelloAuth",f=()=>e.inject(p),g={props:["auth","config"],setup(t){var n,o,a;(n=t==null?void 0:t.config)!=null&&n.login&&(i.login=t.config.login),(o=t==null?void 0:t.config)!=null&&o.auth&&(i.auth=t.config.auth),(a=t==null?void 0:t.config)!=null&&a.logout&&(i.logout=t.config.logout),e.provide(p,t.auth)},render(){return this.$slots.default()}};var r;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(r||(r={}));const m=["disabled"],b=["innerHTML"],c=e.defineComponent({__name:"BaseButton",props:{label:{default:"ō Continue with Hellō"},style:{},color:{default:"black"},theme:{default:"ignore-light"},hover:{default:"pop"},scope:{},updateScope:{},targetURI:{},providerHint:{},showLoader:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(t){let n=!1;e.onMounted(()=>{typeof window<"u"&&!n&&(Array.from(document.head.getElementsByTagName("link")).find(_=>{var u;return _.getAttribute("rel")==="stylesheet"&&((u=_.getAttribute("href"))==null?void 0:u.startsWith(r.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),n=!0)});const o=e.ref(!1),a=t,s=new URL(i.login,window.location.origin);a.scope&&s.searchParams.set("scope",a.scope.join(" ")),s.searchParams.set("target_uri",a.targetURI||window.location.pathname),a.updateScope&&s.searchParams.set("scope","profile_update "+a.updateScope),a.providerHint&&s.searchParams.set("provider_hint",a.providerHint.join(" "));const T=()=>{o.value=!0,window.location.href=s.href};return(d,_)=>{var u;return e.openBlock(),e.createElementBlock("button",{onClick:T,class:e.normalizeClass(["hello-btn",(u=e.unref(r).CLASS_MAPPING[a.color])==null?void 0:u[a.theme],e.unref(r).HOVER_MAPPING[d.hover],(d.showLoader||o.value)&&"hello-btn-loader"]),disabled:a.disabled||o.value,style:e.normalizeStyle(d.style)},[e.createElementVNode("span",{innerHTML:d.label},null,8,b)],14,m)}}}),B=e.defineComponent({__name:"ContinueButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c))}}),w=e.defineComponent({__name:"LoginButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō Login with Hellō"}))}}),k=e.defineComponent({__name:"UpdateEmailButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō Update Email with Hellō",updateScope:"email"}))}}),L=e.defineComponent({__name:"UpdatePictureButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō Update Picture with Hellō",updateScope:"picture"}))}}),S=e.defineComponent({__name:"UpdateTwitterButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō Update Twitter with Hellō",updateScope:"twitter"}))}}),C=e.defineComponent({__name:"UpdateDiscordButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō Update Discord with Hellō",updateScope:"discord"}))}}),H=e.defineComponent({__name:"UpdateGitHubButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō Update GitHub with Hellō",updateScope:"github"}))}}),y=e.defineComponent({__name:"UpdateGitLabButton",setup(t){return(n,o)=>(e.openBlock(),e.createBlock(c,{label:"ō Update GitLab with Hellō",updateScope:"gitlab"}))}}),U=async t=>{try{return await(await fetch(t)).json()}catch(n){console.error(n);return}},h=()=>{const t=f(),{data:n=t,isValidating:o}=useSWR(i.auth,U);return{auth:n||{},isLoading:o,isLoggedIn:n==null?void 0:n.isLoggedIn}},P={key:0},I=e.defineComponent({__name:"LoggedIn",setup(t){const n=()=>{var o;return((o=h())==null?void 0:o.isLoggedIn)||!1};return(o,a)=>n()?(e.openBlock(),e.createElementBlock("div",P,[e.renderSlot(o.$slots,"default")])):e.createCommentVNode("",!0)}}),$={key:0},E=e.defineComponent({__name:"LoggedOut",setup(t){const n=()=>{var o;return((o=h())==null?void 0:o.isLoggedIn)||!1};return(o,a)=>n()?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",$,[e.renderSlot(o.$slots,"default")]))}}),A=()=>i.logout;function R(){window.location.href=i.logout}l.ContinueButton=B,l.HelloProvider=g,l.LoggedIn=I,l.LoggedOut=E,l.LoginButton=w,l.UpdateDiscordButton=C,l.UpdateEmailButton=k,l.UpdateGitHubButton=H,l.UpdateGitLabButton=y,l.UpdatePictureButton=L,l.UpdateTwitterButton=S,l.getLogOutRoute=A,l.logOut=R,l.routeConfig=i,l.useAuth=h,l.useHelloProviderContext=f,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|