@salesforce/design-system-react 11.0.0-rc.1 → 11.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dist/cjs/components/accordion/index.cjs +1 -1
- package/dist/cjs/components/accordion/index.cjs.map +1 -1
- package/dist/cjs/components/accordion/panel.cjs.map +1 -1
- package/dist/cjs/components/builder-header/nav-dropdown.cjs.map +1 -1
- package/dist/cjs/components/builder-header/nav-link.cjs.map +1 -1
- package/dist/cjs/components/builder-header/toolbar.cjs.map +1 -1
- package/dist/cjs/components/button/index.cjs.map +1 -1
- package/dist/cjs/components/button-stateful/index.cjs.map +1 -1
- package/dist/cjs/components/checkbox/index.cjs.map +1 -1
- package/dist/cjs/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/cjs/components/combobox/combobox.cjs +1 -1
- package/dist/cjs/components/combobox/combobox.cjs.map +1 -1
- package/dist/cjs/components/date-picker/date-picker.cjs +1 -1
- package/dist/cjs/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/cjs/components/date-picker/index.cjs.map +1 -1
- package/dist/cjs/components/files/file.cjs.map +1 -1
- package/dist/cjs/components/icon/index.cjs.map +1 -1
- package/dist/cjs/components/icon/input-icon/index.cjs.map +1 -1
- package/dist/cjs/components/icon-settings/index.cjs.map +1 -1
- package/dist/cjs/components/input/index.cjs.map +1 -1
- package/dist/cjs/components/input/private/inner-input.cjs.map +1 -1
- package/dist/cjs/components/menu-dropdown/button-trigger.cjs.map +1 -1
- package/dist/cjs/components/menu-dropdown/menu-dropdown.cjs.map +1 -1
- package/dist/cjs/components/modal/index.cjs.map +1 -1
- package/dist/cjs/components/panel/filtering/group.cjs.map +1 -1
- package/dist/cjs/components/pill/index.cjs.map +1 -1
- package/dist/cjs/components/popover/edit-dialog.cjs.map +1 -1
- package/dist/cjs/components/popover/popover.cjs.map +1 -1
- package/dist/cjs/components/progress-indicator/index.cjs.map +1 -1
- package/dist/cjs/components/progress-ring/index.cjs.map +1 -1
- package/dist/cjs/components/radio/index.cjs.map +1 -1
- package/dist/cjs/components/radio-group/check-props.cjs.map +1 -1
- package/dist/cjs/components/radio-group/index.cjs.map +1 -1
- package/dist/cjs/components/scoped-notification/index.cjs.map +1 -1
- package/dist/cjs/components/setup-assistant/step.cjs.map +1 -1
- package/dist/cjs/components/slider/index.cjs.map +1 -1
- package/dist/cjs/components/split-view/header.cjs.map +1 -1
- package/dist/cjs/components/tabs/index.cjs.map +1 -1
- package/dist/cjs/components/tabs/panel.cjs.map +1 -1
- package/dist/cjs/components/textarea/index.cjs +1 -1
- package/dist/cjs/components/textarea/index.cjs.map +1 -1
- package/dist/cjs/components/tooltip/index.cjs.map +1 -1
- package/dist/cjs/components/tree/tree.cjs.map +1 -1
- package/dist/cjs/components/trial-bar/button.cjs.map +1 -1
- package/dist/cjs/components/trial-bar/dropdown.cjs.map +1 -1
- package/dist/cjs/components/utilities/menu-list/item-label.cjs.map +1 -1
- package/dist/cjs/utilities/get-component-doc.cjs +1 -1
- package/dist/cjs/utilities/get-component-doc.cjs.map +1 -1
- package/dist/cjs/utilities/warning/children-as-trigger.cjs +1 -1
- package/dist/cjs/utilities/warning/children-as-trigger.cjs.map +1 -1
- package/dist/cjs/utilities/warning/deprecated-property-value.cjs +1 -1
- package/dist/cjs/utilities/warning/deprecated-property-value.cjs.map +1 -1
- package/dist/cjs/utilities/warning/deprecated-property.cjs +1 -1
- package/dist/cjs/utilities/warning/deprecated-property.cjs.map +1 -1
- package/dist/cjs/utilities/warning/removal-version.cjs +2 -0
- package/dist/cjs/utilities/warning/removal-version.cjs.map +1 -0
- package/dist/es/components/accordion/index.js +7 -3
- package/dist/es/components/accordion/index.js.map +1 -1
- package/dist/es/components/accordion/panel.js.map +1 -1
- package/dist/es/components/builder-header/nav-dropdown.js.map +1 -1
- package/dist/es/components/builder-header/nav-link.js.map +1 -1
- package/dist/es/components/builder-header/toolbar.js.map +1 -1
- package/dist/es/components/button/index.js.map +1 -1
- package/dist/es/components/button-stateful/index.js.map +1 -1
- package/dist/es/components/checkbox/index.js.map +1 -1
- package/dist/es/components/color-picker/color-picker.js.map +1 -1
- package/dist/es/components/combobox/combobox.js +4 -2
- package/dist/es/components/combobox/combobox.js.map +1 -1
- package/dist/es/components/date-picker/date-picker.js +1 -1
- package/dist/es/components/date-picker/date-picker.js.map +1 -1
- package/dist/es/components/date-picker/index.js.map +1 -1
- package/dist/es/components/files/file.js.map +1 -1
- package/dist/es/components/icon/index.js.map +1 -1
- package/dist/es/components/icon/input-icon/index.js.map +1 -1
- package/dist/es/components/icon-settings/index.js.map +1 -1
- package/dist/es/components/input/index.js.map +1 -1
- package/dist/es/components/input/private/inner-input.js.map +1 -1
- package/dist/es/components/menu-dropdown/button-trigger.js.map +1 -1
- package/dist/es/components/menu-dropdown/menu-dropdown.js.map +1 -1
- package/dist/es/components/modal/index.js.map +1 -1
- package/dist/es/components/panel/filtering/group.js.map +1 -1
- package/dist/es/components/pill/index.js.map +1 -1
- package/dist/es/components/popover/edit-dialog.js.map +1 -1
- package/dist/es/components/popover/popover.js.map +1 -1
- package/dist/es/components/progress-indicator/index.js.map +1 -1
- package/dist/es/components/progress-ring/index.js.map +1 -1
- package/dist/es/components/radio/index.js.map +1 -1
- package/dist/es/components/radio-group/check-props.js.map +1 -1
- package/dist/es/components/radio-group/index.js.map +1 -1
- package/dist/es/components/scoped-notification/index.js.map +1 -1
- package/dist/es/components/setup-assistant/step.js.map +1 -1
- package/dist/es/components/slider/index.js.map +1 -1
- package/dist/es/components/split-view/header.js.map +1 -1
- package/dist/es/components/tabs/index.js.map +1 -1
- package/dist/es/components/tabs/panel.js.map +1 -1
- package/dist/es/components/textarea/index.js +29 -44
- package/dist/es/components/textarea/index.js.map +1 -1
- package/dist/es/components/tooltip/index.js.map +1 -1
- package/dist/es/components/tree/tree.js.map +1 -1
- package/dist/es/components/trial-bar/button.js.map +1 -1
- package/dist/es/components/trial-bar/dropdown.js.map +1 -1
- package/dist/es/components/utilities/menu-list/item-label.js.map +1 -1
- package/dist/es/utilities/get-component-doc.js +6 -6
- package/dist/es/utilities/get-component-doc.js.map +1 -1
- package/dist/es/utilities/warning/children-as-trigger.js +9 -8
- package/dist/es/utilities/warning/children-as-trigger.js.map +1 -1
- package/dist/es/utilities/warning/deprecated-property-value.js +11 -10
- package/dist/es/utilities/warning/deprecated-property-value.js.map +1 -1
- package/dist/es/utilities/warning/deprecated-property.js +9 -8
- package/dist/es/utilities/warning/deprecated-property.js.map +1 -1
- package/dist/es/utilities/warning/removal-version.js +6 -0
- package/dist/es/utilities/warning/removal-version.js.map +1 -0
- package/dist/llms/components/accordion.md +267 -0
- package/dist/llms/components/alert.md +228 -0
- package/dist/llms/components/avatar.md +167 -0
- package/dist/llms/components/badge.md +153 -0
- package/dist/llms/components/breadcrumb.md +148 -0
- package/dist/llms/components/builder-header.examples.md +239 -0
- package/dist/llms/components/builder-header.md +736 -0
- package/dist/llms/components/button-group.md +167 -0
- package/dist/llms/components/button-stateful.md +246 -0
- package/dist/llms/components/button.md +661 -0
- package/dist/llms/components/card.md +368 -0
- package/dist/llms/components/carousel.md +365 -0
- package/dist/llms/components/checkbox.md +887 -0
- package/dist/llms/components/color-picker.md +591 -0
- package/dist/llms/components/combobox.examples.md +802 -0
- package/dist/llms/components/combobox.md +929 -0
- package/dist/llms/components/date-picker.md +546 -0
- package/dist/llms/components/docked-composer.md +173 -0
- package/dist/llms/components/dynamic-icon.md +226 -0
- package/dist/llms/components/expandable-section.md +198 -0
- package/dist/llms/components/files.md +337 -0
- package/dist/llms/components/filter.md +775 -0
- package/dist/llms/components/icon-settings.md +301 -0
- package/dist/llms/components/icon.md +1040 -0
- package/dist/llms/components/input.md +746 -0
- package/dist/llms/components/media-object.md +125 -0
- package/dist/llms/components/menu-dropdown.md +732 -0
- package/dist/llms/components/modal.md +504 -0
- package/dist/llms/components/page-header.md +282 -0
- package/dist/llms/components/panel.md +256 -0
- package/dist/llms/components/pill-container.md +218 -0
- package/dist/llms/components/pill.md +266 -0
- package/dist/llms/components/popover.md +600 -0
- package/dist/llms/components/portal-settings.md +371 -0
- package/dist/llms/components/progress-bar.md +175 -0
- package/dist/llms/components/progress-indicator.md +399 -0
- package/dist/llms/components/progress-ring.md +146 -0
- package/dist/llms/components/radio-button-group.md +285 -0
- package/dist/llms/components/radio-group.md +242 -0
- package/dist/llms/components/radio.md +269 -0
- package/dist/llms/components/scoped-notification.md +156 -0
- package/dist/llms/components/setup-assistant.md +398 -0
- package/dist/llms/components/simple-data-table.examples.md +2773 -0
- package/dist/llms/components/simple-data-table.md +919 -0
- package/dist/llms/components/slider.md +217 -0
- package/dist/llms/components/spinner.md +232 -0
- package/dist/llms/components/split-view.md +350 -0
- package/dist/llms/components/tabs.md +311 -0
- package/dist/llms/components/textarea.md +331 -0
- package/dist/llms/components/toast.md +267 -0
- package/dist/llms/components/tooltip.md +470 -0
- package/dist/llms/components/tree.md +1011 -0
- package/dist/llms/components/trial-bar.md +383 -0
- package/dist/llms/components/vertical-navigation.md +196 -0
- package/dist/llms/components/visual-picker.md +362 -0
- package/dist/llms/components/welcome-mat.md +885 -0
- package/dist/llms/docs/migration-v11.md +471 -0
- package/dist/llms/llms-full.txt +6874 -0
- package/dist/llms/llms.txt +133 -0
- package/dist/llms/rules.md +36 -0
- package/dist/types/components/accordion/index.d.ts.map +1 -1
- package/dist/types/components/accordion/panel.d.ts +7 -7
- package/dist/types/components/builder-header/nav-dropdown.d.ts +1 -0
- package/dist/types/components/builder-header/nav-dropdown.d.ts.map +1 -1
- package/dist/types/components/builder-header/nav-link.d.ts +0 -1
- package/dist/types/components/builder-header/nav-link.d.ts.map +1 -1
- package/dist/types/components/builder-header/toolbar.d.ts +0 -1
- package/dist/types/components/builder-header/toolbar.d.ts.map +1 -1
- package/dist/types/components/button/index.d.ts +6 -3
- package/dist/types/components/button/index.d.ts.map +1 -1
- package/dist/types/components/button-stateful/index.d.ts +4 -1
- package/dist/types/components/button-stateful/index.d.ts.map +1 -1
- package/dist/types/components/checkbox/index.d.ts +19 -5
- package/dist/types/components/checkbox/index.d.ts.map +1 -1
- package/dist/types/components/color-picker/color-picker.d.ts +6 -4
- package/dist/types/components/color-picker/color-picker.d.ts.map +1 -1
- package/dist/types/components/color-picker/types.d.ts +2 -2
- package/dist/types/components/combobox/combobox.d.ts +22 -0
- package/dist/types/components/combobox/combobox.d.ts.map +1 -1
- package/dist/types/components/date-picker/date-picker.d.ts +16 -4
- package/dist/types/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/types/components/date-picker/index.d.ts +2 -6
- package/dist/types/components/date-picker/index.d.ts.map +1 -1
- package/dist/types/components/files/file.d.ts +1 -1
- package/dist/types/components/icon/index.d.ts +1 -0
- package/dist/types/components/icon/index.d.ts.map +1 -1
- package/dist/types/components/icon/input-icon/index.d.ts +3 -0
- package/dist/types/components/icon/input-icon/index.d.ts.map +1 -1
- package/dist/types/components/icon-settings/index.d.ts.map +1 -1
- package/dist/types/components/input/index.d.ts +2 -1
- package/dist/types/components/input/index.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/button-trigger.d.ts +5 -0
- package/dist/types/components/menu-dropdown/button-trigger.d.ts.map +1 -1
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts +4 -0
- package/dist/types/components/menu-dropdown/menu-dropdown.d.ts.map +1 -1
- package/dist/types/components/modal/index.d.ts +5 -5
- package/dist/types/components/page-header/types.d.ts +3 -0
- package/dist/types/components/page-header/types.d.ts.map +1 -1
- package/dist/types/components/panel/filtering/group.d.ts +2 -0
- package/dist/types/components/panel/filtering/group.d.ts.map +1 -1
- package/dist/types/components/pill/index.d.ts +1 -0
- package/dist/types/components/pill/index.d.ts.map +1 -1
- package/dist/types/components/popover/edit-dialog.d.ts +1 -3
- package/dist/types/components/popover/edit-dialog.d.ts.map +1 -1
- package/dist/types/components/popover/popover.d.ts +1 -0
- package/dist/types/components/popover/popover.d.ts.map +1 -1
- package/dist/types/components/progress-indicator/index.d.ts +1 -0
- package/dist/types/components/progress-indicator/index.d.ts.map +1 -1
- package/dist/types/components/progress-ring/index.d.ts +1 -0
- package/dist/types/components/progress-ring/index.d.ts.map +1 -1
- package/dist/types/components/radio/index.d.ts +2 -2
- package/dist/types/components/radio/index.d.ts.map +1 -1
- package/dist/types/components/radio-group/index.d.ts +2 -0
- package/dist/types/components/radio-group/index.d.ts.map +1 -1
- package/dist/types/components/scoped-notification/index.d.ts +1 -0
- package/dist/types/components/scoped-notification/index.d.ts.map +1 -1
- package/dist/types/components/setup-assistant/step.d.ts +0 -1
- package/dist/types/components/setup-assistant/step.d.ts.map +1 -1
- package/dist/types/components/simple-data-table/types.d.ts +1 -0
- package/dist/types/components/simple-data-table/types.d.ts.map +1 -1
- package/dist/types/components/slider/index.d.ts +4 -2
- package/dist/types/components/slider/index.d.ts.map +1 -1
- package/dist/types/components/tabs/index.d.ts +1 -0
- package/dist/types/components/tabs/index.d.ts.map +1 -1
- package/dist/types/components/tabs/panel.d.ts +2 -1
- package/dist/types/components/tabs/panel.d.ts.map +1 -1
- package/dist/types/components/textarea/index.d.ts +9 -40
- package/dist/types/components/textarea/index.d.ts.map +1 -1
- package/dist/types/components/tooltip/index.d.ts +5 -0
- package/dist/types/components/tooltip/index.d.ts.map +1 -1
- package/dist/types/components/tree/tree.d.ts +5 -0
- package/dist/types/components/tree/tree.d.ts.map +1 -1
- package/dist/types/components/utilities/menu-list/item-label.d.ts +12 -0
- package/dist/types/components/utilities/menu-list/item-label.d.ts.map +1 -1
- package/package.json +8 -5
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# SplitView
|
|
2
|
+
|
|
3
|
+
Split view is used to navigate between records in a list while staying on the same screen.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { SplitView, SplitViewHeader, SplitViewListbox } from '@salesforce/design-system-react';
|
|
9
|
+
// or, one entry point per module:
|
|
10
|
+
import SplitView from '@salesforce/design-system-react/components/split-view';
|
|
11
|
+
import SplitViewHeader from '@salesforce/design-system-react/components/split-view/header';
|
|
12
|
+
import SplitViewListbox from '@salesforce/design-system-react/components/split-view/listbox';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## SplitView props
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type { SplitViewProps } from '@salesforce/design-system-react/components/split-view';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Required | Description |
|
|
22
|
+
| --- | --- | --- | --- |
|
|
23
|
+
| `assistiveText` | `SplitViewAssistiveText` | | Assistive text for accessibility |
|
|
24
|
+
| `className` | `string \| string[] \| Record<string, boolean>` | | CSS classes |
|
|
25
|
+
| `defaultIsOpen` | `boolean` | | Whether the split view starts open when `isOpen` is not passed. Defaults to `true` (the split view starts open); an exception to the boolean-default rule. |
|
|
26
|
+
| `detail` | `ReactNode` | Yes | Detail panel content (required) |
|
|
27
|
+
| `events` | `SplitViewEvents` | | **Event handlers** * `onToggle`: Called with `(event, { isOpen })` when the toggle button is clicked; `isOpen` is the requested (next) state. * `onOpen` / `onClose`: Deprecated, use `onToggle`. |
|
|
28
|
+
| `events.onToggle` | `(event: MouseEvent<HTMLButtonElement, MouseEvent>, data: { isOpen: boolean }) => void` | | Called when the toggle button is clicked. `data.isOpen` is the requested (next) open state. Called whether or not `isOpen` is controlled; when `isOpen` is passed, update it from this callback. |
|
|
29
|
+
| `events.onClose` | `(event: MouseEvent<HTMLButtonElement, MouseEvent>) => void` | | **Deprecated.** use `events.onToggle`<br><br>Called when the split view closes. Only called when `events.onToggle` is not provided. |
|
|
30
|
+
| `events.onOpen` | `(event: MouseEvent<HTMLButtonElement, MouseEvent>) => void` | | **Deprecated.** use `events.onToggle`<br><br>Called when the split view opens. Only called when `events.onToggle` is not provided. |
|
|
31
|
+
| `id` | `string` | | HTML id |
|
|
32
|
+
| `isOpen` | `boolean` | | Whether the split view is open. Pass it to control the open state and update it from `events.onToggle`. Leave it `undefined` to let the split view manage the open state itself, starting from `defaultIsOpen`. |
|
|
33
|
+
| `master` | `ReactNode` | Yes | Master panel content (required) |
|
|
34
|
+
| `masterWidth` | `string` | | Width of the master section |
|
|
35
|
+
|
|
36
|
+
## SplitViewHeader props
|
|
37
|
+
|
|
38
|
+
The Split View Header takes the same properties as the `PageHeader` component.
|
|
39
|
+
|
|
40
|
+
The props type is a union: some props only apply to some variants (see the Types block). A prop is marked required only when every variant requires it.
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Required | Description |
|
|
43
|
+
| --- | --- | --- | --- |
|
|
44
|
+
| `actions` | `ReactNode` | | Actions shown in the upper right. Pass a `PageHeaderControl`, or a fragment whose children are all `PageHeaderControl` elements. |
|
|
45
|
+
| `className` | `string \| string[] \| Record<string, boolean>` | | CSS classes |
|
|
46
|
+
| `controls` | `ReactNode` | | Controls shown in the lower right (upper right for the `base` variant). Pass a `PageHeaderControl`, or a fragment whose children are all `PageHeaderControl` elements. |
|
|
47
|
+
| `details` | `PageHeaderDetail[]` | | Detail blocks |
|
|
48
|
+
| `icon` | `ReactElement` | | Icon element |
|
|
49
|
+
| `info` | `ReactNode` | | Info text or element |
|
|
50
|
+
| `joined` | `boolean` | | Whether joined with SimpleDataTable |
|
|
51
|
+
| `label` | `ReactNode` | | Label text or element |
|
|
52
|
+
| `nameSwitcherDropdown` | `ReactNode` | | Name switcher dropdown |
|
|
53
|
+
| `onRenderActions` | `() => ReactNode` | | **Deprecated.** Use `actions` instead. |
|
|
54
|
+
| `onRenderControls` | `() => ReactNode` | | **Deprecated.** Use `controls` instead. |
|
|
55
|
+
| `title` | `ReactNode` | | Title text or element |
|
|
56
|
+
| `trail` | `ReactNode[]` | | Breadcrumb trail |
|
|
57
|
+
| `variant` | `'base' \| 'object-home' \| 'record-home' \| 'related-list'` | | Page header variant |
|
|
58
|
+
|
|
59
|
+
## SplitViewListbox props
|
|
60
|
+
|
|
61
|
+
The menu with the ARIA role of a listbox.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import type { SplitViewListboxProps } from '@salesforce/design-system-react/components/split-view/listbox';
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Required | Description |
|
|
68
|
+
| --- | --- | --- | --- |
|
|
69
|
+
| `assistiveText` | `SplitViewListboxAssistiveText` | | **Assistive text for accessibility** * `list`: aria label for the list * `sort` * `sortedBy`: Clickable sort header for the list. * `descending`: Descending sorting. * `ascending`: Ascending sorting. |
|
|
70
|
+
| `className` | `unknown[] \| Record<string, unknown> \| string` | | CSS classes to be added to the parent `div` tag. |
|
|
71
|
+
| `events` | `SplitViewListboxEvents<T>` | Yes | Event Callbacks * `onSelect` (required): Called with `(event, { selection, selectedItems, item })` when the selection is asked to change. `selection` is the requested selection as item ids. * `onSort`: Called when the list is sorted. |
|
|
72
|
+
| `events.onSelect` | `(event: SyntheticEvent<Element, Event>, data: { selection: SplitViewListboxItemId[]; selectedItems: T[]; item: T }) => void` | Yes | Called when the selection is asked to change (click, meta/shift-click, Ctrl+A). `data.selection` is the requested selection; update `selection` to apply it. |
|
|
73
|
+
| `events.onSort` | `(event: SyntheticEvent<Element, Event>) => void` | | Called when the list is sorted. |
|
|
74
|
+
| `id` | `string` | | HTML id for component. |
|
|
75
|
+
| `labels` | `SplitViewListboxLabels` | | **Text labels for internationalization** * `header`: This is the header of the list. |
|
|
76
|
+
| `listItem` | `React.ComponentType<{ item: T; }>` | | **Deprecated.** Use `renderListItem` instead, which is called as a function with `{ isFocused, isSelected, isUnread, item }`. |
|
|
77
|
+
| `multiple` | `boolean` | | Allows multiple item to be selection |
|
|
78
|
+
| `options` | `T[]` | Yes | The list of items. It is recommended that you have a unique `id` for each item. |
|
|
79
|
+
| `renderListItem` | `(data: SplitViewListboxRenderListItemData<T>) => ReactNode` | | Renders the content of each list item in place of the default label and text. The listbox still renders the option, its selection and the unread indicator around it. Receives `{ isFocused, isSelected, isUnread, item }`. |
|
|
80
|
+
| `selection` | `SplitViewListboxItemId[] \| T[]` | Yes | Ids (`item.id`) of the selected items (`[]` for none). The listbox is controlled: it renders this selection and reports changes through `events.onSelect`. For single selection, pass an array of one id.<br><br>Passing item objects is deprecated: they are still matched by `id` (or by identity when an item has no `id`), and the listbox warns. |
|
|
81
|
+
| `sortDirection` | `'up' \| 'down'` (`'down' \| 'up'`) | | The direction of the sort arrow. Option are: * SORT_OPTIONS.UP: `up` * SORT_OPTIONS.DOWN: `down` |
|
|
82
|
+
| `unread` | `SplitViewListboxItemId[] \| T[]` | | Ids (`item.id`) of the unread items.<br><br>Passing item objects is deprecated: they are still matched by `id` (or by identity when an item has no `id`), and the listbox warns. |
|
|
83
|
+
|
|
84
|
+
## Types
|
|
85
|
+
|
|
86
|
+
Declarations the props above refer to, from the package `.d.ts`:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
/**
|
|
90
|
+
* Assistive text for SplitView
|
|
91
|
+
*/
|
|
92
|
+
export interface SplitViewAssistiveText {
|
|
93
|
+
/** Text for the toggle button while the split view is open (the button closes it) */
|
|
94
|
+
closeToggle?: string;
|
|
95
|
+
/** Text for the toggle button while the split view is closed (the button opens it) */
|
|
96
|
+
openToggle?: string;
|
|
97
|
+
/** @deprecated Use `closeToggle` instead. Despite its name, this is the text shown while open. */
|
|
98
|
+
toggleButtonOpen?: string;
|
|
99
|
+
/** @deprecated Use `openToggle` instead. Despite its name, this is the text shown while closed. */
|
|
100
|
+
toggleButtonClose?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Event handlers for SplitView
|
|
105
|
+
*/
|
|
106
|
+
export interface SplitViewEvents {
|
|
107
|
+
/**
|
|
108
|
+
* Called when the toggle button is clicked. `data.isOpen` is the requested (next) open state.
|
|
109
|
+
* Called whether or not `isOpen` is controlled; when `isOpen` is passed, update it from this callback.
|
|
110
|
+
*/
|
|
111
|
+
onToggle?: (event: MouseEvent<HTMLButtonElement>, data: SplitViewToggleData) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Called when the split view closes. Only called when `events.onToggle` is not provided.
|
|
114
|
+
* @deprecated use `events.onToggle`
|
|
115
|
+
*/
|
|
116
|
+
onClose?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
117
|
+
/**
|
|
118
|
+
* Called when the split view opens. Only called when `events.onToggle` is not provided.
|
|
119
|
+
* @deprecated use `events.onToggle`
|
|
120
|
+
*/
|
|
121
|
+
onOpen?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Data passed to `events.onToggle`
|
|
126
|
+
*/
|
|
127
|
+
export interface SplitViewToggleData {
|
|
128
|
+
/** The requested (next) open state: `true` when the toggle asks to open, `false` when it asks to close */
|
|
129
|
+
isOpen: boolean;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Detail block structure
|
|
134
|
+
*/
|
|
135
|
+
export interface PageHeaderDetail {
|
|
136
|
+
/** Detail label */
|
|
137
|
+
label?: ReactNode;
|
|
138
|
+
/** Detail content */
|
|
139
|
+
content?: ReactNode;
|
|
140
|
+
/** Whether content is truncated */
|
|
141
|
+
truncate?: boolean;
|
|
142
|
+
/** Width of the block, appended as `slds-size_{flavor}`, such as `1-of-4` */
|
|
143
|
+
flavor?: `${number}-of-${number}`;
|
|
144
|
+
/** Stable key for the block. Defaults to its index. */
|
|
145
|
+
id?: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface SplitViewListboxAssistiveText {
|
|
149
|
+
list?: string;
|
|
150
|
+
sort?: SplitViewListboxSortAssistiveText;
|
|
151
|
+
unreadItem?: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface SplitViewListboxSortAssistiveText {
|
|
155
|
+
sortedBy?: string;
|
|
156
|
+
descending?: string;
|
|
157
|
+
ascending?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface SplitViewListboxEvents<T extends SplitViewListboxItem = SplitViewListboxItem> {
|
|
161
|
+
/**
|
|
162
|
+
* Called when the selection is asked to change (click, meta/shift-click, Ctrl+A).
|
|
163
|
+
* `data.selection` is the requested selection; update `selection` to apply it.
|
|
164
|
+
*/
|
|
165
|
+
onSelect: (event: SyntheticEvent, data: SplitViewListboxSelectData<T>) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Called when the list is sorted.
|
|
168
|
+
*/
|
|
169
|
+
onSort?: (event: SyntheticEvent) => void;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Fields read by the default list item. Items with other fields are typed by
|
|
174
|
+
* the `SplitViewListbox` type parameter, which flows to `renderListItem`, `listItem` and `onSelect`.
|
|
175
|
+
*/
|
|
176
|
+
export type SplitViewListboxItem = SplitViewListItem & {
|
|
177
|
+
/** Unique id of the item, matched against `selection` and `unread` */
|
|
178
|
+
id: SplitViewListboxItemId;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export interface SplitViewListItem {
|
|
182
|
+
label?: string;
|
|
183
|
+
topRightText?: string;
|
|
184
|
+
bottomLeftText?: string;
|
|
185
|
+
bottomRightText?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** An item's `id`, as used in `selection` and `unread` */
|
|
189
|
+
export type SplitViewListboxItemId = string | number;
|
|
190
|
+
|
|
191
|
+
export interface SplitViewListboxSelectData<T extends SplitViewListboxItem = SplitViewListboxItem> {
|
|
192
|
+
/** The requested selection, as item ids. Pass it back as `selection`. */
|
|
193
|
+
selection: SplitViewListboxItemId[];
|
|
194
|
+
/** The items of the requested selection */
|
|
195
|
+
selectedItems: T[];
|
|
196
|
+
/** The item that was clicked, or the range anchor for select-all (`null` when deselecting all) */
|
|
197
|
+
item: T | null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface SplitViewListboxLabels {
|
|
201
|
+
/** This is the header of the list. */
|
|
202
|
+
header?: string;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Data passed to `renderListItem`
|
|
207
|
+
*/
|
|
208
|
+
export interface SplitViewListboxRenderListItemData<T extends SplitViewListboxItem = SplitViewListboxItem> {
|
|
209
|
+
/** Whether the item has keyboard focus (is the list's tab stop) */
|
|
210
|
+
isFocused: boolean;
|
|
211
|
+
/** Whether the item is in `selection` */
|
|
212
|
+
isSelected: boolean;
|
|
213
|
+
/** Whether the item is in `unread` */
|
|
214
|
+
isUnread: boolean;
|
|
215
|
+
/** The item from `options` */
|
|
216
|
+
item: T;
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
- `PageHeaderProps`: see [page-header.md](https://opensource.salesforce.com/design-system-react/components/page-header.md)
|
|
221
|
+
|
|
222
|
+
## Examples
|
|
223
|
+
|
|
224
|
+
Every story in Storybook for this component, in sidebar order, as code for an app: imports use the package paths, and Storybook's own code (`meta`, decorators, `parameters`) is left out. A story that renders an `__examples__` file shows that file the first time. Icons are served from `/assets/icons` (see `IconSettings`). Storybook: <https://opensource.salesforce.com/design-system-react/?path=/docs/components-splitview--docs>.
|
|
225
|
+
|
|
226
|
+
### Shared code: `components/split-view/__docs__/SplitView.stories.jsx`
|
|
227
|
+
|
|
228
|
+
The stories from Components/SplitView below use these imports and helpers.
|
|
229
|
+
|
|
230
|
+
```jsx
|
|
231
|
+
import { useState } from 'react';
|
|
232
|
+
import SplitView from '@salesforce/design-system-react/components/split-view';
|
|
233
|
+
import Card from '@salesforce/design-system-react/components/card';
|
|
234
|
+
|
|
235
|
+
const sampleMasterContent = (
|
|
236
|
+
<div className="slds-p-around_medium">
|
|
237
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
238
|
+
Master Panel
|
|
239
|
+
</h2>
|
|
240
|
+
<ul className="slds-list_dotted">
|
|
241
|
+
<li className="slds-m-bottom_x-small">Item 1</li>
|
|
242
|
+
<li className="slds-m-bottom_x-small">Item 2</li>
|
|
243
|
+
<li className="slds-m-bottom_x-small">Item 3</li>
|
|
244
|
+
<li className="slds-m-bottom_x-small">Item 4</li>
|
|
245
|
+
<li className="slds-m-bottom_x-small">Item 5</li>
|
|
246
|
+
</ul>
|
|
247
|
+
</div>
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const sampleDetailContent = (
|
|
251
|
+
<div className="slds-p-around_medium">
|
|
252
|
+
<h2 className="slds-text-heading_medium slds-m-bottom_medium">
|
|
253
|
+
Detail Panel
|
|
254
|
+
</h2>
|
|
255
|
+
<p className="slds-m-bottom_medium">
|
|
256
|
+
This is the detail panel. Click the toggle button to show or hide the
|
|
257
|
+
master panel.
|
|
258
|
+
</p>
|
|
259
|
+
<Card heading="Sample Card" bodyClassName="slds-p-around_medium">
|
|
260
|
+
<p>Card content goes here.</p>
|
|
261
|
+
</Card>
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Default
|
|
267
|
+
|
|
268
|
+
```jsx
|
|
269
|
+
const Default = () => (
|
|
270
|
+
<SplitView master={sampleMasterContent} detail={sampleDetailContent} />
|
|
271
|
+
);
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Initially Closed
|
|
275
|
+
|
|
276
|
+
```jsx
|
|
277
|
+
const InitiallyClosed = () => (
|
|
278
|
+
<SplitView
|
|
279
|
+
master={sampleMasterContent}
|
|
280
|
+
detail={sampleDetailContent}
|
|
281
|
+
defaultIsOpen={false}
|
|
282
|
+
/>
|
|
283
|
+
);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Controlled
|
|
287
|
+
|
|
288
|
+
```jsx
|
|
289
|
+
const Controlled = () => {
|
|
290
|
+
const [isOpen, setIsOpen] = useState(true);
|
|
291
|
+
|
|
292
|
+
return (
|
|
293
|
+
<div>
|
|
294
|
+
<div className="slds-m-bottom_medium">
|
|
295
|
+
<button
|
|
296
|
+
className="slds-button slds-button_neutral"
|
|
297
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
298
|
+
>
|
|
299
|
+
{isOpen ? 'Close Panel' : 'Open Panel'}
|
|
300
|
+
</button>
|
|
301
|
+
<span className="slds-m-left_medium">
|
|
302
|
+
State: {isOpen ? 'Open' : 'Closed'}
|
|
303
|
+
</span>
|
|
304
|
+
</div>
|
|
305
|
+
<div style={{ height: '300px', border: '1px solid #d8dde6' }}>
|
|
306
|
+
<SplitView
|
|
307
|
+
master={sampleMasterContent}
|
|
308
|
+
detail={sampleDetailContent}
|
|
309
|
+
isOpen={isOpen}
|
|
310
|
+
events={{
|
|
311
|
+
onToggle: (event, data) => setIsOpen(data.isOpen),
|
|
312
|
+
}}
|
|
313
|
+
/>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
);
|
|
317
|
+
};
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Custom Width
|
|
321
|
+
|
|
322
|
+
```jsx
|
|
323
|
+
const CustomWidth = () => (
|
|
324
|
+
<SplitView
|
|
325
|
+
master={sampleMasterContent}
|
|
326
|
+
detail={sampleDetailContent}
|
|
327
|
+
masterWidth="30rem"
|
|
328
|
+
/>
|
|
329
|
+
);
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### With Event Handlers
|
|
333
|
+
|
|
334
|
+
```jsx
|
|
335
|
+
const WithEventHandlers = () => {
|
|
336
|
+
const handleToggle = (event, { isOpen }) => {
|
|
337
|
+
console.log(isOpen ? 'Split view opening' : 'Split view closing');
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<SplitView
|
|
342
|
+
master={sampleMasterContent}
|
|
343
|
+
detail={sampleDetailContent}
|
|
344
|
+
events={{
|
|
345
|
+
onToggle: handleToggle,
|
|
346
|
+
}}
|
|
347
|
+
/>
|
|
348
|
+
);
|
|
349
|
+
};
|
|
350
|
+
```
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# Tabs
|
|
2
|
+
|
|
3
|
+
Tabs keeps related content in a single container that is shown and hidden through navigation.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Tabs, TabsPanel } from '@salesforce/design-system-react';
|
|
9
|
+
// or, one entry point per module:
|
|
10
|
+
import Tabs from '@salesforce/design-system-react/components/tabs';
|
|
11
|
+
import TabsPanel from '@salesforce/design-system-react/components/tabs/panel';
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Tabs props
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import type { TabsProps } from '@salesforce/design-system-react/components/tabs';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The props type is a union: some props only apply to some variants (see the Types block). A prop is marked required only when every variant requires it.
|
|
21
|
+
|
|
22
|
+
| Prop | Type | Required | Description |
|
|
23
|
+
| --- | --- | --- | --- |
|
|
24
|
+
| `children` | `ChildrenOf<TabsPanelProps>` | Yes | `TabsPanel` elements, one per tab. Tabs reads each panel's `label`, `value`, `disabled`, `hasError` and `assistiveText`. |
|
|
25
|
+
| `className` | `string \| string[] \| Record<string, boolean>` | | CSS classes |
|
|
26
|
+
| `id` | `string` | | HTML id |
|
|
27
|
+
| `onSelect` | `(event: MouseEvent<HTMLDivElement> \| KeyboardEvent<HTMLDivElement>, data: TabsSelectData) => void` | Yes | Called when a tab is requested by click or arrow key. Receives the triggering event and `{ value, previousValue, selectedIndex, previousIndex }`. Tabs is controlled: update `value` from this callback to change tabs. It is not called for a disabled tab or for the tab that is already selected. |
|
|
28
|
+
| `selectedIndex` | `number` | | **Deprecated.** Use `value` instead (set `value` on each `TabsPanel`, or use the index as a string). Index of the selected tab, controlled. Used only when `value` is not passed. |
|
|
29
|
+
| `value` | `string` | | `value` of the selected `TabsPanel` (required, controlled). A panel without a `value` is matched by its index as a string (`'0'`, `'1'`, ...). When no panel matches, no tab is selected. |
|
|
30
|
+
| `variant` | `TabsVariant` (`'default' \| 'vertical' \| 'scoped'`) | | Tab style variant |
|
|
31
|
+
|
|
32
|
+
## TabsPanel props
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import type { TabsPanelProps } from '@salesforce/design-system-react/components/tabs/panel';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
| Prop | Type | Required | Description |
|
|
39
|
+
| --- | --- | --- | --- |
|
|
40
|
+
| `assistiveText` | `{ /** Label of the error icon shown with `hasError`. Defaults to the English text `This item has an error`. */ withErrorIcon?: string; }` | | **Assistive text for accessibility** This object is merged with the default props object on every render. * `withErrorIcon`: This text is for the error icon that will be placed next to the `<Tab />` title |
|
|
41
|
+
| `children` | `ReactNode` | Yes | The `children` are the actual tab panels to be rendered. `<Tabs />` renders them.<br><br>Note that the `<TabsPanel />` component inserts a `div` element around the children, because React requires exactly one "parent" element returned. The `<TabPanel />` component simply dips down into `children` to get the children of this wrapping `div` so that it does not get rendered in the DOM. |
|
|
42
|
+
| `disabled` | `boolean` | | Disables the `<Tab />` associated with this panel so it cannot be selected. |
|
|
43
|
+
| `hasError` | `boolean` | | Show an icon on the `<Tab />` next to the title that can be used to communicate when a tab contains a validation error that needs attention |
|
|
44
|
+
| `label` | `ReactNode` | Yes | The string or element that is handed off to the `<Tab />` component, ends up being the title and the label for the tab associated with its tab panel. |
|
|
45
|
+
| `value` | `string` | | Identifies this panel for the `value` prop of `<Tabs />` and the `value`/`previousValue` reported by its `onSelect`. When omitted, the panel is identified by its index as a string (`'0'`, `'1'`, ...). Rendered `id`s are always index-based. |
|
|
46
|
+
|
|
47
|
+
## Types
|
|
48
|
+
|
|
49
|
+
Declarations the props above refer to, from the package `.d.ts`:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
/**
|
|
53
|
+
* Props for the Tabs component
|
|
54
|
+
*/
|
|
55
|
+
export type TabsProps = TabsBaseProps & (TabsValueProps | TabsSelectedIndexProps);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Select the tab by the `value` of its `TabsPanel`.
|
|
59
|
+
*/
|
|
60
|
+
interface TabsValueProps {
|
|
61
|
+
/**
|
|
62
|
+
* `value` of the selected `TabsPanel` (required, controlled). A panel without a `value` is
|
|
63
|
+
* matched by its index as a string (`'0'`, `'1'`, ...). When no panel matches, no tab is selected.
|
|
64
|
+
*/
|
|
65
|
+
value: string;
|
|
66
|
+
selectedIndex?: never;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Select the tab by index (deprecated).
|
|
71
|
+
*/
|
|
72
|
+
interface TabsSelectedIndexProps {
|
|
73
|
+
/** Unset when the deprecated `selectedIndex` is used. */
|
|
74
|
+
value?: undefined;
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use `value` instead (set `value` on each `TabsPanel`, or use the index as a
|
|
77
|
+
* string). Index of the selected tab, controlled. Used only when `value` is not passed.
|
|
78
|
+
*/
|
|
79
|
+
selectedIndex: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* `children` that must be elements of library components with props `P`
|
|
84
|
+
* (e.g. `ChildrenOf<TabsPanelProps>`), possibly in arrays or
|
|
85
|
+
* skipped with `false`/`null`. The parent matches its children by component
|
|
86
|
+
* reference, so `P` documents the contract; TypeScript can't check which
|
|
87
|
+
* component a JSX element came from.
|
|
88
|
+
*/
|
|
89
|
+
export type ChildrenOf<P> = React.ReactElement<P> | false | null | undefined | ChildrenOf<P>[];
|
|
90
|
+
|
|
91
|
+
export interface TabsPanelProps {
|
|
92
|
+
/**
|
|
93
|
+
* The string or element that is handed off to the `<Tab />` component, ends up being the title and the label for the tab associated with its tab panel.
|
|
94
|
+
*/
|
|
95
|
+
label: ReactNode;
|
|
96
|
+
/**
|
|
97
|
+
* Identifies this panel for the `value` prop of `<Tabs />` and the `value`/`previousValue` reported by its `onSelect`. When omitted, the panel is identified by its index as a string (`'0'`, `'1'`, ...). Rendered `id`s are always index-based.
|
|
98
|
+
*/
|
|
99
|
+
value?: string;
|
|
100
|
+
/**
|
|
101
|
+
* The `children` are the actual tab panels to be rendered. `<Tabs />` renders them.
|
|
102
|
+
*
|
|
103
|
+
* Note that the `<TabsPanel />` component inserts a `div` element around the children, because React requires exactly one "parent" element returned. The `<TabPanel />` component simply dips down into `children` to get the children of this wrapping `div` so that it does not get rendered in the DOM.
|
|
104
|
+
*/
|
|
105
|
+
children: ReactNode;
|
|
106
|
+
/**
|
|
107
|
+
* Disables the `<Tab />` associated with this panel so it cannot be selected.
|
|
108
|
+
*/
|
|
109
|
+
disabled?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Show an icon on the `<Tab />` next to the title that can be used to communicate when a tab contains a validation error that needs attention
|
|
112
|
+
*/
|
|
113
|
+
hasError?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* **Assistive text for accessibility**
|
|
116
|
+
* This object is merged with the default props object on every render.
|
|
117
|
+
* * `withErrorIcon`: This text is for the error icon that will be placed next to the `<Tab />` title
|
|
118
|
+
*/
|
|
119
|
+
assistiveText?: {
|
|
120
|
+
/** Label of the error icon shown with `hasError`. Defaults to the English text `This item has an error`. */
|
|
121
|
+
withErrorIcon?: string;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Data passed to the Tabs `onSelect` callback
|
|
127
|
+
*/
|
|
128
|
+
export interface TabsSelectData {
|
|
129
|
+
/**
|
|
130
|
+
* `value` of the tab being selected: the panel's `value`, or its index as a
|
|
131
|
+
* string (`'0'`, `'1'`, ...) when the panel has no `value`.
|
|
132
|
+
*/
|
|
133
|
+
value: string;
|
|
134
|
+
/**
|
|
135
|
+
* `value` of the tab that was selected before this selection, or `undefined`
|
|
136
|
+
* when no tab was selected.
|
|
137
|
+
*/
|
|
138
|
+
previousValue: string | undefined;
|
|
139
|
+
/** Index of the tab being selected */
|
|
140
|
+
selectedIndex: number;
|
|
141
|
+
/** Index of the tab that was selected before this selection, or `-1` when no tab was selected */
|
|
142
|
+
previousIndex: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Tabs variant types
|
|
147
|
+
*/
|
|
148
|
+
export type TabsVariant = 'default' | 'scoped' | 'vertical';
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Examples
|
|
152
|
+
|
|
153
|
+
Every story in Storybook for this component, in sidebar order, as code for an app: imports use the package paths, and Storybook's own code (`meta`, decorators, `parameters`) is left out. A story that renders an `__examples__` file shows that file the first time. Icons are served from `/assets/icons` (see `IconSettings`). Storybook: <https://opensource.salesforce.com/design-system-react/?path=/docs/components-tabs--docs>.
|
|
154
|
+
|
|
155
|
+
### Shared code: `components/tabs/__docs__/Tabs.stories.jsx`
|
|
156
|
+
|
|
157
|
+
The stories from Components/Tabs below use these imports and helpers.
|
|
158
|
+
|
|
159
|
+
```jsx
|
|
160
|
+
import { useState } from 'react';
|
|
161
|
+
import Tabs from '@salesforce/design-system-react/components/tabs';
|
|
162
|
+
import TabsPanel from '@salesforce/design-system-react/components/tabs/panel';
|
|
163
|
+
|
|
164
|
+
// Tabs is controlled: keep the selected `value` in state and update it in `onSelect`.
|
|
165
|
+
// eslint-disable-next-line react/prop-types
|
|
166
|
+
const ControlledTabs = ({ initialValue, ...props }) => {
|
|
167
|
+
const [value, setValue] = useState(initialValue);
|
|
168
|
+
return (
|
|
169
|
+
<Tabs
|
|
170
|
+
{...props}
|
|
171
|
+
onSelect={(event, data) => setValue(data.value)}
|
|
172
|
+
value={value}
|
|
173
|
+
/>
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Default
|
|
179
|
+
|
|
180
|
+
```jsx
|
|
181
|
+
const Default = () => (
|
|
182
|
+
<ControlledTabs initialValue="tab-1">
|
|
183
|
+
<TabsPanel label="Tab 1" value="tab-1">
|
|
184
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
185
|
+
Tab 1 Content
|
|
186
|
+
</h2>
|
|
187
|
+
<p>This is the content for Tab 1.</p>
|
|
188
|
+
</TabsPanel>
|
|
189
|
+
<TabsPanel label="Tab 2" value="tab-2">
|
|
190
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
191
|
+
Tab 2 Content
|
|
192
|
+
</h2>
|
|
193
|
+
<p>This is the content for Tab 2.</p>
|
|
194
|
+
</TabsPanel>
|
|
195
|
+
<TabsPanel label="Tab 3" value="tab-3">
|
|
196
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
197
|
+
Tab 3 Content
|
|
198
|
+
</h2>
|
|
199
|
+
<p>This is the content for Tab 3.</p>
|
|
200
|
+
</TabsPanel>
|
|
201
|
+
</ControlledTabs>
|
|
202
|
+
);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Scoped
|
|
206
|
+
|
|
207
|
+
```jsx
|
|
208
|
+
const Scoped = () => (
|
|
209
|
+
<ControlledTabs initialValue="tab-1" variant="scoped">
|
|
210
|
+
<TabsPanel label="Tab 1" value="tab-1">
|
|
211
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
212
|
+
Tab 1 Content
|
|
213
|
+
</h2>
|
|
214
|
+
<p>Scoped tabs have a different visual style.</p>
|
|
215
|
+
</TabsPanel>
|
|
216
|
+
<TabsPanel label="Tab 2" value="tab-2">
|
|
217
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
218
|
+
Tab 2 Content
|
|
219
|
+
</h2>
|
|
220
|
+
<p>This is the content for Tab 2.</p>
|
|
221
|
+
</TabsPanel>
|
|
222
|
+
<TabsPanel label="Tab 3" value="tab-3">
|
|
223
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
224
|
+
Tab 3 Content
|
|
225
|
+
</h2>
|
|
226
|
+
<p>This is the content for Tab 3.</p>
|
|
227
|
+
</TabsPanel>
|
|
228
|
+
</ControlledTabs>
|
|
229
|
+
);
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Vertical
|
|
233
|
+
|
|
234
|
+
```jsx
|
|
235
|
+
const Vertical = () => (
|
|
236
|
+
<ControlledTabs initialValue="tab-1" variant="vertical">
|
|
237
|
+
<TabsPanel label="Tab 1" value="tab-1">
|
|
238
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
239
|
+
Tab 1 Content
|
|
240
|
+
</h2>
|
|
241
|
+
<p>Vertical tabs are displayed on the left side.</p>
|
|
242
|
+
</TabsPanel>
|
|
243
|
+
<TabsPanel label="Tab 2" value="tab-2">
|
|
244
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
245
|
+
Tab 2 Content
|
|
246
|
+
</h2>
|
|
247
|
+
<p>This is the content for Tab 2.</p>
|
|
248
|
+
</TabsPanel>
|
|
249
|
+
<TabsPanel label="Tab 3" value="tab-3">
|
|
250
|
+
<h2 className="slds-text-heading_small slds-m-bottom_small">
|
|
251
|
+
Tab 3 Content
|
|
252
|
+
</h2>
|
|
253
|
+
<p>This is the content for Tab 3.</p>
|
|
254
|
+
</TabsPanel>
|
|
255
|
+
</ControlledTabs>
|
|
256
|
+
);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### With Disabled Tab
|
|
260
|
+
|
|
261
|
+
```jsx
|
|
262
|
+
const WithDisabledTab = () => (
|
|
263
|
+
<ControlledTabs initialValue="0">
|
|
264
|
+
<TabsPanel label="Enabled">
|
|
265
|
+
<p>This tab is enabled and can be selected.</p>
|
|
266
|
+
</TabsPanel>
|
|
267
|
+
<TabsPanel label="Disabled" disabled>
|
|
268
|
+
<p>This tab is disabled.</p>
|
|
269
|
+
</TabsPanel>
|
|
270
|
+
<TabsPanel label="Also Enabled">
|
|
271
|
+
<p>This tab is also enabled.</p>
|
|
272
|
+
</TabsPanel>
|
|
273
|
+
</ControlledTabs>
|
|
274
|
+
);
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### With Error Tab
|
|
278
|
+
|
|
279
|
+
```jsx
|
|
280
|
+
const WithErrorTab = () => (
|
|
281
|
+
<ControlledTabs initialValue="0">
|
|
282
|
+
<TabsPanel label="Details">
|
|
283
|
+
<p>This tab has no errors.</p>
|
|
284
|
+
</TabsPanel>
|
|
285
|
+
<TabsPanel label="Billing" hasError>
|
|
286
|
+
<p>This tab has an error.</p>
|
|
287
|
+
</TabsPanel>
|
|
288
|
+
<TabsPanel label="Notes">
|
|
289
|
+
<p>This tab has no errors.</p>
|
|
290
|
+
</TabsPanel>
|
|
291
|
+
</ControlledTabs>
|
|
292
|
+
);
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Initial Value
|
|
296
|
+
|
|
297
|
+
```jsx
|
|
298
|
+
const InitialValue = () => (
|
|
299
|
+
<ControlledTabs initialValue="second">
|
|
300
|
+
<TabsPanel label="First" value="first">
|
|
301
|
+
<p>First tab content.</p>
|
|
302
|
+
</TabsPanel>
|
|
303
|
+
<TabsPanel label="Second (Initial)" value="second">
|
|
304
|
+
<p>This tab is selected initially.</p>
|
|
305
|
+
</TabsPanel>
|
|
306
|
+
<TabsPanel label="Third" value="third">
|
|
307
|
+
<p>Third tab content.</p>
|
|
308
|
+
</TabsPanel>
|
|
309
|
+
</ControlledTabs>
|
|
310
|
+
);
|
|
311
|
+
```
|