import { DatePickerProps, ModalContentProps } from '@box/blueprint-web'; import { FetchedAvatarUrls, UserContactType } from '@box/user-selector'; /** * The date value type returned from the DatePicker component. */ export type DateValue = Parameters[0]; /** * Variants of the Unified Share Modal. */ export type VariantType = 'desktop' | 'modal'; /** * View states in the Unified Share Modal. * * - `unified-share-form` - The sharing form where users can invite collaborators and manage shared links * - `shared-link-settings` - A focused view for configuring the shared link settings and permissions * - `remove-shared-link` - A confirmation view for removing an existing shared link * - `remove-collaborator` - A confirmation view for removing an existing collaborator */ export type ViewType = 'unified-share-form' | 'shared-link-settings' | 'remove-shared-link' | 'remove-collaborator'; /** * Form states in the Unified Share Modal. */ export type FormType = 'default' | 'invite' | 'email'; /** * Supported success and error notifications when the user performs sharing actions. */ export type NotificationType = 'invite-collaborators' | 'remove-collaborator' | 'create-shared-link' | 'delete-shared-link' | 'update-shared-link' | 'email-shared-link' | 'auto-copy-shared-link'; /** * Supported roles for inviting a new collaborator. The available roles are dependent on the Enterprise settings. * * The `owner` role is not supported when inviting a new collaborator. */ export type InvitationRole = 'co_owner' | 'editor' | 'previewer' | 'previewer_uploader' | 'uploader' | 'viewer' | 'viewer_uploader'; /** * Supported access levels for a shared link. The allowed access levels are dependent on the Enterprise settings. */ export type AccessLevelType = 'open' | 'company' | 'collaborators'; /** * Shield policies that restrict access or permissions on the item. */ export type ShieldPolicyType = 'access_policy' | 'malicious_content' | 'information_barrier'; /** * Supported permission levels for a shared link. The allowed permission levels are dependent on the Item and Enterprise settings. */ export type PermissionLevelType = 'can_edit' | 'can_download' | 'can_preview'; /** * Supported item types in the Unified Share Modal. */ export type ItemType = 'file' | 'folder' | 'hubs' | 'prompt' | 'web_link' | 'workflow'; export interface Item { /** * The classification of the item. */ classification?: Classification; /** * The extension of the file. */ extension?: string; /** * The ID of the item. */ id: string; /** * The name of the item. */ name: string; /** * The permissions that the current user has for the item. */ permissions?: { /** * When `true`, the user can invite collaborators on the item. */ canInviteCollaborator?: boolean; /** * When `true`, the user can remove collaborators on the item. */ canRemoveCollaborator?: boolean; /** * When `true`, the user can change the access level of the shared link. */ canSetShareAccess?: boolean; /** * When `true`, the user can create a shared link for the item. */ canShare?: boolean; }; /** * The type of the item. */ type: ItemType; } export interface User { /** * The ID of the user. * * Used with `Collaborator.userId` to exclude the current user in the "Shared with ..." list of avatars. */ id: string; /** * The enterprise of the user. */ enterprise?: Enterprise; } export interface Enterprise { /** * The name of the enterprise. * * Used to display the enterprise name in the access level dropdown menu options. */ name?: string; } export interface Classification { /** * The ID of the color for the classification label. */ colorId: number; /** * The definition of the classification. */ definition: string; /** * The name of the classification. */ name: string; /** * The restrictions applied to the item. */ restrictions?: string; } export interface SharedLink { /** * The access level of the shared link. */ access?: AccessLevelType; /** * The available access levels for the shared link. The allowed levels are dependent on the Enterprise settings. */ accessLevels?: (AccessLevel | AccessLevelType)[]; /** * The reason the direct link to download the shared item is blocked. */ directLinkBlockedReason?: ShieldPolicyType; /** * The URL that can be used to download the shared item. */ downloadUrl?: string; /** * The expiration timestamp of the shared link to indicate when the item will be unshared. */ expiresAt?: number; /** * The permission level of the shared link. */ permission?: PermissionLevelType; /** * The available permission levels for the shared link. The allowed levels are dependent on the Item and Enterprise settings. */ permissionLevels?: (PermissionLevel | PermissionLevelType)[]; /** * The configuration options and permissions for managing the shared link settings. */ settings?: SharedLinkSettings; /** * The URL that can be used to access the shared item. */ url: string; /** * The static domain portion of the shared link. Used with `vanityName` to preview the custom URL. */ vanityDomain?: string; /** * The custom name of the shared link. Used with `vanityDomain` to preview the custom URL. */ vanityName?: string; } /** * The verification modes for OTP-protected shared links. Backend naming. * - `NONE` - OTP is not enabled. * - `OPEN` - "Anyone with an email" can verify and access. * - `ALLOWLIST` - only allowlisted emails/domains can access. */ export declare const OtpMode: { readonly ALLOWLIST: "allowlist"; readonly NONE: "none"; readonly OPEN: "open"; }; export type OtpModeType = (typeof OtpMode)[keyof typeof OtpMode]; /** * The subset of {@link OtpModeType} that is user-selectable in the UI. When OTP is on, * the mode is always `open` or `allowlist`; `none` is only used on the write path to * signal that OTP is being disabled. */ export type OtpActiveModeType = Exclude; export interface SharedLinkSettings { /** * When `true`, the user can update the download settings of the shared link. */ canChangeDownload?: boolean; /** * When `true`, the user can update the expiration settings of the shared link. */ canChangeExpiration?: boolean; /** * When `true`, the user can update OTP protection and change its mode. * Items or users without permission to change shared-link access surface as `false`. */ canChangeOtp?: boolean; /** * When `true`, the user can update the password settings of the shared link. */ canChangePassword?: boolean; /** * When `true`, the user can update the custom URL settings of the shared link. */ canChangeVanityName?: boolean; /** * When `true`, the direct link is available to the user. */ isDirectLinkAvailable?: boolean; /** * When `true`, the download settings of the shared link are visible to the user. */ isDownloadAvailable?: boolean; /** * When `true`, users with the shared link can download the item. */ isDownloadEnabled?: boolean; /** * When `true`, the OTP protection section is visible to the user. */ isOtpAvailable?: boolean; /** * When `true`, the password settings of the shared link are visible to the user. */ isPasswordAvailable?: boolean; /** * When `true`, users with the shared link must enter a password to access the item. */ isPasswordEnabled?: boolean; /** * When `true`, the custom URL settings of the shared link are visible to the user. */ isVanityNameAvailable?: boolean; /** * The number of entries on the link's allowlist, shown as the "+N ITEMS" badge. */ otpAllowlistItemCount?: number; /** * The current saved OTP verification mode. */ otpMode?: OtpModeType; } export interface AccessLevel { /** * The description for the access level. Each access level has a default description. */ description?: string; /** * The policy reason for disabling the option when selecting an access level. */ disabledReason?: ShieldPolicyType; /** * The ID of the access level. The value must be one of the allowed access levels within the Enterprise. */ id: AccessLevelType; /** * The label for the access level. Each access level has a default label. */ label?: string; } export interface PermissionLevel { /** * The description for the permission level. There are no default descriptions. */ description?: string; /** * The ID of the permission level. The value must be one of the allowed permission levels within the Enterprise. */ id: PermissionLevelType; /** * The label for the permission level. Each permission level has a default label. */ label?: string; } export interface Collaborator { /** * The URL to the profile picture of the collaborator. */ avatarUrl?: string; /** * The email address of the collaborator. */ email?: string; /** * The expiration date on the avatar badge to indicate when the collaborator loses access to the item. * * - `number` - The value is treated as a timestamp and will be converted to a localized date string. * - `string` - The value is treated as a localized date string and will be used without transformation. */ expiresAt?: number | string; /** * When `false`, the avatar will show the collaborator's first initial instead of the profile picture. * * Used to prevent showing the default profile picture. */ hasCustomAvatar?: boolean; /** * When `true`, the collaborator's role is treated as a localized string and will be used without transformation. */ hasCustomRole?: boolean; /** * The ID of the collaboration record for the item. This is different than the User ID. */ id: string; /** * When `true`, the collaborator does not appear in the "Shared with ..." list of avatars. */ isCurrentUser?: boolean; /** * When `true`, there is an avatar badge indicating the collaborator is external to the enterprise. */ isExternal?: boolean; /** * When `true`, the collaborator's role is displayed as "Pending" in the list of collaborators. * * Used when the collaborator has not accepted or declined the collaboration invite. */ isPending?: boolean; /** * When `true`, the user can remove the collaborator's access to the item. */ isRemovable?: boolean; /** * The name of the collaborator. */ name: string; /** * The role of the collaborator. The value must be one of the supported roles within the Enterprise. * * Can be used with `hasCustomRole` to support custom collaboration roles. */ role: InvitationRole | 'owner' | string; /** * The user ID of the collaborator. Alternative method to using the `isCurrentUser` property. * * Used with `currentUser.id` to exclude the current user in the "Shared with ..." list of avatars. */ userId?: string; } /** * Collaboration roles available to the user to choose from when inviting a new collaborator. * * These roles are dependent on the Item type and Enterprise settings. * * See https://support.box.com/hc/en-us/articles/360044196413-Understanding-Collaborator-Permission-Levels */ export interface CollaborationRole { /** * The description for the role. Supported roles have default descriptions. */ description?: string; /** * The ID of the role. The value must be one of the supported roles within the Enterprise. * * If the value does not match a supported role, the role is treated as a custom collaboration role. */ id: InvitationRole | string; /** * When `true`, the role will be the default selected collaboration role. */ isDefault?: boolean; /** * When `true`, the role will be disabled when selecting a collaboration role. */ isDisabled?: boolean; /** * The label for the role. Supported roles have default labels. */ label?: string; } export interface EventService { /** * Function called when auto-focusing after the Unified Share Modal closes. * * The event can be prevented to customize focus restoration. */ onCloseAutoFocus?: ModalContentProps['onCloseAutoFocus']; /** * Function to observe when the user changes the collaboration role. */ onCollaborationRoleChange?: (role: InvitationRole | string) => void; /** * Function to customize the click behavior of the "Shared with ..." list of avatars. * * If provided, the default behavior is disabled and the list of collaborators will not be rendered. * * Used to enhance the experience for managing collaborators such as opening the Collaborators Modal. */ onCollaboratorsClick?: () => void; /** * Function to customize the click behavior of the "Manage All" link. * * If provided, the default behavior is disabled and the link will be rendered as a button. * * Used to enhance the experience for managing collaborators or override the default navigation behavior. */ onCollaboratorsManagementClick?: () => void; /** * Function to open the Manage Allowlist Access modal. * * When omitted, the settings "Configure" button is disabled and the footer link is * not rendered. */ onOtpAllowlistConfigure?: () => void; /** * Function to observe when restricted collaborators are removed from the selection. * * This is usually used for data tracking purposes. */ onRestrictedUsersRemoveClick?: (contacts: UserContactType[]) => void; /** * Function to observe when the shared link is copied to the clipboard. */ onSharedLinkCopy?: (result: string | Error) => void; /** * Function to customize the click behavior of the "Link Settings" link. * * If provided, the default behavior is disabled and the shared link settings will not be opened. */ onSharedLinkSettingsClick?: () => void; /** * Function to observe when the user closes the view for the shared link settings. */ onSharedLinkSettingsClose?: () => void; /** * Function to allow the consumer to fetch data for the shared link settings. * * Called when the user opens the view for the shared link settings. */ onSharedLinkSettingsLoad?: () => void; } export interface ContactService { /** * Function to retrieve contacts by email addresses. * * Called when the user enters values that are not in the suggested contacts. */ getContactsByEmail?: (emails: string[]) => Promise>; /** * Function to retrieve a list of suggested contacts. * * Called when the input value of the contact combobox is changed. */ getContacts?: (query: string, view: 'email' | 'invite') => Promise; /** * Function to retrieve avatar URLs for a list of contacts. * * Called when the list of suggested contacts is updated. */ getContactsAvatarUrls?: (userContacts: UserContactType[]) => Promise; /** * Function to retrieve justification reasons for restricted collaborations. * * Called when the user attempts to invite restricted contacts with justification allowed. */ getJustificationReasons?: (item: Item) => Promise<{ classificationId?: string; options: JustificationReason[]; }>; } export interface SharingService { /** * Function to invite new collaborators to the item. * * Called when the user clicks "Send" on the invite view of the sharing form. */ sendInvitations?: (formData: CollaborationFormData) => Promise; /** * Function to remove an existing collaborator on the item. * * Called when the user clicks the "Remove" icon button on a collaborator. */ removeCollaborator?: (collaborator: Collaborator) => Promise; /** * Function to email the shared link to the selected contacts. * * Called when the user clicks "Send" on the email view of the sharing form. */ sendSharedLink?: (formData: CollaborationFormData) => Promise; /** * Function to create a shared link for the item. * * Called when the user enables the "Share Link" toggle on the sharing form. */ createSharedLink?: () => Promise; /** * Function to delete the shared link for the item. * * Called when the user disables the "Share Link" toggle on the sharing form. */ deleteSharedLink?: () => Promise; /** * Function to update the shared link for the item. * * Called when the user saves changes to the shared link settings. */ updateSharedLink?: (formData: LinkSettingsFormData) => Promise; /** * Function to change the access level of the shared link. * * Called when the user selects an access level for the shared link. */ changeSharedLinkAccess?: (access: AccessLevelType) => Promise; /** * Function to change the permission level of the shared link. * * Called when the user selects a permission level for the shared link. */ changeSharedLinkPermission?: (permission: PermissionLevelType) => Promise; } /** * Supported notice types for custom notifications. */ export type NotificationVariant = 'success' | 'error' | 'warning'; /** * Response structure for sharing actions in the Unified Share Modal. */ export interface SharingResponse { /** * Notifications displayed after the user performs sharing actions. If omitted, the default notifications are displayed to the user. */ messages?: Array<{ text: string; type: NotificationVariant; [key: string]: string; }>; } /** * Error structure for sharing actions in the Unified Share Modal. */ export interface SharingError { /** * Error messages for form fields after the user performs sharing actions. */ fields?: { /** * The key must be a field on the collaboration form or link settings form. */ [key: string]: string; }; } /** * Form data structure for the collaboration form in the Unified Share Modal. */ export interface CollaborationFormData { /** * The classification ID of the item for inviting restricted collaborators. */ classificationId?: string; /** * The selected contacts to invite as collaborators or email the shared link. */ contacts: UserContactType[]; /** * The business justification reason for inviting restricted collaborators. * * This property is only included when a justification is required and selected. */ justificationReason?: JustificationReason; /** * The message to send to collaborators or shared link recipients. */ message: string; /** * The selected collaboration role when inviting new collaborators. * * This property is omitted when emailing the shared link. */ role?: InvitationRole | string; } /** * Form data structure for the link settings form in the Unified Share Modal. */ export interface LinkSettingsFormData { /** * The selected calendar date when the item will be unshared. */ expiration: DateValue; /** * When `true`, users with the shared link can download the item. */ isDownloadEnabled: boolean; /** * When `true`, the shared link will expire on a specific date. */ isExpirationEnabled: boolean; /** * When `true`, viewers must verify a one-time passcode to access the shared link. */ isOtpEnabled: boolean; /** * When `true`, users with the shared link must enter a password. */ isPasswordEnabled: boolean; /** * When `true`, users can access the shared link with a custom URL. */ isVanityNameEnabled: boolean; /** * The selected verification mode. Only meaningful when `isOtpEnabled` is `true`. */ otpMode: OtpModeType; /** * The password required by users to access the shared link. */ password: string; /** * The path name for users to access the item through a non-private URL. */ vanityName: string; } export interface ShieldRestriction { /** * The classification ID of the item. */ classificationId?: string; /** * When `true`, a business justification can be provided to invite restricted collaborators. */ isJustificationAllowed?: boolean; /** * The selected business justification reason. */ justificationReason?: JustificationReason; } /** * Justification reason for restricted collaborations. */ export interface JustificationReason { /** * When `true`, the justification reason requires additional details to be provided. * * NOTE: This property is not used internally. */ isDetailsRequired?: boolean; /** * The description of the justification reason. */ description?: string; /** * The unique identifier for the justification reason. */ id: string; /** * The display title of the justification reason. */ title: string; } /** * Error structure when collaboration is restricted by shield policies. */ export interface CollaborationRestrictionError { /** * When `true`, a business justification can be provided to proceed. */ isJustificationAllowed?: boolean; /** * The list of email addresses that are restricted. */ restrictedEmails?: string[]; /** * The list of group IDs that are restricted. */ restrictedGroups?: string[]; /** * The type of restriction. */ restrictionType: 'access_policy' | 'information_barrier'; } /** * Configuration options for configuring features in the Unified Share Modal. * * Generally used for hiding specific sections of the sharing form. * * IMPORTANT: It is recommended to memoize this object to prevent unnecessary re-renders. */ export interface Configuration { /** * Controls whether the collaboration section is visible to the user. * * @default true */ collaboration?: boolean; /** * Controls the number of contacts in the contact combobox that can be added at a time. * * @default 100 */ collaborationLimit?: number; /** * Controls whether the collaboration message text field is visible to the user. * * @default true */ collaborationMessage?: boolean; /** * Controls the maximum character limit for the collaboration message text field. * * @default 750 */ collaborationMessageLimit?: number; /** * Controls whether the collaboration role is visible to the user. * * @default true */ collaborationRole?: boolean; /** * Controls whether the "Shared with ..." list of avatars is visible to the user. * * @default true */ collaborators?: boolean; /** * Controls the number of collaborators that are displayed in the list of collaborators. * * @default 100 */ collaboratorsLimit?: number; /** * Controls whether the "Manage All" link is visible to the user. * * @default true */ collaboratorsManagement?: boolean; /** * Controls which notification types are displayed after sharing related actions. * * All notifications are enabled by default. * * NOTE: This does not affect custom messages provided in the sharing response. */ notifications?: NotificationType[]; /** * Controls whether the shared link section is visible to the user. * * @default true */ sharedLink?: boolean; /** * Controls whether the shared link access level is visible to the user. * * @default true */ sharedLinkAccess?: boolean; /** * Controls whether the shared link is automatically copied on load. * * @default false */ sharedLinkAutoCopy?: boolean; /** * Controls whether the shared link is automatically created on load. * * @default false */ sharedLinkAutoCreate?: boolean; /** * Controls whether the button to email a shared link is visible to the user. * * @default true */ sharedLinkEmail?: boolean; /** * Controls whether the email message text field is visible to the user. * * @default true */ sharedLinkEmailMessage?: boolean; /** * Controls whether the shared link permission level is visible to the user. * * @default true */ sharedLinkPermission?: boolean; /** * Controls whether the "Link Settings" button is visible to the user. * * @default true */ sharedLinkSettings?: boolean; }