diff --git a/src/elements/content-sharing/ContentSharing.js b/src/elements/content-sharing/ContentSharing.js index 5c425753b8..501827fb89 100644 --- a/src/elements/content-sharing/ContentSharing.js +++ b/src/elements/content-sharing/ContentSharing.js @@ -73,6 +73,25 @@ const createAPI = (apiHost, itemID, itemType, token) => version: CLIENT_VERSION, }); +/** + * Top-level React component that initializes the sharing API and renders the content-sharing UI, + * either the feature-flagged ContentSharingV2 wrapped with localization and providers or the legacy SharingModal with an optional custom launch button. + * + * @param {string} [apiHost] - Hostname for the API; defaults to the library's default API hostname. + * @param {React.ReactNode} [children] - Optional children passed into the ContentSharingV2 variant. + * @param {Object} [config] - Configuration object passed to the legacy SharingModal. + * @param {React.ReactElement} [customButton] - Optional custom launch button; when provided it is cloned and wired to open the sharing UI. + * @param {boolean} [displayInModal] - When true, instructs the legacy sharing UI to render inside a modal. + * @param {Object} [features] - Feature-flag map; used to enable the `contentSharingV2` variant. + * @param {boolean} [hasProviders] - When true, wraps ContentSharingV2 with provider context; controls whether Providers is applied. + * @param {string} itemID - Identifier of the item being shared. + * @param {string} itemType - Type of the item being shared. + * @param {string} [language] - Locale code used by the Internationalize wrapper. + * @param {Object} [messages] - Localization messages passed to Internationalize. + * @param {string} [token] - Authorization token used to construct the API client. + * @param {string} [uuid] - Unique identifier used to reset component visibility when it changes. + * @returns {JSX.Element|null} The rendered content-sharing UI (either ContentSharingV2 wrapped with Internationalize and Providers, or the legacy SharingModal and optional launch button), or null while the API is unavailable. + */ function ContentSharing({ apiHost = DEFAULT_HOSTNAME_API, children, @@ -152,4 +171,4 @@ function ContentSharing({ } export { ContentSharing as ContentSharingComponent }; -export default withBlueprintModernization(ContentSharing); +export default withBlueprintModernization(ContentSharing); \ No newline at end of file diff --git a/src/elements/content-sharing/ContentSharingV2.tsx b/src/elements/content-sharing/ContentSharingV2.tsx index 2f076b0838..0fbdd8142f 100644 --- a/src/elements/content-sharing/ContentSharingV2.tsx +++ b/src/elements/content-sharing/ContentSharingV2.tsx @@ -29,6 +29,16 @@ export interface ContentSharingV2Props { itemType: ItemType; } +/** + * Orchestrates fetching item, user, collaborator, and avatar data and renders a UnifiedShareModal when the item is loaded. + * + * This component manages internal state for the item, shared link, collaborators, avatars, roles, and current user, + * resets state when the provided `api` changes, and displays a single error notification on initial data-retrieval failures. + * + * @param itemId - The Box file or folder ID to load and share + * @param itemType - Either `"file"` or `"folder"`, indicating the type of `itemId` + * @returns The rendered UnifiedShareModal element when item data is available, otherwise `null` + */ function ContentSharingV2({ api, children, itemId, itemType }: ContentSharingV2Props) { const [avatarUrlMap, setAvatarUrlMap] = React.useState(null); const [item, setItem] = React.useState(null); @@ -227,4 +237,4 @@ function ContentSharingV2({ api, children, itemId, itemType }: ContentSharingV2P ); } -export default withBlueprintModernization(ContentSharingV2); +export default withBlueprintModernization(ContentSharingV2); \ No newline at end of file