@knocklabs/react-core 0.1.5 → 0.2.0

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/modules/core/utils.js +1 -1
  4. package/dist/cjs/modules/core/utils.js.map +1 -1
  5. package/dist/cjs/modules/i18n/languages/de.js +1 -1
  6. package/dist/cjs/modules/i18n/languages/de.js.map +1 -1
  7. package/dist/cjs/modules/i18n/languages/en.js +1 -1
  8. package/dist/cjs/modules/i18n/languages/en.js.map +1 -1
  9. package/dist/cjs/modules/i18n/languages/index.js +1 -1
  10. package/dist/cjs/modules/i18n/languages/index.js.map +1 -1
  11. package/dist/cjs/modules/slack/context/KnockSlackProvider.js +2 -0
  12. package/dist/cjs/modules/slack/context/KnockSlackProvider.js.map +1 -0
  13. package/dist/cjs/modules/slack/hooks/useConnectedSlackChannels.js +2 -0
  14. package/dist/cjs/modules/slack/hooks/useConnectedSlackChannels.js.map +1 -0
  15. package/dist/cjs/modules/slack/hooks/useSlackAuth.js +2 -0
  16. package/dist/cjs/modules/slack/hooks/useSlackAuth.js.map +1 -0
  17. package/dist/cjs/modules/slack/hooks/useSlackChannels.js +2 -0
  18. package/dist/cjs/modules/slack/hooks/useSlackChannels.js.map +1 -0
  19. package/dist/cjs/modules/slack/hooks/useSlackConnectionStatus.js +2 -0
  20. package/dist/cjs/modules/slack/hooks/useSlackConnectionStatus.js.map +1 -0
  21. package/dist/esm/index.mjs +42 -0
  22. package/dist/esm/index.mjs.map +1 -0
  23. package/dist/esm/modules/core/{constants.js → constants.mjs} +1 -1
  24. package/dist/esm/modules/core/constants.mjs.map +1 -0
  25. package/dist/esm/modules/core/context/{KnockProvider.js → KnockProvider.mjs} +3 -3
  26. package/dist/esm/modules/core/context/KnockProvider.mjs.map +1 -0
  27. package/dist/esm/modules/core/hooks/{useAuthenticatedKnockClient.js → useAuthenticatedKnockClient.mjs} +1 -1
  28. package/dist/esm/modules/core/hooks/useAuthenticatedKnockClient.mjs.map +1 -0
  29. package/dist/esm/modules/core/utils.mjs +46 -0
  30. package/dist/esm/modules/core/utils.mjs.map +1 -0
  31. package/dist/esm/modules/feed/context/{KnockFeedProvider.js → KnockFeedProvider.mjs} +4 -4
  32. package/dist/esm/modules/feed/context/KnockFeedProvider.mjs.map +1 -0
  33. package/dist/esm/modules/feed/hooks/{useFeedSettings.js → useFeedSettings.mjs} +1 -1
  34. package/dist/esm/modules/feed/hooks/useFeedSettings.mjs.map +1 -0
  35. package/dist/esm/modules/feed/hooks/{useNotifications.js → useNotifications.mjs} +1 -1
  36. package/dist/esm/modules/feed/hooks/useNotifications.mjs.map +1 -0
  37. package/dist/esm/modules/i18n/context/{KnockI18nProvider.js → KnockI18nProvider.mjs} +2 -2
  38. package/dist/esm/modules/i18n/context/KnockI18nProvider.mjs.map +1 -0
  39. package/dist/esm/modules/i18n/hooks/{useTranslations.js → useTranslations.mjs} +3 -3
  40. package/dist/esm/modules/i18n/hooks/useTranslations.mjs.map +1 -0
  41. package/dist/esm/modules/i18n/languages/de.mjs +39 -0
  42. package/dist/esm/modules/i18n/languages/de.mjs.map +1 -0
  43. package/dist/esm/modules/i18n/languages/en.mjs +39 -0
  44. package/dist/esm/modules/i18n/languages/en.mjs.map +1 -0
  45. package/dist/esm/modules/i18n/languages/index.mjs +7 -0
  46. package/dist/esm/modules/i18n/languages/index.mjs.map +1 -0
  47. package/dist/esm/modules/slack/context/KnockSlackProvider.mjs +58 -0
  48. package/dist/esm/modules/slack/context/KnockSlackProvider.mjs.map +1 -0
  49. package/dist/esm/modules/slack/hooks/useConnectedSlackChannels.mjs +56 -0
  50. package/dist/esm/modules/slack/hooks/useConnectedSlackChannels.mjs.map +1 -0
  51. package/dist/esm/modules/slack/hooks/useSlackAuth.mjs +64 -0
  52. package/dist/esm/modules/slack/hooks/useSlackAuth.mjs.map +1 -0
  53. package/dist/esm/modules/slack/hooks/useSlackChannels.mjs +53 -0
  54. package/dist/esm/modules/slack/hooks/useSlackChannels.mjs.map +1 -0
  55. package/dist/esm/modules/slack/hooks/useSlackConnectionStatus.mjs +45 -0
  56. package/dist/esm/modules/slack/hooks/useSlackConnectionStatus.mjs.map +1 -0
  57. package/dist/types/index.d.ts +1 -0
  58. package/dist/types/index.d.ts.map +1 -1
  59. package/dist/types/modules/core/utils.d.ts +6 -0
  60. package/dist/types/modules/core/utils.d.ts.map +1 -1
  61. package/dist/types/modules/i18n/languages/de.d.ts.map +1 -1
  62. package/dist/types/modules/i18n/languages/en.d.ts.map +1 -1
  63. package/dist/types/modules/i18n/languages/index.d.ts +21 -0
  64. package/dist/types/modules/i18n/languages/index.d.ts.map +1 -1
  65. package/dist/types/modules/slack/constants.d.ts +12 -0
  66. package/dist/types/modules/slack/constants.d.ts.map +1 -0
  67. package/dist/types/modules/slack/context/KnockSlackProvider.d.ts +20 -0
  68. package/dist/types/modules/slack/context/KnockSlackProvider.d.ts.map +1 -0
  69. package/dist/types/modules/slack/context/index.d.ts +2 -0
  70. package/dist/types/modules/slack/context/index.d.ts.map +1 -0
  71. package/dist/types/modules/slack/hooks/index.d.ts +5 -0
  72. package/dist/types/modules/slack/hooks/index.d.ts.map +1 -0
  73. package/dist/types/modules/slack/hooks/useConnectedSlackChannels.d.ts +15 -0
  74. package/dist/types/modules/slack/hooks/useConnectedSlackChannels.d.ts.map +1 -0
  75. package/dist/types/modules/slack/hooks/useSlackAuth.d.ts +7 -0
  76. package/dist/types/modules/slack/hooks/useSlackAuth.d.ts.map +1 -0
  77. package/dist/types/modules/slack/hooks/useSlackChannels.d.ts +13 -0
  78. package/dist/types/modules/slack/hooks/useSlackChannels.d.ts.map +1 -0
  79. package/dist/types/modules/slack/hooks/useSlackConnectionStatus.d.ts +13 -0
  80. package/dist/types/modules/slack/hooks/useSlackConnectionStatus.d.ts.map +1 -0
  81. package/dist/types/modules/slack/index.d.ts +4 -0
  82. package/dist/types/modules/slack/index.d.ts.map +1 -0
  83. package/package.json +8 -6
  84. package/dist/esm/index.js +0 -30
  85. package/dist/esm/index.js.map +0 -1
  86. package/dist/esm/modules/core/constants.js.map +0 -1
  87. package/dist/esm/modules/core/context/KnockProvider.js.map +0 -1
  88. package/dist/esm/modules/core/hooks/useAuthenticatedKnockClient.js.map +0 -1
  89. package/dist/esm/modules/core/utils.js +0 -37
  90. package/dist/esm/modules/core/utils.js.map +0 -1
  91. package/dist/esm/modules/feed/context/KnockFeedProvider.js.map +0 -1
  92. package/dist/esm/modules/feed/hooks/useFeedSettings.js.map +0 -1
  93. package/dist/esm/modules/feed/hooks/useNotifications.js.map +0 -1
  94. package/dist/esm/modules/i18n/context/KnockI18nProvider.js.map +0 -1
  95. package/dist/esm/modules/i18n/hooks/useTranslations.js.map +0 -1
  96. package/dist/esm/modules/i18n/languages/de.js +0 -18
  97. package/dist/esm/modules/i18n/languages/de.js.map +0 -1
  98. package/dist/esm/modules/i18n/languages/en.js +0 -18
  99. package/dist/esm/modules/i18n/languages/en.js.map +0 -1
  100. package/dist/esm/modules/i18n/languages/index.js +0 -7
  101. package/dist/esm/modules/i18n/languages/index.js.map +0 -1
