@slotted/react 0.1.0-beta.41 → 0.1.0-beta.42
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/dist/{accordion-n5D6mcmS.js → accordion-xW-aFeGb.js} +1 -1
- package/dist/accordion.js +1 -1
- package/dist/{action-bar-Cq4dt4hP.js → action-bar-BSUuY6pJ.js} +1 -1
- package/dist/action-bar.js +1 -1
- package/dist/{action-sheet-dNnB26br.js → action-sheet-BouG2qh_.js} +1 -1
- package/dist/action-sheet.js +1 -1
- package/dist/{app-shell-DyPHYe4K.js → app-shell-D54YkU7E.js} +126 -110
- package/dist/app-shell.js +2 -2
- package/dist/{calendar-DRuJ7z0H.js → calendar-YQ784o4d.js} +139 -123
- package/dist/calendar.js +1 -1
- package/dist/{cascader-CivJ76VR.js → cascader-fq8fNWSr.js} +1 -1
- package/dist/cascader.js +1 -1
- package/dist/{chart-CgXbG6gZ.js → chart-vedR0BDN.js} +1 -1
- package/dist/chart.js +1 -1
- package/dist/{checkbox-D3E4gzMe.js → checkbox-DsJhlB5c.js} +3 -3
- package/dist/{checkbox-group-Dg5YN3fx.js → checkbox-group-pvX9R_yS.js} +2 -2
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{collapsible-CT4_3aXm.js → collapsible-KzBs5HvA.js} +2 -2
- package/dist/collapsible.js +1 -1
- package/dist/{color-picker-CeOl4ikV.js → color-picker-i-MJ5VVs.js} +4 -4
- package/dist/color-picker.js +1 -1
- package/dist/{column-manager-CnOhzVGP.js → column-manager-D028QbfO.js} +5 -5
- package/dist/column-manager.js +1 -1
- package/dist/{combobox-C2qlkTw6.js → combobox-599heRN_.js} +1 -1
- package/dist/combobox.js +1 -1
- package/dist/{context-menu-WiKS4Zwv.js → context-menu-WM_tT9hz.js} +1 -1
- package/dist/context-menu.js +1 -1
- package/dist/{currency-field-LAawS9qo.js → currency-field-rS36pjCO.js} +1 -1
- package/dist/currency-field.js +1 -1
- package/dist/{dashboard-grid-Zzqmbzqq.js → dashboard-grid-Dh2Q3IQv.js} +2 -2
- package/dist/dashboard-grid.js +1 -1
- package/dist/{data-grid-Y5aX9njc.js → data-grid-D106baPp.js} +17 -17
- package/dist/data-grid.js +1 -1
- package/dist/{data-list-CyEq7M2D.js → data-list-BA0xrySM.js} +2 -2
- package/dist/data-list.js +1 -1
- package/dist/{date-field-CxubN_3u.js → date-field-BZ5JcvXJ.js} +1 -1
- package/dist/date-field.js +1 -1
- package/dist/{date-picker-6hj83x5D.js → date-picker-BvEbsbJC.js} +4 -4
- package/dist/date-picker.js +2 -2
- package/dist/{date-range-picker-CBWnFTgL.js → date-range-picker-uIr-yReE.js} +5 -5
- package/dist/date-range-picker.js +1 -1
- package/dist/{datetime-field-GMIqBuTa.js → datetime-field-DDs3mV9Z.js} +1 -1
- package/dist/datetime-field.js +1 -1
- package/dist/{datetime-picker-DwUYd3zF.js → datetime-picker-DDYXqrjm.js} +6 -6
- package/dist/datetime-picker.js +1 -1
- package/dist/{datetime-range-picker-CX_tBt6b.js → datetime-range-picker-CFTHW771.js} +6 -6
- package/dist/datetime-range-picker.js +1 -1
- package/dist/docs/accordion.examples.md +743 -0
- package/dist/docs/accordion.json +84 -28
- package/dist/docs/accordion.md +56 -152
- package/dist/docs/action-sheet.examples.md +771 -0
- package/dist/docs/action-sheet.json +91 -51
- package/dist/docs/action-sheet.md +72 -233
- package/dist/docs/app-shell.json +7 -0
- package/dist/docs/app-shell.md +1 -0
- package/dist/docs/breadcrumb.json +64 -16
- package/dist/docs/breadcrumb.md +489 -56
- package/dist/docs/collapsible.examples.md +575 -0
- package/dist/docs/collapsible.json +89 -49
- package/dist/docs/collapsible.md +47 -197
- package/dist/docs/context-menu.json +58 -18
- package/dist/docs/context-menu.md +442 -77
- package/dist/docs/field.json +15 -1
- package/dist/docs/field.md +3 -1
- package/dist/docs/floating-panel.json +56 -0
- package/dist/docs/floating-panel.md +329 -8
- package/dist/docs/hover-card.json +65 -17
- package/dist/docs/hover-card.md +422 -64
- package/dist/docs/loading-overlay.examples.md +577 -0
- package/dist/docs/loading-overlay.json +55 -23
- package/dist/docs/loading-overlay.md +49 -168
- package/dist/docs/menu.json +67 -0
- package/dist/docs/menu.md +8 -1
- package/dist/docs/menubar.json +55 -15
- package/dist/docs/menubar.md +488 -42
- package/dist/docs/pagination.json +89 -33
- package/dist/docs/pagination.md +462 -55
- package/dist/docs/popover.json +1 -1
- package/dist/docs/popover.md +1 -1
- package/dist/docs/select.json +55 -1
- package/dist/docs/select.md +7 -2
- package/dist/docs/toggle-group.examples.md +584 -0
- package/dist/docs/toggle-group.json +84 -20
- package/dist/docs/toggle-group.md +17 -182
- package/dist/docs/toggle.json +93 -37
- package/dist/docs/toggle.md +304 -51
- package/dist/{drawer-Du1aC1px.js → drawer-CQagePr_.js} +256 -256
- package/dist/drawer.js +1 -1
- package/dist/{entity-picker-BwJX0gNJ.js → entity-picker-CC4VoC3p.js} +2 -2
- package/dist/entity-picker.js +1 -1
- package/dist/{event-calendar-DzlL95E4.js → event-calendar-CjmF_e0H.js} +5 -5
- package/dist/event-calendar.js +1 -1
- package/dist/field-C-HRhke0.js +421 -0
- package/dist/{field-group-7zV68b3d.js → field-group-CU0PasvW.js} +1 -1
- package/dist/field-group.js +1 -1
- package/dist/field.js +1 -1
- package/dist/{filter-bar-DMuP5P6e.js → filter-bar-B3QJD7SZ.js} +11 -11
- package/dist/filter-bar.js +1 -1
- package/dist/{hover-card-CWCSZ5_p.js → hover-card-CTItbEfH.js} +2 -2
- package/dist/hover-card.js +1 -1
- package/dist/{import-export-center-DzAUMTq5.js → import-export-center-CW8YVZev.js} +1 -1
- package/dist/import-export-center.js +1 -1
- package/dist/index.js +132 -132
- package/dist/{listbox-CWU3DiEt.js → listbox-ZqiJ2yer.js} +1 -1
- package/dist/listbox.js +1 -1
- package/dist/{markdown-7wOBMXTl.js → markdown-BdskE4-L.js} +1 -1
- package/dist/markdown.js +1 -1
- package/dist/menu-parts-DXs5YuUA.js +932 -0
- package/dist/menu.js +1 -1
- package/dist/{menubar-k8Q4_p9l.js → menubar-CVoAFc6r.js} +2 -2
- package/dist/menubar.js +1 -1
- package/dist/{multi-select-DEd_92BC.js → multi-select-Dc2d6dDB.js} +1 -1
- package/dist/multi-select.js +1 -1
- package/dist/{number-field-BJKoidAE.js → number-field-BQ54hXmk.js} +1 -1
- package/dist/number-field.js +1 -1
- package/dist/{otp-input-Czz9Z6dQ.js → otp-input-DRooqa3f.js} +1 -1
- package/dist/otp-input.js +1 -1
- package/dist/{pagination-D0PUAFYm.js → pagination-BRXuyPzo.js} +1 -1
- package/dist/pagination.js +1 -1
- package/dist/{picker-frame-CT5WNEnw.js → picker-frame-B6sPCP5Y.js} +1 -1
- package/dist/{popover-B2t__iNO.js → popover-1DlOu95x.js} +198 -197
- package/dist/popover.js +1 -1
- package/dist/{prompt-composer-Lsfcz_i9.js → prompt-composer-tYIs39rn.js} +1 -1
- package/dist/prompt-composer.js +1 -1
- package/dist/{radio-group-_ZRUgcI5.js → radio-group-AW3xcYYh.js} +2 -2
- package/dist/radio-group.js +1 -1
- package/dist/{rating-C6AkIIUi.js → rating-h3qdHLNi.js} +1 -1
- package/dist/rating.js +1 -1
- package/dist/{saved-views-zM-DxT1F.js → saved-views-nqn0SDXn.js} +4 -4
- package/dist/saved-views.js +1 -1
- package/dist/{segmented-control-D52GeOlS.js → segmented-control-CbK7SurB.js} +2 -2
- package/dist/segmented-control.js +1 -1
- package/dist/select-d448Wkzb.js +1124 -0
- package/dist/select.js +1 -1
- package/dist/{side-navigation-CtZuP87S.js → side-navigation-CKRETc8E.js} +99 -99
- package/dist/side-navigation.js +1 -1
- package/dist/{slider-DQqQ0skr.js → slider-DQ2CnxTO.js} +1 -1
- package/dist/slider.js +1 -1
- package/dist/{split-button-BYowsA6Q.js → split-button-D4MPKSB2.js} +1 -1
- package/dist/split-button.js +1 -1
- package/dist/styles/action-bar.css +1 -1
- package/dist/styles/app-shell.css +1 -1
- package/dist/styles/cascader.css +2 -0
- package/dist/styles/chart.css +1 -1
- package/dist/styles/checkbox-group.css +2 -0
- package/dist/styles/checkbox.css +2 -0
- package/dist/styles/color-picker.css +3 -3
- package/dist/styles/column-manager.css +2 -2
- package/dist/styles/combobox.css +2 -0
- package/dist/styles/context-menu.css +1 -1
- package/dist/styles/currency-field.css +2 -0
- package/dist/styles/dashboard-grid.css +2 -2
- package/dist/styles/data-grid.css +4 -4
- package/dist/styles/data-list.css +3 -1
- package/dist/styles/date-field.css +2 -0
- package/dist/styles/date-picker.css +3 -1
- package/dist/styles/date-range-picker.css +3 -1
- package/dist/styles/datetime-field.css +2 -0
- package/dist/styles/datetime-picker.css +3 -1
- package/dist/styles/datetime-range-picker.css +3 -1
- package/dist/styles/entity-picker.css +3 -1
- package/dist/styles/event-calendar.css +2 -2
- package/dist/styles/field-group.css +2 -0
- package/dist/styles/field.css +2 -0
- package/dist/styles/filter-bar.css +4 -4
- package/dist/styles/floating-panel.css +1 -1
- package/dist/styles/hover-card.css +1 -1
- package/dist/styles/import-export-center.css +3 -3
- package/dist/styles/index.css +9 -9
- package/dist/styles/listbox.css +2 -0
- package/dist/styles/markdown.css +2 -0
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -1
- package/dist/styles/multi-select.css +2 -0
- package/dist/styles/number-field.css +2 -0
- package/dist/styles/otp-input.css +2 -0
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/popover.css +1 -1
- package/dist/styles/prompt-composer.css +2 -0
- package/dist/styles/radio-group.css +2 -0
- package/dist/styles/rating.css +2 -0
- package/dist/styles/saved-views.css +3 -3
- package/dist/styles/segmented-control.css +2 -0
- package/dist/styles/select.css +3 -1
- package/dist/styles/side-navigation.css +1 -1
- package/dist/styles/slider.css +2 -0
- package/dist/styles/split-button.css +1 -1
- package/dist/styles/switch.css +2 -0
- package/dist/styles/table.css +3 -3
- package/dist/styles/tags-input.css +2 -0
- package/dist/styles/text-field.css +2 -0
- package/dist/styles/textarea.css +2 -0
- package/dist/styles/time-field.css +2 -0
- package/dist/styles/time-picker.css +3 -1
- package/dist/styles/time-range-picker.css +3 -1
- package/dist/styles/toggle-group.css +3 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/top-navigation.css +1 -1
- package/dist/styles/transfer.css +2 -0
- package/dist/styles/upload.css +2 -0
- package/dist/styles.css +1 -1
- package/dist/{switch-CcZAVLiW.js → switch-DxMukg7F.js} +1 -1
- package/dist/switch.js +1 -1
- package/dist/{table-D4oX9Gvn.js → table-BecApjeD.js} +13 -13
- package/dist/table.js +1 -1
- package/dist/{tags-input-O87zTh7h.js → tags-input-CqCeLtk-.js} +1 -1
- package/dist/tags-input.js +1 -1
- package/dist/{text-field-Cnjc7LB5.js → text-field-CMOkJ9Z6.js} +1 -1
- package/dist/text-field.js +1 -1
- package/dist/{textarea-DcA7jwOM.js → textarea-DfqPfXTr.js} +1 -1
- package/dist/textarea.js +1 -1
- package/dist/{time-field-BanhrUvf.js → time-field-GyLQsxcc.js} +1 -1
- package/dist/time-field.js +1 -1
- package/dist/{time-picker-Cu1iV039.js → time-picker-CGHPnust.js} +3 -3
- package/dist/time-picker.js +1 -1
- package/dist/{time-range-picker-sdbaFJFN.js → time-range-picker-BMRtAqPy.js} +4 -4
- package/dist/time-range-picker.js +1 -1
- package/dist/{toggle-zDTD5G3H.js → toggle-DSEEtL3Y.js} +7 -2
- package/dist/{toggle-group-D7GQyNQP.js → toggle-group-DZEWkVRo.js} +8 -3
- package/dist/toggle-group.js +1 -1
- package/dist/toggle.js +1 -1
- package/dist/{toolbar-DOV4BKY8.js → toolbar-BP7ka6lN.js} +1 -1
- package/dist/toolbar.js +1 -1
- package/dist/{top-navigation-D3rpgBV2.js → top-navigation-D8IHPOmm.js} +1 -1
- package/dist/top-navigation.js +1 -1
- package/dist/{transfer-CuLlF_nY.js → transfer-sKUvmEKe.js} +5 -5
- package/dist/transfer.js +1 -1
- package/dist/types/app-shell/app-shell-parts.d.ts +7 -0
- package/dist/types/app-shell/app-shell-parts.d.ts.map +1 -1
- package/dist/types/app-shell/index.d.ts +1 -1
- package/dist/types/app-shell/index.d.ts.map +1 -1
- package/dist/types/calendar/calendar.d.ts.map +1 -1
- package/dist/types/calendar/use-clock-today.d.ts +10 -0
- package/dist/types/calendar/use-clock-today.d.ts.map +1 -0
- package/dist/types/field/field-defaults.d.ts +1 -1
- package/dist/types/field/field-defaults.d.ts.map +1 -1
- package/dist/types/field/field-help-sheet.d.ts +15 -0
- package/dist/types/field/field-help-sheet.d.ts.map +1 -0
- package/dist/types/field/field-parts.d.ts +1 -1
- package/dist/types/field/field-parts.d.ts.map +1 -1
- package/dist/types/field/field.types.d.ts +11 -0
- package/dist/types/field/field.types.d.ts.map +1 -1
- package/dist/types/field/index.d.ts +1 -1
- package/dist/types/field/index.d.ts.map +1 -1
- package/dist/types/menu/index.d.ts +1 -1
- package/dist/types/menu/index.d.ts.map +1 -1
- package/dist/types/menu/menu-defaults.d.ts.map +1 -1
- package/dist/types/menu/menu-parts.d.ts.map +1 -1
- package/dist/types/menu/menu-sheet-step.d.ts +6 -0
- package/dist/types/menu/menu-sheet-step.d.ts.map +1 -0
- package/dist/types/menu/menu.d.ts +1 -1
- package/dist/types/menu/menu.d.ts.map +1 -1
- package/dist/types/menu/menu.types.d.ts +15 -0
- package/dist/types/menu/menu.types.d.ts.map +1 -1
- package/dist/types/menu/use-menu-sheet.d.ts +9 -0
- package/dist/types/menu/use-menu-sheet.d.ts.map +1 -0
- package/dist/types/pagination/pagination-parts.d.ts.map +1 -1
- package/dist/types/picker-panel/picker-layer.d.ts +4 -1
- package/dist/types/picker-panel/picker-layer.d.ts.map +1 -1
- package/dist/types/picker-panel/use-picker-layer.d.ts.map +1 -1
- package/dist/types/popover/popover-parts.d.ts.map +1 -1
- package/dist/types/select/index.d.ts +1 -1
- package/dist/types/select/index.d.ts.map +1 -1
- package/dist/types/select/select-defaults.d.ts.map +1 -1
- package/dist/types/select/select-parts.d.ts.map +1 -1
- package/dist/types/select/select.d.ts +6 -2
- package/dist/types/select/select.d.ts.map +1 -1
- package/dist/types/select/select.types.d.ts +9 -0
- package/dist/types/select/select.types.d.ts.map +1 -1
- package/dist/types/select/use-select-sheet.d.ts +9 -0
- package/dist/types/select/use-select-sheet.d.ts.map +1 -0
- package/dist/types/toggle/toggle.d.ts.map +1 -1
- package/dist/types/toggle/toggle.types.d.ts +4 -1
- package/dist/types/toggle/toggle.types.d.ts.map +1 -1
- package/dist/types/toggle-group/toggle-group-parts.d.ts.map +1 -1
- package/dist/types/toggle-group/toggle-group.types.d.ts +4 -1
- package/dist/types/toggle-group/toggle-group.types.d.ts.map +1 -1
- package/dist/{upload-CPl38p-S.js → upload-CuMOaPK3.js} +1 -1
- package/dist/upload.js +1 -1
- package/dist/{use-date-picker-DWV7KWS7.js → use-date-picker-DdSX3RE4.js} +2 -2
- package/dist/{use-picker-draft-BJlHcb6J.js → use-picker-draft-I_pxqYsc.js} +48 -35
- package/package.json +6 -6
- package/dist/field-vOVzvq5t.js +0 -368
- package/dist/menu-parts-DgL617_H.js +0 -814
- package/dist/select-BkUuIVBK.js +0 -1017
package/dist/docs/collapsible.md
CHANGED
|
@@ -6,20 +6,34 @@
|
|
|
6
6
|
## Import
|
|
7
7
|
|
|
8
8
|
```tsx
|
|
9
|
-
import { Collapsible, CollapsibleActions, CollapsibleDefaultsProvider, CollapsibleHeader, CollapsiblePanel, CollapsibleTrigger } from '@slotted/react';
|
|
9
|
+
import { Collapsible, CollapsibleActions, CollapsibleDefaultsProvider, CollapsibleHeader, CollapsibleMore, CollapsiblePanel, CollapsibleTrigger } from '@slotted/react';
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Minimal example
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Example
|
|
15
15
|
|
|
16
16
|
```tsx
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
import {
|
|
18
|
+
Collapsible,
|
|
19
|
+
CollapsibleHeader,
|
|
20
|
+
CollapsiblePanel,
|
|
21
|
+
CollapsibleTrigger,
|
|
22
|
+
} from '@slotted/react/collapsible';
|
|
23
|
+
|
|
24
|
+
export default function CollapsibleBasic() {
|
|
25
|
+
return (
|
|
26
|
+
<Collapsible defaultOpen>
|
|
27
|
+
<CollapsibleHeader>
|
|
28
|
+
<CollapsibleTrigger>Delivery address</CollapsibleTrigger>
|
|
29
|
+
</CollapsibleHeader>
|
|
30
|
+
<CollapsiblePanel>
|
|
31
|
+
Northwind Traders, 402 Maple Street, Seattle, WA 98101. The dock entrance is on the east
|
|
32
|
+
side.
|
|
33
|
+
</CollapsiblePanel>
|
|
34
|
+
</Collapsible>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
23
37
|
```
|
|
24
38
|
|
|
25
39
|
## Anatomy
|
|
@@ -42,33 +56,33 @@ Excerpt — not a complete module
|
|
|
42
56
|
|
|
43
57
|
| Name | Type | Default | Applies to | Description |
|
|
44
58
|
| --- | --- | --- | --- | --- |
|
|
45
|
-
| `open` | `boolean` | — | Collapsible | Present means the consumer owns the state, for the life of the component. Inside an Accordion the set owns it instead, and an explicit open still wins over both |
|
|
46
|
-
| `defaultOpen` | `boolean` | — | Collapsible | The value an uncontrolled disclosure starts from, read once. A later change to it does not silently become new state |
|
|
47
|
-
| `size` | `'sm' \| 'md' \| 'lg'` | md | Collapsible, Accordion, CollapsibleDefaultsProvider | The step the header sits at. The title comes from the type scale and everything geometric from the control scales, so a density changes the rhythm rather than the reading size |
|
|
48
|
-
| `variant` | `'plain' \| 'ruled' \| 'framed'` | plain | Collapsible, CollapsibleDefaultsProvider | plain paints no chrome, ruled draws a hairline above the header so a stack reads as one list, and framed is its own card. An Accordion hands its items the one its own variant maps onto |
|
|
49
|
-
| `indicator` | `'chevron' \| 'plus-minus' \| 'none'` | chevron | Collapsible, Accordion, CollapsibleDefaultsProvider | The mark, drawn from a glyph token. The chevron turns between down and up rather than pointing along the inline axis, so nothing is mirrored for a right-to-left document |
|
|
50
|
-
| `togglePlacement` | `'end' \| 'start'` | end | Collapsible, Accordion, CollapsibleDefaultsProvider | Which side of the words the mark stands on. With it at the start the panel’s content is indented to line up with the title rather than with the mark |
|
|
51
|
-
| `level` | `'none' \| '1' \| '2' \| '3' \| '4' \| '5' \| '6'` | none | Collapsible, CollapsibleDefaultsProvider | The heading element the trigger is wrapped in. none renders a div and writes no heading semantics; an Accordion sets it for a whole set through headingLevel |
|
|
52
|
-
| `mount` | `'active' \| 'lazy' \| 'eager' \| 'until-found'` | eager | Collapsible, Accordion, CollapsibleDefaultsProvider | When the panel’s content exists. The box always does, so aria-controls never names an element that is gone. until-found writes hidden="until-found" and answers beforematch by opening |
|
|
53
|
-
| `peek` | `string` | — | Collapsible, CollapsibleDefaultsProvider | A length (9rem): a closed panel keeps that block size of its content in view under a fade, stays inert, and animates to its full size with the same durations; forced colors drop the fade and keep the clip. The panel carries data-state="peek", and mount is forced to eager |
|
|
54
|
-
| `truncate` | `boolean` | false | Collapsible, Accordion, CollapsibleDefaultsProvider | Clips the title to one line instead of letting the row grow. The whole string stays in the DOM, which
|
|
55
|
-
| `region` | `boolean` | false | Collapsible | Makes the panel a region landmark. Off by default, because the pattern’s own example warns that a landmark per panel fills the landmark list |
|
|
56
|
-
| `disabled` | `boolean` | false | Collapsible | Reaches the trigger as the native attribute, which is also what stops the press. Unstated rather than false, so the disclosure defers to the Accordion around it |
|
|
57
|
-
| `loading` | `boolean` | false | Collapsible | The panel keeps a line’s height and carries aria-busy; what stands in for the content is Skeleton, composed by the consumer |
|
|
58
|
-
| `value` | `string` | from useId | Collapsible | What this disclosure is called inside an Accordion. It is identity rather than state, and it reaches the DOM as data-value |
|
|
59
|
-
| `summary` | `ReactNode` | — | CollapsibleTrigger | What the disclosure holds, at the end of the title line and before the mark, cut with an ellipsis; inside the trigger and therefore inside its accessible name |
|
|
60
|
-
| `description` | `ReactNode` | — | CollapsibleTrigger | A second line under the title, inside the trigger and therefore inside its accessible name |
|
|
61
|
-
| `render` | `(props) => ReactNode` | — | Collapsible, CollapsibleHeader, CollapsibleTrigger, CollapsibleActions, CollapsiblePanel | Substitutes any of the five roots and hands it every attribute — a disclosure can be a section, a panel an article. The heading may become another element, but the trigger has to stay its only child |
|
|
62
|
-
| `ref` | `Ref<HTMLElement>` | — | every part | Reaches the element itself, so focus() and click() are the platform’s and no imperative handle is invented for what it already ships |
|
|
63
|
-
| `useCollapsible()` | `() => CollapsibleContextValue` | — | inside Collapsible | What the parts read: the open state, the identifiers, the mount strategy, whether the group holds this one open, and toggle(next, reason). It throws outside
|
|
64
|
-
| `CollapsibleDefaultsProvider` | `{ size, variant, indicator, togglePlacement, level, mount, truncate }` | — | a subtree | The
|
|
59
|
+
| `open` | `boolean` | — | Collapsible | Present means the consumer owns the state, for the life of the component. Inside an Accordion the set owns it instead, and an explicit open still wins over both. |
|
|
60
|
+
| `defaultOpen` | `boolean` | — | Collapsible | The value an uncontrolled disclosure starts from, read once. A later change to it does not silently become new state. |
|
|
61
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | md | Collapsible, Accordion, CollapsibleDefaultsProvider | The step the header sits at. The title comes from the type scale and everything geometric from the control scales, so a density changes the rhythm rather than the reading size. |
|
|
62
|
+
| `variant` | `'plain' \| 'ruled' \| 'framed'` | plain | Collapsible, CollapsibleDefaultsProvider | plain paints no chrome, ruled draws a hairline above the header so a stack reads as one list, and framed is its own card. An Accordion hands its items the one its own variant maps onto. |
|
|
63
|
+
| `indicator` | `'chevron' \| 'plus-minus' \| 'none'` | chevron | Collapsible, Accordion, CollapsibleDefaultsProvider | The mark, drawn from a glyph token. The chevron turns between down and up rather than pointing along the inline axis, so nothing is mirrored for a right-to-left document. |
|
|
64
|
+
| `togglePlacement` | `'end' \| 'start'` | end | Collapsible, Accordion, CollapsibleDefaultsProvider | Which side of the words the mark stands on. With it at the start the panel’s content is indented to line up with the title rather than with the mark. |
|
|
65
|
+
| `level` | `'none' \| '1' \| '2' \| '3' \| '4' \| '5' \| '6'` | none | Collapsible, CollapsibleDefaultsProvider | The heading element the trigger is wrapped in. none renders a div and writes no heading semantics; an Accordion sets it for a whole set through headingLevel. |
|
|
66
|
+
| `mount` | `'active' \| 'lazy' \| 'eager' \| 'until-found'` | eager | Collapsible, Accordion, CollapsibleDefaultsProvider | When the panel’s content exists. The box always does, so aria-controls never names an element that is gone. until-found writes hidden="until-found" and answers beforematch by opening. |
|
|
67
|
+
| `peek` | `string` | — | Collapsible, CollapsibleDefaultsProvider | A length (9rem): a closed panel keeps that block size of its content in view under a fade, stays inert, and animates to its full size with the same durations; forced colors drop the fade and keep the clip. The panel carries data-state="peek", and mount is forced to eager. |
|
|
68
|
+
| `truncate` | `boolean` | false | Collapsible, Accordion, CollapsibleDefaultsProvider | Clips the title to one line instead of letting the row grow. The whole string stays in the DOM, which holds for every component. |
|
|
69
|
+
| `region` | `boolean` | false | Collapsible | Makes the panel a region landmark. Off by default, because the pattern’s own example warns that a landmark per panel fills the landmark list. |
|
|
70
|
+
| `disabled` | `boolean` | false | Collapsible | Reaches the trigger as the native attribute, which is also what stops the press. Unstated rather than false, so the disclosure defers to the Accordion around it. |
|
|
71
|
+
| `loading` | `boolean` | false | Collapsible | The panel keeps a line’s height and carries aria-busy; what stands in for the content is Skeleton, composed by the consumer. |
|
|
72
|
+
| `value` | `string` | from useId | Collapsible | What this disclosure is called inside an Accordion. It is identity rather than state, and it reaches the DOM as data-value. |
|
|
73
|
+
| `summary` | `ReactNode` | — | CollapsibleTrigger | What the disclosure holds, at the end of the title line and before the mark, cut with an ellipsis; inside the trigger and therefore inside its accessible name. |
|
|
74
|
+
| `description` | `ReactNode` | — | CollapsibleTrigger | A second line under the title, inside the trigger and therefore inside its accessible name. |
|
|
75
|
+
| `render` | `(props) => ReactNode` | — | Collapsible, CollapsibleHeader, CollapsibleTrigger, CollapsibleActions, CollapsiblePanel | Substitutes any of the five roots and hands it every attribute — a disclosure can be a section, a panel an article. The heading may become another element, but the trigger has to stay its only child. |
|
|
76
|
+
| `ref` | `Ref<HTMLElement>` | — | every part | Reaches the element itself, so focus() and click() are the platform’s and no imperative handle is invented for what it already ships. |
|
|
77
|
+
| `useCollapsible()` | `() => CollapsibleContextValue` | — | inside Collapsible | What the parts read: the open state, the identifiers, the mount strategy, whether the group holds this one open, and toggle(next, reason). It throws outside Collapsible rather than rendering a control that does nothing. |
|
|
78
|
+
| `CollapsibleDefaultsProvider` | `{ size, variant, indicator, togglePlacement, level, mount, peek, truncate }` | — | a subtree | The decisions an application takes once: size, variant, indicator, togglePlacement, level, mount, peek and truncate. An Accordion sits between it and the item, and a disclosure that states any of them itself still wins. |
|
|
65
79
|
|
|
66
80
|
## Events
|
|
67
81
|
|
|
68
82
|
| Name | Payload | When |
|
|
69
83
|
| --- | --- | --- |
|
|
70
84
|
| `onOpenChange` | `(open: boolean, request: ChangeRequest<boolean>)` | Before the panel moves. The request carries the new value, the value it replaces, the reason (pointer, keyboard, select or programmatic), the originating event, and cancel(), which refuses the move before anything commits. Inside an Accordion it still fires, so a consumer may watch one panel without unpacking the set’s array. |
|
|
71
|
-
| `onClick, onFocus, onKeyDown, on the trigger` | `the element’s own events` | Whenever the button fires them.
|
|
85
|
+
| `onClick, onFocus, onKeyDown, on the trigger` | `the element’s own events` | Whenever the button fires them. Collapsible composes with a consumer’s handler rather than replacing it: the consumer’s runs first, and preventDefault() in onClick refuses the toggle as well. |
|
|
72
86
|
|
|
73
87
|
## Axes and defaults
|
|
74
88
|
|
|
@@ -83,12 +97,12 @@ Excerpt — not a complete module
|
|
|
83
97
|
|
|
84
98
|
## Rules
|
|
85
99
|
|
|
86
|
-
- The pattern is the WAI-ARIA APG’s Disclosure (w3.org/WAI/ARIA/apg/patterns/disclosure/), and inside an Accordion it answers the Accordion pattern as well. Its whole keyboard table is the platform’s: the trigger is a button, so Enter and Space toggle without
|
|
100
|
+
- The pattern is the WAI-ARIA APG’s Disclosure (w3.org/WAI/ARIA/apg/patterns/disclosure/), and inside an Accordion it answers the Accordion pattern as well. Its whole keyboard table is the platform’s: the trigger is a button, so Enter and Space toggle without Collapsible binding a key, and Tab reaches it like any other control — the pattern requires every focusable element in an accordion to be in the page tab sequence, which is why nothing here writes tabindex.
|
|
87
101
|
- The trigger carries aria-expanded and aria-controls; the panel carries aria-labelledby pointing back. Both identifiers come from useId, so a server response and the first client render agree. The panel’s box is never removed — mount drops its content, not the box — because aria-controls naming an element that is not there is a reference a screen reader has to make sense of.
|
|
88
|
-
- A closed panel is out of the tab sequence and out of the accessibility tree twice over: the stylesheet with content-visibility, and the binding with inert, so a browser without the property still cannot put focus inside it. Under mount="until-found" neither applies: hidden="until-found" is what lets the browser’s page search reach the text and open the panel, and beforematch is what tells
|
|
102
|
+
- A closed panel is out of the tab sequence and out of the accessibility tree twice over: the stylesheet with content-visibility, and the binding with inert, so a browser without the property still cannot put focus inside it. Under mount="until-found" neither applies: hidden="until-found" is what lets the browser’s page search reach the text and open the panel, and beforematch is what tells Collapsible to open.
|
|
89
103
|
- The heading is real. level renders h1 to h6 and the trigger is its only element, which is what the pattern requires; an accordion sets the level once for a whole set. level="none" writes no heading semantics at all, for a disclosure that belongs to no outline.
|
|
90
104
|
- aria-disabled appears on the trigger only when an Accordion refuses to let this panel close. That is the pattern’s own instruction for a set that requires one panel to stay open, and it leaves the control focusable and announced rather than removing it from the reader’s path.
|
|
91
|
-
- The
|
|
105
|
+
- The trigger is a button and the panel a div, rather than details and summary. What that costs is written down: a page with JavaScript disabled cannot open a panel. What it buys is the accordion pattern — a summary cannot be wrapped in a heading — a value the consumer can own, a request that carries a reason, and a panel that animates without interpolate-size.
|
|
92
106
|
- The mark is never the only thing that says the state: aria-expanded says it to a reader, and the indicator turns rather than changing color, so the high-contrast scheme and forced colors both keep it.
|
|
93
107
|
|
|
94
108
|
## Tokens
|
|
@@ -97,168 +111,4 @@ Excerpt — not a complete module
|
|
|
97
111
|
|
|
98
112
|
## Examples
|
|
99
113
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
plain paints no chrome, ruled puts a hairline above the header so a stack reads as one list, and framed is a card. All three keep the same geometry.
|
|
103
|
-
|
|
104
|
-
Excerpt — not a complete module
|
|
105
|
-
|
|
106
|
-
```tsx
|
|
107
|
-
<Collapsible variant="framed" defaultOpen>
|
|
108
|
-
<CollapsibleHeader>
|
|
109
|
-
<CollapsibleTrigger>Payment methods</CollapsibleTrigger>
|
|
110
|
-
</CollapsibleHeader>
|
|
111
|
-
<CollapsiblePanel>Credit card, ACH transfer and Zelle.</CollapsiblePanel>
|
|
112
|
-
</Collapsible>;
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### The step the header sits at
|
|
116
|
-
|
|
117
|
-
The title comes from the type scale, because a header is prose; the row’s height, padding, gap and mark come from the control scales, so a dense page is tighter rather than smaller.
|
|
118
|
-
|
|
119
|
-
Excerpt — not a complete module
|
|
120
|
-
|
|
121
|
-
```tsx
|
|
122
|
-
<Collapsible size="lg" defaultOpen>
|
|
123
|
-
<CollapsibleHeader>
|
|
124
|
-
<CollapsibleTrigger description="3 of 12 items">Summary</CollapsibleTrigger>
|
|
125
|
-
</CollapsibleHeader>
|
|
126
|
-
<CollapsiblePanel>Delivery scheduled for September 12.</CollapsiblePanel>
|
|
127
|
-
</Collapsible>;
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### The mark, and which side it stands on
|
|
131
|
-
|
|
132
|
-
The chevron turns rather than pointing along the inline axis, so a right-to-left document needs no mirrored artwork; plus-minus is one pair drawn on one grid, and none draws nothing.
|
|
133
|
-
|
|
134
|
-
Excerpt — not a complete module
|
|
135
|
-
|
|
136
|
-
```tsx
|
|
137
|
-
<Collapsible indicator="plus-minus" togglePlacement="start">
|
|
138
|
-
<CollapsibleHeader>
|
|
139
|
-
<CollapsibleTrigger>Invoice</CollapsibleTrigger>
|
|
140
|
-
</CollapsibleHeader>
|
|
141
|
-
<CollapsiblePanel>Issued on September 3.</CollapsiblePanel>
|
|
142
|
-
</Collapsible>;
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Where it sits in the outline
|
|
146
|
-
|
|
147
|
-
level renders the heading element itself, so a screen reader’s heading list holds the disclosure at the right depth. none renders a div, for a control that belongs to no outline.
|
|
148
|
-
|
|
149
|
-
Excerpt — not a complete module
|
|
150
|
-
|
|
151
|
-
```tsx
|
|
152
|
-
<Collapsible level="3">
|
|
153
|
-
<CollapsibleHeader>
|
|
154
|
-
<CollapsibleTrigger>Return conditions</CollapsibleTrigger>
|
|
155
|
-
</CollapsibleHeader>
|
|
156
|
-
<CollapsiblePanel>Thirty calendar days.</CollapsiblePanel>
|
|
157
|
-
</Collapsible>;
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### A summary that stays visible
|
|
161
|
-
|
|
162
|
-
The second line is inside the trigger and therefore inside the accessible name, which is what the pattern means by a snippet of the hidden content staying visible.
|
|
163
|
-
|
|
164
|
-
Excerpt — not a complete module
|
|
165
|
-
|
|
166
|
-
```tsx
|
|
167
|
-
<CollapsibleTrigger description="2 regras ativas">Regras de frete</CollapsibleTrigger>;
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### A control beside the heading
|
|
171
|
-
|
|
172
|
-
It is a sibling of the heading rather than a child, because the pattern requires the button to be the only element inside it — and a control inside a button is invalid besides.
|
|
173
|
-
|
|
174
|
-
Excerpt — not a complete module
|
|
175
|
-
|
|
176
|
-
```tsx
|
|
177
|
-
<Collapsible variant="framed" defaultOpen>
|
|
178
|
-
<CollapsibleHeader>
|
|
179
|
-
<CollapsibleTrigger>Regras de frete</CollapsibleTrigger>
|
|
180
|
-
</CollapsibleHeader>
|
|
181
|
-
<CollapsibleActions>
|
|
182
|
-
<Toolbar aria-label="Rule actions" size="sm">
|
|
183
|
-
<Button size="sm" variant="ghost">
|
|
184
|
-
Edit
|
|
185
|
-
</Button>
|
|
186
|
-
</Toolbar>
|
|
187
|
-
</CollapsibleActions>
|
|
188
|
-
<CollapsiblePanel>Free shipping over $250.00.</CollapsiblePanel>
|
|
189
|
-
</Collapsible>;
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### When the content exists
|
|
193
|
-
|
|
194
|
-
eager builds it up front so the panel can transition closed, lazy builds it on the first open, active drops it each time, and until-found lets the browser’s own page search open the panel. A closed item under active commits once and reads no layout and no computed style; it creates no observer and no portal. Fifty closed items inside an Accordion, measured in Chrome: 7 ms of script and 23 ms to layout with a production build of React, 46 ms of script and 83 ms to layout with its development build.
|
|
195
|
-
|
|
196
|
-
Excerpt — not a complete module
|
|
197
|
-
|
|
198
|
-
```tsx
|
|
199
|
-
<Collapsible mount="until-found">
|
|
200
|
-
<CollapsibleHeader>
|
|
201
|
-
<CollapsibleTrigger>Delivery history</CollapsibleTrigger>
|
|
202
|
-
</CollapsibleHeader>
|
|
203
|
-
<CollapsiblePanel>Delivered on September 2 by Anna Rivers.</CollapsiblePanel>
|
|
204
|
-
</Collapsible>;
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Every state the family paints
|
|
208
|
-
|
|
209
|
-
Hover lays a wash under the row and press goes one step further; disabled answers neither, because the browser has already taken the control out of action; loading holds the box open and says so.
|
|
210
|
-
|
|
211
|
-
Excerpt — not a complete module
|
|
212
|
-
|
|
213
|
-
```tsx
|
|
214
|
-
<Collapsible loading defaultOpen mount="lazy">
|
|
215
|
-
<CollapsibleHeader>
|
|
216
|
-
<CollapsibleTrigger>Delivery history</CollapsibleTrigger>
|
|
217
|
-
</CollapsibleHeader>
|
|
218
|
-
<CollapsiblePanel>
|
|
219
|
-
<Skeleton shape="text" />
|
|
220
|
-
</CollapsiblePanel>
|
|
221
|
-
</Collapsible>;
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Content the family did not choose
|
|
225
|
-
|
|
226
|
-
A long title grows the row instead of pushing the mark off the line, truncate clips it to one line with the whole string still in the DOM, and a title in another script reads its own way.
|
|
227
|
-
|
|
228
|
-
Excerpt — not a complete module
|
|
229
|
-
|
|
230
|
-
```tsx
|
|
231
|
-
<Collapsible truncate>
|
|
232
|
-
<CollapsibleHeader>
|
|
233
|
-
<CollapsibleTrigger>Return conditions for international orders</CollapsibleTrigger>
|
|
234
|
-
</CollapsibleHeader>
|
|
235
|
-
<CollapsiblePanel>Thirty calendar days.</CollapsiblePanel>
|
|
236
|
-
</Collapsible>;
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### Setting it once, and reaching past it
|
|
240
|
-
|
|
241
|
-
The provider carries the seven decisions an application takes once, render substitutes every root, and a disclosure nests inside another’s panel without the outer one opening it.
|
|
242
|
-
|
|
243
|
-
Excerpt — not a complete module
|
|
244
|
-
|
|
245
|
-
```tsx
|
|
246
|
-
<CollapsibleDefaultsProvider variant="framed" size="sm">
|
|
247
|
-
<Collapsible>…</Collapsible>
|
|
248
|
-
</CollapsibleDefaultsProvider>;
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
### The pattern’s table, and which device asked
|
|
252
|
-
|
|
253
|
-
Enter and Space toggle because the trigger is a button; Tab reaches it like any other control, because the pattern keeps every disclosure in the page tab sequence.
|
|
254
|
-
|
|
255
|
-
Excerpt — not a complete module
|
|
256
|
-
|
|
257
|
-
```tsx
|
|
258
|
-
<Collapsible onOpenChange={(open, request) => report(request.reason)}>
|
|
259
|
-
<CollapsibleHeader>
|
|
260
|
-
<CollapsibleTrigger>With the pointer, then with the keyboard</CollapsibleTrigger>
|
|
261
|
-
</CollapsibleHeader>
|
|
262
|
-
<CollapsiblePanel>The reason changes with the device.</CollapsiblePanel>
|
|
263
|
-
</Collapsible>;
|
|
264
|
-
```
|
|
114
|
+
See [collapsible.examples.md](./collapsible.examples.md).
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"docs": {
|
|
44
44
|
"contextMenu": {
|
|
45
45
|
"imports": {
|
|
46
|
-
"source": "import {
|
|
46
|
+
"source": "import {\n ContextMenu,\n ContextMenuTrigger,\n ContextMenuDefaultsProvider,\n} from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem, MenuSeparator } from '@slotted/react/menu';"
|
|
47
47
|
},
|
|
48
48
|
"anatomy": [
|
|
49
49
|
{
|
|
@@ -94,14 +94,14 @@
|
|
|
94
94
|
"type": "boolean",
|
|
95
95
|
"defaultValue": "false",
|
|
96
96
|
"appliesTo": "ContextMenu",
|
|
97
|
-
"description": "The
|
|
97
|
+
"description": "The context menu never opens and the browser's own menu passes through. The target carries data-disabled."
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"name": "size, side, align, closeOnSelect, loop, typeahead, …",
|
|
101
101
|
"type": "MenuProps",
|
|
102
102
|
"defaultValue": "—",
|
|
103
103
|
"appliesTo": "ContextMenu",
|
|
104
|
-
"description": "Every prop of Menu except anchor and finalFocus, which
|
|
104
|
+
"description": "Every prop of Menu except anchor and finalFocus, which ContextMenu decides, reaches the menu it renders."
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
107
|
"name": "render",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"type": "attribute",
|
|
139
139
|
"defaultValue": "—",
|
|
140
140
|
"appliesTo": "MenuContent",
|
|
141
|
-
"description": "The surface is named after the target's text unless given
|
|
141
|
+
"description": "The surface is named after the target's text unless given an aria-label. The text fits a row and does not fit a canvas."
|
|
142
142
|
},
|
|
143
143
|
{
|
|
144
144
|
"name": "native props",
|
|
@@ -156,10 +156,10 @@
|
|
|
156
156
|
}
|
|
157
157
|
],
|
|
158
158
|
"accessibility": [
|
|
159
|
-
"The platform supplies the gesture: the contextmenu event is the secondary click, the Menu key and Shift+F10 on every desktop, and the
|
|
160
|
-
"The
|
|
159
|
+
"The platform supplies the gesture: the contextmenu event is the secondary click, the Menu key and Shift+F10 on every desktop, and the target answers all three with preventDefault while the context menu is enabled and with nothing while it is disabled, so a reader is never left with no menu at all.",
|
|
160
|
+
"The target writes no aria-haspopup — it is not permitted on a generic element — so a screen reader is not told the region has a menu. For that reason every command in a context menu also exists by another path, and the other-path example shows one.",
|
|
161
161
|
"Focus goes to the first item on open and, on Escape or after a command, back to whatever held it when the menu opened — the checkbox in the row, the tile itself — rather than to a trigger that never had it. A press elsewhere leaves focus where the reader put it.",
|
|
162
|
-
"The
|
|
162
|
+
"The target writes no tabindex. A target the page made focusable opens from the keyboard; one it did not make focusable does not. A tab stop on every wrapped region would break a grid with roving focus."
|
|
163
163
|
]
|
|
164
164
|
}
|
|
165
165
|
},
|
|
@@ -196,40 +196,40 @@
|
|
|
196
196
|
"title": "One menu for many rows",
|
|
197
197
|
"note": "A list of files with one ContextMenu around all of them. Right-click any row: the request carries the event, the handler reads the row from it, and the menu names the file it acts on. Mounting a menu per row is the shape this composition exists to avoid.",
|
|
198
198
|
"language": "tsx",
|
|
199
|
-
"source": "const [file, setFile] = useState<string | null>(null);\n\n
|
|
200
|
-
"verdict": "
|
|
199
|
+
"source": "import { useState } from 'react';\nimport { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem, MenuSeparator } from '@slotted/react/menu';\nimport type { MenuChangeRequest } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst FILES = [\n { name: 'Supplier contract.docx', size: '180 KB' },\n { name: 'Stock count March.xlsx', size: '640 KB' },\n { name: 'Carrier rates 2026.pdf', size: '2.1 MB' },\n];\n\nexport default function ContextMenuRows() {\n const [file, setFile] = useState<string | null>(null);\n\n function handleOpenChange(open: boolean, request: MenuChangeRequest) {\n if (open) setFile(fileOf(request.source));\n }\n\n return (\n <Stack gap={3}>\n <ContextMenu onOpenChange={handleOpenChange}>\n <ContextMenuTrigger>\n <Stack gap={3}>\n {FILES.map((entry) => (\n <Text data-file={entry.name} key={entry.name}>\n {entry.name} · {entry.size}\n </Text>\n ))}\n </Stack>\n </ContextMenuTrigger>\n <MenuContent aria-label={file ?? 'File actions'}>\n <MenuItem>Open</MenuItem>\n <MenuItem>Download</MenuItem>\n <MenuSeparator />\n <MenuItem tone=\"danger\">Move to trash</MenuItem>\n </MenuContent>\n </ContextMenu>\n <Text size=\"sm\" tone=\"muted\">\n {file === null ? 'Right-click a file.' : `The menu acts on ${file}.`}\n </Text>\n </Stack>\n );\n}\n\nfunction fileOf(source: unknown): string | null {\n const target = (source as Event | undefined)?.target;\n const row = target instanceof Element ? target.closest('[data-file]') : null;\n\n return row?.getAttribute('data-file') ?? null;\n}\n",
|
|
200
|
+
"verdict": "example"
|
|
201
201
|
},
|
|
202
202
|
{
|
|
203
203
|
"id": "keyboard",
|
|
204
204
|
"title": "From the keyboard",
|
|
205
205
|
"note": "Tab to the tile — it is focusable because the page said so, with tabIndex — and press Shift+F10 or the Menu key. The menu hangs from the tile rather than from wherever the pointer last was, focus lands on the first item, and Escape brings it back to the tile.",
|
|
206
206
|
"language": "tsx",
|
|
207
|
-
"source": "<ContextMenu>\n
|
|
208
|
-
"verdict": "
|
|
207
|
+
"source": "import { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem, MenuSeparator } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuKeyboard() {\n return (\n <ContextMenu>\n <ContextMenuTrigger tabIndex={0}>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Release notes 4.2\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Press Tab to focus this item, then Shift+F10 or the Menu key.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>Open</MenuItem>\n <MenuItem>Copy link</MenuItem>\n <MenuSeparator />\n <MenuItem>Archive</MenuItem>\n </MenuContent>\n </ContextMenu>\n );\n}\n",
|
|
208
|
+
"verdict": "example"
|
|
209
209
|
},
|
|
210
210
|
{
|
|
211
211
|
"id": "touch",
|
|
212
212
|
"title": "On touch",
|
|
213
213
|
"note": "There is no secondary button on a touch screen: holding the tile for half a second opens the menu at the finger, while text selection and the platform's callout are held off for the duration of the press. Lifting or moving past ten pixels before then cancels it, so a scroll that starts on the tile is still a scroll.",
|
|
214
214
|
"language": "tsx",
|
|
215
|
-
"source": "<
|
|
216
|
-
"verdict": "
|
|
215
|
+
"source": "import { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuTouch() {\n return (\n <ContextMenu longPressDelay={800}>\n <ContextMenuTrigger>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Order SO-10482\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Out for delivery. On touch, hold for 800 ms.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>View order</MenuItem>\n <MenuItem>Track delivery</MenuItem>\n <MenuItem>Print packing slip</MenuItem>\n </MenuContent>\n </ContextMenu>\n );\n}\n",
|
|
216
|
+
"verdict": "example"
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
"id": "other-path",
|
|
220
220
|
"title": "The other path",
|
|
221
221
|
"note": "A context menu is found by convention, and a reader who never right-clicks must still reach every command in it: the same actions sit behind the Actions button on the tile, as a menu opened the ordinary way. The two surfaces are one MenuContent rendered twice.",
|
|
222
222
|
"language": "tsx",
|
|
223
|
-
"source": "const actions = (\n
|
|
224
|
-
"verdict": "
|
|
223
|
+
"source": "import { Button } from '@slotted/react/button';\nimport { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport { Inline } from '@slotted/react/inline';\nimport { Menu, MenuContent, MenuItem, MenuTrigger } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuOtherPath() {\n const actions = (\n <MenuContent aria-label=\"Shipment actions\">\n <MenuItem>Track shipment</MenuItem>\n <MenuItem>Print label</MenuItem>\n <MenuItem>Contact carrier</MenuItem>\n </MenuContent>\n );\n\n return (\n <ContextMenu>\n <ContextMenuTrigger>\n <Stack gap={2}>\n <Heading level={2} size=\"md\">\n Shipment SH-20418\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Right-click this shipment or press Actions: both open the same commands.\n </Text>\n <Inline>\n <Menu>\n <MenuTrigger\n render={(props) => (\n <Button {...props} variant=\"outline\">\n Actions\n </Button>\n )}\n />\n {actions}\n </Menu>\n </Inline>\n </Stack>\n </ContextMenuTrigger>\n {actions}\n </ContextMenu>\n );\n}\n",
|
|
224
|
+
"verdict": "example"
|
|
225
225
|
},
|
|
226
226
|
{
|
|
227
227
|
"id": "disabled",
|
|
228
228
|
"title": "Disabled",
|
|
229
|
-
"note": "A disabled
|
|
229
|
+
"note": "A disabled context menu suppresses nothing: the browser's own menu opens on the secondary click, because taking both away would leave the reader with none. The target says so with data-disabled and paints nothing, since the content it wraps still works.",
|
|
230
230
|
"language": "tsx",
|
|
231
|
-
"source": "<ContextMenu disabled>\n
|
|
232
|
-
"verdict": "
|
|
231
|
+
"source": "import { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuDisabled() {\n return (\n <Stack gap={4}>\n <ContextMenu>\n <ContextMenuTrigger>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Draft report\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Enabled: right-click opens the commands.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>Edit</MenuItem>\n <MenuItem>Publish</MenuItem>\n </MenuContent>\n </ContextMenu>\n <ContextMenu disabled>\n <ContextMenuTrigger>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Published report\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Disabled: right-click opens the browser menu.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>Edit</MenuItem>\n <MenuItem>Unpublish</MenuItem>\n </MenuContent>\n </ContextMenu>\n </Stack>\n );\n}\n",
|
|
232
|
+
"verdict": "example"
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
235
|
"id": "states",
|
|
@@ -238,6 +238,46 @@
|
|
|
238
238
|
"language": "css",
|
|
239
239
|
"source": "[data-ui='context-menu'][data-open] {\n --slotted-context-menu-mark-color: var(--slotted-tone-accent-border);\n}\n[data-ui='context-menu'][data-pressed] {\n opacity: 0.9;\n}\n",
|
|
240
240
|
"verdict": "excerpt"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"id": "basic",
|
|
244
|
+
"title": "basic.tsx",
|
|
245
|
+
"note": null,
|
|
246
|
+
"language": "tsx",
|
|
247
|
+
"source": "import { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem, MenuSeparator } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuBasic() {\n return (\n <ContextMenu>\n <ContextMenuTrigger>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Q3 board deck.pdf\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n 4.2 MB, edited yesterday. Right-click anywhere on this file.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>Open</MenuItem>\n <MenuItem>Rename</MenuItem>\n <MenuItem>Duplicate</MenuItem>\n <MenuSeparator />\n <MenuItem tone=\"danger\">Move to trash</MenuItem>\n </MenuContent>\n </ContextMenu>\n );\n}\n",
|
|
248
|
+
"verdict": "example"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"id": "canvas",
|
|
252
|
+
"title": "canvas.tsx",
|
|
253
|
+
"note": null,
|
|
254
|
+
"language": "tsx",
|
|
255
|
+
"source": "import { useState } from 'react';\nimport { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport {\n MenuCheckboxItem,\n MenuContent,\n MenuGroup,\n MenuItem,\n MenuSeparator,\n} from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuCanvas() {\n const [labels, setLabels] = useState(true);\n const [paths, setPaths] = useState(false);\n\n return (\n <ContextMenu>\n <ContextMenuTrigger>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Warehouse floor plan\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Aisles A1 to D4. {labels ? 'Aisle labels on.' : 'Aisle labels off.'}{' '}\n {paths ? 'Pick paths on.' : 'Pick paths off.'}\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent aria-label=\"Floor plan actions\">\n <MenuGroup label=\"View\">\n <MenuCheckboxItem checked={labels} onCheckedChange={setLabels}>\n Aisle labels\n </MenuCheckboxItem>\n <MenuCheckboxItem checked={paths} onCheckedChange={setPaths}>\n Pick paths\n </MenuCheckboxItem>\n </MenuGroup>\n <MenuSeparator />\n <MenuItem>Export as PDF</MenuItem>\n </MenuContent>\n </ContextMenu>\n );\n}\n",
|
|
256
|
+
"verdict": "example"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"id": "controlled",
|
|
260
|
+
"title": "controlled.tsx",
|
|
261
|
+
"note": null,
|
|
262
|
+
"language": "tsx",
|
|
263
|
+
"source": "import { useState } from 'react';\nimport { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem } from '@slotted/react/menu';\nimport type { MenuChangeRequest } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuControlled() {\n const [open, setOpen] = useState(false);\n const [last, setLast] = useState('Closed');\n\n function handleOpenChange(next: boolean, request: MenuChangeRequest) {\n setOpen(next);\n setLast(`${next ? 'Opened' : 'Closed'} by ${request.reason}`);\n }\n\n return (\n <Stack gap={3}>\n <ContextMenu onOpenChange={handleOpenChange} open={open}>\n <ContextMenuTrigger tabIndex={0}>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Purchase order PO-5521\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Right-click, press Shift+F10, press Escape or click elsewhere.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>Approve</MenuItem>\n <MenuItem>Request changes</MenuItem>\n <MenuItem>Send to supplier</MenuItem>\n </MenuContent>\n </ContextMenu>\n <Text size=\"sm\" tone=\"muted\">\n {last}\n </Text>\n </Stack>\n );\n}\n",
|
|
264
|
+
"verdict": "example"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"id": "defaults",
|
|
268
|
+
"title": "defaults.tsx",
|
|
269
|
+
"note": null,
|
|
270
|
+
"language": "tsx",
|
|
271
|
+
"source": "import {\n ContextMenu,\n ContextMenuDefaultsProvider,\n ContextMenuTrigger,\n} from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuDefaults() {\n return (\n <ContextMenuDefaultsProvider longPressDelay={800}>\n <Stack gap={4}>\n <ContextMenu>\n <ContextMenuTrigger>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Inbound dock\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Holds for 800 ms, the delay the provider sets.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>Schedule unloading</MenuItem>\n <MenuItem>View arrivals</MenuItem>\n </MenuContent>\n </ContextMenu>\n <ContextMenu longPressDelay={300}>\n <ContextMenuTrigger>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Outbound dock\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Holds for 300 ms, the delay this target sets.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>Schedule loading</MenuItem>\n <MenuItem>View departures</MenuItem>\n </MenuContent>\n </ContextMenu>\n </Stack>\n </ContextMenuDefaultsProvider>\n );\n}\n",
|
|
272
|
+
"verdict": "example"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"id": "long-press-off",
|
|
276
|
+
"title": "long-press-off.tsx",
|
|
277
|
+
"note": null,
|
|
278
|
+
"language": "tsx",
|
|
279
|
+
"source": "import { ContextMenu, ContextMenuTrigger } from '@slotted/react/context-menu';\nimport { MenuContent, MenuItem } from '@slotted/react/menu';\nimport { Stack } from '@slotted/react/stack';\nimport { Heading, Text } from '@slotted/react/typography';\n\nexport default function ContextMenuLongPressOff() {\n return (\n <ContextMenu longPress={false}>\n <ContextMenuTrigger tabIndex={0}>\n <Stack gap={1}>\n <Heading level={2} size=\"md\">\n Invoice INV-3307\n </Heading>\n <Text size=\"sm\" tone=\"muted\">\n Touch and pen keep their own long-press behavior here.\n </Text>\n </Stack>\n </ContextMenuTrigger>\n <MenuContent>\n <MenuItem>Send reminder</MenuItem>\n <MenuItem>Record payment</MenuItem>\n <MenuItem>Download PDF</MenuItem>\n </MenuContent>\n </ContextMenu>\n );\n}\n",
|
|
280
|
+
"verdict": "example"
|
|
241
281
|
}
|
|
242
282
|
]
|
|
243
283
|
}
|