import { useActionQuery } from "../use-action.js"; import { type ShareVisibilityTransition } from "./useShareVisibilityTransition.js"; export type ShareButtonVisibility = "private" | "org" | "public"; export type ShareButtonRole = "viewer" | "commenter" | "editor" | "admin"; export interface ShareButtonShare { id: string; principalType: "user" | "group" | "org"; principalId: string; displayName?: string | null; role: ShareButtonRole; } export interface ShareButtonGroup { id: string; name: string; memberEmails?: string[]; } export interface ShareButtonSharesResponse { ownerEmail: string | null; orgId: string | null; visibility: ShareButtonVisibility | null; role?: "owner" | ShareButtonRole; agentReadable?: boolean; shares: ShareButtonShare[]; policy?: { allowPublic: boolean; requireOrgMemberForUserShares: boolean; supportsGroupShares?: boolean; }; } export interface ShareButtonOrgMember { email: string; name?: string | null; image?: string | null; role?: string | null; joinedAt?: number | null; } export interface ShareButtonOrgMemberSearch { members: ShareButtonOrgMember[]; isLoading: boolean; isLoadingMore: boolean; hasMore: boolean; error: boolean; loadMore: () => void; } export interface ShareButtonControllerOptions { resourceType: string; resourceId: string; defaultOpen?: boolean; onOpenChange?: (open: boolean) => void; onShareSuccess?: () => void; shareTabs?: { defaultValue?: string; onValueChange?: (value: string) => void; }; shareUrl?: string; allowedRoles?: readonly ShareButtonRole[]; hideInSearchControl?: { checked: boolean; pending?: boolean; onCheckedChange: (checked: boolean) => void | Promise; }; } export interface ShareButtonController { open: boolean; handleOpenChange: (open: boolean) => void; activeShareTab: string; handleShareTabChange: (value: string) => void; inviteEmail: string; setInviteEmail: (email: string) => void; sharesQuery: ReturnType>; visibilityOverride: ShareButtonVisibility | null; /** * @deprecated Use `visibilityTransition.request`, which this calls. It * resolves only once the change is persisted. A direct change rejects when * its save fails. A private-to-Organization change stays pending through * `visibilityTransition.confirm()` failures (retry is possible) and rejects * with `ShareVisibilityNotSavedError` once it is cancelled or invalidated. * Without manage rights it * sets `shareError` and resolves, as it always has. */ handleVisibilityChange: (visibility: ShareButtonVisibility) => Promise; /** Request, confirm and cancel a visibility change that needs confirming. */ visibilityTransition: ShareVisibilityTransition; data: ShareButtonSharesResponse | undefined; policy: { allowPublic: boolean; requireOrgMemberForUserShares: boolean; supportsGroupShares?: boolean; }; visibility: ShareButtonVisibility; triggerVisibility: ShareButtonVisibility | null; canManage: boolean; role: ShareButtonRole; setRole: (role: ShareButtonRole) => void; notifyPeople: boolean; setNotifyPeople: (notify: boolean) => void; shareMessage: string; setShareMessage: (message: string) => void; messageOpen: boolean; setMessageOpen: (open: boolean) => void; shareError: string | null; setShareError: (error: string | null) => void; suggestionsOpen: boolean; setSuggestionsOpen: (open: boolean) => void; inFlight: Set; memberSearch: ShareButtonOrgMemberSearch; memberSuggestions: ShareButtonOrgMember[]; groupSuggestions: ShareButtonGroup[]; knownMembers: ShareButtonOrgMember[]; selectedGroup: ShareButtonGroup | null; selectGroup: (group: ShareButtonGroup) => void; shares: ShareButtonShare[]; handleVisibility: (visibility: ShareButtonVisibility) => void; handleHideInSearch: () => void; handleAdd: () => void; handleChangeRole: (share: ShareButtonShare, role: ShareButtonRole) => void; handleRemove: (share: ShareButtonShare) => void; } export declare function useShareButtonController(options: ShareButtonControllerOptions): ShareButtonController;