package/dist/esm/index.js DELETED
@@ -1,30 +0,0 @@
1
- import { KnockProvider as r, useKnockClient as t } from "./modules/core/context/KnockProvider.js";
2
- import { default as a } from "./modules/core/hooks/useAuthenticatedKnockClient.js";
3
- import { FilterStatus as s } from "./modules/core/constants.js";
4
- import { feedProviderKey as i, formatBadgeCount as m, formatTimestamp as u, renderNodeOrFallback as c, toSentenceCase as l } from "./modules/core/utils.js";
5
- import { KnockFeedProvider as x, useKnockFeed as k } from "./modules/feed/context/KnockFeedProvider.js";
6
- import { default as C } from "./modules/feed/hooks/useNotifications.js";
7
- import { default as v } from "./modules/feed/hooks/useFeedSettings.js";
8
- import { I18nContext as S, KnockI18nProvider as g } from "./modules/i18n/context/KnockI18nProvider.js";
9
- import { useTranslations as N } from "./modules/i18n/hooks/useTranslations.js";
10
- import { locales as b } from "./modules/i18n/languages/index.js";
11
- export {
12
- s as FilterStatus,
13
- S as I18nContext,
14
- x as KnockFeedProvider,
15
- g as KnockI18nProvider,
16
- r as KnockProvider,
17
- i as feedProviderKey,
18
- m as formatBadgeCount,
19
- u as formatTimestamp,
20
- b as locales,
21
- c as renderNodeOrFallback,
22
- l as toSentenceCase,
23
- a as useAuthenticatedKnockClient,
24
- v as useFeedSettings,
25
- t as useKnockClient,
26
- k as useKnockFeed,
27
- C as useNotifications,
28
- N as useTranslations
29
- };
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../src/modules/core/constants.ts"],"sourcesContent":["export enum FilterStatus {\n All = \"all\",\n Read = \"read\",\n Unseen = \"unseen\",\n Unread = \"unread\",\n}\n\nexport type ColorMode = \"light\" | \"dark\";\n"],"names":["FilterStatus"],"mappings":"AAAY,IAAAA,sBAAAA,OACVA,EAAA,MAAM,OACNA,EAAA,OAAO,QACPA,EAAA,SAAS,UACTA,EAAA,SAAS,UAJCA,IAAAA,KAAA,CAAA,CAAA;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst ProviderStateContext = React.createContext<KnockProviderState | null>(\n null,\n);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: string;\n userToken?: string;\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n\n // Extra options\n children?: React.ReactElement;\n\n // i18n translations\n i18n?: I18nContent;\n\n logLevel?: LogLevel;\n}\n\nexport const KnockProvider: React.FC<KnockProviderProps> = ({\n apiKey,\n host,\n logLevel,\n userId,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n}) => {\n // We memoize the options here so that we don't create a new object on every re-render\n // TODO: we probably need to put this optimization into the `useAuthenticatedKnockClient`\n // hook itself to fix this\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey,\n userId,\n userToken,\n authenticateOptions,\n );\n\n return (\n <ProviderStateContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </ProviderStateContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(ProviderStateContext) as KnockProviderState;\n if (context === undefined) {\n throw new Error(\"useKnock must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["ProviderStateContext","React","KnockProvider","apiKey","host","logLevel","userId","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","authenticateOptions","knock","useAuthenticatedKnockClient","jsx","KnockI18nProvider","useKnockClient","context"],"mappings":";;;;AAUA,MAAMA,IAAuBC,EAAM;AAAA,EACjC;AACF,GAqBaC,IAA8C,CAAC;AAAA,EAC1D,QAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,0BAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC;AACF,MAAM;AAIJ,QAAMC,IAAsBX,EAAM;AAAA,IAChC,OAAO;AAAA,MACL,MAAAG;AAAA,MACA,qBAAAI;AAAA,MACA,0BAAAC;AAAA,MACA,UAAAJ;AAAA,IAAA;AAAA,IAEF,CAACD,GAAMI,GAAqBC,GAA0BJ,CAAQ;AAAA,EAAA,GAG1DQ,IAAQC;AAAA,IACZX;AAAA,IACAG;AAAA,IACAC;AAAA,IACAK;AAAA,EAAA;AAIA,SAAA,gBAAAG;AAAA,IAACf,EAAqB;AAAA,IAArB;AAAA,MACC,OAAO;AAAA,QACL,OAAAa;AAAA,MACF;AAAA,MAEA,UAAA,gBAAAE,EAACC,GAAkB,EAAA,MAAAL,GAAa,UAAAD,EAAS,CAAA;AAAA,IAAA;AAAA,EAAA;AAG/C,GAEaO,IAAiB,MAAa;AACnC,QAAAC,IAAUjB,EAAM,WAAWD,CAAoB;AACrD,MAAIkB,MAAY;AACR,UAAA,IAAI,MAAM,8CAA8C;AAEhE,SAAOA,EAAQ;AACjB;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAuthenticatedKnockClient.js","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, { AuthenticateOptions, KnockOptions } from \"@knocklabs/client\";\nimport React, { useMemo } from \"react\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userId: string,\n userToken?: string,\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userId, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n });\n}\n\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userId: string,\n userToken?: string,\n options: KnockOptions & AuthenticateOptions = {},\n) {\n const knockRef = React.useRef<Knock | null>();\n\n return useMemo(() => {\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(currentKnock, userId, userToken, options);\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, options);\n authenticateWithOptions(knock, userId, userToken, options);\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, userId, userToken, options]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userId","userToken","options","useAuthenticatedKnockClient","apiKey","knockRef","React","useMemo","currentKnock","Knock"],"mappings":";;AAGA,SAASA,EACPC,GACAC,GACAC,GACAC,IAA+B,CAAA,GAC/B;AACM,EAAAH,EAAA,aAAaC,GAAQC,GAAW;AAAA,IACpC,qBAAqBC,KAAA,gBAAAA,EAAS;AAAA,IAC9B,0BAA0BA,KAAA,gBAAAA,EAAS;AAAA,EAAA,CACpC;AACH;AAEA,SAASC,EACPC,GACAJ,GACAC,GACAC,IAA8C,CAAA,GAC9C;AACM,QAAAG,IAAWC,EAAM;AAEvB,SAAOC,EAAQ,MAAM;AACnB,UAAMC,IAAeH,EAAS;AAI5B,QAAAG,KACAA,EAAa,gBAAgB,MAC5BA,EAAa,WAAWR,KAAUQ,EAAa,cAAcP;AAEtC,aAAAH,EAAAU,GAAcR,GAAQC,GAAWC,CAAO,GACzDM;AAGT,IAAIA,KACFA,EAAa,SAAS;AAIxB,UAAMT,IAAQ,IAAIU,EAAML,GAAQF,CAAO;AACf,WAAAJ,EAAAC,GAAOC,GAAQC,GAAWC,CAAO,GACzDG,EAAS,UAAUN,GAEZA;AAAA,KACN,CAACK,GAAQJ,GAAQC,GAAWC,CAAO,CAAC;AACzC;"}
@@ -1,37 +0,0 @@
1
- import { parseISO as n, intlFormatDistance as a } from "date-fns";
2
- function u(e) {
3
- return e > 9 ? "9+" : e;
4
- }
5
- function i(e, r = {}) {
6
- try {
7
- const t = n(e);
8
- return a(t, /* @__PURE__ */ new Date(), {
9
- locale: r.locale
10
- });
11
- } catch {
12
- return e;
13
- }
14
- }
15
- function f(e) {
16
- return e.charAt(0).toUpperCase() + e.slice(1);
17
- }
18
- function l(e, r) {
19
- return e !== void 0 ? e : r;
20
- }
21
- function d(e, r = {}) {
22
- return [
23
- e,
24
- r.source,
25
- r.tenant,
26
- r.has_tenant,
27
- r.archived
28
- ].filter((t) => t != null).join("-");
29
- }
30
- export {
31
- d as feedProviderKey,
32
- u as formatBadgeCount,
33
- i as formatTimestamp,
34
- l as renderNodeOrFallback,
35
- f as toSentenceCase
36
- };
37
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import { FeedClientOptions } from \"@knocklabs/client\";\nimport { parseISO, intlFormatDistance } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\ntype FormatTimestampOptions = {\n locale?: string | string[];\n};\n\nexport function formatTimestamp(\n ts: string,\n options: FormatTimestampOptions = {},\n) {\n try {\n const parsedTs = parseISO(ts);\n const formatted = intlFormatDistance(parsedTs, new Date(), {\n locale: options.locale,\n });\n\n return formatted;\n } catch (e) {\n return ts;\n }\n}\n\nexport function toSentenceCase(string: string): string {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\nexport function renderNodeOrFallback(node: ReactNode, fallback: ReactNode) {\n return node !== undefined ? node : fallback;\n}\n\n/*\n Used to build a consistent key for the KnockFeedProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function feedProviderKey(\n userFeedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userFeedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","intlFormatDistance","toSentenceCase","string","renderNodeOrFallback","node","fallback","feedProviderKey","userFeedId","f"],"mappings":";AAIO,SAASA,EAAiBC,GAAgC;AACxD,SAAAA,IAAQ,IAAI,OAAOA;AAC5B;AAMO,SAASC,EACdC,GACAC,IAAkC,IAClC;AACI,MAAA;AACI,UAAAC,IAAWC,EAASH,CAAE;AAKrB,WAJWI,EAAmBF,GAAU,oBAAI,QAAQ;AAAA,MACzD,QAAQD,EAAQ;AAAA,IAAA,CACjB;AAAA,UAGS;AACH,WAAAD;AAAA,EACT;AACF;AAEO,SAASK,EAAeC,GAAwB;AAC9C,SAAAA,EAAO,OAAO,CAAC,EAAE,gBAAgBA,EAAO,MAAM,CAAC;AACxD;AAEgB,SAAAC,EAAqBC,GAAiBC,GAAqB;AAClE,SAAAD,MAAS,SAAYA,IAAOC;AACrC;AAMO,SAASC,EACdC,GACAV,IAA6B,IAC7B;AACO,SAAA;AAAA,IACLU;AAAA,IACAV,EAAQ;AAAA,IACRA,EAAQ;AAAA,IACRA,EAAQ;AAAA,IACRA,EAAQ;AAAA,EACV,EACG,OAAO,CAACW,MAAMA,KAAM,IAAuB,EAC3C,KAAK,GAAG;AACb;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"KnockFeedProvider.js","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import Knock, {\n Feed,\n FeedClientOptions,\n FeedStoreState,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport create, { UseBoundStore } from \"zustand\";\n\nimport { useKnockClient } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\nimport { feedProviderKey } from \"../../core/utils\";\nimport useNotifications from \"../hooks/useNotifications\";\n\nexport interface KnockFeedProviderState {\n knock: Knock;\n feedClient: Feed;\n useFeedStore: UseBoundStore<FeedStoreState>;\n colorMode: ColorMode;\n}\n\nconst FeedStateContext = React.createContext<KnockFeedProviderState | null>(\n null,\n);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string;\n\n // Extra options\n children?: React.ReactElement;\n colorMode?: ColorMode;\n\n // Feed client options\n defaultFeedOptions?: FeedClientOptions;\n}\n\nexport const KnockFeedProvider: React.FC<KnockFeedProviderProps> = ({\n feedId,\n children,\n defaultFeedOptions = {},\n colorMode = \"light\",\n}) => {\n const knock = useKnockClient();\n const feedClient = useNotifications(knock, feedId, defaultFeedOptions);\n const useFeedStore = create<FeedStoreState>(feedClient.store);\n\n return (\n <FeedStateContext.Provider\n key={feedProviderKey(feedId, defaultFeedOptions)}\n value={{\n knock,\n feedClient,\n useFeedStore,\n colorMode,\n }}\n >\n {children}\n </FeedStateContext.Provider>\n );\n};\n\nexport const useKnockFeed = (): KnockFeedProviderState => {\n const context = React.useContext(FeedStateContext);\n if (context === undefined) {\n throw new Error(\"useKnockFeed must be used within a KnockFeedProvider\");\n }\n return context as KnockFeedProviderState;\n};\n"],"names":["FeedStateContext","React","KnockFeedProvider","feedId","children","defaultFeedOptions","colorMode","knock","useKnockClient","feedClient","useNotifications","useFeedStore","create","jsx","feedProviderKey","useKnockFeed","context"],"mappings":";;;;;;;AAoBA,MAAMA,IAAmBC,EAAM;AAAA,EAC7B;AACF,GAcaC,IAAsD,CAAC;AAAA,EAClE,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,oBAAAC,IAAqB,CAAC;AAAA,EACtB,WAAAC,IAAY;AACd,MAAM;AACJ,QAAMC,IAAQC,KACRC,IAAaC,EAAiBH,GAAOJ,GAAQE,CAAkB,GAC/DM,IAAeC,EAAuBH,EAAW,KAAK;AAG1D,SAAA,gBAAAI;AAAA,IAACb,EAAiB;AAAA,IAAjB;AAAA,MAEC,OAAO;AAAA,QACL,OAAAO;AAAA,QACA,YAAAE;AAAA,QACA,cAAAE;AAAA,QACA,WAAAL;AAAA,MACF;AAAA,MAEC,UAAAF;AAAA,IAAA;AAAA,IARIU,EAAgBX,GAAQE,CAAkB;AAAA,EAAA;AAWrD,GAEaU,IAAe,MAA8B;AAClD,QAAAC,IAAUf,EAAM,WAAWD,CAAgB;AACjD,MAAIgB,MAAY;AACR,UAAA,IAAI,MAAM,sDAAsD;AAEjE,SAAAA;AACT;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFeedSettings.js","sources":["../../../../../src/modules/feed/hooks/useFeedSettings.ts"],"sourcesContent":["import { Feed } from \"@knocklabs/client\";\nimport { useEffect, useState } from \"react\";\n\nexport type FeedSettings = {\n features: {\n branding_required: boolean;\n };\n};\n\nfunction useFeedSettings(feedClient: Feed): {\n settings: FeedSettings | null;\n loading: boolean;\n} {\n const [settings, setSettings] = useState(null);\n const [isLoading, setIsLoading] = useState(false);\n\n // TODO: consider moving this into the feed client and into the feed store state when\n // we're using this in other areas of the feed\n useEffect(() => {\n async function getSettings() {\n const knock = feedClient.knock;\n const apiClient = knock.client();\n const feedSettingsPath = `/v1/users/${knock.userId}/feeds/${feedClient.feedId}/settings`;\n setIsLoading(true);\n\n const response = await apiClient.makeRequest({\n method: \"GET\",\n url: feedSettingsPath,\n });\n\n if (!response.error) {\n setSettings(response.body);\n }\n\n setIsLoading(false);\n }\n\n getSettings();\n }, []);\n\n return { settings, loading: isLoading };\n}\n\nexport default useFeedSettings;\n"],"names":["useFeedSettings","feedClient","settings","setSettings","useState","isLoading","setIsLoading","useEffect","getSettings","knock","apiClient","feedSettingsPath","response"],"mappings":";AASA,SAASA,EAAgBC,GAGvB;AACA,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,IAAI,GACvC,CAACC,GAAWC,CAAY,IAAIF,EAAS,EAAK;AAIhD,SAAAG,EAAU,MAAM;AACd,mBAAeC,IAAc;AAC3B,YAAMC,IAAQR,EAAW,OACnBS,IAAYD,EAAM,UAClBE,IAAmB,aAAaF,EAAM,MAAM,UAAUR,EAAW,MAAM;AAC7E,MAAAK,EAAa,EAAI;AAEX,YAAAM,IAAW,MAAMF,EAAU,YAAY;AAAA,QAC3C,QAAQ;AAAA,QACR,KAAKC;AAAA,MAAA,CACN;AAEG,MAACC,EAAS,SACZT,EAAYS,EAAS,IAAI,GAG3BN,EAAa,EAAK;AAAA,IACpB;AAEY,IAAAE;EACd,GAAG,CAAE,CAAA,GAEE,EAAE,UAAAN,GAAU,SAASG;AAC9B;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) {\n feedClientRef.current.dispose();\n }\n\n const feedClient = knock.feeds.initialize(feedChannelId, options);\n\n feedClient.listenForUpdates();\n feedClientRef.current = feedClient;\n\n return feedClient;\n }, [\n knock,\n feedChannelId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","feedClientRef","useRef","useMemo","feedClient"],"mappings":";AAGA,SAASA,EACPC,GACAC,GACAC,IAA6B,CAAA,GAC7B;AACA,QAAMC,IAAgBC;AAEtB,SAAOC,EAAQ,MAAM;AACnB,IAAIF,EAAc,WAChBA,EAAc,QAAQ;AAGxB,UAAMG,IAAaN,EAAM,MAAM,WAAWC,GAAeC,CAAO;AAEhE,WAAAI,EAAW,iBAAiB,GAC5BH,EAAc,UAAUG,GAEjBA;AAAA,EAAA,GACN;AAAA,IACDN;AAAA,IACAC;AAAA,IACAC,EAAQ;AAAA,IACRA,EAAQ;AAAA,IACRA,EAAQ;AAAA,IACRA,EAAQ;AAAA,EAAA,CACT;AACH;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"KnockI18nProvider.js","sources":["../../../../../src/modules/i18n/context/KnockI18nProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { locales, I18nContent } from \"../languages\";\n\nexport const I18nContext = React.createContext<I18nContent>(locales.en);\n\ninterface KnockI18nProviderProps {\n i18n?: I18nContent;\n children: JSX.Element | undefined;\n}\n\nexport function KnockI18nProvider({\n i18n = locales.en,\n ...props\n}: KnockI18nProviderProps) {\n return <I18nContext.Provider {...props} value={i18n} />;\n}\n"],"names":["I18nContext","React","locales","KnockI18nProvider","i18n","props"],"mappings":";;;AAGO,MAAMA,IAAcC,EAAM,cAA2BC,EAAQ,EAAE;AAO/D,SAASC,EAAkB;AAAA,EAChC,MAAAC,IAAOF,EAAQ;AAAA,EACf,GAAGG;AACL,GAA2B;AACzB,2BAAQL,EAAY,UAAZ,EAAsB,GAAGK,GAAO,OAAOD,EAAM,CAAA;AACvD;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTranslations.js","sources":["../../../../../src/modules/i18n/hooks/useTranslations.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { I18nContent, locales } from \"../languages\";\nimport { I18nContext } from \"../context/KnockI18nProvider\";\n\nexport function useTranslations() {\n const { translations, locale } = useContext<I18nContent>(I18nContext);\n\n return {\n locale,\n t: (key: keyof typeof translations) => {\n // We always use english as the default translation when a key doesn't exist\n return translations[key] || locales.en.translations[key];\n },\n };\n}\n"],"names":["useTranslations","translations","locale","useContext","I18nContext","key","locales"],"mappings":";;;AAIO,SAASA,IAAkB;AAChC,QAAM,EAAE,cAAAC,GAAc,QAAAC,EAAO,IAAIC,EAAwBC,CAAW;AAE7D,SAAA;AAAA,IACL,QAAAF;AAAA,IACA,GAAG,CAACG,MAEKJ,EAAaI,CAAG,KAAKC,EAAQ,GAAG,aAAaD,CAAG;AAAA,EACzD;AAEJ;"}
@@ -1,18 +0,0 @@
1
- const e = {
2
- translations: {
3
- archiveNotification: "Benachrichtigung archivieren",
4
- markAllAsRead: "Alle als gelesen markieren",
5
- notifications: "Benachrichtigungen",
6
- emptyFeedTitle: "Noch keine Benachrichtigungen",
7
- emptyFeedBody: "Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.",
8
- all: "Alle",
9
- unread: "Ungelesen",
10
- read: "Gelesen",
11
- unseen: "Ungesehen"
12
- },
13
- locale: "de"
14
- };
15
- export {
16
- e as default
17
- };
18
- //# sourceMappingURL=de.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"de.js","sources":["../../../../../src/modules/i18n/languages/de.ts"],"sourcesContent":["import { I18nContent } from \".\";\n\nconst de: I18nContent = {\n translations: {\n archiveNotification: \"Benachrichtigung archivieren\",\n markAllAsRead: \"Alle als gelesen markieren\",\n notifications: \"Benachrichtigungen\",\n emptyFeedTitle: \"Noch keine Benachrichtigungen\",\n emptyFeedBody:\n \"Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.\",\n all: \"Alle\",\n unread: \"Ungelesen\",\n read: \"Gelesen\",\n unseen: \"Ungesehen\",\n },\n locale: \"de\",\n};\n\nexport default de;\n"],"names":["de"],"mappings":"AAEA,MAAMA,IAAkB;AAAA,EACtB,cAAc;AAAA,IACZ,qBAAqB;AAAA,IACrB,eAAe;AAAA,IACf,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,eACE;AAAA,IACF,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AACV;"}
@@ -1,18 +0,0 @@
1
- const e = {
2
- translations: {
3
- archiveNotification: "Archive this notification",
4
- markAllAsRead: "Mark all as read",
5
- notifications: "Notifications",
6
- emptyFeedTitle: "No notifications yet",
7
- emptyFeedBody: "We'll let you know when we've got something new for you.",
8
- all: "All",
9
- unread: "Unread",
10
- read: "Read",
11
- unseen: "Unseen"
12
- },
13
- locale: "en"
14
- };
15
- export {
16
- e as default
17
- };
18
- //# sourceMappingURL=en.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"en.js","sources":["../../../../../src/modules/i18n/languages/en.ts"],"sourcesContent":["import { I18nContent } from \".\";\n\nconst en: I18nContent = {\n translations: {\n archiveNotification: \"Archive this notification\",\n markAllAsRead: \"Mark all as read\",\n notifications: \"Notifications\",\n emptyFeedTitle: \"No notifications yet\",\n emptyFeedBody: \"We'll let you know when we've got something new for you.\",\n all: \"All\",\n unread: \"Unread\",\n read: \"Read\",\n unseen: \"Unseen\",\n },\n locale: \"en\",\n};\n\nexport default en;\n"],"names":["en"],"mappings":"AAEA,MAAMA,IAAkB;AAAA,EACtB,cAAc;AAAA,IACZ,qBAAqB;AAAA,IACrB,eAAe;AAAA,IACf,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AACV;"}
@@ -1,7 +0,0 @@
1
- import o from "./en.js";
2
- import r from "./de.js";
3
- const t = { en: o, de: r };
4
- export {
5
- t as locales
6
- };
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/modules/i18n/languages/index.ts"],"sourcesContent":["import en from \"./en\";\nimport de from \"./de\";\n\nexport interface Translations {\n readonly emptyFeedTitle: string;\n readonly emptyFeedBody: string;\n readonly notifications: string;\n readonly poweredBy: string;\n readonly markAllAsRead: string;\n readonly archiveNotification: string;\n readonly all: string;\n readonly unread: string;\n readonly read: string;\n readonly unseen: string;\n}\n\nexport interface I18nContent {\n readonly translations: Partial<Translations>;\n readonly locale: string;\n}\n\nexport const locales = { en, de };\n"],"names":["locales","en","de"],"mappings":";;AAqBa,MAAAA,IAAU,EAAE,IAAAC,GAAI,IAAAC,EAAG;"}