@knocklabs/react 0.7.8 → 0.7.10
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/CHANGELOG.md +16 -0
- package/dist/cjs/modules/slack/components/SlackAuthButton/SlackAuthButton.js +1 -1
- package/dist/cjs/modules/slack/components/SlackAuthButton/SlackAuthButton.js.map +1 -1
- package/dist/esm/modules/slack/components/SlackAuthButton/SlackAuthButton.mjs +27 -23
- package/dist/esm/modules/slack/components/SlackAuthButton/SlackAuthButton.mjs.map +1 -1
- package/dist/types/modules/slack/components/SlackAuthButton/SlackAuthButton.d.ts +1 -0
- package/dist/types/modules/slack/components/SlackAuthButton/SlackAuthButton.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.7.10
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 337bade: feat: introduce ability to override slack scopes
|
8
|
+
- Updated dependencies [337bade]
|
9
|
+
- @knocklabs/react-core@0.6.10
|
10
|
+
|
11
|
+
## 0.7.9
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- Updated dependencies [329ee05]
|
16
|
+
- @knocklabs/react-core@0.6.9
|
17
|
+
- @knocklabs/client@0.14.8
|
18
|
+
|
3
19
|
## 0.7.8
|
4
20
|
|
5
21
|
### Patch Changes
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),s=require("@knocklabs/react-core"),h=require("../../../core/utils.js");;/* empty css */const l=require("../SlackIcon/SlackIcon.js");;/* empty css */const C=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},e=C(i),L=({slackClientId:t,redirectUrl:p,onAuthenticationComplete:u,scopes:d,additionalScopes:k})=>{const{t:n}=s.useTranslations(),f=s.useKnockClient(),{setConnectionStatus:o,connectionStatus:c,setActionLabel:a,actionLabel:_,errorLabel:E}=s.useKnockSlackClient(),g=i.useMemo(()=>({scopes:d,additionalScopes:k}),[d,k]),{buildSlackAuthUrl:m,disconnectFromSlack:S}=s.useSlackAuth(t,p,g);i.useEffect(()=>{const b=r=>{if(r.origin===f.host)try{r.data==="authComplete"&&o("connected"),r.data==="authFailed"&&o("error"),u&&u(r.data)}catch{o("error")}};return window.addEventListener("message",b,!1),()=>{window.removeEventListener("message",b)}},[f.host,u,o]);const w=n("slackDisconnect")||null,x=n("slackReconnect")||null;return c==="connecting"||c==="disconnecting"?e.default.createElement("div",{className:"rsk-connect__button rsk-connect__button--loading"},e.default.createElement(l.SlackIcon,{height:"16px",width:"16px"}),e.default.createElement("span",null,n(c==="connecting"?"slackConnecting":"slackDisconnecting"))):c==="error"?e.default.createElement("button",{onClick:()=>h.openPopupWindow(m()),className:"rsk-connect__button rsk-connect__button--error",onMouseEnter:()=>a(x),onMouseLeave:()=>a(null)},e.default.createElement(l.SlackIcon,{height:"16px",width:"16px"}),e.default.createElement("span",{className:"rsk-connect__button__text--error"},_||E||n("slackError"))):c==="disconnected"?e.default.createElement("button",{onClick:()=>h.openPopupWindow(m()),className:"rsk-connect__button rsk-connect__button--disconnected"},e.default.createElement(l.SlackIcon,{height:"16px",width:"16px"}),e.default.createElement("span",null,n("slackConnect"))):e.default.createElement("button",{onClick:S,className:"rsk-connect__button rsk-connect__button--connected",onMouseEnter:()=>a(w),onMouseLeave:()=>a(null)},e.default.createElement(l.SlackIcon,{height:"16px",width:"16px"}),e.default.createElement("span",{className:"rsk-connect__button__text--connected"},_||n("slackConnected")))};exports.SlackAuthButton=L;
|
2
2
|
//# sourceMappingURL=SlackAuthButton.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SlackAuthButton.js","sources":["../../../../../../src/modules/slack/components/SlackAuthButton/SlackAuthButton.tsx"],"sourcesContent":["import {\n useKnockClient,\n useKnockSlackClient,\n useSlackAuth,\n useTranslations,\n} from \"@knocklabs/react-core\";\nimport { FunctionComponent } from \"react\";\nimport { useEffect } from \"react\";\n\nimport { openPopupWindow } from \"../../../core/utils\";\nimport \"../../theme.css\";\nimport { SlackIcon } from \"../SlackIcon\";\n\nimport \"./styles.css\";\n\nexport interface SlackAuthButtonProps {\n slackClientId: string;\n redirectUrl?: string;\n onAuthenticationComplete?: (authenticationResp: string) => void;\n additionalScopes?: string[];\n}\n\nexport const SlackAuthButton: FunctionComponent<SlackAuthButtonProps> = ({\n slackClientId,\n redirectUrl,\n onAuthenticationComplete,\n additionalScopes,\n}) => {\n const { t } = useTranslations();\n const knock = useKnockClient();\n\n const {\n setConnectionStatus,\n connectionStatus,\n setActionLabel,\n actionLabel,\n errorLabel,\n } = useKnockSlackClient();\n\n const { buildSlackAuthUrl, disconnectFromSlack } = useSlackAuth(\n slackClientId,\n redirectUrl,\n
|
1
|
+
{"version":3,"file":"SlackAuthButton.js","sources":["../../../../../../src/modules/slack/components/SlackAuthButton/SlackAuthButton.tsx"],"sourcesContent":["import {\n useKnockClient,\n useKnockSlackClient,\n useSlackAuth,\n useTranslations,\n} from \"@knocklabs/react-core\";\nimport { FunctionComponent, useMemo } from \"react\";\nimport { useEffect } from \"react\";\n\nimport { openPopupWindow } from \"../../../core/utils\";\nimport \"../../theme.css\";\nimport { SlackIcon } from \"../SlackIcon\";\n\nimport \"./styles.css\";\n\nexport interface SlackAuthButtonProps {\n slackClientId: string;\n redirectUrl?: string;\n onAuthenticationComplete?: (authenticationResp: string) => void;\n // When provided, the default scopes will be overridden with the provided scopes\n scopes?: string[];\n // Additional scopes to add to the default scopes\n additionalScopes?: string[];\n}\n\nexport const SlackAuthButton: FunctionComponent<SlackAuthButtonProps> = ({\n slackClientId,\n redirectUrl,\n onAuthenticationComplete,\n scopes,\n additionalScopes,\n}) => {\n const { t } = useTranslations();\n const knock = useKnockClient();\n\n const {\n setConnectionStatus,\n connectionStatus,\n setActionLabel,\n actionLabel,\n errorLabel,\n } = useKnockSlackClient();\n\n const useSlackAuthOptions = useMemo(\n () => ({\n scopes,\n additionalScopes,\n }),\n [scopes, additionalScopes],\n );\n\n const { buildSlackAuthUrl, disconnectFromSlack } = useSlackAuth(\n slackClientId,\n redirectUrl,\n useSlackAuthOptions,\n );\n\n useEffect(() => {\n const receiveMessage = (event: MessageEvent) => {\n if (event.origin !== knock.host) {\n return;\n }\n\n try {\n if (event.data === \"authComplete\") {\n setConnectionStatus(\"connected\");\n }\n\n if (event.data === \"authFailed\") {\n setConnectionStatus(\"error\");\n }\n\n if (onAuthenticationComplete) {\n onAuthenticationComplete(event.data);\n }\n } catch (_error) {\n setConnectionStatus(\"error\");\n }\n };\n\n window.addEventListener(\"message\", receiveMessage, false);\n\n // Cleanup the event listener when the component unmounts\n return () => {\n window.removeEventListener(\"message\", receiveMessage);\n };\n }, [knock.host, onAuthenticationComplete, setConnectionStatus]);\n\n const disconnectLabel = t(\"slackDisconnect\") || null;\n const reconnectLabel = t(\"slackReconnect\") || null;\n\n // Loading states\n if (\n connectionStatus === \"connecting\" ||\n connectionStatus === \"disconnecting\"\n ) {\n return (\n <div className=\"rsk-connect__button rsk-connect__button--loading\">\n <SlackIcon height=\"16px\" width=\"16px\" />\n <span>\n {connectionStatus === \"connecting\"\n ? t(\"slackConnecting\")\n : t(\"slackDisconnecting\")}\n </span>\n </div>\n );\n }\n\n // Error state\n if (connectionStatus === \"error\") {\n return (\n <button\n onClick={() => openPopupWindow(buildSlackAuthUrl())}\n className=\"rsk-connect__button rsk-connect__button--error\"\n onMouseEnter={() => setActionLabel(reconnectLabel)}\n onMouseLeave={() => setActionLabel(null)}\n >\n <SlackIcon height=\"16px\" width=\"16px\" />\n <span className=\"rsk-connect__button__text--error\">\n {actionLabel || errorLabel || t(\"slackError\")}\n </span>\n </button>\n );\n }\n\n // Disconnected state\n if (connectionStatus === \"disconnected\") {\n return (\n <button\n onClick={() => openPopupWindow(buildSlackAuthUrl())}\n className=\"rsk-connect__button rsk-connect__button--disconnected\"\n >\n <SlackIcon height=\"16px\" width=\"16px\" />\n <span>{t(\"slackConnect\")}</span>\n </button>\n );\n }\n\n // Connected state\n return (\n <button\n onClick={disconnectFromSlack}\n className=\"rsk-connect__button rsk-connect__button--connected\"\n onMouseEnter={() => setActionLabel(disconnectLabel)}\n onMouseLeave={() => setActionLabel(null)}\n >\n <SlackIcon height=\"16px\" width=\"16px\" />\n <span className=\"rsk-connect__button__text--connected\">\n {actionLabel || t(\"slackConnected\")}\n </span>\n </button>\n );\n};\n"],"names":["SlackAuthButton","slackClientId","redirectUrl","onAuthenticationComplete","scopes","additionalScopes","t","useTranslations","knock","useKnockClient","setConnectionStatus","connectionStatus","setActionLabel","actionLabel","errorLabel","useKnockSlackClient","useSlackAuthOptions","useMemo","buildSlackAuthUrl","disconnectFromSlack","useSlackAuth","useEffect","receiveMessage","event","origin","host","data","addEventListener","removeEventListener","disconnectLabel","reconnectLabel","React","SlackIcon","openPopupWindow"],"mappings":"2VAyBaA,EAA2DA,CAAC,CACvEC,cAAAA,EACAC,YAAAA,EACAC,yBAAAA,EACAC,OAAAA,EACAC,iBAAAA,CACF,IAAM,CACE,KAAA,CAAEC,EAAAA,GAAMC,kBAAgB,EACxBC,EAAQC,EAAAA,eAAe,EAEvB,CACJC,oBAAAA,EACAC,iBAAAA,EACAC,eAAAA,EACAC,YAAAA,EACAC,WAAAA,GACEC,sBAAoB,EAElBC,EAAsBC,EAAAA,QAC1B,KAAO,CACLb,OAAAA,EACAC,iBAAAA,CAAAA,GAEF,CAACD,EAAQC,CAAgB,CAC3B,EAEM,CAAEa,kBAAAA,EAAmBC,oBAAAA,CAAwBC,EAAAA,eACjDnB,EACAC,EACAc,CACF,EAEAK,EAAAA,UAAU,IAAM,CACRC,MAAAA,EAAkBC,GAAwB,CAC1CA,GAAAA,EAAMC,SAAWhB,EAAMiB,KAIvB,GAAA,CACEF,EAAMG,OAAS,gBACjBhB,EAAo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EAAAA,QAAA,cAACC,EAAAA,UAAU,CAAA,OAAO,OAAO,MAAM,MAAM,CAAA,EACrCD,EAAA,QAAA,cAAC,OAAK,CAAA,UAAU,sCACblB,EAAAA,GAAeP,EAAE,gBAAgB,CACpC,CACF,CAEJ"}
|
@@ -1,44 +1,48 @@
|
|
1
|
-
import e, { useEffect as
|
2
|
-
import { useTranslations as
|
3
|
-
import { openPopupWindow as
|
1
|
+
import e, { useMemo as w, useEffect as L } from "react";
|
2
|
+
import { useTranslations as C, useKnockClient as S, useKnockSlackClient as M, useSlackAuth as N } from "@knocklabs/react-core";
|
3
|
+
import { openPopupWindow as d } from "../../../core/utils.mjs";
|
4
4
|
/* empty css */
|
5
5
|
import { SlackIcon as s } from "../SlackIcon/SlackIcon.mjs";
|
6
6
|
/* empty css */
|
7
|
-
const
|
8
|
-
slackClientId:
|
9
|
-
redirectUrl:
|
7
|
+
const B = ({
|
8
|
+
slackClientId: p,
|
9
|
+
redirectUrl: b,
|
10
10
|
onAuthenticationComplete: a,
|
11
|
-
|
11
|
+
scopes: l,
|
12
|
+
additionalScopes: i
|
12
13
|
}) => {
|
13
14
|
const {
|
14
15
|
t
|
15
|
-
} =
|
16
|
+
} = C(), u = S(), {
|
16
17
|
setConnectionStatus: c,
|
17
18
|
connectionStatus: n,
|
18
19
|
setActionLabel: o,
|
19
|
-
actionLabel:
|
20
|
-
errorLabel:
|
21
|
-
} =
|
22
|
-
|
23
|
-
|
24
|
-
}
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
actionLabel: m,
|
21
|
+
errorLabel: h
|
22
|
+
} = M(), E = w(() => ({
|
23
|
+
scopes: l,
|
24
|
+
additionalScopes: i
|
25
|
+
}), [l, i]), {
|
26
|
+
buildSlackAuthUrl: k,
|
27
|
+
disconnectFromSlack: f
|
28
|
+
} = N(p, b, E);
|
29
|
+
L(() => {
|
30
|
+
const _ = (r) => {
|
31
|
+
if (r.origin === u.host)
|
28
32
|
try {
|
29
33
|
r.data === "authComplete" && c("connected"), r.data === "authFailed" && c("error"), a && a(r.data);
|
30
34
|
} catch {
|
31
35
|
c("error");
|
32
36
|
}
|
33
37
|
};
|
34
|
-
return window.addEventListener("message",
|
35
|
-
window.removeEventListener("message",
|
38
|
+
return window.addEventListener("message", _, !1), () => {
|
39
|
+
window.removeEventListener("message", _);
|
36
40
|
};
|
37
|
-
}, [
|
38
|
-
const
|
39
|
-
return n === "connecting" || n === "disconnecting" ? /* @__PURE__ */ e.createElement("div", { className: "rsk-connect__button rsk-connect__button--loading" }, /* @__PURE__ */ e.createElement(s, { height: "16px", width: "16px" }), /* @__PURE__ */ e.createElement("span", null, t(n === "connecting" ? "slackConnecting" : "slackDisconnecting"))) : n === "error" ? /* @__PURE__ */ e.createElement("button", { onClick: () => k(
|
41
|
+
}, [u.host, a, c]);
|
42
|
+
const g = t("slackDisconnect") || null, x = t("slackReconnect") || null;
|
43
|
+
return n === "connecting" || n === "disconnecting" ? /* @__PURE__ */ e.createElement("div", { className: "rsk-connect__button rsk-connect__button--loading" }, /* @__PURE__ */ e.createElement(s, { height: "16px", width: "16px" }), /* @__PURE__ */ e.createElement("span", null, t(n === "connecting" ? "slackConnecting" : "slackDisconnecting"))) : n === "error" ? /* @__PURE__ */ e.createElement("button", { onClick: () => d(k()), className: "rsk-connect__button rsk-connect__button--error", onMouseEnter: () => o(x), onMouseLeave: () => o(null) }, /* @__PURE__ */ e.createElement(s, { height: "16px", width: "16px" }), /* @__PURE__ */ e.createElement("span", { className: "rsk-connect__button__text--error" }, m || h || t("slackError"))) : n === "disconnected" ? /* @__PURE__ */ e.createElement("button", { onClick: () => d(k()), className: "rsk-connect__button rsk-connect__button--disconnected" }, /* @__PURE__ */ e.createElement(s, { height: "16px", width: "16px" }), /* @__PURE__ */ e.createElement("span", null, t("slackConnect"))) : /* @__PURE__ */ e.createElement("button", { onClick: f, className: "rsk-connect__button rsk-connect__button--connected", onMouseEnter: () => o(g), onMouseLeave: () => o(null) }, /* @__PURE__ */ e.createElement(s, { height: "16px", width: "16px" }), /* @__PURE__ */ e.createElement("span", { className: "rsk-connect__button__text--connected" }, m || t("slackConnected")));
|
40
44
|
};
|
41
45
|
export {
|
42
|
-
|
46
|
+
B as SlackAuthButton
|
43
47
|
};
|
44
48
|
//# sourceMappingURL=SlackAuthButton.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SlackAuthButton.mjs","sources":["../../../../../../src/modules/slack/components/SlackAuthButton/SlackAuthButton.tsx"],"sourcesContent":["import {\n useKnockClient,\n useKnockSlackClient,\n useSlackAuth,\n useTranslations,\n} from \"@knocklabs/react-core\";\nimport { FunctionComponent } from \"react\";\nimport { useEffect } from \"react\";\n\nimport { openPopupWindow } from \"../../../core/utils\";\nimport \"../../theme.css\";\nimport { SlackIcon } from \"../SlackIcon\";\n\nimport \"./styles.css\";\n\nexport interface SlackAuthButtonProps {\n slackClientId: string;\n redirectUrl?: string;\n onAuthenticationComplete?: (authenticationResp: string) => void;\n additionalScopes?: string[];\n}\n\nexport const SlackAuthButton: FunctionComponent<SlackAuthButtonProps> = ({\n slackClientId,\n redirectUrl,\n onAuthenticationComplete,\n additionalScopes,\n}) => {\n const { t } = useTranslations();\n const knock = useKnockClient();\n\n const {\n setConnectionStatus,\n connectionStatus,\n setActionLabel,\n actionLabel,\n errorLabel,\n } = useKnockSlackClient();\n\n const { buildSlackAuthUrl, disconnectFromSlack } = useSlackAuth(\n slackClientId,\n redirectUrl,\n
|
1
|
+
{"version":3,"file":"SlackAuthButton.mjs","sources":["../../../../../../src/modules/slack/components/SlackAuthButton/SlackAuthButton.tsx"],"sourcesContent":["import {\n useKnockClient,\n useKnockSlackClient,\n useSlackAuth,\n useTranslations,\n} from \"@knocklabs/react-core\";\nimport { FunctionComponent, useMemo } from \"react\";\nimport { useEffect } from \"react\";\n\nimport { openPopupWindow } from \"../../../core/utils\";\nimport \"../../theme.css\";\nimport { SlackIcon } from \"../SlackIcon\";\n\nimport \"./styles.css\";\n\nexport interface SlackAuthButtonProps {\n slackClientId: string;\n redirectUrl?: string;\n onAuthenticationComplete?: (authenticationResp: string) => void;\n // When provided, the default scopes will be overridden with the provided scopes\n scopes?: string[];\n // Additional scopes to add to the default scopes\n additionalScopes?: string[];\n}\n\nexport const SlackAuthButton: FunctionComponent<SlackAuthButtonProps> = ({\n slackClientId,\n redirectUrl,\n onAuthenticationComplete,\n scopes,\n additionalScopes,\n}) => {\n const { t } = useTranslations();\n const knock = useKnockClient();\n\n const {\n setConnectionStatus,\n connectionStatus,\n setActionLabel,\n actionLabel,\n errorLabel,\n } = useKnockSlackClient();\n\n const useSlackAuthOptions = useMemo(\n () => ({\n scopes,\n additionalScopes,\n }),\n [scopes, additionalScopes],\n );\n\n const { buildSlackAuthUrl, disconnectFromSlack } = useSlackAuth(\n slackClientId,\n redirectUrl,\n useSlackAuthOptions,\n );\n\n useEffect(() => {\n const receiveMessage = (event: MessageEvent) => {\n if (event.origin !== knock.host) {\n return;\n }\n\n try {\n if (event.data === \"authComplete\") {\n setConnectionStatus(\"connected\");\n }\n\n if (event.data === \"authFailed\") {\n setConnectionStatus(\"error\");\n }\n\n if (onAuthenticationComplete) {\n onAuthenticationComplete(event.data);\n }\n } catch (_error) {\n setConnectionStatus(\"error\");\n }\n };\n\n window.addEventListener(\"message\", receiveMessage, false);\n\n // Cleanup the event listener when the component unmounts\n return () => {\n window.removeEventListener(\"message\", receiveMessage);\n };\n }, [knock.host, onAuthenticationComplete, setConnectionStatus]);\n\n const disconnectLabel = t(\"slackDisconnect\") || null;\n const reconnectLabel = t(\"slackReconnect\") || null;\n\n // Loading states\n if (\n connectionStatus === \"connecting\" ||\n connectionStatus === \"disconnecting\"\n ) {\n return (\n <div className=\"rsk-connect__button rsk-connect__button--loading\">\n <SlackIcon height=\"16px\" width=\"16px\" />\n <span>\n {connectionStatus === \"connecting\"\n ? t(\"slackConnecting\")\n : t(\"slackDisconnecting\")}\n </span>\n </div>\n );\n }\n\n // Error state\n if (connectionStatus === \"error\") {\n return (\n <button\n onClick={() => openPopupWindow(buildSlackAuthUrl())}\n className=\"rsk-connect__button rsk-connect__button--error\"\n onMouseEnter={() => setActionLabel(reconnectLabel)}\n onMouseLeave={() => setActionLabel(null)}\n >\n <SlackIcon height=\"16px\" width=\"16px\" />\n <span className=\"rsk-connect__button__text--error\">\n {actionLabel || errorLabel || t(\"slackError\")}\n </span>\n </button>\n );\n }\n\n // Disconnected state\n if (connectionStatus === \"disconnected\") {\n return (\n <button\n onClick={() => openPopupWindow(buildSlackAuthUrl())}\n className=\"rsk-connect__button rsk-connect__button--disconnected\"\n >\n <SlackIcon height=\"16px\" width=\"16px\" />\n <span>{t(\"slackConnect\")}</span>\n </button>\n );\n }\n\n // Connected state\n return (\n <button\n onClick={disconnectFromSlack}\n className=\"rsk-connect__button rsk-connect__button--connected\"\n onMouseEnter={() => setActionLabel(disconnectLabel)}\n onMouseLeave={() => setActionLabel(null)}\n >\n <SlackIcon height=\"16px\" width=\"16px\" />\n <span className=\"rsk-connect__button__text--connected\">\n {actionLabel || t(\"slackConnected\")}\n </span>\n </button>\n );\n};\n"],"names":["SlackAuthButton","slackClientId","redirectUrl","onAuthenticationComplete","scopes","additionalScopes","t","useTranslations","knock","useKnockClient","setConnectionStatus","connectionStatus","setActionLabel","actionLabel","errorLabel","useKnockSlackClient","useSlackAuthOptions","useMemo","buildSlackAuthUrl","disconnectFromSlack","useSlackAuth","useEffect","receiveMessage","event","origin","host","data","addEventListener","removeEventListener","disconnectLabel","reconnectLabel","React","SlackIcon","openPopupWindow"],"mappings":";;;;;;AAyBO,MAAMA,IAA2DA,CAAC;AAAA,EACvEC,eAAAA;AAAAA,EACAC,aAAAA;AAAAA,EACAC,0BAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC,kBAAAA;AACF,MAAM;AACE,QAAA;AAAA,IAAEC;AAAAA,MAAMC,EAAgB,GACxBC,IAAQC,EAAe,GAEvB;AAAA,IACJC,qBAAAA;AAAAA,IACAC,kBAAAA;AAAAA,IAC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B,GAAU,EAAA,QAAO,QAAO,OAAM,QAAM,GACrCD,gBAAAA,EAAA,cAAC,QAAK,EAAA,WAAU,sCACblB,KAAeC,KAAcR,EAAE,YAAY,CAC9C,CACF,IAKAK,MAAqB,iBAErBoB,gBAAAA,EAAA,cAAC,YACC,SAAS,MAAME,EAAgBf,EAAkB,CAAC,GAClD,WAAU,wDAEV,GAAAa,gBAAAA,EAAA,cAACC,KAAU,QAAO,QAAO,OAAM,OAAM,CAAA,mCACpC,QAAM1B,MAAAA,EAAE,cAAc,CAAE,CAC3B,IAMDyB,gBAAAA,EAAA,cAAA,UAAA,EACC,SAASZ,GACT,WAAU,sDACV,cAAc,MAAMP,EAAeiB,CAAe,GAClD,cAAc,MAAMjB,EAAe,IAAI,KAEvCmB,gBAAAA,EAAA,cAACC,GAAU,EAAA,QAAO,QAAO,OAAM,OAAM,CAAA,GACrCD,gBAAAA,EAAA,cAAC,QAAK,EAAA,WAAU,uCACblB,GAAAA,KAAeP,EAAE,gBAAgB,CACpC,CACF;AAEJ;"}
|
@@ -3,6 +3,7 @@ export interface SlackAuthButtonProps {
|
|
3
3
|
slackClientId: string;
|
4
4
|
redirectUrl?: string;
|
5
5
|
onAuthenticationComplete?: (authenticationResp: string) => void;
|
6
|
+
scopes?: string[];
|
6
7
|
additionalScopes?: string[];
|
7
8
|
}
|
8
9
|
export declare const SlackAuthButton: FunctionComponent<SlackAuthButtonProps>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SlackAuthButton.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/slack/components/SlackAuthButton/SlackAuthButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,
|
1
|
+
{"version":3,"file":"SlackAuthButton.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/slack/components/SlackAuthButton/SlackAuthButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAC;AAInD,OAAO,iBAAiB,CAAC;AAGzB,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wBAAwB,CAAC,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,CA+HnE,CAAC"}
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@knocklabs/react",
|
3
3
|
"description": "A set of React components to build notification experiences powered by Knock",
|
4
4
|
"author": "@knocklabs",
|
5
|
-
"version": "0.7.
|
5
|
+
"version": "0.7.10",
|
6
6
|
"license": "MIT",
|
7
7
|
"main": "dist/cjs/index.js",
|
8
8
|
"module": "dist/esm/index.mjs",
|
@@ -52,10 +52,10 @@
|
|
52
52
|
"react-dom": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
53
53
|
},
|
54
54
|
"dependencies": {
|
55
|
-
"@knocklabs/client": "^0.14.
|
56
|
-
"@knocklabs/react-core": "^0.6.
|
55
|
+
"@knocklabs/client": "^0.14.8",
|
56
|
+
"@knocklabs/react-core": "^0.6.10",
|
57
57
|
"@popperjs/core": "^2.11.8",
|
58
|
-
"@radix-ui/react-dialog": "^1.1.
|
58
|
+
"@radix-ui/react-dialog": "^1.1.13",
|
59
59
|
"@telegraph/combobox": "^0.0.81",
|
60
60
|
"@telegraph/icon": "^0.0.50",
|
61
61
|
"@telegraph/layout": "^0.1.16",
|
@@ -66,12 +66,12 @@
|
|
66
66
|
},
|
67
67
|
"devDependencies": {
|
68
68
|
"@testing-library/dom": "^10.4.0",
|
69
|
-
"@testing-library/react": "^16.
|
69
|
+
"@testing-library/react": "^16.3.0",
|
70
70
|
"@types/eslint-plugin-jsx-a11y": "^6",
|
71
71
|
"@types/lodash.debounce": "^4.0.9",
|
72
72
|
"@types/react": "^18.3.6",
|
73
73
|
"@types/react-dom": "^18.2.15",
|
74
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
74
|
+
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
75
75
|
"@typescript-eslint/parser": "^8.27.0",
|
76
76
|
"@vitejs/plugin-react": "^4.4.1",
|
77
77
|
"babel-plugin-react-require": "^4.0.3",
|