@knocklabs/react-core 0.13.0 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7f8bdfe: Add accessible labels to `UnseenBadge` so screen readers announce the count with context (e.g. "3 unseen notifications") instead of just the bare number
8
+ - Updated dependencies [ddd7981]
9
+ - @knocklabs/client@0.21.1
10
+
3
11
  ## 0.13.0
4
12
 
5
13
  ### Minor Changes
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./modules/core/context/KnockProvider.js"),c=require("./modules/core/hooks/useAuthenticatedKnockClient.js"),a=require("./modules/core/hooks/useStableOptions.js"),d=require("./modules/core/hooks/useAuthPostMessageListener.js"),l=require("./modules/core/hooks/useAuthPolling.js"),k=require("./modules/core/constants.js"),e=require("./modules/core/utils.js"),n=require("./modules/feed/context/KnockFeedProvider.js"),C=require("./modules/feed/hooks/useNotifications.js"),K=require("./modules/feed/hooks/useFeedSettings.js"),t=require("./modules/feed/hooks/useNotificationStore.js"),o=require("./modules/guide/context/KnockGuideProvider.js"),P=require("./modules/guide/hooks/useGuide.js"),S=require("./modules/guide/hooks/useGuides.js"),m=require("./modules/guide/hooks/useGuideContext.js"),r=require("./modules/ms-teams/context/KnockMsTeamsProvider.js"),q=require("./modules/ms-teams/hooks/useMsTeamsConnectionStatus.js"),v=require("./modules/ms-teams/hooks/useMsTeamsAuth.js"),T=require("./modules/ms-teams/hooks/useMsTeamsTeams.js"),h=require("./modules/ms-teams/hooks/useMsTeamsChannels.js"),M=require("./modules/ms-teams/hooks/useConnectedMsTeamsChannels.js"),u=require("./modules/slack/context/KnockSlackProvider.js"),f=require("./modules/slack/hooks/useSlackConnectionStatus.js"),G=require("./modules/slack/hooks/useSlackChannels.js"),g=require("./modules/slack/hooks/useConnectedSlackChannels.js"),A=require("./modules/slack/hooks/useSlackAuth.js"),i=require("./modules/i18n/context/KnockI18nProvider.js"),F=require("./modules/i18n/hooks/useTranslations.js"),y=require("./modules/i18n/languages/index.js"),b=require("./modules/preferences/hooks/usePreferences.js"),x=require("@tanstack/react-store");exports.KnockProvider=s.KnockProvider;exports.useKnockClient=s.useKnockClient;exports.useAuthenticatedKnockClient=c;exports.useStableOptions=a;exports.useAuthPostMessageListener=d.useAuthPostMessageListener;exports.useAuthPolling=l.useAuthPolling;exports.FilterStatus=k.FilterStatus;exports.feedProviderKey=e.feedProviderKey;exports.formatBadgeCount=e.formatBadgeCount;exports.formatTimestamp=e.formatTimestamp;exports.msTeamsProviderKey=e.msTeamsProviderKey;exports.renderNodeOrFallback=e.renderNodeOrFallback;exports.slackProviderKey=e.slackProviderKey;exports.toSentenceCase=e.toSentenceCase;exports.KnockFeedProvider=n.KnockFeedProvider;exports.useKnockFeed=n.useKnockFeed;exports.useNotifications=C;exports.useFeedSettings=K;exports.useCreateNotificationStore=t.useCreateNotificationStore;exports.useNotificationStore=t.default;exports.KnockGuideContext=o.KnockGuideContext;exports.KnockGuideProvider=o.KnockGuideProvider;exports.useGuide=P.useGuide;exports.useGuides=S.useGuides;exports.useGuideContext=m.useGuideContext;exports.KnockMsTeamsProvider=r.KnockMsTeamsProvider;exports.useKnockMsTeamsClient=r.useKnockMsTeamsClient;exports.useMsTeamsConnectionStatus=q;exports.useMsTeamsAuth=v;exports.useMsTeamsTeams=T;exports.useMsTeamsChannels=h;exports.useConnectedMsTeamsChannels=M;exports.KnockSlackProvider=u.KnockSlackProvider;exports.useKnockSlackClient=u.useKnockSlackClient;exports.useSlackConnectionStatus=f;exports.useSlackChannels=G;exports.useConnectedSlackChannels=g;exports.useSlackAuth=A;exports.I18nContext=i.I18nContext;exports.KnockI18nProvider=i.KnockI18nProvider;exports.useTranslations=F.useTranslations;exports.locales=y.locales;exports.usePreferences=b.usePreferences;Object.defineProperty(exports,"useStore",{enumerable:!0,get:()=>x.useStore});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./modules/core/context/KnockProvider.js"),c=require("./modules/core/hooks/useAuthenticatedKnockClient.js"),a=require("./modules/core/hooks/useStableOptions.js"),d=require("./modules/core/hooks/useAuthPostMessageListener.js"),l=require("./modules/core/hooks/useAuthPolling.js"),k=require("./modules/core/constants.js"),e=require("./modules/core/utils.js"),n=require("./modules/feed/context/KnockFeedProvider.js"),C=require("./modules/feed/hooks/useNotifications.js"),K=require("./modules/feed/hooks/useFeedSettings.js"),t=require("./modules/feed/hooks/useNotificationStore.js"),r=require("./modules/guide/context/KnockGuideProvider.js"),P=require("./modules/guide/hooks/useGuide.js"),S=require("./modules/guide/hooks/useGuides.js"),m=require("./modules/guide/hooks/useGuideContext.js"),o=require("./modules/ms-teams/context/KnockMsTeamsProvider.js"),q=require("./modules/ms-teams/hooks/useMsTeamsConnectionStatus.js"),v=require("./modules/ms-teams/hooks/useMsTeamsAuth.js"),T=require("./modules/ms-teams/hooks/useMsTeamsTeams.js"),h=require("./modules/ms-teams/hooks/useMsTeamsChannels.js"),M=require("./modules/ms-teams/hooks/useConnectedMsTeamsChannels.js"),u=require("./modules/slack/context/KnockSlackProvider.js"),f=require("./modules/slack/hooks/useSlackConnectionStatus.js"),g=require("./modules/slack/hooks/useSlackChannels.js"),A=require("./modules/slack/hooks/useConnectedSlackChannels.js"),G=require("./modules/slack/hooks/useSlackAuth.js"),i=require("./modules/i18n/context/KnockI18nProvider.js"),F=require("./modules/i18n/hooks/useTranslations.js"),b=require("./modules/i18n/languages/index.js"),y=require("./modules/preferences/hooks/usePreferences.js"),x=require("@tanstack/react-store");exports.KnockProvider=s.KnockProvider;exports.useKnockClient=s.useKnockClient;exports.useAuthenticatedKnockClient=c;exports.useStableOptions=a;exports.useAuthPostMessageListener=d.useAuthPostMessageListener;exports.useAuthPolling=l.useAuthPolling;exports.FilterStatus=k.FilterStatus;exports.feedProviderKey=e.feedProviderKey;exports.formatBadgeCount=e.formatBadgeCount;exports.formatTimestamp=e.formatTimestamp;exports.getBadgeAriaLabel=e.getBadgeAriaLabel;exports.msTeamsProviderKey=e.msTeamsProviderKey;exports.renderNodeOrFallback=e.renderNodeOrFallback;exports.slackProviderKey=e.slackProviderKey;exports.toSentenceCase=e.toSentenceCase;exports.KnockFeedProvider=n.KnockFeedProvider;exports.useKnockFeed=n.useKnockFeed;exports.useNotifications=C;exports.useFeedSettings=K;exports.useCreateNotificationStore=t.useCreateNotificationStore;exports.useNotificationStore=t.default;exports.KnockGuideContext=r.KnockGuideContext;exports.KnockGuideProvider=r.KnockGuideProvider;exports.useGuide=P.useGuide;exports.useGuides=S.useGuides;exports.useGuideContext=m.useGuideContext;exports.KnockMsTeamsProvider=o.KnockMsTeamsProvider;exports.useKnockMsTeamsClient=o.useKnockMsTeamsClient;exports.useMsTeamsConnectionStatus=q;exports.useMsTeamsAuth=v;exports.useMsTeamsTeams=T;exports.useMsTeamsChannels=h;exports.useConnectedMsTeamsChannels=M;exports.KnockSlackProvider=u.KnockSlackProvider;exports.useKnockSlackClient=u.useKnockSlackClient;exports.useSlackConnectionStatus=f;exports.useSlackChannels=g;exports.useConnectedSlackChannels=A;exports.useSlackAuth=G;exports.I18nContext=i.I18nContext;exports.KnockI18nProvider=i.KnockI18nProvider;exports.useTranslations=F.useTranslations;exports.locales=b.locales;exports.usePreferences=y.usePreferences;Object.defineProperty(exports,"useStore",{enumerable:!0,get:()=>x.useStore});
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("date-fns");function i(e){return e>9?"9+":e}function c(e,t={}){try{const r=o.parseISO(e);return o.intlFormatDistance(r,new Date,{locale:t.locale})}catch{return e}}function d(e){return e.charAt(0).toUpperCase()+e.slice(1)}function l(e,t){return e!==void 0?e:t}function u(e,t,r={}){return[e,t,r.source,r.tenant,r.has_tenant,r.archived].filter(n=>n!=null).join("-")}function s({knockSlackChannelId:e,tenantId:t,connectionStatus:r,errorLabel:n}){return[e,t,r,n].filter(a=>a!=null).join("-")}function f({knockMsTeamsChannelId:e,tenantId:t,connectionStatus:r,errorLabel:n}){return[e,t,r,n].filter(a=>a!=null).join("-")}exports.feedProviderKey=u;exports.formatBadgeCount=i;exports.formatTimestamp=c;exports.msTeamsProviderKey=f;exports.renderNodeOrFallback=l;exports.slackProviderKey=s;exports.toSentenceCase=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("date-fns");function i(e){return e>9?"9+":e}function c(e,t){const r=t==="all"?"":`${t} `;return`${e} ${r}${e===1?"notification":"notifications"}`}function l(e,t={}){try{const r=o.parseISO(e);return o.intlFormatDistance(r,new Date,{locale:t.locale})}catch{return e}}function u(e){return e.charAt(0).toUpperCase()+e.slice(1)}function d(e,t){return e!==void 0?e:t}function s(e,t,r={}){return[e,t,r.source,r.tenant,r.has_tenant,r.archived].filter(n=>n!=null).join("-")}function f({knockSlackChannelId:e,tenantId:t,connectionStatus:r,errorLabel:n}){return[e,t,r,n].filter(a=>a!=null).join("-")}function m({knockMsTeamsChannelId:e,tenantId:t,connectionStatus:r,errorLabel:n}){return[e,t,r,n].filter(a=>a!=null).join("-")}exports.feedProviderKey=s;exports.formatBadgeCount=i;exports.formatTimestamp=l;exports.getBadgeAriaLabel=c;exports.msTeamsProviderKey=m;exports.renderNodeOrFallback=d;exports.slackProviderKey=f;exports.toSentenceCase=u;
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import Knock, { FeedClientOptions } from \"@knocklabs/client\";\nimport { intlFormatDistance, parseISO } 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 userId: Knock[\"userId\"],\n feedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userId,\n feedId,\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\n/*\n Used to build a consistent key for the KnockSlackProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function slackProviderKey({\n knockSlackChannelId,\n tenantId,\n connectionStatus,\n errorLabel,\n}: {\n knockSlackChannelId: string;\n tenantId: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockSlackChannelId, tenantId, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n\n/*\n Used to build a consistent key for the KnockMsTeamsProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function msTeamsProviderKey({\n knockMsTeamsChannelId,\n tenantId,\n connectionStatus,\n errorLabel,\n}: {\n knockMsTeamsChannelId: string;\n tenantId: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockMsTeamsChannelId, tenantId, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","formatted","intlFormatDistance","Date","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userId","feedId","source","tenant","has_tenant","archived","filter","f","join","slackProviderKey","knockSlackChannelId","tenantId","connectionStatus","errorLabel","msTeamsProviderKey","knockMsTeamsChannelId"],"mappings":"4GAIO,SAASA,EAAiBC,EAAgC,CACxDA,OAAAA,EAAQ,EAAI,KAAOA,CAC5B,CAMO,SAASC,EACdC,EACAC,EAAkC,GAClC,CACI,GAAA,CACIC,MAAAA,EAAWC,WAASH,CAAE,EAKrBI,OAJWC,EAAAA,mBAAmBH,EAAU,IAAII,KAAQ,CACzDC,OAAQN,EAAQM,MAAAA,CACjB,OAGU,CACJP,OAAAA,CAAAA,CAEX,CAEO,SAASQ,EAAeC,EAAwB,CAC9CA,OAAAA,EAAOC,OAAO,CAAC,EAAEC,cAAgBF,EAAOG,MAAM,CAAC,CACxD,CAEgBC,SAAAA,EAAqBC,EAAiBC,EAAqB,CAClED,OAAAA,IAASE,OAAYF,EAAOC,CACrC,CAMO,SAASE,EACdC,EACAC,EACAlB,EAA6B,CAAA,EAC7B,CACO,MAAA,CACLiB,EACAC,EACAlB,EAAQmB,OACRnB,EAAQoB,OACRpB,EAAQqB,WACRrB,EAAQsB,QAAQ,EAEfC,UAAcC,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb,CAMO,SAASC,EAAiB,CAC/BC,oBAAAA,EACAC,SAAAA,EACAC,iBAAAA,EACAC,WAAAA,CAMF,EAAG,CACD,MAAO,CAACH,EAAqBC,EAAUC,EAAkBC,CAAU,EAChEP,OAAcC,GAAAA,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb,CAMO,SAASM,EAAmB,CACjCC,sBAAAA,EACAJ,SAAAA,EACAC,iBAAAA,EACAC,WAAAA,CAMF,EAAG,CACD,MAAO,CAACE,EAAuBJ,EAAUC,EAAkBC,CAAU,EAClEP,OAAcC,GAAAA,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import Knock, { FeedClientOptions } from \"@knocklabs/client\";\nimport { intlFormatDistance, parseISO } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nimport { BadgeCountType } from \"./types\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\n/**\n * Returns a string that describes the badge count and type.\n *\n * `all` = \"12 notifications\"\n * `unread` = \"1 unread notification\"\n * `unseen` = \"7 unseen notifications\"\n */\nexport function getBadgeAriaLabel(\n count: number,\n badgeCountType: BadgeCountType,\n): string {\n const qualifier = badgeCountType === \"all\" ? \"\" : `${badgeCountType} `;\n const noun = count === 1 ? \"notification\" : \"notifications\";\n return `${count} ${qualifier}${noun}`;\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 userId: Knock[\"userId\"],\n feedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userId,\n feedId,\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\n/*\n Used to build a consistent key for the KnockSlackProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function slackProviderKey({\n knockSlackChannelId,\n tenantId,\n connectionStatus,\n errorLabel,\n}: {\n knockSlackChannelId: string;\n tenantId: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockSlackChannelId, tenantId, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n\n/*\n Used to build a consistent key for the KnockMsTeamsProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function msTeamsProviderKey({\n knockMsTeamsChannelId,\n tenantId,\n connectionStatus,\n errorLabel,\n}: {\n knockMsTeamsChannelId: string;\n tenantId: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockMsTeamsChannelId, tenantId, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","getBadgeAriaLabel","badgeCountType","qualifier","formatTimestamp","ts","options","parsedTs","parseISO","formatted","intlFormatDistance","Date","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userId","feedId","source","tenant","has_tenant","archived","filter","f","join","slackProviderKey","knockSlackChannelId","tenantId","connectionStatus","errorLabel","msTeamsProviderKey","knockMsTeamsChannelId"],"mappings":"4GAMO,SAASA,EAAiBC,EAAgC,CACxDA,OAAAA,EAAQ,EAAI,KAAOA,CAC5B,CASgBC,SAAAA,EACdD,EACAE,EACQ,CACR,MAAMC,EAAYD,IAAmB,MAAQ,GAAK,GAAGA,CAAc,IAEnE,MAAO,GAAGF,CAAK,IAAIG,CAAS,GADfH,IAAU,EAAI,eAAiB,eACT,EACrC,CAMO,SAASI,EACdC,EACAC,EAAkC,GAClC,CACI,GAAA,CACIC,MAAAA,EAAWC,WAASH,CAAE,EAKrBI,OAJWC,EAAAA,mBAAmBH,EAAU,IAAII,KAAQ,CACzDC,OAAQN,EAAQM,MAAAA,CACjB,OAGU,CACJP,OAAAA,CAAAA,CAEX,CAEO,SAASQ,EAAeC,EAAwB,CAC9CA,OAAAA,EAAOC,OAAO,CAAC,EAAEC,cAAgBF,EAAOG,MAAM,CAAC,CACxD,CAEgBC,SAAAA,EAAqBC,EAAiBC,EAAqB,CAClED,OAAAA,IAASE,OAAYF,EAAOC,CACrC,CAMO,SAASE,EACdC,EACAC,EACAlB,EAA6B,CAAA,EAC7B,CACO,MAAA,CACLiB,EACAC,EACAlB,EAAQmB,OACRnB,EAAQoB,OACRpB,EAAQqB,WACRrB,EAAQsB,QAAQ,EAEfC,UAAcC,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb,CAMO,SAASC,EAAiB,CAC/BC,oBAAAA,EACAC,SAAAA,EACAC,iBAAAA,EACAC,WAAAA,CAMF,EAAG,CACD,MAAO,CAACH,EAAqBC,EAAUC,EAAkBC,CAAU,EAChEP,OAAcC,GAAAA,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb,CAMO,SAASM,EAAmB,CACjCC,sBAAAA,EACAJ,SAAAA,EACAC,iBAAAA,EACAC,WAAAA,CAMF,EAAG,CACD,MAAO,CAACE,EAAuBJ,EAAUC,EAAkBC,CAAU,EAClEP,OAAcC,GAAAA,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("@knocklabs/client"),p=require("react"),K=require("../../core/context/KnockProvider.js"),P=require("../../core/hooks/useStableOptions.js");require("date-fns");function m(e){if(e&&typeof e=="object"&&"default"in e)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const c=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,c.get?c:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const o=m(p),l=o.createContext(void 0),v=({channelId:e,readyToTarget:r,listenForUpdates:t=!0,colorMode:c="light",targetParams:f={},trackLocationFromWindow:u=!0,orderResolutionDuration:s=0,throttleCheckInterval:a,children:b})=>{let i;try{i=K.useKnockClient()}catch{throw new Error("KnockGuideProvider must be used within a KnockProvider")}const d=P(f),n=o.useMemo(()=>new k.KnockGuideClient(i,e,d,{trackLocationFromWindow:u,orderResolutionDuration:s,throttleCheckInterval:a}),[i,e,d,u,s,a]);return o.useEffect(()=>(r&&(n.fetch(),t&&n.subscribe()),()=>n.cleanup()),[r,t,n]),o.createElement(l.Provider,{value:{client:n,colorMode:c}},b)};exports.KnockGuideContext=l;exports.KnockGuideProvider=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@knocklabs/client"),K=require("react"),v=require("../../core/context/KnockProvider.js"),P=require("../../core/hooks/useStableOptions.js");require("date-fns");function m(e){if(e&&typeof e=="object"&&"default"in e)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const c=m(K),a=c.createContext(void 0),g=({channelId:e,readyToTarget:r,listenForUpdates:t=!0,colorMode:o="light",targetParams:b={},trackLocationFromWindow:u=!0,trackDebugParams:s=!1,orderResolutionDuration:l=0,throttleCheckInterval:d,children:k})=>{let i;try{i=v.useKnockClient()}catch{throw new Error("KnockGuideProvider must be used within a KnockProvider")}const f=P(b),n=c.useMemo(()=>new p.KnockGuideClient(i,e,f,{trackLocationFromWindow:u,trackDebugParams:s,orderResolutionDuration:l,throttleCheckInterval:d}),[i,e,f,u,s,l,d]);return c.useEffect(()=>(r&&(n.fetch(),t&&n.subscribe()),()=>n.cleanup()),[r,t,n]),c.createElement(a.Provider,{value:{client:n,colorMode:o}},k)};exports.KnockGuideContext=a;exports.KnockGuideProvider=g;
2
2
  //# sourceMappingURL=KnockGuideProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KnockGuideProvider.js","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"sourcesContent":["import Knock, {\n KnockGuideClient,\n KnockGuideTargetParams,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { useKnockClient, useStableOptions } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\n\ntype KnockGuideProviderValue = {\n client: KnockGuideClient;\n colorMode: ColorMode;\n};\n\nexport const KnockGuideContext = React.createContext<\n KnockGuideProviderValue | undefined\n>(undefined);\n\nexport type KnockGuideProviderProps = {\n channelId: string;\n readyToTarget: boolean;\n listenForUpdates?: boolean;\n colorMode?: ColorMode;\n targetParams?: KnockGuideTargetParams;\n trackLocationFromWindow?: boolean;\n orderResolutionDuration?: number; // in milliseconds\n throttleCheckInterval?: number; // in milliseconds\n};\n\nexport const KnockGuideProvider: React.FC<\n React.PropsWithChildren<KnockGuideProviderProps>\n> = ({\n channelId,\n readyToTarget,\n listenForUpdates = true,\n colorMode = \"light\",\n targetParams = {},\n trackLocationFromWindow = true,\n // Default to 0 which works well for react apps as this \"yields\" to react for\n // one render cyle first and close the group stage.\n orderResolutionDuration = 0,\n throttleCheckInterval,\n children,\n}) => {\n let knock: Knock;\n\n try {\n knock = useKnockClient();\n } catch (_) {\n throw new Error(\"KnockGuideProvider must be used within a KnockProvider\");\n }\n\n const stableTargetParams = useStableOptions(targetParams);\n\n const knockGuideClient = React.useMemo(() => {\n return new KnockGuideClient(knock, channelId, stableTargetParams, {\n trackLocationFromWindow,\n orderResolutionDuration,\n throttleCheckInterval,\n });\n }, [\n knock,\n channelId,\n stableTargetParams,\n trackLocationFromWindow,\n orderResolutionDuration,\n throttleCheckInterval,\n ]);\n\n React.useEffect(() => {\n if (readyToTarget) {\n knockGuideClient.fetch();\n if (listenForUpdates) knockGuideClient.subscribe();\n }\n\n return () => knockGuideClient.cleanup();\n }, [readyToTarget, listenForUpdates, knockGuideClient]);\n\n return (\n <KnockGuideContext.Provider\n value={{\n client: knockGuideClient,\n colorMode,\n }}\n >\n {children}\n </KnockGuideContext.Provider>\n );\n};\n"],"names":["KnockGuideContext","React","createContext","undefined","KnockGuideProvider","channelId","readyToTarget","listenForUpdates","colorMode","targetParams","trackLocationFromWindow","orderResolutionDuration","throttleCheckInterval","children","knock","useKnockClient","Error","stableTargetParams","useStableOptions","knockGuideClient","useMemo","KnockGuideClient","useEffect","fetch","subscribe","cleanup","client"],"mappings":"0kBAcaA,EAAoBC,EAAMC,cAErCC,MAAS,EAaEC,EAETA,CAAC,CACHC,UAAAA,EACAC,cAAAA,EACAC,iBAAAA,EAAmB,GACnBC,UAAAA,EAAY,QACZC,aAAAA,EAAe,CAAC,EAChBC,wBAAAA,EAA0B,GAG1BC,wBAAAA,EAA0B,EAC1BC,sBAAAA,EACAC,SAAAA,CACF,IAAM,CACAC,IAAAA,EAEA,GAAA,CACFA,EAAQC,EAAAA,eAAe,OACb,CACJ,MAAA,IAAIC,MAAM,wDAAwD,CAAA,CAGpEC,MAAAA,EAAqBC,EAAiBT,CAAY,EAElDU,EAAmBlB,EAAMmB,QAAQ,IAC9B,IAAIC,EAAAA,iBAAiBP,EAAOT,EAAWY,EAAoB,CAChEP,wBAAAA,EACAC,wBAAAA,EACAC,sBAAAA,CAAAA,CACD,EACA,CACDE,EACAT,EACAY,EACAP,EACAC,EACAC,CAAqB,CACtB,EAEDX,OAAAA,EAAMqB,UAAU,KACVhB,IACFa,EAAiBI,MAAM,EACnBhB,KAAmCiB,UAAU,GAG5C,IAAML,EAAiBM,QAAQ,GACrC,CAACnB,EAAeC,EAAkBY,CAAgB,CAAC,EAGnDlB,EAAA,cAAAD,EAAkB,SAAlB,CACC,MAAO,CACL0B,OAAQP,EACRX,UAAAA,IAGDK,CACH,CAEJ"}
1
+ {"version":3,"file":"KnockGuideProvider.js","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"sourcesContent":["import Knock, {\n KnockGuideClient,\n KnockGuideTargetParams,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { useKnockClient, useStableOptions } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\n\ntype KnockGuideProviderValue = {\n client: KnockGuideClient;\n colorMode: ColorMode;\n};\n\nexport const KnockGuideContext = React.createContext<\n KnockGuideProviderValue | undefined\n>(undefined);\n\nexport type KnockGuideProviderProps = {\n channelId: string;\n readyToTarget: boolean;\n listenForUpdates?: boolean;\n colorMode?: ColorMode;\n targetParams?: KnockGuideTargetParams;\n trackLocationFromWindow?: boolean;\n trackDebugParams?: boolean;\n orderResolutionDuration?: number; // in milliseconds\n throttleCheckInterval?: number; // in milliseconds\n};\n\nexport const KnockGuideProvider: React.FC<\n React.PropsWithChildren<KnockGuideProviderProps>\n> = ({\n channelId,\n readyToTarget,\n listenForUpdates = true,\n colorMode = \"light\",\n targetParams = {},\n trackLocationFromWindow = true,\n // Whether the guide client should look for debug params in url/local storage\n // to launch guide toolbar. Set to true if using toolbar v1.\n // TODO(KNO-11523): Remove this once we ship v2.\n trackDebugParams = false,\n // Default to 0 which works well for react apps as this \"yields\" to react for\n // one render cyle first and close the group stage.\n orderResolutionDuration = 0,\n throttleCheckInterval,\n children,\n}) => {\n let knock: Knock;\n\n try {\n knock = useKnockClient();\n } catch (_) {\n throw new Error(\"KnockGuideProvider must be used within a KnockProvider\");\n }\n\n const stableTargetParams = useStableOptions(targetParams);\n\n const knockGuideClient = React.useMemo(() => {\n return new KnockGuideClient(knock, channelId, stableTargetParams, {\n trackLocationFromWindow,\n trackDebugParams,\n orderResolutionDuration,\n throttleCheckInterval,\n });\n }, [\n knock,\n channelId,\n stableTargetParams,\n trackLocationFromWindow,\n trackDebugParams,\n orderResolutionDuration,\n throttleCheckInterval,\n ]);\n\n React.useEffect(() => {\n if (readyToTarget) {\n knockGuideClient.fetch();\n if (listenForUpdates) knockGuideClient.subscribe();\n }\n\n return () => knockGuideClient.cleanup();\n }, [readyToTarget, listenForUpdates, knockGuideClient]);\n\n return (\n <KnockGuideContext.Provider\n value={{\n client: knockGuideClient,\n colorMode,\n }}\n >\n {children}\n </KnockGuideContext.Provider>\n );\n};\n"],"names":["KnockGuideContext","React","createContext","undefined","KnockGuideProvider","channelId","readyToTarget","listenForUpdates","colorMode","targetParams","trackLocationFromWindow","trackDebugParams","orderResolutionDuration","throttleCheckInterval","children","knock","useKnockClient","Error","stableTargetParams","useStableOptions","knockGuideClient","useMemo","KnockGuideClient","useEffect","fetch","subscribe","cleanup","client"],"mappings":"0kBAcaA,EAAoBC,EAAMC,cAErCC,MAAS,EAcEC,EAETA,CAAC,CACHC,UAAAA,EACAC,cAAAA,EACAC,iBAAAA,EAAmB,GACnBC,UAAAA,EAAY,QACZC,aAAAA,EAAe,CAAC,EAChBC,wBAAAA,EAA0B,GAI1BC,iBAAAA,EAAmB,GAGnBC,wBAAAA,EAA0B,EAC1BC,sBAAAA,EACAC,SAAAA,CACF,IAAM,CACAC,IAAAA,EAEA,GAAA,CACFA,EAAQC,EAAAA,eAAe,OACb,CACJ,MAAA,IAAIC,MAAM,wDAAwD,CAAA,CAGpEC,MAAAA,EAAqBC,EAAiBV,CAAY,EAElDW,EAAmBnB,EAAMoB,QAAQ,IAC9B,IAAIC,EAAAA,iBAAiBP,EAAOV,EAAWa,EAAoB,CAChER,wBAAAA,EACAC,iBAAAA,EACAC,wBAAAA,EACAC,sBAAAA,CAAAA,CACD,EACA,CACDE,EACAV,EACAa,EACAR,EACAC,EACAC,EACAC,CAAqB,CACtB,EAEDZ,OAAAA,EAAMsB,UAAU,KACVjB,IACFc,EAAiBI,MAAM,EACnBjB,KAAmCkB,UAAU,GAG5C,IAAML,EAAiBM,QAAQ,GACrC,CAACpB,EAAeC,EAAkBa,CAAgB,CAAC,EAGnDnB,EAAA,cAAAD,EAAkB,SAAlB,CACC,MAAO,CACL2B,OAAQP,EACRZ,UAAAA,IAGDM,CACH,CAEJ"}
@@ -4,75 +4,76 @@ import { default as n } from "./modules/core/hooks/useStableOptions.mjs";
4
4
  import { useAuthPostMessageListener as m } from "./modules/core/hooks/useAuthPostMessageListener.mjs";
5
5
  import { useAuthPolling as l } from "./modules/core/hooks/useAuthPolling.mjs";
6
6
  import { FilterStatus as x } from "./modules/core/constants.mjs";
7
- import { feedProviderKey as c, formatBadgeCount as k, formatTimestamp as C, msTeamsProviderKey as K, renderNodeOrFallback as S, slackProviderKey as P, toSentenceCase as T } from "./modules/core/utils.mjs";
8
- import { KnockFeedProvider as v, useKnockFeed as M } from "./modules/feed/context/KnockFeedProvider.mjs";
7
+ import { feedProviderKey as c, formatBadgeCount as k, formatTimestamp as C, getBadgeAriaLabel as K, msTeamsProviderKey as S, renderNodeOrFallback as P, slackProviderKey as T, toSentenceCase as h } from "./modules/core/utils.mjs";
8
+ import { KnockFeedProvider as M, useKnockFeed as g } from "./modules/feed/context/KnockFeedProvider.mjs";
9
9
  import { default as F } from "./modules/feed/hooks/useNotifications.mjs";
10
- import { default as g } from "./modules/feed/hooks/useFeedSettings.mjs";
11
- import { useCreateNotificationStore as y, default as b } from "./modules/feed/hooks/useNotificationStore.mjs";
12
- import { KnockGuideContext as O, KnockGuideProvider as B } from "./modules/guide/context/KnockGuideProvider.mjs";
13
- import { useGuide as j } from "./modules/guide/hooks/useGuide.mjs";
14
- import { useGuides as w } from "./modules/guide/hooks/useGuides.mjs";
15
- import { useGuideContext as D } from "./modules/guide/hooks/useGuideContext.mjs";
16
- import { KnockMsTeamsProvider as H, useKnockMsTeamsClient as J } from "./modules/ms-teams/context/KnockMsTeamsProvider.mjs";
17
- import { default as R } from "./modules/ms-teams/hooks/useMsTeamsConnectionStatus.mjs";
18
- import { default as V } from "./modules/ms-teams/hooks/useMsTeamsAuth.mjs";
19
- import { default as X } from "./modules/ms-teams/hooks/useMsTeamsTeams.mjs";
20
- import { default as Z } from "./modules/ms-teams/hooks/useMsTeamsChannels.mjs";
21
- import { default as $ } from "./modules/ms-teams/hooks/useConnectedMsTeamsChannels.mjs";
22
- import { KnockSlackProvider as oe, useKnockSlackClient as te } from "./modules/slack/context/KnockSlackProvider.mjs";
23
- import { default as se } from "./modules/slack/hooks/useSlackConnectionStatus.mjs";
24
- import { default as ue } from "./modules/slack/hooks/useSlackChannels.mjs";
25
- import { default as fe } from "./modules/slack/hooks/useConnectedSlackChannels.mjs";
26
- import { default as de } from "./modules/slack/hooks/useSlackAuth.mjs";
27
- import { I18nContext as ie, KnockI18nProvider as xe } from "./modules/i18n/context/KnockI18nProvider.mjs";
28
- import { useTranslations as ce } from "./modules/i18n/hooks/useTranslations.mjs";
29
- import { locales as Ce } from "./modules/i18n/languages/index.mjs";
30
- import { usePreferences as Se } from "./modules/preferences/hooks/usePreferences.mjs";
31
- import { useStore as Te } from "@tanstack/react-store";
10
+ import { default as N } from "./modules/feed/hooks/useFeedSettings.mjs";
11
+ import { useCreateNotificationStore as y, default as B } from "./modules/feed/hooks/useNotificationStore.mjs";
12
+ import { KnockGuideContext as L, KnockGuideProvider as O } from "./modules/guide/context/KnockGuideProvider.mjs";
13
+ import { useGuide as q } from "./modules/guide/hooks/useGuide.mjs";
14
+ import { useGuides as z } from "./modules/guide/hooks/useGuides.mjs";
15
+ import { useGuideContext as E } from "./modules/guide/hooks/useGuideContext.mjs";
16
+ import { KnockMsTeamsProvider as J, useKnockMsTeamsClient as Q } from "./modules/ms-teams/context/KnockMsTeamsProvider.mjs";
17
+ import { default as U } from "./modules/ms-teams/hooks/useMsTeamsConnectionStatus.mjs";
18
+ import { default as W } from "./modules/ms-teams/hooks/useMsTeamsAuth.mjs";
19
+ import { default as Y } from "./modules/ms-teams/hooks/useMsTeamsTeams.mjs";
20
+ import { default as _ } from "./modules/ms-teams/hooks/useMsTeamsChannels.mjs";
21
+ import { default as ee } from "./modules/ms-teams/hooks/useConnectedMsTeamsChannels.mjs";
22
+ import { KnockSlackProvider as te, useKnockSlackClient as re } from "./modules/slack/context/KnockSlackProvider.mjs";
23
+ import { default as ae } from "./modules/slack/hooks/useSlackConnectionStatus.mjs";
24
+ import { default as ne } from "./modules/slack/hooks/useSlackChannels.mjs";
25
+ import { default as me } from "./modules/slack/hooks/useConnectedSlackChannels.mjs";
26
+ import { default as le } from "./modules/slack/hooks/useSlackAuth.mjs";
27
+ import { I18nContext as xe, KnockI18nProvider as pe } from "./modules/i18n/context/KnockI18nProvider.mjs";
28
+ import { useTranslations as ke } from "./modules/i18n/hooks/useTranslations.mjs";
29
+ import { locales as Ke } from "./modules/i18n/languages/index.mjs";
30
+ import { usePreferences as Pe } from "./modules/preferences/hooks/usePreferences.mjs";
31
+ import { useStore as he } from "@tanstack/react-store";
32
32
  export {
33
33
  x as FilterStatus,
34
- ie as I18nContext,
35
- v as KnockFeedProvider,
36
- O as KnockGuideContext,
37
- B as KnockGuideProvider,
38
- xe as KnockI18nProvider,
39
- H as KnockMsTeamsProvider,
34
+ xe as I18nContext,
35
+ M as KnockFeedProvider,
36
+ L as KnockGuideContext,
37
+ O as KnockGuideProvider,
38
+ pe as KnockI18nProvider,
39
+ J as KnockMsTeamsProvider,
40
40
  t as KnockProvider,
41
- oe as KnockSlackProvider,
41
+ te as KnockSlackProvider,
42
42
  c as feedProviderKey,
43
43
  k as formatBadgeCount,
44
44
  C as formatTimestamp,
45
- Ce as locales,
46
- K as msTeamsProviderKey,
47
- S as renderNodeOrFallback,
48
- P as slackProviderKey,
49
- T as toSentenceCase,
45
+ K as getBadgeAriaLabel,
46
+ Ke as locales,
47
+ S as msTeamsProviderKey,
48
+ P as renderNodeOrFallback,
49
+ T as slackProviderKey,
50
+ h as toSentenceCase,
50
51
  l as useAuthPolling,
51
52
  m as useAuthPostMessageListener,
52
53
  a as useAuthenticatedKnockClient,
53
- $ as useConnectedMsTeamsChannels,
54
- fe as useConnectedSlackChannels,
54
+ ee as useConnectedMsTeamsChannels,
55
+ me as useConnectedSlackChannels,
55
56
  y as useCreateNotificationStore,
56
- g as useFeedSettings,
57
- j as useGuide,
58
- D as useGuideContext,
59
- w as useGuides,
57
+ N as useFeedSettings,
58
+ q as useGuide,
59
+ E as useGuideContext,
60
+ z as useGuides,
60
61
  r as useKnockClient,
61
- M as useKnockFeed,
62
- J as useKnockMsTeamsClient,
63
- te as useKnockSlackClient,
64
- V as useMsTeamsAuth,
65
- Z as useMsTeamsChannels,
66
- R as useMsTeamsConnectionStatus,
67
- X as useMsTeamsTeams,
68
- b as useNotificationStore,
62
+ g as useKnockFeed,
63
+ Q as useKnockMsTeamsClient,
64
+ re as useKnockSlackClient,
65
+ W as useMsTeamsAuth,
66
+ _ as useMsTeamsChannels,
67
+ U as useMsTeamsConnectionStatus,
68
+ Y as useMsTeamsTeams,
69
+ B as useNotificationStore,
69
70
  F as useNotifications,
70
- Se as usePreferences,
71
- de as useSlackAuth,
72
- ue as useSlackChannels,
73
- se as useSlackConnectionStatus,
71
+ Pe as usePreferences,
72
+ le as useSlackAuth,
73
+ ne as useSlackChannels,
74
+ ae as useSlackConnectionStatus,
74
75
  n as useStableOptions,
75
- Te as useStore,
76
- ce as useTranslations
76
+ he as useStore,
77
+ ke as useTranslations
77
78
  };
78
79
  //# sourceMappingURL=index.mjs.map
@@ -1,12 +1,16 @@
1
- import { parseISO as a, intlFormatDistance as i } from "date-fns";
2
- function u(e) {
1
+ import { parseISO as i, intlFormatDistance as a } from "date-fns";
2
+ function l(e) {
3
3
  return e > 9 ? "9+" : e;
4
4
  }
5
- function l(e, t = {}) {
5
+ function u(e, r) {
6
+ const n = r === "all" ? "" : `${r} `;
7
+ return `${e} ${n}${e === 1 ? "notification" : "notifications"}`;
8
+ }
9
+ function f(e, r = {}) {
6
10
  try {
7
- const r = a(e);
8
- return i(r, /* @__PURE__ */ new Date(), {
9
- locale: t.locale
11
+ const n = i(e);
12
+ return a(n, /* @__PURE__ */ new Date(), {
13
+ locale: r.locale
10
14
  });
11
15
  } catch {
12
16
  return e;
@@ -15,35 +19,36 @@ function l(e, t = {}) {
15
19
  function d(e) {
16
20
  return e.charAt(0).toUpperCase() + e.slice(1);
17
21
  }
18
- function f(e, t) {
19
- return e !== void 0 ? e : t;
22
+ function s(e, r) {
23
+ return e !== void 0 ? e : r;
20
24
  }
21
- function m(e, t, r = {}) {
22
- return [e, t, r.source, r.tenant, r.has_tenant, r.archived].filter((n) => n != null).join("-");
25
+ function m(e, r, n = {}) {
26
+ return [e, r, n.source, n.tenant, n.has_tenant, n.archived].filter((t) => t != null).join("-");
23
27
  }
24
- function s({
28
+ function v({
25
29
  knockSlackChannelId: e,
26
- tenantId: t,
27
- connectionStatus: r,
28
- errorLabel: n
30
+ tenantId: r,
31
+ connectionStatus: n,
32
+ errorLabel: t
29
33
  }) {
30
- return [e, t, r, n].filter((o) => o != null).join("-");
34
+ return [e, r, n, t].filter((o) => o != null).join("-");
31
35
  }
32
- function v({
36
+ function h({
33
37
  knockMsTeamsChannelId: e,
34
- tenantId: t,
35
- connectionStatus: r,
36
- errorLabel: n
38
+ tenantId: r,
39
+ connectionStatus: n,
40
+ errorLabel: t
37
41
  }) {
38
- return [e, t, r, n].filter((o) => o != null).join("-");
42
+ return [e, r, n, t].filter((o) => o != null).join("-");
39
43
  }
40
44
  export {
41
45
  m as feedProviderKey,
42
- u as formatBadgeCount,
43
- l as formatTimestamp,
44
- v as msTeamsProviderKey,
45
- f as renderNodeOrFallback,
46
- s as slackProviderKey,
46
+ l as formatBadgeCount,
47
+ f as formatTimestamp,
48
+ u as getBadgeAriaLabel,
49
+ h as msTeamsProviderKey,
50
+ s as renderNodeOrFallback,
51
+ v as slackProviderKey,
47
52
  d as toSentenceCase
48
53
  };
49
54
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import Knock, { FeedClientOptions } from \"@knocklabs/client\";\nimport { intlFormatDistance, parseISO } 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 userId: Knock[\"userId\"],\n feedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userId,\n feedId,\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\n/*\n Used to build a consistent key for the KnockSlackProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function slackProviderKey({\n knockSlackChannelId,\n tenantId,\n connectionStatus,\n errorLabel,\n}: {\n knockSlackChannelId: string;\n tenantId: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockSlackChannelId, tenantId, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n\n/*\n Used to build a consistent key for the KnockMsTeamsProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function msTeamsProviderKey({\n knockMsTeamsChannelId,\n tenantId,\n connectionStatus,\n errorLabel,\n}: {\n knockMsTeamsChannelId: string;\n tenantId: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockMsTeamsChannelId, tenantId, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","formatted","intlFormatDistance","Date","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userId","feedId","source","tenant","has_tenant","archived","filter","f","join","slackProviderKey","knockSlackChannelId","tenantId","connectionStatus","errorLabel","msTeamsProviderKey","knockMsTeamsChannelId"],"mappings":";AAIO,SAASA,EAAiBC,GAAgC;AACxDA,SAAAA,IAAQ,IAAI,OAAOA;AAC5B;AAMO,SAASC,EACdC,GACAC,IAAkC,IAClC;AACI,MAAA;AACIC,UAAAA,IAAWC,EAASH,CAAE;AAKrBI,WAJWC,EAAmBH,GAAU,oBAAII,QAAQ;AAAA,MACzDC,QAAQN,EAAQM;AAAAA,IAAAA,CACjB;AAAA,UAGU;AACJP,WAAAA;AAAAA,EAAAA;AAEX;AAEO,SAASQ,EAAeC,GAAwB;AAC9CA,SAAAA,EAAOC,OAAO,CAAC,EAAEC,gBAAgBF,EAAOG,MAAM,CAAC;AACxD;AAEgBC,SAAAA,EAAqBC,GAAiBC,GAAqB;AAClED,SAAAA,MAASE,SAAYF,IAAOC;AACrC;AAMO,SAASE,EACdC,GACAC,GACAlB,IAA6B,CAAA,GAC7B;AACO,SAAA,CACLiB,GACAC,GACAlB,EAAQmB,QACRnB,EAAQoB,QACRpB,EAAQqB,YACRrB,EAAQsB,QAAQ,EAEfC,OAAQC,OAAMA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;AAMO,SAASC,EAAiB;AAAA,EAC/BC,qBAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,kBAAAA;AAAAA,EACAC,YAAAA;AAMF,GAAG;AACD,SAAO,CAACH,GAAqBC,GAAUC,GAAkBC,CAAU,EAChEP,OAAQC,CAAMA,MAAAA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;AAMO,SAASM,EAAmB;AAAA,EACjCC,uBAAAA;AAAAA,EACAJ,UAAAA;AAAAA,EACAC,kBAAAA;AAAAA,EACAC,YAAAA;AAMF,GAAG;AACD,SAAO,CAACE,GAAuBJ,GAAUC,GAAkBC,CAAU,EAClEP,OAAQC,CAAMA,MAAAA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import Knock, { FeedClientOptions } from \"@knocklabs/client\";\nimport { intlFormatDistance, parseISO } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nimport { BadgeCountType } from \"./types\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\n/**\n * Returns a string that describes the badge count and type.\n *\n * `all` = \"12 notifications\"\n * `unread` = \"1 unread notification\"\n * `unseen` = \"7 unseen notifications\"\n */\nexport function getBadgeAriaLabel(\n count: number,\n badgeCountType: BadgeCountType,\n): string {\n const qualifier = badgeCountType === \"all\" ? \"\" : `${badgeCountType} `;\n const noun = count === 1 ? \"notification\" : \"notifications\";\n return `${count} ${qualifier}${noun}`;\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 userId: Knock[\"userId\"],\n feedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userId,\n feedId,\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\n/*\n Used to build a consistent key for the KnockSlackProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function slackProviderKey({\n knockSlackChannelId,\n tenantId,\n connectionStatus,\n errorLabel,\n}: {\n knockSlackChannelId: string;\n tenantId: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockSlackChannelId, tenantId, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n\n/*\n Used to build a consistent key for the KnockMsTeamsProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function msTeamsProviderKey({\n knockMsTeamsChannelId,\n tenantId,\n connectionStatus,\n errorLabel,\n}: {\n knockMsTeamsChannelId: string;\n tenantId: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockMsTeamsChannelId, tenantId, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","getBadgeAriaLabel","badgeCountType","qualifier","formatTimestamp","ts","options","parsedTs","parseISO","formatted","intlFormatDistance","Date","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userId","feedId","source","tenant","has_tenant","archived","filter","f","join","slackProviderKey","knockSlackChannelId","tenantId","connectionStatus","errorLabel","msTeamsProviderKey","knockMsTeamsChannelId"],"mappings":";AAMO,SAASA,EAAiBC,GAAgC;AACxDA,SAAAA,IAAQ,IAAI,OAAOA;AAC5B;AASgBC,SAAAA,EACdD,GACAE,GACQ;AACR,QAAMC,IAAYD,MAAmB,QAAQ,KAAK,GAAGA,CAAc;AAEnE,SAAO,GAAGF,CAAK,IAAIG,CAAS,GADfH,MAAU,IAAI,iBAAiB,eACT;AACrC;AAMO,SAASI,EACdC,GACAC,IAAkC,IAClC;AACI,MAAA;AACIC,UAAAA,IAAWC,EAASH,CAAE;AAKrBI,WAJWC,EAAmBH,GAAU,oBAAII,QAAQ;AAAA,MACzDC,QAAQN,EAAQM;AAAAA,IAAAA,CACjB;AAAA,UAGU;AACJP,WAAAA;AAAAA,EAAAA;AAEX;AAEO,SAASQ,EAAeC,GAAwB;AAC9CA,SAAAA,EAAOC,OAAO,CAAC,EAAEC,gBAAgBF,EAAOG,MAAM,CAAC;AACxD;AAEgBC,SAAAA,EAAqBC,GAAiBC,GAAqB;AAClED,SAAAA,MAASE,SAAYF,IAAOC;AACrC;AAMO,SAASE,EACdC,GACAC,GACAlB,IAA6B,CAAA,GAC7B;AACO,SAAA,CACLiB,GACAC,GACAlB,EAAQmB,QACRnB,EAAQoB,QACRpB,EAAQqB,YACRrB,EAAQsB,QAAQ,EAEfC,OAAQC,OAAMA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;AAMO,SAASC,EAAiB;AAAA,EAC/BC,qBAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,kBAAAA;AAAAA,EACAC,YAAAA;AAMF,GAAG;AACD,SAAO,CAACH,GAAqBC,GAAUC,GAAkBC,CAAU,EAChEP,OAAQC,CAAMA,MAAAA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;AAMO,SAASM,EAAmB;AAAA,EACjCC,uBAAAA;AAAAA,EACAJ,UAAAA;AAAAA,EACAC,kBAAAA;AAAAA,EACAC,YAAAA;AAMF,GAAG;AACD,SAAO,CAACE,GAAuBJ,GAAUC,GAAkBC,CAAU,EAClEP,OAAQC,CAAMA,MAAAA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;"}
@@ -1,39 +1,44 @@
1
1
  import { KnockGuideClient as d } from "@knocklabs/client";
2
2
  import * as t from "react";
3
- import { useKnockClient as l } from "../../core/context/KnockProvider.mjs";
4
- import K from "../../core/hooks/useStableOptions.mjs";
3
+ import { useKnockClient as K } from "../../core/context/KnockProvider.mjs";
4
+ import v from "../../core/hooks/useStableOptions.mjs";
5
5
  import "date-fns";
6
- const a = t.createContext(void 0), w = ({
6
+ const G = t.createContext(void 0), x = ({
7
7
  channelId: o,
8
8
  readyToTarget: i,
9
9
  listenForUpdates: n = !0,
10
- colorMode: f = "light",
11
- targetParams: k = {},
10
+ colorMode: k = "light",
11
+ targetParams: l = {},
12
12
  trackLocationFromWindow: c = !0,
13
+ // Whether the guide client should look for debug params in url/local storage
14
+ // to launch guide toolbar. Set to true if using toolbar v1.
15
+ // TODO(KNO-11523): Remove this once we ship v2.
16
+ trackDebugParams: u = !1,
13
17
  // Default to 0 which works well for react apps as this "yields" to react for
14
18
  // one render cyle first and close the group stage.
15
- orderResolutionDuration: u = 0,
16
- throttleCheckInterval: s,
19
+ orderResolutionDuration: s = 0,
20
+ throttleCheckInterval: m,
17
21
  children: p
18
22
  }) => {
19
23
  let r;
20
24
  try {
21
- r = l();
25
+ r = K();
22
26
  } catch {
23
27
  throw new Error("KnockGuideProvider must be used within a KnockProvider");
24
28
  }
25
- const m = K(k), e = t.useMemo(() => new d(r, o, m, {
29
+ const f = v(l), e = t.useMemo(() => new d(r, o, f, {
26
30
  trackLocationFromWindow: c,
27
- orderResolutionDuration: u,
28
- throttleCheckInterval: s
29
- }), [r, o, m, c, u, s]);
30
- return t.useEffect(() => (i && (e.fetch(), n && e.subscribe()), () => e.cleanup()), [i, n, e]), /* @__PURE__ */ t.createElement(a.Provider, { value: {
31
+ trackDebugParams: u,
32
+ orderResolutionDuration: s,
33
+ throttleCheckInterval: m
34
+ }), [r, o, f, c, u, s, m]);
35
+ return t.useEffect(() => (i && (e.fetch(), n && e.subscribe()), () => e.cleanup()), [i, n, e]), /* @__PURE__ */ t.createElement(G.Provider, { value: {
31
36
  client: e,
32
- colorMode: f
37
+ colorMode: k
33
38
  } }, p);
34
39
  };
35
40
  export {
36
- a as KnockGuideContext,
37
- w as KnockGuideProvider
41
+ G as KnockGuideContext,
42
+ x as KnockGuideProvider
38
43
  };
39
44
  //# sourceMappingURL=KnockGuideProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"KnockGuideProvider.mjs","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"sourcesContent":["import Knock, {\n KnockGuideClient,\n KnockGuideTargetParams,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { useKnockClient, useStableOptions } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\n\ntype KnockGuideProviderValue = {\n client: KnockGuideClient;\n colorMode: ColorMode;\n};\n\nexport const KnockGuideContext = React.createContext<\n KnockGuideProviderValue | undefined\n>(undefined);\n\nexport type KnockGuideProviderProps = {\n channelId: string;\n readyToTarget: boolean;\n listenForUpdates?: boolean;\n colorMode?: ColorMode;\n targetParams?: KnockGuideTargetParams;\n trackLocationFromWindow?: boolean;\n orderResolutionDuration?: number; // in milliseconds\n throttleCheckInterval?: number; // in milliseconds\n};\n\nexport const KnockGuideProvider: React.FC<\n React.PropsWithChildren<KnockGuideProviderProps>\n> = ({\n channelId,\n readyToTarget,\n listenForUpdates = true,\n colorMode = \"light\",\n targetParams = {},\n trackLocationFromWindow = true,\n // Default to 0 which works well for react apps as this \"yields\" to react for\n // one render cyle first and close the group stage.\n orderResolutionDuration = 0,\n throttleCheckInterval,\n children,\n}) => {\n let knock: Knock;\n\n try {\n knock = useKnockClient();\n } catch (_) {\n throw new Error(\"KnockGuideProvider must be used within a KnockProvider\");\n }\n\n const stableTargetParams = useStableOptions(targetParams);\n\n const knockGuideClient = React.useMemo(() => {\n return new KnockGuideClient(knock, channelId, stableTargetParams, {\n trackLocationFromWindow,\n orderResolutionDuration,\n throttleCheckInterval,\n });\n }, [\n knock,\n channelId,\n stableTargetParams,\n trackLocationFromWindow,\n orderResolutionDuration,\n throttleCheckInterval,\n ]);\n\n React.useEffect(() => {\n if (readyToTarget) {\n knockGuideClient.fetch();\n if (listenForUpdates) knockGuideClient.subscribe();\n }\n\n return () => knockGuideClient.cleanup();\n }, [readyToTarget, listenForUpdates, knockGuideClient]);\n\n return (\n <KnockGuideContext.Provider\n value={{\n client: knockGuideClient,\n colorMode,\n }}\n >\n {children}\n </KnockGuideContext.Provider>\n );\n};\n"],"names":["KnockGuideContext","React","createContext","undefined","KnockGuideProvider","channelId","readyToTarget","listenForUpdates","colorMode","targetParams","trackLocationFromWindow","orderResolutionDuration","throttleCheckInterval","children","knock","useKnockClient","Error","stableTargetParams","useStableOptions","knockGuideClient","useMemo","KnockGuideClient","useEffect","fetch","subscribe","cleanup","client"],"mappings":";;;;;AAcaA,MAAAA,IAAoBC,EAAMC,cAErCC,MAAS,GAaEC,IAETA,CAAC;AAAA,EACHC,WAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,kBAAAA,IAAmB;AAAA,EACnBC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe,CAAC;AAAA,EAChBC,yBAAAA,IAA0B;AAAA;AAAA;AAAA,EAG1BC,yBAAAA,IAA0B;AAAA,EAC1BC,uBAAAA;AAAAA,EACAC,UAAAA;AACF,MAAM;AACAC,MAAAA;AAEA,MAAA;AACFA,IAAAA,IAAQC,EAAe;AAAA,UACb;AACJ,UAAA,IAAIC,MAAM,wDAAwD;AAAA,EAAA;AAGpEC,QAAAA,IAAqBC,EAAiBT,CAAY,GAElDU,IAAmBlB,EAAMmB,QAAQ,MAC9B,IAAIC,EAAiBP,GAAOT,GAAWY,GAAoB;AAAA,IAChEP,yBAAAA;AAAAA,IACAC,yBAAAA;AAAAA,IACAC,uBAAAA;AAAAA,EAAAA,CACD,GACA,CACDE,GACAT,GACAY,GACAP,GACAC,GACAC,CAAqB,CACtB;AAEDX,SAAAA,EAAMqB,UAAU,OACVhB,MACFa,EAAiBI,MAAM,GACnBhB,OAAmCiB,UAAU,IAG5C,MAAML,EAAiBM,QAAQ,IACrC,CAACnB,GAAeC,GAAkBY,CAAgB,CAAC,GAGnD,gBAAAlB,EAAA,cAAAD,EAAkB,UAAlB,EACC,OAAO;AAAA,IACL0B,QAAQP;AAAAA,IACRX,WAAAA;AAAAA,OAGDK,CACH;AAEJ;"}
1
+ {"version":3,"file":"KnockGuideProvider.mjs","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"sourcesContent":["import Knock, {\n KnockGuideClient,\n KnockGuideTargetParams,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { useKnockClient, useStableOptions } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\n\ntype KnockGuideProviderValue = {\n client: KnockGuideClient;\n colorMode: ColorMode;\n};\n\nexport const KnockGuideContext = React.createContext<\n KnockGuideProviderValue | undefined\n>(undefined);\n\nexport type KnockGuideProviderProps = {\n channelId: string;\n readyToTarget: boolean;\n listenForUpdates?: boolean;\n colorMode?: ColorMode;\n targetParams?: KnockGuideTargetParams;\n trackLocationFromWindow?: boolean;\n trackDebugParams?: boolean;\n orderResolutionDuration?: number; // in milliseconds\n throttleCheckInterval?: number; // in milliseconds\n};\n\nexport const KnockGuideProvider: React.FC<\n React.PropsWithChildren<KnockGuideProviderProps>\n> = ({\n channelId,\n readyToTarget,\n listenForUpdates = true,\n colorMode = \"light\",\n targetParams = {},\n trackLocationFromWindow = true,\n // Whether the guide client should look for debug params in url/local storage\n // to launch guide toolbar. Set to true if using toolbar v1.\n // TODO(KNO-11523): Remove this once we ship v2.\n trackDebugParams = false,\n // Default to 0 which works well for react apps as this \"yields\" to react for\n // one render cyle first and close the group stage.\n orderResolutionDuration = 0,\n throttleCheckInterval,\n children,\n}) => {\n let knock: Knock;\n\n try {\n knock = useKnockClient();\n } catch (_) {\n throw new Error(\"KnockGuideProvider must be used within a KnockProvider\");\n }\n\n const stableTargetParams = useStableOptions(targetParams);\n\n const knockGuideClient = React.useMemo(() => {\n return new KnockGuideClient(knock, channelId, stableTargetParams, {\n trackLocationFromWindow,\n trackDebugParams,\n orderResolutionDuration,\n throttleCheckInterval,\n });\n }, [\n knock,\n channelId,\n stableTargetParams,\n trackLocationFromWindow,\n trackDebugParams,\n orderResolutionDuration,\n throttleCheckInterval,\n ]);\n\n React.useEffect(() => {\n if (readyToTarget) {\n knockGuideClient.fetch();\n if (listenForUpdates) knockGuideClient.subscribe();\n }\n\n return () => knockGuideClient.cleanup();\n }, [readyToTarget, listenForUpdates, knockGuideClient]);\n\n return (\n <KnockGuideContext.Provider\n value={{\n client: knockGuideClient,\n colorMode,\n }}\n >\n {children}\n </KnockGuideContext.Provider>\n );\n};\n"],"names":["KnockGuideContext","React","createContext","undefined","KnockGuideProvider","channelId","readyToTarget","listenForUpdates","colorMode","targetParams","trackLocationFromWindow","trackDebugParams","orderResolutionDuration","throttleCheckInterval","children","knock","useKnockClient","Error","stableTargetParams","useStableOptions","knockGuideClient","useMemo","KnockGuideClient","useEffect","fetch","subscribe","cleanup","client"],"mappings":";;;;;AAcaA,MAAAA,IAAoBC,EAAMC,cAErCC,MAAS,GAcEC,IAETA,CAAC;AAAA,EACHC,WAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,kBAAAA,IAAmB;AAAA,EACnBC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe,CAAC;AAAA,EAChBC,yBAAAA,IAA0B;AAAA;AAAA;AAAA;AAAA,EAI1BC,kBAAAA,IAAmB;AAAA;AAAA;AAAA,EAGnBC,yBAAAA,IAA0B;AAAA,EAC1BC,uBAAAA;AAAAA,EACAC,UAAAA;AACF,MAAM;AACAC,MAAAA;AAEA,MAAA;AACFA,IAAAA,IAAQC,EAAe;AAAA,UACb;AACJ,UAAA,IAAIC,MAAM,wDAAwD;AAAA,EAAA;AAGpEC,QAAAA,IAAqBC,EAAiBV,CAAY,GAElDW,IAAmBnB,EAAMoB,QAAQ,MAC9B,IAAIC,EAAiBP,GAAOV,GAAWa,GAAoB;AAAA,IAChER,yBAAAA;AAAAA,IACAC,kBAAAA;AAAAA,IACAC,yBAAAA;AAAAA,IACAC,uBAAAA;AAAAA,EAAAA,CACD,GACA,CACDE,GACAV,GACAa,GACAR,GACAC,GACAC,GACAC,CAAqB,CACtB;AAEDZ,SAAAA,EAAMsB,UAAU,OACVjB,MACFc,EAAiBI,MAAM,GACnBjB,OAAmCkB,UAAU,IAG5C,MAAML,EAAiBM,QAAQ,IACrC,CAACpB,GAAeC,GAAkBa,CAAgB,CAAC,GAGnD,gBAAAnB,EAAA,cAAAD,EAAkB,UAAlB,EACC,OAAO;AAAA,IACL2B,QAAQP;AAAAA,IACRZ,WAAAA;AAAAA,OAGDM,CACH;AAEJ;"}
@@ -1,4 +1,4 @@
1
- export { FilterStatus, KnockProvider, feedProviderKey, formatBadgeCount, formatTimestamp, msTeamsProviderKey, renderNodeOrFallback, slackProviderKey, toSentenceCase, type AuthCheckResult, type ColorMode, type ConnectionStatus, type KnockProviderProps, type KnockProviderState, useAuthenticatedKnockClient, useAuthPolling, useAuthPostMessageListener, useKnockClient, useStableOptions, } from './modules/core';
1
+ export { FilterStatus, KnockProvider, feedProviderKey, type BadgeCountType, formatBadgeCount, getBadgeAriaLabel, formatTimestamp, msTeamsProviderKey, renderNodeOrFallback, slackProviderKey, toSentenceCase, type AuthCheckResult, type ColorMode, type ConnectionStatus, type KnockProviderProps, type KnockProviderState, useAuthenticatedKnockClient, useAuthPolling, useAuthPostMessageListener, useKnockClient, useStableOptions, } from './modules/core';
2
2
  export { KnockFeedProvider, type KnockFeedProviderProps, type KnockFeedProviderState, type Selector, useCreateNotificationStore, useFeedSettings, useKnockFeed, useNotificationStore, useNotifications, } from './modules/feed';
3
3
  export { KnockGuideProvider, KnockGuideContext, type KnockGuideProviderProps, useGuide, useGuides, useGuideContext, } from './modules/guide';
4
4
  export { type MsTeamsChannelQueryOptions, type MsTeamsTeamQueryOptions, KnockMsTeamsProvider, type KnockMsTeamsProviderProps, type KnockMsTeamsProviderState, useConnectedMsTeamsChannels, useKnockMsTeamsClient, useMsTeamsAuth, useMsTeamsChannels, useMsTeamsConnectionStatus, useMsTeamsTeams, } from './modules/ms-teams';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,2BAA2B,EAC3B,cAAc,EACd,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,QAAQ,EACR,SAAS,EACT,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,yBAAyB,EACzB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,KAAK,cAAc,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,2BAA2B,EAC3B,cAAc,EACd,0BAA0B,EAC1B,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,QAAQ,EACR,SAAS,EACT,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,yBAAyB,EACzB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export { KnockProvider, useKnockClient, type KnockProviderProps, type KnockProviderState, } from './context';
2
2
  export { useAuthenticatedKnockClient, useStableOptions, useAuthPostMessageListener, useAuthPolling, } from './hooks';
3
3
  export { FilterStatus, type ColorMode } from './constants';
4
- export { formatBadgeCount, formatTimestamp, toSentenceCase, renderNodeOrFallback, feedProviderKey, slackProviderKey, msTeamsProviderKey, } from './utils';
5
- export { type ConnectionStatus, type AuthCheckResult } from './types';
4
+ export { formatBadgeCount, getBadgeAriaLabel, formatTimestamp, toSentenceCase, renderNodeOrFallback, feedProviderKey, slackProviderKey, msTeamsProviderKey, } from './utils';
5
+ export { type BadgeCountType, type ConnectionStatus, type AuthCheckResult, } from './types';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC"}
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Represents the badge count type for notification badges.
3
+ */
4
+ export type BadgeCountType = "unseen" | "unread" | "all";
1
5
  /**
2
6
  * Represents the connection status for OAuth-based integrations (Slack, MS Teams, etc.)
3
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,WAAW,GACX,cAAc,GACd,OAAO,GACP,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE;QACX,EAAE,CAAC,EAAE,OAAO,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE;YACL,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,WAAW,GACX,cAAc,GACd,OAAO,GACP,eAAe,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE;QACX,EAAE,CAAC,EAAE,OAAO,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE;YACL,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH"}
@@ -1,6 +1,15 @@
1
1
  import { default as Knock, FeedClientOptions } from '@knocklabs/client';
2
2
  import { ReactNode } from 'react';
3
+ import { BadgeCountType } from './types';
3
4
  export declare function formatBadgeCount(count: number): string | number;
5
+ /**
6
+ * Returns a string that describes the badge count and type.
7
+ *
8
+ * `all` = "12 notifications"
9
+ * `unread` = "1 unread notification"
10
+ * `unseen` = "7 unseen notifications"
11
+ */
12
+ export declare function getBadgeAriaLabel(count: number, badgeCountType: BadgeCountType): string;
4
13
  type FormatTimestampOptions = {
5
14
  locale?: string | string[];
6
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED,KAAK,sBAAsB,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,sBAA2B,UAYrC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,aAExE;AAMD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,UAYhC;AAMD,wBAAgB,gBAAgB,CAAC,EAC/B,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,UAIA;AAMD,wBAAgB,kBAAkB,CAAC,EACjC,qBAAqB,EACrB,QAAQ,EACR,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,UAIA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,cAAc,GAC7B,MAAM,CAIR;AAED,KAAK,sBAAsB,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,sBAA2B,UAYrC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,aAExE;AAMD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,UAYhC;AAMD,wBAAgB,gBAAgB,CAAC,EAC/B,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,UAIA;AAMD,wBAAgB,kBAAkB,CAAC,EACjC,qBAAqB,EACrB,QAAQ,EACR,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,UAIA"}
@@ -13,6 +13,7 @@ export type KnockGuideProviderProps = {
13
13
  colorMode?: ColorMode;
14
14
  targetParams?: KnockGuideTargetParams;
15
15
  trackLocationFromWindow?: boolean;
16
+ trackDebugParams?: boolean;
16
17
  orderResolutionDuration?: number;
17
18
  throttleCheckInterval?: number;
18
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"KnockGuideProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"names":[],"mappings":"AAAA,OAAc,EACZ,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,oDAElB,CAAC;AAEb,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CACvC,KAAK,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,CA0DjD,CAAC"}
1
+ {"version":3,"file":"KnockGuideProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"names":[],"mappings":"AAAA,OAAc,EACZ,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,oDAElB,CAAC;AAEb,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CACvC,KAAK,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,CAgEjD,CAAC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@knocklabs/react-core",
3
3
  "description": "A set of React components to build notification experiences powered by Knock",
4
4
  "author": "@knocklabs",
5
- "version": "0.13.0",
5
+ "version": "0.13.1",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.mjs",
@@ -47,7 +47,7 @@
47
47
  "react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
48
48
  },
49
49
  "dependencies": {
50
- "@knocklabs/client": "^0.21.0",
50
+ "@knocklabs/client": "^0.21.1",
51
51
  "@tanstack/react-store": "^0.7.3",
52
52
  "date-fns": "^4.0.0",
53
53
  "fast-deep-equal": "^3.1.3",
@@ -75,6 +75,6 @@
75
75
  "vite": "^5.4.19",
76
76
  "vite-plugin-dts": "^4.5.0",
77
77
  "vite-plugin-no-bundle": "^4.0.0",
78
- "vitest": "^3.1.1"
78
+ "vitest": "^3.2.4"
79
79
  }
80
80
  }
package/src/index.ts CHANGED
@@ -2,7 +2,9 @@ export {
2
2
  FilterStatus,
3
3
  KnockProvider,
4
4
  feedProviderKey,
5
+ type BadgeCountType,
5
6
  formatBadgeCount,
7
+ getBadgeAriaLabel,
6
8
  formatTimestamp,
7
9
  msTeamsProviderKey,
8
10
  renderNodeOrFallback,
@@ -13,6 +13,7 @@ export {
13
13
  export { FilterStatus, type ColorMode } from "./constants";
14
14
  export {
15
15
  formatBadgeCount,
16
+ getBadgeAriaLabel,
16
17
  formatTimestamp,
17
18
  toSentenceCase,
18
19
  renderNodeOrFallback,
@@ -20,4 +21,8 @@ export {
20
21
  slackProviderKey,
21
22
  msTeamsProviderKey,
22
23
  } from "./utils";
23
- export { type ConnectionStatus, type AuthCheckResult } from "./types";
24
+ export {
25
+ type BadgeCountType,
26
+ type ConnectionStatus,
27
+ type AuthCheckResult,
28
+ } from "./types";
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Represents the badge count type for notification badges.
3
+ */
4
+ export type BadgeCountType = "unseen" | "unread" | "all";
5
+
1
6
  /**
2
7
  * Represents the connection status for OAuth-based integrations (Slack, MS Teams, etc.)
3
8
  */
@@ -2,10 +2,28 @@ import Knock, { FeedClientOptions } from "@knocklabs/client";
2
2
  import { intlFormatDistance, parseISO } from "date-fns";
3
3
  import { ReactNode } from "react";
4
4
 
5
+ import { BadgeCountType } from "./types";
6
+
5
7
  export function formatBadgeCount(count: number): string | number {
6
8
  return count > 9 ? "9+" : count;
7
9
  }
8
10
 
11
+ /**
12
+ * Returns a string that describes the badge count and type.
13
+ *
14
+ * `all` = "12 notifications"
15
+ * `unread` = "1 unread notification"
16
+ * `unseen` = "7 unseen notifications"
17
+ */
18
+ export function getBadgeAriaLabel(
19
+ count: number,
20
+ badgeCountType: BadgeCountType,
21
+ ): string {
22
+ const qualifier = badgeCountType === "all" ? "" : `${badgeCountType} `;
23
+ const noun = count === 1 ? "notification" : "notifications";
24
+ return `${count} ${qualifier}${noun}`;
25
+ }
26
+
9
27
  type FormatTimestampOptions = {
10
28
  locale?: string | string[];
11
29
  };
@@ -23,6 +23,7 @@ export type KnockGuideProviderProps = {
23
23
  colorMode?: ColorMode;
24
24
  targetParams?: KnockGuideTargetParams;
25
25
  trackLocationFromWindow?: boolean;
26
+ trackDebugParams?: boolean;
26
27
  orderResolutionDuration?: number; // in milliseconds
27
28
  throttleCheckInterval?: number; // in milliseconds
28
29
  };
@@ -36,6 +37,10 @@ export const KnockGuideProvider: React.FC<
36
37
  colorMode = "light",
37
38
  targetParams = {},
38
39
  trackLocationFromWindow = true,
40
+ // Whether the guide client should look for debug params in url/local storage
41
+ // to launch guide toolbar. Set to true if using toolbar v1.
42
+ // TODO(KNO-11523): Remove this once we ship v2.
43
+ trackDebugParams = false,
39
44
  // Default to 0 which works well for react apps as this "yields" to react for
40
45
  // one render cyle first and close the group stage.
41
46
  orderResolutionDuration = 0,
@@ -55,6 +60,7 @@ export const KnockGuideProvider: React.FC<
55
60
  const knockGuideClient = React.useMemo(() => {
56
61
  return new KnockGuideClient(knock, channelId, stableTargetParams, {
57
62
  trackLocationFromWindow,
63
+ trackDebugParams,
58
64
  orderResolutionDuration,
59
65
  throttleCheckInterval,
60
66
  });
@@ -63,6 +69,7 @@ export const KnockGuideProvider: React.FC<
63
69
  channelId,
64
70
  stableTargetParams,
65
71
  trackLocationFromWindow,
72
+ trackDebugParams,
66
73
  orderResolutionDuration,
67
74
  throttleCheckInterval,
68
75
  ]);