@slotted/react 0.1.0-beta.42 → 0.1.0-beta.43
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/{app-shell-D54YkU7E.js → app-shell-DsWhsSMU.js} +3 -2
- package/dist/app-shell.js +1 -1
- package/dist/attachment-TZykYNu5.js +300 -0
- package/dist/attachment.js +2 -2
- package/dist/{avatar-group-bJaZE1_C.js → avatar-group-Bzmmj2HI.js} +2 -1
- package/dist/avatar-group.js +1 -1
- package/dist/{carousel-B9nMK7Yf.js → carousel-CRNz-T3g.js} +1 -1
- package/dist/carousel.js +1 -1
- package/dist/{command-palette-C90CzfQi.js → command-palette-Bgf5tfCI.js} +160 -156
- package/dist/command-palette.js +1 -1
- package/dist/{data-grid-D106baPp.js → data-grid-DUft3rJb.js} +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/{data-list-BA0xrySM.js → data-list-Dv3orBtf.js} +15 -15
- package/dist/data-list.js +1 -1
- package/dist/detail-panel-Cke3ZFU3.js +342 -0
- package/dist/detail-panel.js +2 -2
- package/dist/docs/action-bar.examples.md +768 -0
- package/dist/docs/action-bar.json +74 -50
- package/dist/docs/action-bar.md +49 -311
- package/dist/docs/app-shell.examples.md +1221 -64
- package/dist/docs/app-shell.json +92 -60
- package/dist/docs/app-shell.md +92 -57
- package/dist/docs/attachment.examples.md +689 -0
- package/dist/docs/attachment.json +69 -37
- package/dist/docs/attachment.md +44 -203
- package/dist/docs/avatar-group.json +111 -23
- package/dist/docs/avatar-group.md +487 -28
- package/dist/docs/button-group.json +98 -2
- package/dist/docs/button-group.md +411 -8
- package/dist/docs/calendar.examples.md +512 -0
- package/dist/docs/calendar.json +72 -24
- package/dist/docs/calendar.md +18 -147
- package/dist/docs/carousel.examples.md +868 -0
- package/dist/docs/carousel.json +58 -50
- package/dist/docs/carousel.md +66 -300
- package/dist/docs/cascader.examples.md +1269 -0
- package/dist/docs/cascader.json +72 -16
- package/dist/docs/cascader.md +78 -154
- package/dist/docs/chart.examples.md +734 -24
- package/dist/docs/chart.json +93 -13
- package/dist/docs/chart.md +28 -7
- package/dist/docs/clock.json +71 -15
- package/dist/docs/clock.md +326 -21
- package/dist/docs/code-block.json +79 -55
- package/dist/docs/code-block.md +417 -74
- package/dist/docs/color-picker.json +60 -12
- package/dist/docs/color-picker.md +245 -22
- package/dist/docs/column-manager.examples.md +764 -0
- package/dist/docs/column-manager.json +68 -12
- package/dist/docs/column-manager.md +44 -203
- package/dist/docs/command-palette.examples.md +747 -0
- package/dist/docs/command-palette.json +48 -24
- package/dist/docs/command-palette.md +60 -339
- package/dist/docs/currency-field.examples.md +355 -73
- package/dist/docs/currency-field.json +96 -64
- package/dist/docs/currency-field.md +57 -50
- package/dist/docs/dashboard-grid.examples.md +629 -0
- package/dist/docs/dashboard-grid.json +64 -16
- package/dist/docs/dashboard-grid.md +34 -152
- package/dist/docs/data-list.examples.md +1556 -0
- package/dist/docs/data-list.json +58 -18
- package/dist/docs/data-list.md +139 -224
- package/dist/docs/date-field.examples.md +543 -0
- package/dist/docs/date-field.json +64 -24
- package/dist/docs/date-field.md +22 -168
- package/dist/docs/datetime-field.examples.md +699 -0
- package/dist/docs/datetime-field.json +79 -31
- package/dist/docs/datetime-field.md +24 -269
- package/dist/docs/datetime-range-picker.examples.md +682 -0
- package/dist/docs/datetime-range-picker.json +117 -61
- package/dist/docs/datetime-range-picker.md +59 -224
- package/dist/docs/description-list.examples.md +652 -0
- package/dist/docs/description-list.json +49 -25
- package/dist/docs/description-list.md +33 -188
- package/dist/docs/detail-panel.examples.md +1177 -0
- package/dist/docs/detail-panel.json +69 -53
- package/dist/docs/detail-panel.md +114 -324
- package/dist/docs/entity-picker.examples.md +1037 -0
- package/dist/docs/entity-picker.json +66 -18
- package/dist/docs/entity-picker.md +56 -246
- package/dist/docs/event-calendar.examples.md +749 -49
- package/dist/docs/event-calendar.json +46 -22
- package/dist/docs/event-calendar.md +81 -11
- package/dist/docs/field-group.examples.md +554 -0
- package/dist/docs/field-group.json +98 -34
- package/dist/docs/field-group.md +55 -133
- package/dist/docs/filter-bar.examples.md +772 -0
- package/dist/docs/filter-bar.json +41 -25
- package/dist/docs/filter-bar.md +42 -246
- package/dist/docs/form.examples.md +579 -0
- package/dist/docs/form.json +87 -39
- package/dist/docs/form.md +53 -177
- package/dist/docs/fullscreen.examples.md +558 -0
- package/dist/docs/fullscreen.json +58 -18
- package/dist/docs/fullscreen.md +50 -169
- package/dist/docs/highlight.json +57 -25
- package/dist/docs/highlight.md +402 -50
- package/dist/docs/icon.json +85 -5
- package/dist/docs/icon.md +401 -10
- package/dist/docs/image.examples.md +670 -0
- package/dist/docs/image.json +44 -28
- package/dist/docs/image.md +24 -176
- package/dist/docs/import-export-center.examples.md +1280 -0
- package/dist/docs/import-export-center.json +67 -27
- package/dist/docs/import-export-center.md +121 -226
- package/dist/docs/list-item.examples.md +769 -0
- package/dist/docs/list-item.json +110 -38
- package/dist/docs/list-item.md +84 -201
- package/dist/docs/listbox.examples.md +858 -0
- package/dist/docs/listbox.json +76 -28
- package/dist/docs/listbox.md +41 -263
- package/dist/docs/markdown.json +79 -55
- package/dist/docs/markdown.md +581 -85
- package/dist/docs/media-viewer.examples.md +1038 -0
- package/dist/docs/media-viewer.json +70 -15
- package/dist/docs/media-viewer.md +84 -135
- package/dist/docs/message-scroller.examples.md +1193 -0
- package/dist/docs/message-scroller.json +41 -17
- package/dist/docs/message-scroller.md +80 -134
- package/dist/docs/message.examples.md +944 -0
- package/dist/docs/message.json +64 -16
- package/dist/docs/message.md +34 -326
- package/dist/docs/meter.json +58 -26
- package/dist/docs/meter.md +312 -32
- package/dist/docs/navigation-menu.examples.md +1107 -0
- package/dist/docs/navigation-menu.json +57 -41
- package/dist/docs/navigation-menu.md +105 -298
- package/dist/docs/notification-center.examples.md +1045 -0
- package/dist/docs/notification-center.json +71 -15
- package/dist/docs/notification-center.md +76 -266
- package/dist/docs/otp-input.examples.md +490 -0
- package/dist/docs/otp-input.json +65 -25
- package/dist/docs/otp-input.md +20 -191
- package/dist/docs/page-header.examples.md +1041 -0
- package/dist/docs/page-header.json +75 -43
- package/dist/docs/page-header.md +79 -291
- package/dist/docs/page.examples.md +633 -0
- package/dist/docs/page.json +48 -16
- package/dist/docs/page.md +62 -129
- package/dist/docs/prompt-composer.examples.md +630 -0
- package/dist/docs/prompt-composer.json +66 -18
- package/dist/docs/prompt-composer.md +35 -161
- package/dist/docs/prose.json +69 -37
- package/dist/docs/prose.md +393 -75
- package/dist/docs/rating.examples.md +525 -0
- package/dist/docs/rating.json +92 -28
- package/dist/docs/rating.md +27 -241
- package/dist/docs/saved-views.examples.md +1108 -0
- package/dist/docs/saved-views.json +53 -21
- package/dist/docs/saved-views.md +86 -171
- package/dist/docs/scroll-area.examples.md +837 -0
- package/dist/docs/scroll-area.json +64 -24
- package/dist/docs/scroll-area.md +57 -140
- package/dist/docs/section.examples.md +676 -0
- package/dist/docs/section.json +68 -20
- package/dist/docs/section.md +39 -162
- package/dist/docs/segmented-control.examples.md +480 -0
- package/dist/docs/segmented-control.json +76 -28
- package/dist/docs/segmented-control.md +20 -191
- package/dist/docs/side-navigation.examples.md +1468 -0
- package/dist/docs/side-navigation.json +53 -53
- package/dist/docs/side-navigation.md +79 -354
- package/dist/docs/slider.examples.md +505 -0
- package/dist/docs/slider.json +91 -51
- package/dist/docs/slider.md +47 -212
- package/dist/docs/sparkline.json +60 -36
- package/dist/docs/sparkline.md +447 -71
- package/dist/docs/split-button.examples.md +509 -0
- package/dist/docs/split-button.json +73 -41
- package/dist/docs/split-button.md +64 -194
- package/dist/docs/splitter.examples.md +921 -0
- package/dist/docs/splitter.json +94 -46
- package/dist/docs/splitter.md +75 -182
- package/dist/docs/stat-card.examples.md +725 -0
- package/dist/docs/stat-card.json +89 -41
- package/dist/docs/stat-card.md +55 -227
- package/dist/docs/status-indicator.json +80 -32
- package/dist/docs/status-indicator.md +409 -65
- package/dist/docs/stepper.json +53 -21
- package/dist/docs/stepper.md +369 -48
- package/dist/docs/table-of-contents.examples.md +550 -0
- package/dist/docs/table-of-contents.json +60 -28
- package/dist/docs/table-of-contents.md +70 -205
- package/dist/docs/tags-input.examples.md +541 -0
- package/dist/docs/tags-input.json +64 -16
- package/dist/docs/tags-input.md +15 -262
- package/dist/docs/time-field.examples.md +587 -0
- package/dist/docs/time-field.json +69 -29
- package/dist/docs/time-field.md +21 -223
- package/dist/docs/time-picker.json +117 -53
- package/dist/docs/time-picker.md +499 -54
- package/dist/docs/time-range-picker.examples.md +750 -0
- package/dist/docs/time-range-picker.json +139 -75
- package/dist/docs/time-range-picker.md +63 -225
- package/dist/docs/timeline.examples.md +617 -0
- package/dist/docs/timeline.json +44 -28
- package/dist/docs/timeline.md +34 -208
- package/dist/docs/toolbar.json +56 -16
- package/dist/docs/toolbar.md +357 -63
- package/dist/docs/top-navigation.examples.md +1206 -140
- package/dist/docs/top-navigation.json +49 -33
- package/dist/docs/top-navigation.md +87 -36
- package/dist/docs/tour.examples.md +960 -0
- package/dist/docs/tour.json +57 -25
- package/dist/docs/tour.md +60 -244
- package/dist/docs/transfer.examples.md +631 -0
- package/dist/docs/transfer.json +80 -16
- package/dist/docs/transfer.md +41 -170
- package/dist/docs/typography.json +96 -0
- package/dist/docs/typography.md +352 -4
- package/dist/docs/upload.examples.md +555 -53
- package/dist/docs/upload.json +62 -30
- package/dist/docs/upload.md +46 -11
- package/dist/docs/wizard.examples.md +1389 -0
- package/dist/docs/wizard.json +89 -49
- package/dist/docs/wizard.md +122 -263
- package/dist/{entity-picker-CC4VoC3p.js → entity-picker-C78f3Z0o.js} +9 -6
- package/dist/entity-picker.js +1 -1
- package/dist/{event-calendar-CjmF_e0H.js → event-calendar-DJPoCi-O.js} +1 -1
- package/dist/event-calendar.js +1 -1
- package/dist/{filter-bar-B3QJD7SZ.js → filter-bar-D61wiQFP.js} +1 -1
- package/dist/filter-bar.js +1 -1
- package/dist/{import-export-center-CW8YVZev.js → import-export-center-mqvmlzwB.js} +44 -36
- package/dist/import-export-center.js +1 -1
- package/dist/index.js +58 -58
- package/dist/{markdown-BdskE4-L.js → markdown-8CtV4k44.js} +2 -2
- package/dist/markdown.js +1 -1
- package/dist/{media-viewer-zEXcwfEY.js → media-viewer-C_cbuAq-.js} +64 -60
- package/dist/media-viewer.js +2 -2
- package/dist/message-P91bEGyV.js +455 -0
- package/dist/message.js +2 -2
- package/dist/{page-header-DmwBGwlm.js → page-header-jeAIQSZM.js} +103 -108
- package/dist/page-header.js +1 -1
- package/dist/section-CVTQdWBl.js +216 -0
- package/dist/section.js +2 -2
- package/dist/{segmented-control-CbK7SurB.js → segmented-control-BSMVjukr.js} +1 -1
- package/dist/segmented-control.js +1 -1
- package/dist/{side-navigation-CKRETc8E.js → side-navigation-BQzBxz2B.js} +179 -179
- package/dist/side-navigation.js +1 -1
- package/dist/{stat-card-CL3Xe6pV.js → stat-card-BpGZiFbG.js} +12 -14
- package/dist/stat-card.js +1 -1
- package/dist/{stepper-DHdrANZI.js → stepper-Cxb_tHnA.js} +130 -127
- package/dist/stepper.js +2 -2
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/{timeline-BiL2CXfn.js → timeline-ZngK6zLC.js} +9 -6
- package/dist/timeline.js +1 -1
- package/dist/top-navigation-YSEQzBhD.js +744 -0
- package/dist/top-navigation.js +2 -2
- package/dist/{transfer-sKUvmEKe.js → transfer-Cv5yQuTN.js} +1 -1
- package/dist/transfer.js +1 -1
- package/dist/types/attachment/attachment-parts.d.ts +24 -11
- package/dist/types/attachment/attachment-parts.d.ts.map +1 -1
- package/dist/types/attachment/attachment.d.ts +3 -3
- package/dist/types/attachment/attachment.d.ts.map +1 -1
- package/dist/types/avatar-group/avatar-group.d.ts.map +1 -1
- package/dist/types/carousel/carousel-parts.d.ts +2 -2
- package/dist/types/command-palette/command-palette.d.ts.map +1 -1
- package/dist/types/data-list/data-list.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel-parts.d.ts +10 -3
- package/dist/types/detail-panel/detail-panel-parts.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel.types.d.ts +7 -0
- package/dist/types/detail-panel/detail-panel.types.d.ts.map +1 -1
- package/dist/types/entity-picker/entity-picker.d.ts.map +1 -1
- package/dist/types/import-export-center/import-export-center.d.ts.map +1 -1
- package/dist/types/media-viewer/index.d.ts +2 -2
- package/dist/types/media-viewer/index.d.ts.map +1 -1
- package/dist/types/media-viewer/media-viewer-bar.d.ts +3 -1
- package/dist/types/media-viewer/media-viewer-bar.d.ts.map +1 -1
- package/dist/types/media-viewer/media-viewer.types.d.ts +1 -0
- package/dist/types/media-viewer/media-viewer.types.d.ts.map +1 -1
- package/dist/types/message/message-parts.d.ts +7 -0
- package/dist/types/message/message-parts.d.ts.map +1 -1
- package/dist/types/message/message.d.ts.map +1 -1
- package/dist/types/page-header/page-header-parts.d.ts.map +1 -1
- package/dist/types/section/section-parts.d.ts +16 -8
- package/dist/types/section/section-parts.d.ts.map +1 -1
- package/dist/types/section/section.d.ts.map +1 -1
- package/dist/types/segmented-control/segmented-control-parts.d.ts.map +1 -1
- package/dist/types/side-navigation/side-navigation-parts.d.ts.map +1 -1
- package/dist/types/stat-card/stat-card-delta.d.ts.map +1 -1
- package/dist/types/stat-card/stat-card-parts.d.ts +3 -3
- package/dist/types/stat-card/stat-card-parts.d.ts.map +1 -1
- package/dist/types/stepper/stepper-parts.d.ts +11 -2
- package/dist/types/stepper/stepper-parts.d.ts.map +1 -1
- package/dist/types/stepper/stepper.d.ts.map +1 -1
- package/dist/types/timeline/timeline-parts.d.ts.map +1 -1
- package/dist/types/top-navigation/top-navigation.d.ts.map +1 -1
- package/dist/{wizard-4c0X7Bx_.js → wizard-Dfryz1id.js} +214 -214
- package/dist/wizard.js +1 -1
- package/package.json +6 -6
- package/dist/attachment-MqczA38F.js +0 -292
- package/dist/detail-panel-EImAtksY.js +0 -327
- package/dist/message-D1Dd6Y2k.js +0 -452
- package/dist/section-D_qOfdxR.js +0 -213
- package/dist/top-navigation-D8IHPOmm.js +0 -744
|
@@ -492,7 +492,7 @@
|
|
|
492
492
|
"type": "ReactNode",
|
|
493
493
|
"defaultValue": "—",
|
|
494
494
|
"appliesTo": "CommandPalette",
|
|
495
|
-
"description": "The trigger, rendered where it was written; the panel is the
|
|
495
|
+
"description": "The trigger, rendered where it was written; the panel is the palette’s and goes into the layer"
|
|
496
496
|
},
|
|
497
497
|
{
|
|
498
498
|
"name": "render",
|
|
@@ -506,7 +506,7 @@
|
|
|
506
506
|
"type": "(item, state: { current, disabled, pending, label, query }) => ReactNode",
|
|
507
507
|
"defaultValue": "—",
|
|
508
508
|
"appliesTo": "CommandPalette",
|
|
509
|
-
"description": "Replaces the row’s content; the option element and its wiring stay the
|
|
509
|
+
"description": "Replaces the row’s content; the option element and its wiring stay the palette’s. state.label is the marked label"
|
|
510
510
|
},
|
|
511
511
|
{
|
|
512
512
|
"name": "empty",
|
|
@@ -527,7 +527,7 @@
|
|
|
527
527
|
"type": "ComponentPropsWithRef<'input'>",
|
|
528
528
|
"defaultValue": "—",
|
|
529
529
|
"appliesTo": "CommandPalette",
|
|
530
|
-
"description": "Native props for the field, ref included; onKeyDown and onChange run before the
|
|
530
|
+
"description": "Native props for the field, ref included; onKeyDown and onChange run before the palette’s own handlers and preventDefault() skips it"
|
|
531
531
|
},
|
|
532
532
|
{
|
|
533
533
|
"name": "container",
|
|
@@ -588,7 +588,7 @@
|
|
|
588
588
|
"The layer is the dialog family’s: role=\"dialog\", aria-modal, the page inert behind the scrim, focus contained and returned to the trigger. Its name is the label message; the field’s name is the input message, and the list borrows it.",
|
|
589
589
|
"A row with a shortcut carries aria-keyshortcuts in the platform’s own words — Meta+Shift+D on a Mac, Control+Shift+D elsewhere — while the drawn keys are aria-hidden; a sequence has no syntax in the attribute and is drawn only. A disabled row is announced with aria-disabled, stays in the list, and is skipped by every movement key.",
|
|
590
590
|
"The result count, the loading sentence and the failure of a rejected handler are one visually hidden role=\"status\" row, spoken through the shared live announcer so the same sentence is never said twice in a row.",
|
|
591
|
-
"Escape is three steps in a fixed order — clear the query, return one page, close — so a reader who typed does not lose the palette on the first press; the footer draws the same keys the
|
|
591
|
+
"Escape is three steps in a fixed order — clear the query, return one page, close — so a reader who typed does not lose the palette on the first press; the footer draws the same keys the palette answers.",
|
|
592
592
|
"The panel answers its own width: below 360 pixels the description and the meta go and the binding stays; inside a dialog on a narrow screen the panel takes the whole layer."
|
|
593
593
|
]
|
|
594
594
|
}
|
|
@@ -702,24 +702,24 @@
|
|
|
702
702
|
"title": "Ranking, and the adapter",
|
|
703
703
|
"note": "Type “dep”: a label that starts with it outranks a word that starts with it, which outranks a run inside a word, which outranks a keyword; groups reorder by their best row. The third panel hands the order to a ranker of the product’s own.",
|
|
704
704
|
"language": "tsx",
|
|
705
|
-
"source": "<CommandPalette defaultQuery=\"
|
|
706
|
-
"verdict": "
|
|
705
|
+
"source": "import { CommandPalette } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst items: CommandPaletteItem[] = [\n { id: 'deposit-report', label: 'Direct deposit report' },\n { id: 'received', label: 'Mark as received' },\n { id: 'archive', label: 'Archive order' },\n { id: 'restock', label: 'Restock warehouse', keywords: ['receiving'] },\n { id: 'reconcile', label: 'Reconcile invoices' },\n { id: 'packing-slip', label: 'Print packing slip' },\n { id: 'receive', label: 'Receive shipment' },\n];\n\nexport default function CommandPaletteRankingExample() {\n return (\n <Stack gap={5}>\n <Stack gap={2}>\n <Text size=\"sm\" tone=\"muted\">\n Default ranker\n </Text>\n <CommandPalette defaultQuery=\"rec\" footer={null} items={items} presentation=\"inline\" />\n </Stack>\n\n <Stack gap={2}>\n <Text size=\"sm\" tone=\"muted\">\n rank is null: the list as it came\n </Text>\n <CommandPalette\n defaultQuery=\"rec\"\n footer={null}\n items={items}\n presentation=\"inline\"\n rank={null}\n />\n </Stack>\n\n <Stack gap={2}>\n <Text size=\"sm\" tone=\"muted\">\n highlightMatch is false\n </Text>\n <CommandPalette\n defaultQuery=\"rec\"\n footer={null}\n highlightMatch={false}\n items={items}\n presentation=\"inline\"\n />\n </Stack>\n </Stack>\n );\n}\n",
|
|
706
|
+
"verdict": "example"
|
|
707
707
|
},
|
|
708
708
|
{
|
|
709
709
|
"id": "pages",
|
|
710
710
|
"title": "Pages, stacked",
|
|
711
711
|
"note": "A row with children opens a page: the trail appears before the field, the children take the list, and Backspace on an empty query or Escape returns one page. pages is state the product may own.",
|
|
712
712
|
"language": "tsx",
|
|
713
|
-
"source": "
|
|
714
|
-
"verdict": "
|
|
713
|
+
"source": "import { useState } from 'react';\n\nimport { CommandPalette } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst items: CommandPaletteItem[] = [\n {\n id: 'switch-warehouse',\n label: 'Switch warehouse…',\n keywords: ['location', 'site'],\n children: [\n { id: 'seattle', label: 'Seattle', description: 'Main distribution center' },\n { id: 'rotterdam', label: 'Rotterdam', description: 'European hub' },\n { id: 'singapore', label: 'Singapore', description: 'Asia-Pacific hub' },\n ],\n },\n {\n id: 'change-status',\n label: 'Change order status…',\n children: [\n { id: 'processing', label: 'Processing' },\n { id: 'shipped', label: 'Shipped' },\n { id: 'delivered', label: 'Delivered' },\n ],\n },\n { id: 'dashboard', label: 'Open dashboard' },\n];\n\nexport default function CommandPalettePagesExample() {\n const [chosen, setChosen] = useState('None yet');\n\n return (\n <Stack gap={3}>\n <CommandPalette\n defaultPages={['switch-warehouse']}\n footer={null}\n items={items}\n onSelect={(item) => setChosen(item.label)}\n presentation=\"inline\"\n />\n\n <Text size=\"sm\" tone=\"muted\">\n Last choice: {chosen}\n </Text>\n </Stack>\n );\n}\n",
|
|
714
|
+
"verdict": "example"
|
|
715
715
|
},
|
|
716
716
|
{
|
|
717
717
|
"id": "recent",
|
|
718
718
|
"title": "What the reader ran last",
|
|
719
719
|
"note": "With nothing typed, the recents open the list under their own heading; running a row moves it to the front and cuts the array at recentLimit. Persisting it is the product’s — it receives the array.",
|
|
720
720
|
"language": "tsx",
|
|
721
|
-
"source": "
|
|
722
|
-
"verdict": "
|
|
721
|
+
"source": "import { useState } from 'react';\n\nimport { CommandPalette } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst items: CommandPaletteItem[] = [\n { id: 'create-order', label: 'Create order' },\n { id: 'export-invoices', label: 'Export invoices' },\n { id: 'reorder', label: 'Reorder low-stock products' },\n { id: 'print-labels', label: 'Print shipping labels' },\n { id: 'close-day', label: 'Close the day' },\n];\n\nexport default function CommandPaletteRecentExample() {\n const [recent, setRecent] = useState<readonly string[]>(['export-invoices', 'create-order']);\n\n return (\n <Stack gap={3}>\n <CommandPalette\n footer={null}\n items={items}\n onRecentChange={setRecent}\n presentation=\"inline\"\n recent={recent}\n recentLimit={3}\n />\n\n <Text size=\"sm\" tone=\"muted\">\n Kept by the product: {recent.join(', ')}\n </Text>\n </Stack>\n );\n}\n",
|
|
722
|
+
"verdict": "example"
|
|
723
723
|
},
|
|
724
724
|
{
|
|
725
725
|
"id": "shortcuts",
|
|
@@ -742,40 +742,40 @@
|
|
|
742
742
|
"title": "A command that takes a while",
|
|
743
743
|
"note": "A handler that returns a promise keeps the palette open and the row busy, refuses a second run of the same row until it settles, then closes; a rejection keeps it open and the status row says why. Press the first row and wait two seconds.",
|
|
744
744
|
"language": "tsx",
|
|
745
|
-
"source": "const items = [\n
|
|
746
|
-
"verdict": "
|
|
745
|
+
"source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { CommandPalette, CommandPaletteTrigger } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Inline } from '@slotted/react/inline';\nimport { Text } from '@slotted/react/typography';\n\nconst wait = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));\n\nexport default function CommandPaletteAsyncExample() {\n const [status, setStatus] = useState('Inventory not synced');\n const items: CommandPaletteItem[] = [\n {\n id: 'sync',\n label: 'Sync inventory',\n description: 'Takes two seconds',\n onSelect: () => wait(2000).then(() => setStatus('Inventory synced')),\n },\n {\n id: 'publish',\n label: 'Publish price list',\n description: 'Rejected: no effective date',\n onSelect: () => Promise.reject(new Error('The price list has no effective date')),\n },\n { id: 'audit', label: 'Open audit log' },\n ];\n\n return (\n <Inline align=\"center\" gap={3}>\n <CommandPalette hotkey={null} items={items}>\n <CommandPaletteTrigger\n render={(props) => (\n <Button {...props} tone=\"secondary\" variant=\"outline\">\n Run command\n </Button>\n )}\n />\n </CommandPalette>\n\n <Text size=\"sm\" tone=\"muted\">\n {status}\n </Text>\n </Inline>\n );\n}\n",
|
|
746
|
+
"verdict": "example"
|
|
747
747
|
},
|
|
748
748
|
{
|
|
749
749
|
"id": "loading",
|
|
750
750
|
"title": "While the results travel",
|
|
751
751
|
"note": "loading swaps the magnifier for the ring, draws three skeleton rows when there is nothing to show yet, and says the loading message in the status row. The palette debounces nothing: the product does, in three lines.",
|
|
752
752
|
"language": "tsx",
|
|
753
|
-
"source": "
|
|
754
|
-
"verdict": "
|
|
753
|
+
"source": "import { CommandPalette } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst none: CommandPaletteItem[] = [];\n\nconst carriers: CommandPaletteItem[] = [\n { id: 'speedy', label: 'Speedy Express', description: 'Seattle to Portland' },\n { id: 'united', label: 'United Package', description: 'Domestic ground' },\n { id: 'federal', label: 'Federal Shipping', description: 'Overnight air' },\n];\n\nexport default function CommandPaletteLoadingExample() {\n return (\n <Stack gap={5}>\n <Stack gap={2}>\n <Text size=\"sm\" tone=\"muted\">\n Nothing to show yet\n </Text>\n <CommandPalette\n defaultQuery=\"carrier\"\n footer={null}\n items={none}\n loading\n presentation=\"inline\"\n />\n </Stack>\n\n <Stack gap={2}>\n <Text size=\"sm\" tone=\"muted\">\n Refreshing the rows on screen\n </Text>\n <CommandPalette footer={null} items={carriers} loading presentation=\"inline\" />\n </Stack>\n </Stack>\n );\n}\n",
|
|
754
|
+
"verdict": "example"
|
|
755
755
|
},
|
|
756
756
|
{
|
|
757
757
|
"id": "empty",
|
|
758
758
|
"title": "Nothing matched",
|
|
759
759
|
"note": "The empty part takes the list, the count row says “0 results”, and the root carries data-empty. The second panel replaces the sentence with the product’s own node.",
|
|
760
760
|
"language": "tsx",
|
|
761
|
-
"source": "<CommandPalette\n
|
|
762
|
-
"verdict": "
|
|
761
|
+
"source": "import { CommandPalette } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst items: CommandPaletteItem[] = [\n { id: 'orders', label: 'Orders' },\n { id: 'inventory', label: 'Inventory' },\n { id: 'shipments', label: 'Shipments' },\n];\n\nexport default function CommandPaletteEmptyExample() {\n return (\n <Stack gap={5}>\n <Stack gap={2}>\n <Text size=\"sm\" tone=\"muted\">\n The empty message\n </Text>\n <CommandPalette\n defaultQuery=\"pallet jack\"\n footer={null}\n items={items}\n presentation=\"inline\"\n />\n </Stack>\n\n <Stack gap={2}>\n <Text size=\"sm\" tone=\"muted\">\n The empty prop\n </Text>\n <CommandPalette\n defaultQuery=\"pallet jack\"\n empty={<span>No command matches. Try a section name.</span>}\n footer={null}\n items={items}\n presentation=\"inline\"\n />\n </Stack>\n </Stack>\n );\n}\n",
|
|
762
|
+
"verdict": "example"
|
|
763
763
|
},
|
|
764
764
|
{
|
|
765
765
|
"id": "inline",
|
|
766
766
|
"title": "Without a layer",
|
|
767
767
|
"note": "presentation=\"inline\" draws the panel where it was written — here inside a popover on an “Assign to” button — with no scrim, no hotkey and no Escape to close. It is the filtered menu that menu refused.",
|
|
768
768
|
"language": "tsx",
|
|
769
|
-
"source": "<Popover>\n
|
|
770
|
-
"verdict": "
|
|
769
|
+
"source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { CommandPalette } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Inline } from '@slotted/react/inline';\nimport { Popover, PopoverContent, PopoverLayer, PopoverTrigger } from '@slotted/react/popover';\nimport { Text } from '@slotted/react/typography';\n\nconst people: CommandPaletteItem[] = [\n { id: 'nancy', label: 'Nancy Davolio', description: 'Sales Representative' },\n { id: 'andrew', label: 'Andrew Fuller', description: 'Vice President, Sales' },\n { id: 'janet', label: 'Janet Leverling', description: 'Sales Representative' },\n { id: 'margaret', label: 'Margaret Peacock', description: 'Sales Representative' },\n];\n\nexport default function CommandPaletteInlineExample() {\n const [assignee, setAssignee] = useState('Nobody');\n\n return (\n <Inline align=\"center\" gap={3}>\n <Popover>\n <PopoverTrigger\n render={(props) => (\n <Button {...props} tone=\"secondary\" variant=\"outline\">\n Assign to…\n </Button>\n )}\n />\n <PopoverLayer>\n <PopoverContent>\n <CommandPalette\n footer={null}\n items={people}\n messages={{ placeholder: 'Search people…' }}\n onSelect={(item) => setAssignee(item.label)}\n presentation=\"inline\"\n />\n </PopoverContent>\n </PopoverLayer>\n </Popover>\n\n <Text size=\"sm\" tone=\"muted\">\n Assigned to: {assignee}\n </Text>\n </Inline>\n );\n}\n",
|
|
770
|
+
"verdict": "example"
|
|
771
771
|
},
|
|
772
772
|
{
|
|
773
773
|
"id": "sizes",
|
|
774
774
|
"title": "Three measures",
|
|
775
775
|
"note": "size is the dialog’s measure — 24, 32 and 42 rems — and the row’s step: sm rows read the small control geometry, lg rows the large, and the header stands one step above the rows in each.",
|
|
776
776
|
"language": "tsx",
|
|
777
|
-
"source": "
|
|
778
|
-
"verdict": "
|
|
777
|
+
"source": "import { CommandPalette } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst sizes = ['sm', 'md', 'lg'] as const;\n\nconst items: CommandPaletteItem[] = [\n { id: 'orders', label: 'Orders', description: 'Open and fulfilled orders' },\n { id: 'inventory', label: 'Inventory', description: 'Stock levels by warehouse' },\n { id: 'shipments', label: 'Shipments', meta: 'Page' },\n];\n\nexport default function CommandPaletteSizesExample() {\n return (\n <Stack gap={5}>\n {sizes.map((size) => (\n <Stack gap={2} key={size}>\n <Text size=\"sm\" tone=\"muted\">\n size {size}\n </Text>\n <CommandPalette footer={null} items={items} presentation=\"inline\" size={size} />\n </Stack>\n ))}\n </Stack>\n );\n}\n",
|
|
778
|
+
"verdict": "example"
|
|
779
779
|
},
|
|
780
780
|
{
|
|
781
781
|
"id": "states",
|
|
@@ -787,7 +787,7 @@
|
|
|
787
787
|
},
|
|
788
788
|
{
|
|
789
789
|
"id": "content",
|
|
790
|
-
"title": "Content the
|
|
790
|
+
"title": "Content the palette did not choose",
|
|
791
791
|
"note": "A German label of sixty characters, a description longer than the row, a binding of four keys and a row with no icon beside rows that have one: the label gives way, the binding never does, and the icon column keeps every label on one line.",
|
|
792
792
|
"language": "tsx",
|
|
793
793
|
"source": "const items = [\n {\n id: 'sync',\n label: 'Benachrichtigungseinstellungen für alle Arbeitsbereiche synchronisieren',\n shortcut: 'mod+shift+alt+p',\n },\n];\n",
|
|
@@ -804,7 +804,7 @@
|
|
|
804
804
|
{
|
|
805
805
|
"id": "defaults",
|
|
806
806
|
"title": "Set once for the application",
|
|
807
|
-
"note": "The provider holds every axis, and SlottedProvider the language
|
|
807
|
+
"note": "The provider holds every axis, and SlottedProvider the language its messages use: the panel below reads Portuguese words, a size and a hotkey it did not state itself.",
|
|
808
808
|
"language": "tsx",
|
|
809
809
|
"source": "<SlottedProvider locale=\"pt-BR\">\n <CommandPaletteDefaultsProvider hotkey=\"mod+p\" size=\"sm\">\n <App />\n </CommandPaletteDefaultsProvider>\n</SlottedProvider>;\n",
|
|
810
810
|
"verdict": "excerpt"
|
|
@@ -814,8 +814,8 @@
|
|
|
814
814
|
"title": "In an application’s top bar",
|
|
815
815
|
"note": "The trigger is a search-shaped Button with a Kbd in it, rendered through render so the palette hands it the wiring and the ref; the row content is the product’s own through renderItem, with an avatar where the icon column is.",
|
|
816
816
|
"language": "tsx",
|
|
817
|
-
"source": "<CommandPalette\n
|
|
818
|
-
"verdict": "
|
|
817
|
+
"source": "import { Avatar } from '@slotted/react/avatar';\nimport { Button } from '@slotted/react/button';\nimport { CommandPalette, CommandPaletteTrigger } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Kbd } from '@slotted/react/kbd';\n\nconst customers: CommandPaletteItem[] = [\n { id: 'alfreds', label: 'Alfreds Futterkiste', description: 'Berlin' },\n { id: 'ana', label: 'Ana Trujillo Emparedados', description: 'Mexico City' },\n { id: 'antonio', label: 'Antonio Moreno Taqueria', description: 'Mexico City' },\n { id: 'horn', label: 'Around the Horn', description: 'London' },\n { id: 'berglunds', label: 'Berglunds snabbköp', description: 'Luleå' },\n];\n\nexport default function CommandPaletteCompositionExample() {\n return (\n <CommandPalette\n hotkey=\"/\"\n items={customers}\n messages={{ input: 'Search customers', label: 'Customers', placeholder: 'Search customers…' }}\n renderItem={(item, state) => (\n <>\n <span data-part=\"icon\">\n <Avatar name={item.label} size=\"xs\" />\n </span>\n <span data-part=\"label\">{state.label}</span>\n {item.description === undefined ? null : (\n <span data-part=\"description\">{item.description}</span>\n )}\n </>\n )}\n >\n <CommandPaletteTrigger\n render={(props) => (\n <Button {...props} tone=\"secondary\" variant=\"outline\">\n Search customers <Kbd size=\"sm\">/</Kbd>\n </Button>\n )}\n />\n </CommandPalette>\n );\n}\n",
|
|
818
|
+
"verdict": "example"
|
|
819
819
|
},
|
|
820
820
|
{
|
|
821
821
|
"id": "keyboard",
|
|
@@ -832,6 +832,30 @@
|
|
|
832
832
|
"language": "tsx",
|
|
833
833
|
"source": "<CommandPalette\n items={items}\n messages={{ input: 'Search deployments', label: 'Deployment commands' }}\n/>;\n",
|
|
834
834
|
"verdict": "excerpt"
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
"id": "basic",
|
|
838
|
+
"title": "basic.tsx",
|
|
839
|
+
"note": null,
|
|
840
|
+
"language": "tsx",
|
|
841
|
+
"source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { CommandPalette, CommandPaletteTrigger } from '@slotted/react/command-palette';\nimport type { CommandGroup, CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Inline } from '@slotted/react/inline';\nimport { Text } from '@slotted/react/typography';\n\nconst groups: CommandGroup[] = [\n { id: 'go', label: 'Go to' },\n { id: 'actions', label: 'Actions' },\n];\n\nconst items: CommandPaletteItem[] = [\n { id: 'orders', label: 'Orders', description: 'Open and fulfilled orders', group: 'go' },\n { id: 'inventory', label: 'Inventory', description: 'Stock levels by warehouse', group: 'go' },\n { id: 'shipments', label: 'Shipments', group: 'go' },\n {\n id: 'create-order',\n label: 'Create order',\n keywords: ['new', 'sale'],\n group: 'actions',\n shortcut: 'mod+shift+o',\n },\n { id: 'export-invoices', label: 'Export invoices', keywords: ['csv'], group: 'actions' },\n {\n id: 'reorder',\n label: 'Reorder low-stock products',\n group: 'actions',\n shortcut: 'mod+shift+r',\n },\n];\n\nexport default function CommandPaletteBasicExample() {\n const [last, setLast] = useState('None yet');\n\n return (\n <Inline align=\"center\" gap={3}>\n <CommandPalette groups={groups} items={items} onSelect={(item) => setLast(item.label)}>\n <CommandPaletteTrigger\n render={(props) => (\n <Button {...props} tone=\"secondary\" variant=\"outline\">\n Search commands\n </Button>\n )}\n />\n </CommandPalette>\n\n <Text size=\"sm\" tone=\"muted\">\n Last command: {last}\n </Text>\n </Inline>\n );\n}\n",
|
|
842
|
+
"verdict": "example"
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
"id": "behavior",
|
|
846
|
+
"title": "behavior.tsx",
|
|
847
|
+
"note": null,
|
|
848
|
+
"language": "tsx",
|
|
849
|
+
"source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { CommandPalette, CommandPaletteTrigger } from '@slotted/react/command-palette';\nimport type { CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst items: CommandPaletteItem[] = [\n { id: 'approve', label: 'Approve order' },\n { id: 'hold', label: 'Hold order' },\n { id: 'cancel', label: 'Cancel order' },\n { id: 'flag', label: 'Flag for review' },\n];\n\nexport default function CommandPaletteBehaviorExample() {\n const [runs, setRuns] = useState(0);\n\n return (\n <Stack gap={3}>\n <Inline align=\"center\" gap={3}>\n <CommandPalette\n autoHighlight={false}\n clearOnClose={false}\n closeOnSelect={false}\n highlightMatch={false}\n hotkey=\"mod+j\"\n items={items}\n loop={false}\n onSelect={() => setRuns((count) => count + 1)}\n outsidePress=\"none\"\n >\n <CommandPaletteTrigger\n render={(props) => (\n <Button {...props} tone=\"secondary\" variant=\"outline\">\n Review orders\n </Button>\n )}\n />\n </CommandPalette>\n\n <CommandPalette disabled hotkey={null} items={items}>\n <CommandPaletteTrigger\n render={(props) => (\n <Button {...props} tone=\"secondary\" variant=\"outline\">\n Archived orders\n </Button>\n )}\n />\n </CommandPalette>\n </Inline>\n\n <Text size=\"sm\" tone=\"muted\">\n Commands run: {runs}\n </Text>\n </Stack>\n );\n}\n",
|
|
850
|
+
"verdict": "example"
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
"id": "rows",
|
|
854
|
+
"title": "rows.tsx",
|
|
855
|
+
"note": null,
|
|
856
|
+
"language": "tsx",
|
|
857
|
+
"source": "import { useState } from 'react';\n\nimport { CommandPalette } from '@slotted/react/command-palette';\nimport type { CommandGroup, CommandPaletteItem } from '@slotted/react/command-palette';\nimport { Stack } from '@slotted/react/stack';\nimport { Text } from '@slotted/react/typography';\n\nconst groups: CommandGroup[] = [\n { id: 'pages', label: 'Pages' },\n { id: 'actions', label: 'Actions' },\n];\n\nexport default function CommandPaletteRowsExample() {\n const [last, setLast] = useState('None yet');\n const items: CommandPaletteItem[] = [\n { id: 'billing', label: 'Billing', href: '#billing', meta: 'Page', group: 'pages' },\n { id: 'carriers', label: 'Carriers', href: '#carriers', meta: 'Page', group: 'pages' },\n {\n id: 'invoice',\n label: 'Download last invoice',\n description: 'PDF, one page',\n group: 'actions',\n shortcut: 'mod+shift+i',\n onSelect: () => setLast('Invoice downloaded'),\n },\n {\n id: 'close-year',\n label: 'Close the fiscal year',\n description: 'Requires the finance role',\n disabled: true,\n group: 'actions',\n },\n ];\n\n return (\n <Stack gap={3}>\n <CommandPalette footer={null} groups={groups} items={items} presentation=\"inline\" />\n\n <Text size=\"sm\" tone=\"muted\">\n Last action: {last}\n </Text>\n </Stack>\n );\n}\n",
|
|
858
|
+
"verdict": "example"
|
|
835
859
|
}
|
|
836
860
|
]
|
|
837
861
|
}
|
|
@@ -11,12 +11,63 @@ import { CommandPalette, CommandPaletteDefaultsProvider, CommandPaletteTrigger }
|
|
|
11
11
|
|
|
12
12
|
## Minimal example
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Example
|
|
15
15
|
|
|
16
16
|
```tsx
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
import { useState } from 'react';
|
|
18
|
+
|
|
19
|
+
import { Button } from '@slotted/react/button';
|
|
20
|
+
import { CommandPalette, CommandPaletteTrigger } from '@slotted/react/command-palette';
|
|
21
|
+
import type { CommandGroup, CommandPaletteItem } from '@slotted/react/command-palette';
|
|
22
|
+
import { Inline } from '@slotted/react/inline';
|
|
23
|
+
import { Text } from '@slotted/react/typography';
|
|
24
|
+
|
|
25
|
+
const groups: CommandGroup[] = [
|
|
26
|
+
{ id: 'go', label: 'Go to' },
|
|
27
|
+
{ id: 'actions', label: 'Actions' },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const items: CommandPaletteItem[] = [
|
|
31
|
+
{ id: 'orders', label: 'Orders', description: 'Open and fulfilled orders', group: 'go' },
|
|
32
|
+
{ id: 'inventory', label: 'Inventory', description: 'Stock levels by warehouse', group: 'go' },
|
|
33
|
+
{ id: 'shipments', label: 'Shipments', group: 'go' },
|
|
34
|
+
{
|
|
35
|
+
id: 'create-order',
|
|
36
|
+
label: 'Create order',
|
|
37
|
+
keywords: ['new', 'sale'],
|
|
38
|
+
group: 'actions',
|
|
39
|
+
shortcut: 'mod+shift+o',
|
|
40
|
+
},
|
|
41
|
+
{ id: 'export-invoices', label: 'Export invoices', keywords: ['csv'], group: 'actions' },
|
|
42
|
+
{
|
|
43
|
+
id: 'reorder',
|
|
44
|
+
label: 'Reorder low-stock products',
|
|
45
|
+
group: 'actions',
|
|
46
|
+
shortcut: 'mod+shift+r',
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export default function CommandPaletteBasicExample() {
|
|
51
|
+
const [last, setLast] = useState('None yet');
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Inline align="center" gap={3}>
|
|
55
|
+
<CommandPalette groups={groups} items={items} onSelect={(item) => setLast(item.label)}>
|
|
56
|
+
<CommandPaletteTrigger
|
|
57
|
+
render={(props) => (
|
|
58
|
+
<Button {...props} tone="secondary" variant="outline">
|
|
59
|
+
Search commands
|
|
60
|
+
</Button>
|
|
61
|
+
)}
|
|
62
|
+
/>
|
|
63
|
+
</CommandPalette>
|
|
64
|
+
|
|
65
|
+
<Text size="sm" tone="muted">
|
|
66
|
+
Last command: {last}
|
|
67
|
+
</Text>
|
|
68
|
+
</Inline>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
20
71
|
```
|
|
21
72
|
|
|
22
73
|
## Anatomy
|
|
@@ -83,12 +134,12 @@ Excerpt — not a complete module
|
|
|
83
134
|
| `loading` | `boolean` | false | CommandPalette | The ring in the header, three skeleton rows when there is nothing to show, aria-busy on the list, the loading message in the status row |
|
|
84
135
|
| `disabled` | `boolean` | false | CommandPalette | Disables the field, the trigger and the hotkey |
|
|
85
136
|
| `messages` | `Partial<CommandPaletteMessages>` | — | CommandPalette | Words laid over the language in force, key by key: the dialog’s name (label), the field’s name and placeholder (input, placeholder), the empty, loading, count and error sentences, the recents heading, the clear, close and back controls, and the footer’s hints |
|
|
86
|
-
| `children` | `ReactNode` | — | CommandPalette | The trigger, rendered where it was written; the panel is the
|
|
137
|
+
| `children` | `ReactNode` | — | CommandPalette | The trigger, rendered where it was written; the panel is the palette’s and goes into the layer |
|
|
87
138
|
| `render` | `(props: CommandPaletteTriggerRootProps) => ReactNode` | — | CommandPaletteTrigger | Substitutes the trigger’s element. Attach the ref it hands you beside your own: it is the layer’s focus origin |
|
|
88
|
-
| `renderItem` | `(item, state: { current, disabled, pending, label, query }) => ReactNode` | — | CommandPalette | Replaces the row’s content; the option element and its wiring stay the
|
|
139
|
+
| `renderItem` | `(item, state: { current, disabled, pending, label, query }) => ReactNode` | — | CommandPalette | Replaces the row’s content; the option element and its wiring stay the palette’s. state.label is the marked label |
|
|
89
140
|
| `empty` | `ReactNode` | — | CommandPalette | Replaces the empty message |
|
|
90
141
|
| `footer` | `ReactNode \| null` | — | CommandPalette | Replaces the footer; null removes it |
|
|
91
|
-
| `inputProps` | `ComponentPropsWithRef<'input'>` | — | CommandPalette | Native props for the field, ref included; onKeyDown and onChange run before the
|
|
142
|
+
| `inputProps` | `ComponentPropsWithRef<'input'>` | — | CommandPalette | Native props for the field, ref included; onKeyDown and onChange run before the palette’s own handlers and preventDefault() skips it |
|
|
92
143
|
| `container` | `Element \| null` | — | CommandPalette | A parent for the layer alone, instead of the portal root made beside the trigger |
|
|
93
144
|
| `ref` | `Ref<CommandPaletteHandle>` | — | CommandPalette | open(), close(), toggle(), focus(), setQuery(), scrollToId(), and the input element |
|
|
94
145
|
| `CommandPaletteDefaultsProvider` | `Partial<CommandPaletteDefaults>` | — | a subtree | Every axis, set once; an explicit prop still wins |
|
|
@@ -125,7 +176,7 @@ Excerpt — not a complete module
|
|
|
125
176
|
- The layer is the dialog family’s: role="dialog", aria-modal, the page inert behind the scrim, focus contained and returned to the trigger. Its name is the label message; the field’s name is the input message, and the list borrows it.
|
|
126
177
|
- A row with a shortcut carries aria-keyshortcuts in the platform’s own words — Meta+Shift+D on a Mac, Control+Shift+D elsewhere — while the drawn keys are aria-hidden; a sequence has no syntax in the attribute and is drawn only. A disabled row is announced with aria-disabled, stays in the list, and is skipped by every movement key.
|
|
127
178
|
- The result count, the loading sentence and the failure of a rejected handler are one visually hidden role="status" row, spoken through the shared live announcer so the same sentence is never said twice in a row.
|
|
128
|
-
- Escape is three steps in a fixed order — clear the query, return one page, close — so a reader who typed does not lose the palette on the first press; the footer draws the same keys the
|
|
179
|
+
- Escape is three steps in a fixed order — clear the query, return one page, close — so a reader who typed does not lose the palette on the first press; the footer draws the same keys the palette answers.
|
|
129
180
|
- The panel answers its own width: below 360 pixels the description and the meta go and the binding stays; inside a dialog on a narrow screen the panel takes the whole layer.
|
|
130
181
|
|
|
131
182
|
## Tokens
|
|
@@ -134,334 +185,4 @@ Excerpt — not a complete module
|
|
|
134
185
|
|
|
135
186
|
## Examples
|
|
136
187
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
The same panel with no layer around it, so every part can be pointed at: the header with its mark and clear, the grouped list, the current row, a row with a description and a binding, and the footer of hints.
|
|
140
|
-
|
|
141
|
-
Excerpt — not a complete module
|
|
142
|
-
|
|
143
|
-
```tsx
|
|
144
|
-
const items = [
|
|
145
|
-
{
|
|
146
|
-
id: 'deploy',
|
|
147
|
-
label: 'Deploy to production',
|
|
148
|
-
description: 'Ship the current release of api-gateway',
|
|
149
|
-
keywords: ['ship', 'release'],
|
|
150
|
-
group: 'actions',
|
|
151
|
-
icon: <RocketIcon />,
|
|
152
|
-
shortcut: 'mod+shift+d',
|
|
153
|
-
onSelect: () => deploy(),
|
|
154
|
-
},
|
|
155
|
-
];
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Groups, in the order the product declares
|
|
159
|
-
|
|
160
|
-
groups gives each heading its label and its place; an item whose group is not listed lands under its own id, after them, and an item with no group closes the list.
|
|
161
|
-
|
|
162
|
-
Excerpt — not a complete module
|
|
163
|
-
|
|
164
|
-
```tsx
|
|
165
|
-
<CommandPalette
|
|
166
|
-
groups={[
|
|
167
|
-
{ id: 'nav', label: 'Go to' },
|
|
168
|
-
{ id: 'actions', label: 'Actions' },
|
|
169
|
-
]}
|
|
170
|
-
items={items}
|
|
171
|
-
presentation="inline"
|
|
172
|
-
/>;
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### Ranking, and the adapter
|
|
176
|
-
|
|
177
|
-
Type “dep”: a label that starts with it outranks a word that starts with it, which outranks a run inside a word, which outranks a keyword; groups reorder by their best row. The third panel hands the order to a ranker of the product’s own.
|
|
178
|
-
|
|
179
|
-
Excerpt — not a complete module
|
|
180
|
-
|
|
181
|
-
```tsx
|
|
182
|
-
<CommandPalette defaultQuery="dep" items={items} presentation="inline" />;
|
|
183
|
-
|
|
184
|
-
// A server has already ranked the list: show it as it came.
|
|
185
|
-
<CommandPalette items={results} presentation="inline" rank={null} />;
|
|
186
|
-
|
|
187
|
-
// Or score it yourself.
|
|
188
|
-
<CommandPalette
|
|
189
|
-
items={items}
|
|
190
|
-
presentation="inline"
|
|
191
|
-
rank={(item, query) => (item.label.toLowerCase().includes(query) ? item.weight : null)}
|
|
192
|
-
/>;
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Pages, stacked
|
|
196
|
-
|
|
197
|
-
A row with children opens a page: the trail appears before the field, the children take the list, and Backspace on an empty query or Escape returns one page. pages is state the product may own.
|
|
198
|
-
|
|
199
|
-
Excerpt — not a complete module
|
|
200
|
-
|
|
201
|
-
```tsx
|
|
202
|
-
const items = [
|
|
203
|
-
{
|
|
204
|
-
id: 'team',
|
|
205
|
-
label: 'Switch team…',
|
|
206
|
-
children: [
|
|
207
|
-
{ id: 'acme', label: 'Acme Robotics', onSelect: () => switchTo('acme') },
|
|
208
|
-
{ id: 'globex', label: 'Globex Freight', onSelect: () => switchTo('globex') },
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
];
|
|
212
|
-
|
|
213
|
-
<CommandPalette defaultPages={['team']} items={items} presentation="inline" />;
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### What the reader ran last
|
|
217
|
-
|
|
218
|
-
With nothing typed, the recents open the list under their own heading; running a row moves it to the front and cuts the array at recentLimit. Persisting it is the product’s — it receives the array.
|
|
219
|
-
|
|
220
|
-
Excerpt — not a complete module
|
|
221
|
-
|
|
222
|
-
```tsx
|
|
223
|
-
const [recent, setRecent] = useState(() => JSON.parse(localStorage.getItem('recent') ?? '[]'));
|
|
224
|
-
|
|
225
|
-
<CommandPalette
|
|
226
|
-
items={items}
|
|
227
|
-
onRecentChange={(next) => {
|
|
228
|
-
setRecent(next);
|
|
229
|
-
localStorage.setItem('recent', JSON.stringify(next));
|
|
230
|
-
}}
|
|
231
|
-
presentation="inline"
|
|
232
|
-
recent={recent}
|
|
233
|
-
recentLimit={3}
|
|
234
|
-
/>;
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Shortcuts, drawn for the platform
|
|
238
|
-
|
|
239
|
-
One notation, mod+shift+d, becomes ⌘⇧D on a Mac and Ctrl+Shift+D elsewhere, and is announced as Meta+Shift+D or Control+Shift+D. A sequence such as g i is drawn and not announced. The palette binds none of them: the three lines below do.
|
|
240
|
-
|
|
241
|
-
Excerpt — not a complete module
|
|
242
|
-
|
|
243
|
-
```tsx
|
|
244
|
-
useEffect(() => {
|
|
245
|
-
const onKey = (event: KeyboardEvent) => {
|
|
246
|
-
const hit = items.find(
|
|
247
|
-
(item) => item.shortcut && matchesShortcut(event, item.shortcut, platform),
|
|
248
|
-
);
|
|
249
|
-
if (hit) hit.onSelect?.();
|
|
250
|
-
};
|
|
251
|
-
document.addEventListener('keydown', onKey);
|
|
252
|
-
return () => document.removeEventListener('keydown', onKey);
|
|
253
|
-
}, [items, platform]);
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
### Rows that are places
|
|
257
|
-
|
|
258
|
-
A row with href renders as a link with role option: Enter follows it, ⌘Enter opens it in a new tab because the browser, not the palette, answers the modifier. meta says what kind of place it is.
|
|
259
|
-
|
|
260
|
-
Excerpt — not a complete module
|
|
261
|
-
|
|
262
|
-
```tsx
|
|
263
|
-
const items = [
|
|
264
|
-
{ id: 'billing', label: 'Billing', href: '/settings/billing', meta: 'Page' },
|
|
265
|
-
{ id: 'invoice', label: 'Download last invoice', onSelect: () => download() },
|
|
266
|
-
];
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### A command that takes a while
|
|
270
|
-
|
|
271
|
-
A handler that returns a promise keeps the palette open and the row busy, refuses a second run of the same row until it settles, then closes; a rejection keeps it open and the status row says why. Press the first row and wait two seconds.
|
|
272
|
-
|
|
273
|
-
Excerpt — not a complete module
|
|
274
|
-
|
|
275
|
-
```tsx
|
|
276
|
-
const items = [
|
|
277
|
-
{ id: 'restart', label: 'Restart api-gateway', onSelect: () => api.restart('api-gateway') },
|
|
278
|
-
{
|
|
279
|
-
id: 'purge',
|
|
280
|
-
label: 'Purge CDN cache',
|
|
281
|
-
onSelect: () => Promise.reject(new Error('Not allowed')),
|
|
282
|
-
},
|
|
283
|
-
];
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### While the results travel
|
|
287
|
-
|
|
288
|
-
loading swaps the magnifier for the ring, draws three skeleton rows when there is nothing to show yet, and says the loading message in the status row. The palette debounces nothing: the product does, in three lines.
|
|
289
|
-
|
|
290
|
-
Excerpt — not a complete module
|
|
291
|
-
|
|
292
|
-
```tsx
|
|
293
|
-
const [query, setQuery] = useState('');
|
|
294
|
-
const [loading, setLoading] = useState(false);
|
|
295
|
-
const [results, setResults] = useState([]);
|
|
296
|
-
|
|
297
|
-
useEffect(() => {
|
|
298
|
-
setLoading(true);
|
|
299
|
-
const timer = setTimeout(
|
|
300
|
-
() =>
|
|
301
|
-
search(query)
|
|
302
|
-
.then(setResults)
|
|
303
|
-
.finally(() => setLoading(false)),
|
|
304
|
-
200,
|
|
305
|
-
);
|
|
306
|
-
return () => clearTimeout(timer);
|
|
307
|
-
}, [query]);
|
|
308
|
-
|
|
309
|
-
<CommandPalette
|
|
310
|
-
items={results}
|
|
311
|
-
loading={loading}
|
|
312
|
-
onQueryChange={setQuery}
|
|
313
|
-
query={query}
|
|
314
|
-
rank={null}
|
|
315
|
-
/>;
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### Nothing matched
|
|
319
|
-
|
|
320
|
-
The empty part takes the list, the count row says “0 results”, and the root carries data-empty. The second panel replaces the sentence with the product’s own node.
|
|
321
|
-
|
|
322
|
-
Excerpt — not a complete module
|
|
323
|
-
|
|
324
|
-
```tsx
|
|
325
|
-
<CommandPalette
|
|
326
|
-
defaultQuery="xylophone"
|
|
327
|
-
empty={<span>No command matches. Try a service name.</span>}
|
|
328
|
-
items={items}
|
|
329
|
-
presentation="inline"
|
|
330
|
-
/>;
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
### Without a layer
|
|
334
|
-
|
|
335
|
-
presentation="inline" draws the panel where it was written — here inside a popover on an “Assign to” button — with no scrim, no hotkey and no Escape to close. It is the filtered menu that menu refused.
|
|
336
|
-
|
|
337
|
-
Excerpt — not a complete module
|
|
338
|
-
|
|
339
|
-
```tsx
|
|
340
|
-
<Popover>
|
|
341
|
-
<PopoverTrigger render={(props) => <Button {...props}>Assign to…</Button>} />
|
|
342
|
-
<PopoverContent>
|
|
343
|
-
<CommandPalette items={people} presentation="inline" footer={null} />
|
|
344
|
-
</PopoverContent>
|
|
345
|
-
</Popover>;
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
### Three measures
|
|
349
|
-
|
|
350
|
-
size is the dialog’s measure — 24, 32 and 42 rems — and the row’s step: sm rows read the small control geometry, lg rows the large, and the header stands one step above the rows in each.
|
|
351
|
-
|
|
352
|
-
Excerpt — not a complete module
|
|
353
|
-
|
|
354
|
-
```tsx
|
|
355
|
-
<CommandPalette items={items} presentation="inline" size="sm" />;
|
|
356
|
-
<CommandPalette items={items} presentation="inline" size="lg" />;
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
### Every state a row can be in
|
|
360
|
-
|
|
361
|
-
At rest, current from the keyboard, busy while its handler runs, disabled but announced and kept in place, opening a page, and a link. Hover a row that is not current for the quieter wash.
|
|
362
|
-
|
|
363
|
-
Excerpt — not a complete module
|
|
364
|
-
|
|
365
|
-
```tsx
|
|
366
|
-
const items = [
|
|
367
|
-
{
|
|
368
|
-
id: 'delete',
|
|
369
|
-
label: 'Delete workspace',
|
|
370
|
-
description: 'Requires the owner role',
|
|
371
|
-
disabled: true,
|
|
372
|
-
},
|
|
373
|
-
];
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
### Content the family did not choose
|
|
377
|
-
|
|
378
|
-
A German label of sixty characters, a description longer than the row, a binding of four keys and a row with no icon beside rows that have one: the label gives way, the binding never does, and the icon column keeps every label on one line.
|
|
379
|
-
|
|
380
|
-
Excerpt — not a complete module
|
|
381
|
-
|
|
382
|
-
```tsx
|
|
383
|
-
const items = [
|
|
384
|
-
{
|
|
385
|
-
id: 'sync',
|
|
386
|
-
label: 'Benachrichtigungseinstellungen für alle Arbeitsbereiche synchronisieren',
|
|
387
|
-
shortcut: 'mod+shift+alt+p',
|
|
388
|
-
},
|
|
389
|
-
];
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
### The chord that opens it
|
|
393
|
-
|
|
394
|
-
mod+k by default, matched on the document in the capture phase with preventDefault, so Firefox’s search bar does not answer first. A bare key such as / stays quiet inside a text field; hotkey={null} turns it off. Focus the page and press ⌘K or Ctrl+K.
|
|
395
|
-
|
|
396
|
-
Excerpt — not a complete module
|
|
397
|
-
|
|
398
|
-
```tsx
|
|
399
|
-
<CommandPalette hotkey="mod+p" items={items} />;
|
|
400
|
-
<CommandPalette hotkey="/" items={items} />;
|
|
401
|
-
<CommandPalette hotkey={null} items={items} />;
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
### Set once for the application
|
|
405
|
-
|
|
406
|
-
The provider holds every axis, and SlottedProvider the language the family speaks: the panel below reads Portuguese words, a size and a hotkey it did not state itself.
|
|
407
|
-
|
|
408
|
-
Excerpt — not a complete module
|
|
409
|
-
|
|
410
|
-
```tsx
|
|
411
|
-
<SlottedProvider locale="pt-BR">
|
|
412
|
-
<CommandPaletteDefaultsProvider hotkey="mod+p" size="sm">
|
|
413
|
-
<App />
|
|
414
|
-
</CommandPaletteDefaultsProvider>
|
|
415
|
-
</SlottedProvider>;
|
|
416
|
-
```
|
|
417
|
-
|
|
418
|
-
### In an application’s top bar
|
|
419
|
-
|
|
420
|
-
The trigger is a search-shaped Button with a Kbd in it, rendered through render so the palette hands it the wiring and the ref; the row content is the product’s own through renderItem, with an avatar where the icon column is.
|
|
421
|
-
|
|
422
|
-
Excerpt — not a complete module
|
|
423
|
-
|
|
424
|
-
```tsx
|
|
425
|
-
<CommandPalette
|
|
426
|
-
items={items}
|
|
427
|
-
renderItem={(item, state) => (
|
|
428
|
-
<>
|
|
429
|
-
<span data-part="icon">
|
|
430
|
-
<Avatar name={item.label} size="xs" />
|
|
431
|
-
</span>
|
|
432
|
-
<span data-part="label">{state.label}</span>
|
|
433
|
-
</>
|
|
434
|
-
)}
|
|
435
|
-
>
|
|
436
|
-
<CommandPaletteTrigger
|
|
437
|
-
render={(props) => (
|
|
438
|
-
<Button {...props} tone="secondary" variant="outline">
|
|
439
|
-
Search <Kbd size="sm">⌘K</Kbd>
|
|
440
|
-
</Button>
|
|
441
|
-
)}
|
|
442
|
-
/>
|
|
443
|
-
</CommandPalette>;
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
### The keys
|
|
447
|
-
|
|
448
|
-
Arrows move and wrap, PageUp and PageDown move ten and stop, Ctrl+Home and Ctrl+End reach the ends, Home and End keep moving the caret, Enter runs, Escape clears then returns a page then closes, Backspace on an empty query returns a page.
|
|
449
|
-
|
|
450
|
-
Excerpt — not a complete module
|
|
451
|
-
|
|
452
|
-
```tsx
|
|
453
|
-
<CommandPalette items={items} presentation="inline" />;
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
### What a screen reader meets
|
|
457
|
-
|
|
458
|
-
The dialog is named by the label message, the field by the input message, the list by the same; the current row is aria-selected and named by aria-activedescendant; the count, the wait and a failure are one live region. Open the tree to read it.
|
|
459
|
-
|
|
460
|
-
Excerpt — not a complete module
|
|
461
|
-
|
|
462
|
-
```tsx
|
|
463
|
-
<CommandPalette
|
|
464
|
-
items={items}
|
|
465
|
-
messages={{ input: 'Search deployments', label: 'Deployment commands' }}
|
|
466
|
-
/>;
|
|
467
|
-
```
|
|
188
|
+
See [command-palette.examples.md](./command-palette.examples.md).
|