import { ID, PutShareResponse, RightStringified, ShareRight, ShareRightAction, ShareRightActionDisplayName, ShareUrls } from '@edifice.io/client'; import { UseMutationResult } from '@tanstack/react-query'; /** * Configuration options for sharing a resource * * @typedef {Object} ShareOptions * @property {ID} resourceId - Unique identifier of the resource to share * @property {RightStringified[]} resourceRights - Current rights assigned to the resource * @property {string} resourceCreatorId - User ID of the resource creator * @property {string} resourceCreatorDisplayName - (optional) Name of the resource creator to display * @property {ShareRightActionDisplayName[]} [filteredActions] - Optional list of allowed actions to display * @property {ShareUrls} [shareUrls] - Optional custom URLs for API endpoints related to sharing operations default endpoints are used if not provided * default: { * getResourceRights: `/${app}/share/json/${resourceId}?search=`, * saveResourceRights: `/${app}/share/resource/${resourceId}`, * getShareMapping: `/${app}/rights/sharing` * } * * @example Example related to sharing thread resources: * ```ts * const shareOptions: ShareOptions = { * resourceId: '12345', * resourceRights: [], * resourceCreatorId: 'user-67890', * filteredActions: ['read', 'contrib'], * defaultActions: [ * { * id: 'read', * displayName: 'read', * }, * ], * shareUrls: { * getResourceRights: '/api/V1/thread/shares', (get endpoint) * saveResourceRights: '/api/V1/thread/shares', (put endpoint) * getShareMapping: '/api/V1/rights/sharing' * } * }; * ``` * * @example Example related to sharing info resources: * ```ts * const shareOptions: ShareOptions = { * resourceId: '12345', * resourceRights: [], * resourceCreatorId: 'user-67890', * resourceCreatorDisplayName: 'Jim', * filteredActions: ['read', 'contrib'], * defaultActions: [ * { * id: 'read', * displayName: 'read', * }, * ], * shareUrls: { * getResourceRights: '/api/V1/info/shares', (get endpoint) * saveResourceRights: '/api/V1/info/shares', (put endpoint) * getShareMapping: '/api/V1/rights/sharing' * } * }; * ``` */ export type ShareOptions = { resourceId: ID; resourceRights: RightStringified[]; resourceCreatorId: string; resourceCreatorDisplayName?: string; filteredActions?: ShareRightActionDisplayName[]; shareUrls?: ShareUrls; defaultActions?: ShareRightAction[]; }; /** * React Query mutation result for share operations * * @typedef {UseMutationResult} ShareResourceMutation */ export type ShareResourceMutation = UseMutationResult; /** * Props for the ShareResources component * * @interface ShareResourceProps * @property {ShareOptions} shareOptions - Configuration for the resource being shared * @property {ShareResourceMutation} [shareResource] - Optional React Query mutation for optimistic UI updates * @property {() => void} [onSuccess] - Callback fired after successful share operation * @property {(shareRights: ShareRight[], isDirty: boolean) => void} [onChange] - Callback fired when share rights change * @property {(isSubmitting: boolean) => void} [onSubmit] - Callback fired when share operation is submitting * @property {string} [classNameSearchInput] - Optional CSS class for the search input wrapper (default: 'col-6') */ interface ShareResourceProps { /** * Expect resourceId, * new rights array (replace shared array), * creatorId * of a resource */ shareOptions: ShareOptions; /** * Use the `shareResource` props when you need to do Optimistic UI * otherwise ShareModal handles everything * Must use React Query */ shareResource?: ShareResourceMutation; /** * onSuccess callback when a resource is successfully shared */ onSuccess?: () => void; /** * Callback when share rights change */ onChange?: (shareRights: ShareRight[], isDirty: boolean) => void; /** * Callback when ShareResources component is submitting share rights or bookmark changes */ onSubmit?: (isSubmitting: boolean) => void; /** * Optional className for the search input wrapper (default: 'col-6') */ classNameSearchInput?: string; } /** * Ref interface exposed by ShareResources component. * Use useRef with this type and call ref.current?.handleShare() to trigger share programmatically. * * @interface ShareResourcesRef * @property {() => void} handleShare - Method to trigger the share operation */ export interface ShareResourcesRef { handleShare: (notify?: boolean) => void; } /** * ShareResources Component * * A component for managing resource sharing permissions with users and groups. * Provides search functionality, bookmark management, and granular rights control. * Use forwardRef to get a ref with handleShare(). See ShareResourcesRef interface. * * @component * @forwardRef */ declare const ShareResources: import('react').ForwardRefExoticComponent>; export default ShareResources;