@cord-sdk/react
Advanced tools
Comparing version 0.0.30 to 0.0.31
@@ -15,28 +15,2 @@ 'use strict'; | ||
function useCustomEventListeners(events) { | ||
const [element, setElement] = React.useState(null); | ||
React.useEffect(() => { | ||
if (!element) { | ||
return; | ||
} | ||
const handlers = Object.keys(events).map((event) => { | ||
const callback = events[event]; | ||
const customEventHandler = (e) => { | ||
if (e instanceof CustomEvent) { | ||
callback === null || callback === void 0 ? void 0 : callback(...e.detail); | ||
} | ||
}; | ||
const eventName = `${element.nodeName.toLowerCase()}:${event}`; | ||
element.addEventListener(eventName, customEventHandler); | ||
return [eventName, customEventHandler]; | ||
}); | ||
return () => { | ||
for (const [eventName, handler] of handlers) { | ||
element.removeEventListener(eventName, handler); | ||
} | ||
}; | ||
}, [element, events]); | ||
return setElement; | ||
} | ||
let shouldLogLoadingTime$1 = false; | ||
@@ -57,3 +31,6 @@ let overrideCordScriptUrl = null; | ||
}); | ||
function CordProvider({ clientAuthToken, enableTasks, enableAnnotations, blurScreenshots, showBlurredScreenshots, annotationMode, cordScriptUrl, navigate, threadOptions, children, onInitError, }) { | ||
function CordProvider({ clientAuthToken, enableTasks, enableAnnotations, blurScreenshots, showBlurredScreenshots, annotationMode, cordScriptUrl, navigate, threadOptions, children, onLoad, onInitError, }) { | ||
if ((clientAuthToken === null || clientAuthToken === void 0 ? void 0 : clientAuthToken.length) === 0) { | ||
console.warn(`CordProvider was given an empty string as token. Cord components will not be rendered.`); | ||
} | ||
const [sdk, setSDK] = React.useState(null); | ||
@@ -75,2 +52,14 @@ const [location, setLocation] = React.useState(); | ||
React.useEffect(() => { | ||
if (onLoad) { | ||
if (window.CordSDK) { | ||
onLoad(window.CordSDK); | ||
} | ||
else { | ||
window.addEventListener('cord:load', () => { | ||
onLoad(window.CordSDK); | ||
}); | ||
} | ||
} | ||
}, [onLoad]); | ||
React.useEffect(() => { | ||
var _a; | ||
@@ -81,2 +70,3 @@ if (window.CordSDK) { | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const onLoad = () => { | ||
@@ -119,3 +109,3 @@ if (shouldLogLoadingTime$1) { | ||
navigate, | ||
react_package_version: "0.0.30", | ||
react_package_version: "0.0.31", | ||
thread_options: threadOptions | ||
@@ -168,2 +158,28 @@ ? { | ||
function useCustomEventListeners(events) { | ||
const [element, setElement] = React.useState(null); | ||
React.useEffect(() => { | ||
if (!element) { | ||
return; | ||
} | ||
const handlers = Object.keys(events).map((event) => { | ||
const callback = events[event]; | ||
const customEventHandler = (e) => { | ||
if (e instanceof CustomEvent) { | ||
callback === null || callback === void 0 ? void 0 : callback(...e.detail); | ||
} | ||
}; | ||
const eventName = `${element.nodeName.toLowerCase()}:${event}`; | ||
element.addEventListener(eventName, customEventHandler); | ||
return [eventName, customEventHandler]; | ||
}); | ||
return () => { | ||
for (const [eventName, handler] of handlers) { | ||
element.removeEventListener(eventName, handler); | ||
} | ||
}; | ||
}, [element, events]); | ||
return setElement; | ||
} | ||
function useCordLocation(newLocation) { | ||
@@ -186,17 +202,10 @@ const { location, setLocation } = useCordContext$1('useCordLocation'); | ||
const propsToAttributes$i = components.propsToAttributeConverter(components.componentAttributes.Collaboration); | ||
function Collaboration(props) { | ||
const setRef = useCustomEventListeners({}); | ||
const location = useCordLocation(); | ||
return (React__default["default"].createElement("cord-collaboration", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$i({ location, ...props }) })); | ||
} | ||
const propsToAttributes$h = components.propsToAttributeConverter(components.componentAttributes.MultipleCursors); | ||
const propsToAttributes$g = components.propsToAttributeConverter(components.componentAttributes.MultipleCursors); | ||
function MultipleCursors(props) { | ||
const setRef = useCustomEventListeners({}); | ||
const location = useCordLocation(); | ||
return (React__default["default"].createElement("cord-multiple-cursors", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$h({ location, ...props }) })); | ||
return (React__default["default"].createElement("cord-multiple-cursors", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$g({ location, ...props }) })); | ||
} | ||
const propsToAttributes$g = components.propsToAttributeConverter(components.componentAttributes.PagePresence); | ||
const propsToAttributes$f = components.propsToAttributeConverter(components.componentAttributes.PagePresence); | ||
function PagePresence(props) { | ||
@@ -208,6 +217,6 @@ const { onUpdate } = props; | ||
const location = useCordLocation(); | ||
return (React__default["default"].createElement("cord-page-presence", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$g({ location, ...props }) })); | ||
return (React__default["default"].createElement("cord-page-presence", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$f({ location, ...props }) })); | ||
} | ||
const propsToAttributes$f = components.propsToAttributeConverter(components.componentAttributes.PresenceFacepile); | ||
const propsToAttributes$e = components.propsToAttributeConverter(components.componentAttributes.PresenceFacepile); | ||
function PresenceFacepile(props) { | ||
@@ -219,6 +228,6 @@ const { onUpdate } = props; | ||
const location = useCordLocation(); | ||
return (React__default["default"].createElement("cord-presence-facepile", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$f({ location, ...props }) })); | ||
return (React__default["default"].createElement("cord-presence-facepile", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$e({ location, ...props }) })); | ||
} | ||
const propsToAttributes$e = components.propsToAttributeConverter(components.componentAttributes.PresenceObserver); | ||
const propsToAttributes$d = components.propsToAttributeConverter(components.componentAttributes.PresenceObserver); | ||
function PresenceObserver(props) { | ||
@@ -230,3 +239,3 @@ const { onChange } = props; | ||
const location = useCordLocation(); | ||
return (React__default["default"].createElement("cord-presence-observer", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$e({ location, ...props }) }, props.children)); | ||
return (React__default["default"].createElement("cord-presence-observer", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$d({ location, ...props }) }, props.children)); | ||
} | ||
@@ -243,2 +252,3 @@ | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const updateForwardedRef = (element) => { | ||
@@ -291,3 +301,3 @@ if (typeof forwardedRef === 'function') { | ||
const propsToAttributes$d = components.propsToAttributeConverter(components.componentAttributes.Sidebar); | ||
const propsToAttributes$c = components.propsToAttributeConverter(components.componentAttributes.Sidebar); | ||
function SidebarWithForwardedRef(props, forwardedRef) { | ||
@@ -302,7 +312,7 @@ const { onOpen, onClose, onThreadOpen, onThreadClose } = props; | ||
const location = useCordLocation(); | ||
return (React__default["default"].createElement("cord-sidebar", { id: props.id, class: props.className, style: props.style, ref: ref, ...propsToAttributes$d({ location, ...props }) })); | ||
return (React__default["default"].createElement("cord-sidebar", { id: props.id, class: props.className, style: props.style, ref: ref, ...propsToAttributes$c({ location, ...props }) })); | ||
} | ||
const Sidebar = React__default["default"].forwardRef(SidebarWithForwardedRef); | ||
const propsToAttributes$c = components.propsToAttributeConverter(components.componentAttributes.SidebarLauncher); | ||
const propsToAttributes$b = components.propsToAttributeConverter(components.componentAttributes.SidebarLauncher); | ||
function SidebarLauncher(props) { | ||
@@ -313,14 +323,5 @@ const { onClick } = props; | ||
}); | ||
return (React__default["default"].createElement("cord-sidebar-launcher", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$c(props) })); | ||
return (React__default["default"].createElement("cord-sidebar-launcher", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$b(props) })); | ||
} | ||
const propsToAttributes$b = components.propsToAttributeConverter(components.componentAttributes.Text); | ||
function Text(props) { | ||
const { onBoop } = props; | ||
const setRef = useCustomEventListeners({ | ||
boop: onBoop, | ||
}); | ||
return (React__default["default"].createElement("cord-text", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$b(props) })); | ||
} | ||
const propsToAttributes$a = components.propsToAttributeConverter(components.componentAttributes.Thread); | ||
@@ -332,2 +333,4 @@ function Thread(props) { | ||
resolved: props.onResolved, | ||
render: props.onRender, | ||
loading: props.onLoading, | ||
}); | ||
@@ -440,3 +443,3 @@ const combinedSetRef = React.useCallback((element) => { | ||
function useCordPresentUsers(location, options = {}) { | ||
const { excludeViewer = false, includeUserDetails = false, onlyPresentUsers = false, exactMatch = false, } = options; | ||
const { excludeViewer = false, includeUserDetails = false, onlyPresentUsers = false, partialMatch = false, } = options; | ||
const { sdk } = useCordContext$1('useCordPresentUsers'); | ||
@@ -455,2 +458,3 @@ const presenceSDK = sdk === null || sdk === void 0 ? void 0 : sdk.presence; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const location = JSON.parse(locationString); | ||
@@ -462,2 +466,3 @@ let current = true; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
setUserLocations((userLocations) => ({ | ||
@@ -470,6 +475,6 @@ ...userLocations, | ||
})); | ||
}, location, { exact_match: exactMatch }); | ||
}, location, { partial_match: partialMatch }); | ||
presenceSDK | ||
.getPresent(location, { | ||
exact_match: exactMatch, | ||
partial_match: partialMatch, | ||
exclude_durable: onlyPresentUsers, | ||
@@ -486,3 +491,3 @@ }) | ||
}; | ||
}, [presenceSDK, locationString, exactMatch, onlyPresentUsers]); | ||
}, [presenceSDK, locationString, partialMatch, onlyPresentUsers]); | ||
const userDetailsListenersRef = React.useRef(new Map()); | ||
@@ -501,2 +506,3 @@ const mountedRef = React.useRef(true); | ||
if (mountedRef.current) { | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
setUserDetails((userDetails) => ({ | ||
@@ -717,3 +723,5 @@ ...userDetails, | ||
const [ids, setIds] = React.useState([]); | ||
const [fetchMore, setFetchMore] = React.useState((_) => (_) => { }); | ||
const [fetchMore, setFetchMore] = React.useState( | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
(_) => (_) => { }); | ||
const { sdk } = useCordContext$1('useCordThreadIDs'); | ||
@@ -728,3 +736,5 @@ const threadsSDK = sdk === null || sdk === void 0 ? void 0 : sdk.experimental.threads; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const location = JSON.parse(locationString); | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const key = threadsSDK.observeThreadIDs(location, ({ ids, fetchMore }) => { | ||
@@ -749,2 +759,3 @@ setIds(ids); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const key = threadsSDK.observeThreadSummary(id, (summary) => setSummary(summary)); | ||
@@ -766,3 +777,2 @@ return () => { | ||
exports.Collaboration = Collaboration; | ||
exports.CordContext = CordContext; | ||
@@ -779,3 +789,2 @@ exports.CordProvider = CordProvider; | ||
exports.SidebarLauncher = SidebarLauncher; | ||
exports.Text = Text; | ||
exports.Thread = Thread; | ||
@@ -782,0 +791,0 @@ exports.ThreadList = ThreadList; |
@@ -10,6 +10,9 @@ import type { PropsWithChildren } from 'react'; | ||
showHeader?: boolean; | ||
composerExpanded?: boolean; | ||
onThreadInfoChange?: (...args: ThreadWebComponentEvents['threadinfochange']) => unknown; | ||
onClose?: (...args: ThreadWebComponentEvents['close']) => unknown; | ||
onResolved?: (...args: ThreadWebComponentEvents['resolved']) => unknown; | ||
onRender?: (...args: ThreadWebComponentEvents['render']) => unknown; | ||
onLoading?: (...args: ThreadWebComponentEvents['loading']) => unknown; | ||
}>; | ||
export declare function Thread(props: PropsWithRef<PropsWithChildren<ReactPropsWithStandardHTMLAttributes<ThreadReactComponentProps>>>): JSX.Element; |
import React from 'react'; | ||
import type { AnnotationMode, BlurDisplayLocation, ICordSDK, Location, NavigateFn, InitErrorCallback } from '@cord-sdk/types'; | ||
import type { AnnotationMode, BlurDisplayLocation, ICordSDK, Location, NavigateFn, InitErrorCallback, LoadCallback } from '@cord-sdk/types'; | ||
declare type CordContextValue = { | ||
@@ -24,2 +24,3 @@ sdk: ICordSDK | null; | ||
annotationMode?: AnnotationMode; | ||
onLoad?: LoadCallback; | ||
onInitError?: InitErrorCallback; | ||
@@ -30,3 +31,3 @@ }; | ||
}; | ||
export declare function CordProvider({ clientAuthToken, enableTasks, enableAnnotations, blurScreenshots, showBlurredScreenshots, annotationMode, cordScriptUrl, navigate, threadOptions, children, onInitError, }: React.PropsWithChildren<Props>): JSX.Element; | ||
export declare function CordProvider({ clientAuthToken, enableTasks, enableAnnotations, blurScreenshots, showBlurredScreenshots, annotationMode, cordScriptUrl, navigate, threadOptions, children, onLoad, onInitError, }: React.PropsWithChildren<Props>): JSX.Element; | ||
export declare function useCordContext(hook: string): { | ||
@@ -33,0 +34,0 @@ sdk: ICordSDK | null; |
@@ -5,3 +5,3 @@ import type { User, Location, UserPresenceInformation } from '@cord-sdk/types'; | ||
onlyPresentUsers?: boolean; | ||
exactMatch?: boolean; | ||
partialMatch?: boolean; | ||
includeUserDetails?: boolean; | ||
@@ -8,0 +8,0 @@ }; |
@@ -1,2 +0,1 @@ | ||
export { Collaboration, CollaborationReactComponentProps, } from './components/Collaboration'; | ||
export { CordProvider, CordContext } from './contexts/CordContext'; | ||
@@ -9,3 +8,2 @@ export { MultipleCursors, MultipleCursorsReactComponentProps, } from './components/MultipleCursors'; | ||
export { SidebarLauncher, SidebarLauncherReactComponentProps, } from './components/SidebarLauncher'; | ||
export { Text, TextReactComponentProps } from './components/Text'; | ||
export { Thread, ThreadReactComponentProps } from './components/Thread'; | ||
@@ -12,0 +10,0 @@ export { ThreadList, ThreadListReactComponentProps, } from './components/ThreadList'; |
@@ -1,2 +0,2 @@ | ||
import React, { useState, useEffect, useRef, useMemo, useContext, useCallback } from 'react'; | ||
import React, { useState, useRef, useEffect, useMemo, useContext, useCallback } from 'react'; | ||
import { propsToAttributeConverter, componentAttributes } from '@cord-sdk/components'; | ||
@@ -6,28 +6,2 @@ import isEqual from 'lodash/isEqual.js'; | ||
function useCustomEventListeners(events) { | ||
const [element, setElement] = useState(null); | ||
useEffect(() => { | ||
if (!element) { | ||
return; | ||
} | ||
const handlers = Object.keys(events).map((event) => { | ||
const callback = events[event]; | ||
const customEventHandler = (e) => { | ||
if (e instanceof CustomEvent) { | ||
callback === null || callback === void 0 ? void 0 : callback(...e.detail); | ||
} | ||
}; | ||
const eventName = `${element.nodeName.toLowerCase()}:${event}`; | ||
element.addEventListener(eventName, customEventHandler); | ||
return [eventName, customEventHandler]; | ||
}); | ||
return () => { | ||
for (const [eventName, handler] of handlers) { | ||
element.removeEventListener(eventName, handler); | ||
} | ||
}; | ||
}, [element, events]); | ||
return setElement; | ||
} | ||
let shouldLogLoadingTime$1 = false; | ||
@@ -48,3 +22,6 @@ let overrideCordScriptUrl = null; | ||
}); | ||
function CordProvider({ clientAuthToken, enableTasks, enableAnnotations, blurScreenshots, showBlurredScreenshots, annotationMode, cordScriptUrl, navigate, threadOptions, children, onInitError, }) { | ||
function CordProvider({ clientAuthToken, enableTasks, enableAnnotations, blurScreenshots, showBlurredScreenshots, annotationMode, cordScriptUrl, navigate, threadOptions, children, onLoad, onInitError, }) { | ||
if ((clientAuthToken === null || clientAuthToken === void 0 ? void 0 : clientAuthToken.length) === 0) { | ||
console.warn(`CordProvider was given an empty string as token. Cord components will not be rendered.`); | ||
} | ||
const [sdk, setSDK] = useState(null); | ||
@@ -66,2 +43,14 @@ const [location, setLocation] = useState(); | ||
useEffect(() => { | ||
if (onLoad) { | ||
if (window.CordSDK) { | ||
onLoad(window.CordSDK); | ||
} | ||
else { | ||
window.addEventListener('cord:load', () => { | ||
onLoad(window.CordSDK); | ||
}); | ||
} | ||
} | ||
}, [onLoad]); | ||
useEffect(() => { | ||
var _a; | ||
@@ -72,2 +61,3 @@ if (window.CordSDK) { | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const onLoad = () => { | ||
@@ -110,3 +100,3 @@ if (shouldLogLoadingTime$1) { | ||
navigate, | ||
react_package_version: "0.0.30", | ||
react_package_version: "0.0.31", | ||
thread_options: threadOptions | ||
@@ -159,2 +149,28 @@ ? { | ||
function useCustomEventListeners(events) { | ||
const [element, setElement] = useState(null); | ||
useEffect(() => { | ||
if (!element) { | ||
return; | ||
} | ||
const handlers = Object.keys(events).map((event) => { | ||
const callback = events[event]; | ||
const customEventHandler = (e) => { | ||
if (e instanceof CustomEvent) { | ||
callback === null || callback === void 0 ? void 0 : callback(...e.detail); | ||
} | ||
}; | ||
const eventName = `${element.nodeName.toLowerCase()}:${event}`; | ||
element.addEventListener(eventName, customEventHandler); | ||
return [eventName, customEventHandler]; | ||
}); | ||
return () => { | ||
for (const [eventName, handler] of handlers) { | ||
element.removeEventListener(eventName, handler); | ||
} | ||
}; | ||
}, [element, events]); | ||
return setElement; | ||
} | ||
function useCordLocation(newLocation) { | ||
@@ -177,17 +193,10 @@ const { location, setLocation } = useCordContext$1('useCordLocation'); | ||
const propsToAttributes$i = propsToAttributeConverter(componentAttributes.Collaboration); | ||
function Collaboration(props) { | ||
const setRef = useCustomEventListeners({}); | ||
const location = useCordLocation(); | ||
return (React.createElement("cord-collaboration", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$i({ location, ...props }) })); | ||
} | ||
const propsToAttributes$h = propsToAttributeConverter(componentAttributes.MultipleCursors); | ||
const propsToAttributes$g = propsToAttributeConverter(componentAttributes.MultipleCursors); | ||
function MultipleCursors(props) { | ||
const setRef = useCustomEventListeners({}); | ||
const location = useCordLocation(); | ||
return (React.createElement("cord-multiple-cursors", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$h({ location, ...props }) })); | ||
return (React.createElement("cord-multiple-cursors", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$g({ location, ...props }) })); | ||
} | ||
const propsToAttributes$g = propsToAttributeConverter(componentAttributes.PagePresence); | ||
const propsToAttributes$f = propsToAttributeConverter(componentAttributes.PagePresence); | ||
function PagePresence(props) { | ||
@@ -199,6 +208,6 @@ const { onUpdate } = props; | ||
const location = useCordLocation(); | ||
return (React.createElement("cord-page-presence", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$g({ location, ...props }) })); | ||
return (React.createElement("cord-page-presence", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$f({ location, ...props }) })); | ||
} | ||
const propsToAttributes$f = propsToAttributeConverter(componentAttributes.PresenceFacepile); | ||
const propsToAttributes$e = propsToAttributeConverter(componentAttributes.PresenceFacepile); | ||
function PresenceFacepile(props) { | ||
@@ -210,6 +219,6 @@ const { onUpdate } = props; | ||
const location = useCordLocation(); | ||
return (React.createElement("cord-presence-facepile", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$f({ location, ...props }) })); | ||
return (React.createElement("cord-presence-facepile", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$e({ location, ...props }) })); | ||
} | ||
const propsToAttributes$e = propsToAttributeConverter(componentAttributes.PresenceObserver); | ||
const propsToAttributes$d = propsToAttributeConverter(componentAttributes.PresenceObserver); | ||
function PresenceObserver(props) { | ||
@@ -221,3 +230,3 @@ const { onChange } = props; | ||
const location = useCordLocation(); | ||
return (React.createElement("cord-presence-observer", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$e({ location, ...props }) }, props.children)); | ||
return (React.createElement("cord-presence-observer", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$d({ location, ...props }) }, props.children)); | ||
} | ||
@@ -234,2 +243,3 @@ | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const updateForwardedRef = (element) => { | ||
@@ -282,3 +292,3 @@ if (typeof forwardedRef === 'function') { | ||
const propsToAttributes$d = propsToAttributeConverter(componentAttributes.Sidebar); | ||
const propsToAttributes$c = propsToAttributeConverter(componentAttributes.Sidebar); | ||
function SidebarWithForwardedRef(props, forwardedRef) { | ||
@@ -293,7 +303,7 @@ const { onOpen, onClose, onThreadOpen, onThreadClose } = props; | ||
const location = useCordLocation(); | ||
return (React.createElement("cord-sidebar", { id: props.id, class: props.className, style: props.style, ref: ref, ...propsToAttributes$d({ location, ...props }) })); | ||
return (React.createElement("cord-sidebar", { id: props.id, class: props.className, style: props.style, ref: ref, ...propsToAttributes$c({ location, ...props }) })); | ||
} | ||
const Sidebar = React.forwardRef(SidebarWithForwardedRef); | ||
const propsToAttributes$c = propsToAttributeConverter(componentAttributes.SidebarLauncher); | ||
const propsToAttributes$b = propsToAttributeConverter(componentAttributes.SidebarLauncher); | ||
function SidebarLauncher(props) { | ||
@@ -304,14 +314,5 @@ const { onClick } = props; | ||
}); | ||
return (React.createElement("cord-sidebar-launcher", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$c(props) })); | ||
return (React.createElement("cord-sidebar-launcher", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$b(props) })); | ||
} | ||
const propsToAttributes$b = propsToAttributeConverter(componentAttributes.Text); | ||
function Text(props) { | ||
const { onBoop } = props; | ||
const setRef = useCustomEventListeners({ | ||
boop: onBoop, | ||
}); | ||
return (React.createElement("cord-text", { id: props.id, class: props.className, style: props.style, ref: setRef, ...propsToAttributes$b(props) })); | ||
} | ||
const propsToAttributes$a = propsToAttributeConverter(componentAttributes.Thread); | ||
@@ -323,2 +324,4 @@ function Thread(props) { | ||
resolved: props.onResolved, | ||
render: props.onRender, | ||
loading: props.onLoading, | ||
}); | ||
@@ -431,3 +434,3 @@ const combinedSetRef = useCallback((element) => { | ||
function useCordPresentUsers(location, options = {}) { | ||
const { excludeViewer = false, includeUserDetails = false, onlyPresentUsers = false, exactMatch = false, } = options; | ||
const { excludeViewer = false, includeUserDetails = false, onlyPresentUsers = false, partialMatch = false, } = options; | ||
const { sdk } = useCordContext$1('useCordPresentUsers'); | ||
@@ -446,2 +449,3 @@ const presenceSDK = sdk === null || sdk === void 0 ? void 0 : sdk.presence; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const location = JSON.parse(locationString); | ||
@@ -453,2 +457,3 @@ let current = true; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
setUserLocations((userLocations) => ({ | ||
@@ -461,6 +466,6 @@ ...userLocations, | ||
})); | ||
}, location, { exact_match: exactMatch }); | ||
}, location, { partial_match: partialMatch }); | ||
presenceSDK | ||
.getPresent(location, { | ||
exact_match: exactMatch, | ||
partial_match: partialMatch, | ||
exclude_durable: onlyPresentUsers, | ||
@@ -477,3 +482,3 @@ }) | ||
}; | ||
}, [presenceSDK, locationString, exactMatch, onlyPresentUsers]); | ||
}, [presenceSDK, locationString, partialMatch, onlyPresentUsers]); | ||
const userDetailsListenersRef = useRef(new Map()); | ||
@@ -492,2 +497,3 @@ const mountedRef = useRef(true); | ||
if (mountedRef.current) { | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
setUserDetails((userDetails) => ({ | ||
@@ -708,3 +714,5 @@ ...userDetails, | ||
const [ids, setIds] = useState([]); | ||
const [fetchMore, setFetchMore] = useState((_) => (_) => { }); | ||
const [fetchMore, setFetchMore] = useState( | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
(_) => (_) => { }); | ||
const { sdk } = useCordContext$1('useCordThreadIDs'); | ||
@@ -719,3 +727,5 @@ const threadsSDK = sdk === null || sdk === void 0 ? void 0 : sdk.experimental.threads; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const location = JSON.parse(locationString); | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const key = threadsSDK.observeThreadIDs(location, ({ ids, fetchMore }) => { | ||
@@ -740,2 +750,3 @@ setIds(ids); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-shadow -- Disabling for pre-existing problems. Please do not copy this comment, and consider fixing this one! | ||
const key = threadsSDK.observeThreadSummary(id, (summary) => setSummary(summary)); | ||
@@ -757,3 +768,3 @@ return () => { | ||
export { Collaboration, CordContext, CordProvider, Inbox, InboxLauncher, MultipleCursors, PagePresence, PresenceFacepile, PresenceObserver, Settings, Sidebar, SidebarLauncher, Text, Thread, ThreadList, beta, experimental, useCordAnnotationCaptureHandler, useCordAnnotationClickHandler, useCordAnnotationRenderer, useCordAnnotationTargetRef, useCordContext, useCordLocation, useCordPresentUsers, useCordThreadActivitySummary }; | ||
export { CordContext, CordProvider, Inbox, InboxLauncher, MultipleCursors, PagePresence, PresenceFacepile, PresenceObserver, Settings, Sidebar, SidebarLauncher, Thread, ThreadList, beta, experimental, useCordAnnotationCaptureHandler, useCordAnnotationClickHandler, useCordAnnotationRenderer, useCordAnnotationTargetRef, useCordContext, useCordLocation, useCordPresentUsers, useCordThreadActivitySummary }; | ||
//# sourceMappingURL=index.js.map |
@@ -18,3 +18,7 @@ import type React from 'react'; | ||
onlyPresentUsers?: boolean; | ||
/** | ||
* @deprecated The exactMatch prop has been replaced by partialMatch. | ||
*/ | ||
exactMatch?: boolean; | ||
partialMatch?: boolean; | ||
}>; | ||
@@ -21,0 +25,0 @@ export declare type PropsWithRef<T> = T & { |
{ | ||
"name": "@cord-sdk/react", | ||
"description": "React components for Cord", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"homepage": "https://docs.cord.com/", | ||
@@ -22,4 +22,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@cord-sdk/types": "0.0.30", | ||
"@cord-sdk/components": "0.0.30", | ||
"@cord-sdk/types": "0.0.31", | ||
"@cord-sdk/components": "0.0.31", | ||
"lodash": "^4.17.21" | ||
@@ -31,3 +31,3 @@ }, | ||
"devDependencies": { | ||
"@cord-sdk/jsx": "0.0.30", | ||
"@cord-sdk/jsx": "0.0.31", | ||
"@types/lodash-es": "^4.17.6", | ||
@@ -34,0 +34,0 @@ "@types/react": "^17.0.43", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90024
1778
41
1
+ Added@cord-sdk/components@0.0.31(transitive)
+ Added@cord-sdk/types@0.0.31(transitive)
- Removed@cord-sdk/components@0.0.30(transitive)
- Removed@cord-sdk/types@0.0.30(transitive)
Updated@cord-sdk/components@0.0.31
Updated@cord-sdk/types@0.0.31