RecordTabs
A record's own tabs followed by a JSON tab that shows the record in a JsonTree.
Import
import { RecordTabs } from '@tallyui/components';Usage
<RecordTabs
json={order}
tabs={[{ value: 'view', label: 'View', content: <OrderDetail {...detailProps} /> }]}
/>This is the body of WCPOS v2's record dialog without the dialog itself, so the host chooses its own page or sheet. The record's own tabs come first, View first, and a JSON tab always comes last. The JSON tab shows json in a scrolling JsonTree. Pass the record as the host holds it, for example a StoreOrder.
Every tab stays mounted and an inactive tab is only hidden. Switching tabs, passing json after load, or adding and removing a tab never remounts what a tab shows, so an unsaved draft in an Edit tab survives a look at JSON.
If the selected tab is removed, the first tab is shown. v2's RecordDialog unmounts inactive tabs; TallyUI keeps them mounted for the reason above.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
tabs | RecordTab[] | Required | The record's own tabs, View first. The JSON tab always follows them. |
json | unknown | Required | What the JSON tab shows. Undefined still draws the tab, with JsonTree's "No data". |
copyText | (text: string) => void | — | Passed to the JSON tab's JsonTree to enable per-node copy. |
initialTab | string | First tab | The tab to open on. 'json' opens the JSON tab; an unknown value falls back to the first tab. |
testID | string | 'record-tabs' | Identifies the root view and prefixes the tab and panel IDs, and the JSON tree's (<testID>-json). |
className | string | — | Classes for the root view. |
json is reserved for the built-in JSON tab, so a host tab must not use that value.
RecordTab
interface RecordTab {
value: string;
label: string;
content: ReactNode;
}