# rn-record-sharing URL: /docs/native/docyrus/record-sharing Share a record with users, teams, roles or the workspace — staged multi-select search, one batch permission, per-row pending states and a share trigger that opens the panel in a bottom sheet. ## Installation ```bash pnpm dlx @docyrus/cli add @docyrus/rn-record-sharing ``` **Dependencies:** - [react-native-gesture-handler](https://www.npmjs.com/package/react-native-gesture-handler) - [react-native-reanimated](https://www.npmjs.com/package/react-native-reanimated) - [react-native-svg](https://www.npmjs.com/package/react-native-svg) ## Usage ### Share button (bottom sheet) ```tsx import { RecordSharingButton, SharingPermissionPreset, type SharingSearchResult } from '@/components/docyrus-native/record-sharing'; ``` Behaviour: - Typing runs `onSearch` after a **300 ms debounce** once the query has at least **2 characters** (native extra). Only the latest request may write results, so slow responses never overwrite newer ones. `onSearch` may return an array or a promise. - Results already shared are hidden; when `resources` is set, results of other types are hidden too. - Tapping results **stages** them as chips. One permission (preset picker sheet with descriptions) applies to the whole batch, and **Add** calls `onAdd(entities[])` once. A rejected `onAdd` keeps the selection. - Shared entities are sorted public → workspace → role → team → user. Each row has a permission picker and a remove button with its own spinner (`pendingPermissionChanges[id]`, `pendingRemovals[id]`). - `RecordSharingPanel` renders without card chrome (like web, where it lives in a popover) — wrap it in your own card when used inline. ## API Reference ### RecordSharingPanelProps | Prop | Type | Default | Description | |------|------|---------|-------------| | `sharedEntities` | `SharedEntity[]` | - | Entities the record is shared with (required) | | `resources` | `SharingResourceType[]` | all types | Resource types offered in search results. Web documents `['user', 'team', 'role']` but never applies the filter; native filters only when the prop is set | | `permissionPresets` | `PermissionPresetOption[]` | Can view / Can comment / Can edit / Can share / Full access | Permission presets (labels + descriptions) | | `defaultPermission` | `number` | `1` (`CAN_VIEW`) | Initial batch permission for new shares | | `onSearch` | `(query: string) => Promise