@orbitcommerce/constellation-docs 0.0.0-stage → 1.2.0
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/LICENSE.md +6 -0
- package/README.md +6 -2
- package/dist/docs.css +20787 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +308 -0
- package/dist/pages/Playground-Mk1yIWXb.js +129 -0
- package/dist/pages/_address-data-L9BR499w.js +161 -0
- package/dist/pages/_builder-demo-C0eJUmPU.js +282 -0
- package/dist/pages/_card-art-0be5ncyV.js +18 -0
- package/dist/pages/_conversation-samples-Bq7cn-4d.js +70 -0
- package/dist/pages/_figures-data-DaDvB7Nm.js +606 -0
- package/dist/pages/_foundations-blXWyYh8.js +30 -0
- package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
- package/dist/pages/_overlays-specimens-bawR331Z.js +320 -0
- package/dist/pages/_preview-specimens-DKQC9HAo.js +153 -0
- package/dist/pages/accordion-Sg0TUqxB.js +1036 -0
- package/dist/pages/address-autocomplete-DP0PUOlK.js +360 -0
- package/dist/pages/address-block-BZOOOPA9.js +368 -0
- package/dist/pages/address-fields-CwSqro3W.js +277 -0
- package/dist/pages/ai-highlight-D3x2vD83.js +642 -0
- package/dist/pages/alert-D3i7xZTU.js +914 -0
- package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
- package/dist/pages/app-shell-D4hdlHps.js +1558 -0
- package/dist/pages/area-chart-BEWFwiB2.js +718 -0
- package/dist/pages/avatar-BFEqQViw.js +895 -0
- package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
- package/dist/pages/badge-0-PyMrih.js +1035 -0
- package/dist/pages/bar-chart-DkLogYlt.js +1060 -0
- package/dist/pages/bar-fold-B-3XeIDZ.js +360 -0
- package/dist/pages/board-card-D2tZY_mU.js +415 -0
- package/dist/pages/brand-mark-BqiLvFSR.js +417 -0
- package/dist/pages/button-DAyfssDY.js +715 -0
- package/dist/pages/calendar-Ds7KsgSI.js +682 -0
- package/dist/pages/canvas-stage-1KiPspkX.js +472 -0
- package/dist/pages/card-CQEM1_wc.js +1567 -0
- package/dist/pages/caret-suggestions-oHI6QvqW.js +526 -0
- package/dist/pages/chart-legend-B20AbakD.js +724 -0
- package/dist/pages/chat-composer-CwzUJYIa.js +437 -0
- package/dist/pages/checkbox-BG9Zkb6j.js +1581 -0
- package/dist/pages/checklist-card-DEyykVFS.js +783 -0
- package/dist/pages/chip-Ck-o3Ui6.js +839 -0
- package/dist/pages/chip-list-k1LxXuCi.js +414 -0
- package/dist/pages/clamp-text-n-iE8RDR.js +203 -0
- package/dist/pages/coachmark-Be2ghobT.js +366 -0
- package/dist/pages/code-block-Dv_Y5GYq.js +622 -0
- package/dist/pages/collab-field-CfqqK7d2.js +696 -0
- package/dist/pages/color-field-CZpfcA-A.js +1127 -0
- package/dist/pages/colour-q2ntvI0w.js +1974 -0
- package/dist/pages/column-mapper-TsTG39cl.js +502 -0
- package/dist/pages/combobox-DvK2j5tI.js +1334 -0
- package/dist/pages/command-palette-CJ7uBA04.js +1386 -0
- package/dist/pages/comment-box-CDSGYhr5.js +346 -0
- package/dist/pages/composer-D4B0NgpA.js +689 -0
- package/dist/pages/condition-builder-BZy2ZGXe.js +715 -0
- package/dist/pages/conflict-chooser-C--_9UIS.js +210 -0
- package/dist/pages/context-menu-F9DV30ia.js +487 -0
- package/dist/pages/copy-button-Cn7WiKRF.js +568 -0
- package/dist/pages/copy-field-D3Xt3Jq6.js +511 -0
- package/dist/pages/danger-zone-Db_UUeiP.js +564 -0
- package/dist/pages/date-input-GOW067EB.js +956 -0
- package/dist/pages/date-picker-GdBciR99.js +1569 -0
- package/dist/pages/date-time-BLKCXtVZ.js +678 -0
- package/dist/pages/delta-CNAGv8JY.js +779 -0
- package/dist/pages/description-list-BPeXn1eW.js +1268 -0
- package/dist/pages/device-switcher-BCaN99c1.js +554 -0
- package/dist/pages/dialog-CRpkRC98.js +3164 -0
- package/dist/pages/docs-lM2UBSir.js +520 -0
- package/dist/pages/doodle-nzkqi2UI.js +201 -0
- package/dist/pages/drag-ghost-B6kpzC3O.js +426 -0
- package/dist/pages/drill-menu-cskH5mol.js +490 -0
- package/dist/pages/dropzone-DOY_Rhw0.js +1069 -0
- package/dist/pages/element-toolbar-DZIhXlCJ.js +498 -0
- package/dist/pages/emoji-picker-CqaWaffD.js +235 -0
- package/dist/pages/empty-state-4U2txFpI.js +1113 -0
- package/dist/pages/facet-filters-McbBeY9e.js +353 -0
- package/dist/pages/figure-D-HF5vCj.js +563 -0
- package/dist/pages/figure-strip-BB3mNl7D.js +1364 -0
- package/dist/pages/figure-tabs-QOeQMY6N.js +578 -0
- package/dist/pages/file-chip-DMDjtlqQ.js +738 -0
- package/dist/pages/filter-pill-DzqNOsD4.js +1295 -0
- package/dist/pages/font-picker-Bqhu0QMh.js +416 -0
- package/dist/pages/form-grid-BfWCVlie.js +692 -0
- package/dist/pages/gallery-BBk2EOri.js +453 -0
- package/dist/pages/gif-picker-CnoDTCaL.js +270 -0
- package/dist/pages/gradient-editor-Bqxp7Fxj.js +378 -0
- package/dist/pages/grouped-checklist-gNZ0tBKU.js +477 -0
- package/dist/pages/heatmap-BohgIcNk.js +507 -0
- package/dist/pages/highlight-text-BfxzfmvS.js +287 -0
- package/dist/pages/home-dashboard-CxPmvduE.js +962 -0
- package/dist/pages/host-B6znjEgQ.js +109 -0
- package/dist/pages/hosted-embed-Jef3aIMP.js +163 -0
- package/dist/pages/hosted-field-BLh-53AE.js +208 -0
- package/dist/pages/hosted-field-DEpI4lVS.js +514 -0
- package/dist/pages/icon-button-Bu4Gj5sy.js +1200 -0
- package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
- package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
- package/dist/pages/icons-CJ9Aar3d.js +736 -0
- package/dist/pages/image-cropper-NyougqLH.js +466 -0
- package/dist/pages/image-field-7knBv4mJ.js +567 -0
- package/dist/pages/import-result-CmTtGXW_.js +486 -0
- package/dist/pages/inline-confirm-CEcI5Lxo.js +327 -0
- package/dist/pages/inline-edit-Ba39SzhM.js +1125 -0
- package/dist/pages/input-CzLCzfyx.js +2372 -0
- package/dist/pages/installation-C3UcpQJT.js +528 -0
- package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
- package/dist/pages/kanban-Dy9sPAI0.js +740 -0
- package/dist/pages/kbd-UNj4zqxn.js +545 -0
- package/dist/pages/layout-primitives-CPRaZeyt.js +483 -0
- package/dist/pages/line-chart-CntWxeMF.js +1117 -0
- package/dist/pages/link-CXqvAg9z.js +689 -0
- package/dist/pages/link-picker-BMFGCC67.js +478 -0
- package/dist/pages/link-row-x8yaUuWc.js +595 -0
- package/dist/pages/live-globe-95ROMhGQ.js +715 -0
- package/dist/pages/loading-overlay-BeGuXM9G.js +456 -0
- package/dist/pages/loading-state-BNbCo51C.js +556 -0
- package/dist/pages/log-viewer-BQz8I_a2.js +503 -0
- package/dist/pages/logo-B38rnzoq.js +571 -0
- package/dist/pages/lottie_light-CxEH8eiR.js +9116 -0
- package/dist/pages/markdown-Ied72vMT.js +237 -0
- package/dist/pages/markdown-field-BfnIEKZH.js +193 -0
- package/dist/pages/media-banner-DkStCia0.js +233 -0
- package/dist/pages/menu-NrLYKqKp.js +2132 -0
- package/dist/pages/message-thread-Bo4zbxqu.js +731 -0
- package/dist/pages/meta-line-D5p2TycR.js +371 -0
- package/dist/pages/model-viewer-BfokvHoc.js +60288 -0
- package/dist/pages/model-viewer-C8PFO8wk.js +577 -0
- package/dist/pages/month-calendar-T1vw9Rup.js +457 -0
- package/dist/pages/motion-CrXtiBvA.js +865 -0
- package/dist/pages/number-input-CuyMZg18.js +968 -0
- package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
- package/dist/pages/orbit-spinner-Dxv5qAhr.js +348 -0
- package/dist/pages/otp-input-CVRoX1mw.js +591 -0
- package/dist/pages/overview-LA9XRhZc.js +130 -0
- package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
- package/dist/pages/pagination-C1EgVtW4.js +294 -0
- package/dist/pages/palette-tile-X9ZXu2Z0.js +414 -0
- package/dist/pages/password-field-DHEQKyUC.js +912 -0
- package/dist/pages/person-cell-BmjbADBz.js +564 -0
- package/dist/pages/phone-input-B3G7Qpb2.js +747 -0
- package/dist/pages/plan-card-DRaA6RuB.js +621 -0
- package/dist/pages/plan-card-DtloWvMh.js +258 -0
- package/dist/pages/plan-comparison-BVIGTtbd.js +559 -0
- package/dist/pages/plan-grid-cfPVTB5V.js +251 -0
- package/dist/pages/point-list-BbPmZjsm.js +222 -0
- package/dist/pages/popover-C3Oar9D5.js +1198 -0
- package/dist/pages/presence-avatars-CRZIk8n9.js +328 -0
- package/dist/pages/preview-frame-Bcwk0y_Q.js +1631 -0
- package/dist/pages/price-CRBLoa9h.js +604 -0
- package/dist/pages/principles-pnDyfHpK.js +483 -0
- package/dist/pages/print-page-BkLv6bW8.js +513 -0
- package/dist/pages/profile-hero-CC9dUzuN.js +498 -0
- package/dist/pages/progress-CP_awmo4.js +904 -0
- package/dist/pages/progress-ring-JuOAwk2T.js +576 -0
- package/dist/pages/radio-group-C-4tg6FS.js +1639 -0
- package/dist/pages/radius-control-B2kRA2Ch.js +441 -0
- package/dist/pages/rating-CweKN2SX.js +471 -0
- package/dist/pages/record-layout-DUP_X0RL.js +719 -0
- package/dist/pages/record-pager-y9D7JFgb.js +278 -0
- package/dist/pages/registry-BZg-xAbi.js +594 -0
- package/dist/pages/release-Cs6tl16C.js +16 -0
- package/dist/pages/repeater-BRZYKRQa.js +1351 -0
- package/dist/pages/reply-feedback-BDnHprla.js +192 -0
- package/dist/pages/reveal-BygENBbL.js +460 -0
- package/dist/pages/rich-text-DOFQZEpT.js +156 -0
- package/dist/pages/rich-text-editor-BhIM20JI.js +1265 -0
- package/dist/pages/rolldown-runtime-CbKu08Hx.js +25 -0
- package/dist/pages/rolling-number-GR3Cyfpz.js +529 -0
- package/dist/pages/row-list-Dl6CYhC-.js +1565 -0
- package/dist/pages/rule-list-DTCmIMpT.js +648 -0
- package/dist/pages/save-status-B5KkyMZP.js +378 -0
- package/dist/pages/schedule-YycI95O1.js +243 -0
- package/dist/pages/scroll-area-B2sGm23Q.js +423 -0
- package/dist/pages/search-field-D1uG7R6A.js +693 -0
- package/dist/pages/search-menu-DMuXyUUW.js +580 -0
- package/dist/pages/secret-field-Dj9x3LL8.js +337 -0
- package/dist/pages/section-rail-BtTCETS5.js +637 -0
- package/dist/pages/section-v2Pubup9.js +639 -0
- package/dist/pages/segmented-control-D-FB1K1T.js +1190 -0
- package/dist/pages/select-DZ43NpOm.js +1434 -0
- package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
- package/dist/pages/separator-CFwqRvfO.js +428 -0
- package/dist/pages/serp-preview-BGwORjmo.js +346 -0
- package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
- package/dist/pages/shape-DzniHAVT.js +627 -0
- package/dist/pages/share-list-D4wgBxKN.js +926 -0
- package/dist/pages/side-panel-CCtkrZjs.js +811 -0
- package/dist/pages/site-preview-Dj1hM2Yo.js +353 -0
- package/dist/pages/skeleton-C1F5HkAu.js +1325 -0
- package/dist/pages/skip-link-BxznhSkz.js +252 -0
- package/dist/pages/slider-CAoPURKD.js +774 -0
- package/dist/pages/sortable-card-Sr44uCpI.js +424 -0
- package/dist/pages/sortable-list-DUAleYE1.js +1298 -0
- package/dist/pages/sortable-tree-BLzK-hTE.js +737 -0
- package/dist/pages/spacing-box-CtuvzxQu.js +550 -0
- package/dist/pages/sparkline-D3aavCly.js +947 -0
- package/dist/pages/split-bar-DYgZnFID.js +414 -0
- package/dist/pages/split-button-Be08-VI-.js +335 -0
- package/dist/pages/split-pane-lSNZgTKt.js +523 -0
- package/dist/pages/status-badge-DOdNhmzn.js +1074 -0
- package/dist/pages/status-checklist-CWkjCZIC.js +1152 -0
- package/dist/pages/status-dot-D99gAGsV.js +567 -0
- package/dist/pages/stepper-CxKTbEA-.js +1093 -0
- package/dist/pages/success-mark-CqFTOBEu.js +142 -0
- package/dist/pages/swatch-H_kNvHuC.js +565 -0
- package/dist/pages/switch-C93K6j9h.js +617 -0
- package/dist/pages/table-CL0vomno.js +3225 -0
- package/dist/pages/tabs-Dh0mUsLw.js +1690 -0
- package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
- package/dist/pages/task-card-Dv0sR1-w.js +295 -0
- package/dist/pages/textarea-CCM-SnGN.js +949 -0
- package/dist/pages/thumbnail-DwFJL_k1.js +1147 -0
- package/dist/pages/time-input-CA9-uZAa.js +442 -0
- package/dist/pages/time-zone-select-CEtMXVYO.js +296 -0
- package/dist/pages/timeline-BsMUTlpR.js +1798 -0
- package/dist/pages/toast-zXLRiMRT.js +1391 -0
- package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
- package/dist/pages/toolbar-B9l_fHKy.js +754 -0
- package/dist/pages/tooltip-LHtCUkF-.js +826 -0
- package/dist/pages/translation-field-CTRXiF2N.js +251 -0
- package/dist/pages/tree-checklist-CJj3OcLg.js +451 -0
- package/dist/pages/tree-select-DU1qXHy_.js +492 -0
- package/dist/pages/tree-view-g_RjLtAb.js +739 -0
- package/dist/pages/typography-BSijtiRl.js +876 -0
- package/dist/pages/unit-input-Dml4fjmK.js +659 -0
- package/dist/pages/upload-rules-yozEzSah.js +419 -0
- package/dist/pages/url-upload-input-SSnMgfpA.js +307 -0
- package/dist/pages/value-change-CnubDKyO.js +489 -0
- package/dist/pages/weekly-hours-i2EpsmTx.js +287 -0
- package/dist/pages/widget-preview-CUJMyZ_k.js +625 -0
- package/dist/pages/working-status-CENemSsw.js +389 -0
- package/manifest.json +13001 -0
- package/package.json +35 -4
|
@@ -0,0 +1,1386 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as DocTable, d as Section$1, i as DocPage, l as Note, m as ThemePair, o as Example, p as SubSection, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
3
|
+
import { c as SpecimenFrame, o as PaletteStill } from "./_overlays-specimens-bawR331Z.js";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Avatar, Button, CommandEmpty, CommandGroup, CommandHints, CommandItem, CommandKey, CommandLoading, CommandPalette, CommandSeparator, IconButton, SearchTrigger } from "@orbitcommerce/constellation";
|
|
7
|
+
import { BellIcon, ChartLineUpIcon, FilePlusIcon, GearSixIcon, HouseIcon, MagnifyingGlassIcon, PackageIcon, PlusSquareIcon, QuestionIcon, ReceiptIcon, UserPlusIcon, UsersThreeIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/command-palette.tsx
|
|
9
|
+
var ORDERS = [
|
|
10
|
+
{
|
|
11
|
+
number: "1043",
|
|
12
|
+
customer: "Sarah Whitfield",
|
|
13
|
+
total: "£240.00",
|
|
14
|
+
status: "Paid"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
number: "1042",
|
|
18
|
+
customer: "James Okafor",
|
|
19
|
+
total: "£89.50",
|
|
20
|
+
status: "Unfulfilled"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
number: "1041",
|
|
24
|
+
customer: "Priya Shah",
|
|
25
|
+
total: "£1,120.00",
|
|
26
|
+
status: "Paid"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
number: "1039",
|
|
30
|
+
customer: "Tom Hughes",
|
|
31
|
+
total: "£34.99",
|
|
32
|
+
status: "Refunded"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
number: "1036",
|
|
36
|
+
customer: "Eleanor Price",
|
|
37
|
+
total: "£412.80",
|
|
38
|
+
status: "Fulfilled"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
number: "1031",
|
|
42
|
+
customer: "Sarah Whitfield",
|
|
43
|
+
total: "£65.00",
|
|
44
|
+
status: "Fulfilled"
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
var PRODUCTS = [
|
|
48
|
+
{
|
|
49
|
+
name: "White oak side table",
|
|
50
|
+
sku: "TBL-OAK-45",
|
|
51
|
+
price: "£149.00",
|
|
52
|
+
stock: "12 in stock"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "Arden ergonomic chair",
|
|
56
|
+
sku: "CHR-ARD-01",
|
|
57
|
+
price: "£229.00",
|
|
58
|
+
stock: "4 in stock"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "Walnut bookcase",
|
|
62
|
+
sku: "BKC-WAL-180",
|
|
63
|
+
price: "£389.00",
|
|
64
|
+
stock: "Out of stock"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "Walnut desk riser",
|
|
68
|
+
sku: "DSK-WAL-60",
|
|
69
|
+
price: "£84.00",
|
|
70
|
+
stock: "19 in stock"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "Brass desk lamp",
|
|
74
|
+
sku: "LMP-BRS-01",
|
|
75
|
+
price: "£72.00",
|
|
76
|
+
stock: "9 in stock"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "Sit-stand desk, 140cm",
|
|
80
|
+
sku: "DSK-SIT-140",
|
|
81
|
+
price: "£449.00",
|
|
82
|
+
stock: "6 in stock"
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
var CUSTOMERS = [
|
|
86
|
+
{
|
|
87
|
+
name: "Sarah Whitfield",
|
|
88
|
+
email: "sarah.whitfield@example.co.uk",
|
|
89
|
+
city: "Leeds",
|
|
90
|
+
orders: 6
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "Sam Whitaker",
|
|
94
|
+
email: "sam.whitaker@example.co.uk",
|
|
95
|
+
city: "York",
|
|
96
|
+
orders: 3
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "James Okafor",
|
|
100
|
+
email: "james.okafor@example.co.uk",
|
|
101
|
+
city: "Manchester",
|
|
102
|
+
orders: 2
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "Priya Shah",
|
|
106
|
+
email: "priya.shah@example.co.uk",
|
|
107
|
+
city: "Bristol",
|
|
108
|
+
orders: 9
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "Eleanor Price",
|
|
112
|
+
email: "eleanor.price@example.co.uk",
|
|
113
|
+
city: "Edinburgh",
|
|
114
|
+
orders: 4
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
/** The "server": a plain substring search over the sample data. */
|
|
118
|
+
function search(query) {
|
|
119
|
+
const q = query.toLowerCase();
|
|
120
|
+
const has = (...fields) => fields.some((f) => f.toLowerCase().includes(q));
|
|
121
|
+
return {
|
|
122
|
+
orders: ORDERS.filter((o) => has(`#${o.number}`, o.customer)).slice(0, 4),
|
|
123
|
+
products: PRODUCTS.filter((p) => has(p.name, p.sku)).slice(0, 4),
|
|
124
|
+
customers: CUSTOMERS.filter((c) => has(c.name, c.email, c.city)).slice(0, 4)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function countOf(results) {
|
|
128
|
+
return results ? results.orders.length + results.products.length + results.customers.length : 0;
|
|
129
|
+
}
|
|
130
|
+
/** Simulates a server search: results land `delay` ms after the last keystroke. */
|
|
131
|
+
function useServerSearch(query, delay) {
|
|
132
|
+
const [results, setResults] = useState(null);
|
|
133
|
+
const [loading, setLoading] = useState(false);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const q = query.trim();
|
|
136
|
+
if (!q) {
|
|
137
|
+
setResults(null);
|
|
138
|
+
setLoading(false);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
setLoading(true);
|
|
142
|
+
const timer = window.setTimeout(() => {
|
|
143
|
+
setResults(search(q));
|
|
144
|
+
setLoading(false);
|
|
145
|
+
}, delay);
|
|
146
|
+
return () => window.clearTimeout(timer);
|
|
147
|
+
}, [query, delay]);
|
|
148
|
+
return {
|
|
149
|
+
results,
|
|
150
|
+
loading
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
var PAGES = [
|
|
154
|
+
{
|
|
155
|
+
label: "Home",
|
|
156
|
+
icon: /* @__PURE__ */ jsx(HouseIcon, {}),
|
|
157
|
+
keys: ["G", "H"]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: "Orders",
|
|
161
|
+
icon: /* @__PURE__ */ jsx(ReceiptIcon, {}),
|
|
162
|
+
keys: ["G", "O"]
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
label: "Products",
|
|
166
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {}),
|
|
167
|
+
keys: ["G", "P"]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
label: "Customers",
|
|
171
|
+
icon: /* @__PURE__ */ jsx(UsersThreeIcon, {}),
|
|
172
|
+
keys: ["G", "C"]
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
label: "Analytics",
|
|
176
|
+
icon: /* @__PURE__ */ jsx(ChartLineUpIcon, {}),
|
|
177
|
+
keys: ["G", "A"]
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
label: "Settings",
|
|
181
|
+
icon: /* @__PURE__ */ jsx(GearSixIcon, {}),
|
|
182
|
+
keys: ["G", "S"]
|
|
183
|
+
}
|
|
184
|
+
];
|
|
185
|
+
var ACTIONS = [
|
|
186
|
+
{
|
|
187
|
+
label: "Create product",
|
|
188
|
+
icon: /* @__PURE__ */ jsx(PlusSquareIcon, {})
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
label: "Create order",
|
|
192
|
+
icon: /* @__PURE__ */ jsx(FilePlusIcon, {})
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
label: "Add customer",
|
|
196
|
+
icon: /* @__PURE__ */ jsx(UserPlusIcon, {})
|
|
197
|
+
}
|
|
198
|
+
];
|
|
199
|
+
function initials(name) {
|
|
200
|
+
return name.split(" ").map((part) => part[0]).join("").slice(0, 2);
|
|
201
|
+
}
|
|
202
|
+
function LocalGroups({ onRun }) {
|
|
203
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
204
|
+
/* @__PURE__ */ jsx(CommandGroup, {
|
|
205
|
+
heading: "Pages",
|
|
206
|
+
children: PAGES.map((page) => /* @__PURE__ */ jsx(CommandItem, {
|
|
207
|
+
value: page.label,
|
|
208
|
+
icon: page.icon,
|
|
209
|
+
shortcut: page.keys,
|
|
210
|
+
onSelect: () => onRun(`Go to ${page.label}`),
|
|
211
|
+
children: page.label
|
|
212
|
+
}, page.label))
|
|
213
|
+
}),
|
|
214
|
+
/* @__PURE__ */ jsx(CommandSeparator, {}),
|
|
215
|
+
/* @__PURE__ */ jsx(CommandGroup, {
|
|
216
|
+
heading: "Quick actions",
|
|
217
|
+
children: ACTIONS.map((action) => /* @__PURE__ */ jsx(CommandItem, {
|
|
218
|
+
value: action.label,
|
|
219
|
+
icon: action.icon,
|
|
220
|
+
onSelect: () => onRun(action.label),
|
|
221
|
+
children: action.label
|
|
222
|
+
}, action.label))
|
|
223
|
+
})
|
|
224
|
+
] });
|
|
225
|
+
}
|
|
226
|
+
function ServerGroups({ results, onRun }) {
|
|
227
|
+
if (!results) return null;
|
|
228
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
229
|
+
results.orders.length > 0 ? /* @__PURE__ */ jsx(CommandGroup, {
|
|
230
|
+
heading: "Orders",
|
|
231
|
+
children: results.orders.map((order) => /* @__PURE__ */ jsxs(CommandItem, {
|
|
232
|
+
value: `Order #${order.number} ${order.customer}`,
|
|
233
|
+
keywords: [order.status, order.total],
|
|
234
|
+
icon: /* @__PURE__ */ jsx(ReceiptIcon, {}),
|
|
235
|
+
hint: `${order.status} · ${order.total}`,
|
|
236
|
+
onSelect: () => onRun(`Open order #${order.number}`),
|
|
237
|
+
children: [
|
|
238
|
+
"#",
|
|
239
|
+
order.number,
|
|
240
|
+
" · ",
|
|
241
|
+
order.customer
|
|
242
|
+
]
|
|
243
|
+
}, order.number))
|
|
244
|
+
}) : null,
|
|
245
|
+
results.products.length > 0 ? /* @__PURE__ */ jsx(CommandGroup, {
|
|
246
|
+
heading: "Products",
|
|
247
|
+
children: results.products.map((product) => /* @__PURE__ */ jsx(CommandItem, {
|
|
248
|
+
value: product.name,
|
|
249
|
+
keywords: [product.sku],
|
|
250
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {}),
|
|
251
|
+
hint: `${product.price} · ${product.stock}`,
|
|
252
|
+
onSelect: () => onRun(`Open ${product.name}`),
|
|
253
|
+
children: product.name
|
|
254
|
+
}, product.sku))
|
|
255
|
+
}) : null,
|
|
256
|
+
results.customers.length > 0 ? /* @__PURE__ */ jsx(CommandGroup, {
|
|
257
|
+
heading: "Customers",
|
|
258
|
+
children: results.customers.map((customer) => /* @__PURE__ */ jsx(CommandItem, {
|
|
259
|
+
value: customer.name,
|
|
260
|
+
keywords: [customer.email, customer.city],
|
|
261
|
+
icon: /* @__PURE__ */ jsx("span", { children: initials(customer.name) }),
|
|
262
|
+
hint: `${customer.city} · ${customer.orders} orders`,
|
|
263
|
+
onSelect: () => onRun(`Open ${customer.name}`),
|
|
264
|
+
children: customer.name
|
|
265
|
+
}, customer.email))
|
|
266
|
+
}) : null
|
|
267
|
+
] });
|
|
268
|
+
}
|
|
269
|
+
function Status({ last, idle }) {
|
|
270
|
+
return /* @__PURE__ */ jsx("p", {
|
|
271
|
+
className: "command-palette-status",
|
|
272
|
+
"aria-live": "polite",
|
|
273
|
+
children: last ? /* @__PURE__ */ jsxs(Fragment$1, { children: ["Last command: ", /* @__PURE__ */ jsx("strong", { children: last })] }) : idle
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
var tileVars = {
|
|
277
|
+
"--o-command-row-h": "40px",
|
|
278
|
+
"--o-command-item-h": "28px",
|
|
279
|
+
"--o-command-tile": "22px",
|
|
280
|
+
"--o-command-input-fs": "13px",
|
|
281
|
+
fontSize: "12.5px"
|
|
282
|
+
};
|
|
283
|
+
function Preview() {
|
|
284
|
+
return /* @__PURE__ */ jsx(PaletteStill, {
|
|
285
|
+
query: "whit",
|
|
286
|
+
footer: false,
|
|
287
|
+
style: {
|
|
288
|
+
...tileVars,
|
|
289
|
+
width: 224
|
|
290
|
+
},
|
|
291
|
+
groups: [{ items: [
|
|
292
|
+
{
|
|
293
|
+
icon: /* @__PURE__ */ jsx(ReceiptIcon, {}),
|
|
294
|
+
label: "#1043 · Sarah Whitfield",
|
|
295
|
+
selected: true
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {}),
|
|
299
|
+
label: "White oak side table"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
icon: /* @__PURE__ */ jsx("span", { children: "SW" }),
|
|
303
|
+
label: "Sam Whitaker"
|
|
304
|
+
}
|
|
305
|
+
] }]
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
function HeaderDemo() {
|
|
309
|
+
const [open, setOpen] = useState(false);
|
|
310
|
+
const [query, setQuery] = useState("");
|
|
311
|
+
const [last, setLast] = useState();
|
|
312
|
+
const { results, loading } = useServerSearch(query, 550);
|
|
313
|
+
const run = (what) => {
|
|
314
|
+
setLast(what);
|
|
315
|
+
setOpen(false);
|
|
316
|
+
};
|
|
317
|
+
const hasResults = countOf(results) > 0;
|
|
318
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
319
|
+
/* @__PURE__ */ jsxs("div", {
|
|
320
|
+
className: "command-palette-strip",
|
|
321
|
+
children: [
|
|
322
|
+
/* @__PURE__ */ jsx("div", {
|
|
323
|
+
className: "command-palette-strip__side",
|
|
324
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
325
|
+
className: "command-palette-store",
|
|
326
|
+
children: [/* @__PURE__ */ jsx(Avatar, {
|
|
327
|
+
name: "Harbour Desk Co",
|
|
328
|
+
shape: "square",
|
|
329
|
+
size: "sm"
|
|
330
|
+
}), /* @__PURE__ */ jsx("span", { children: "Harbour Desk Co" })]
|
|
331
|
+
})
|
|
332
|
+
}),
|
|
333
|
+
/* @__PURE__ */ jsx(SearchTrigger, {
|
|
334
|
+
hotkey: false,
|
|
335
|
+
width: "min(360px, 100%)",
|
|
336
|
+
onOpen: () => {
|
|
337
|
+
setQuery("");
|
|
338
|
+
setOpen(true);
|
|
339
|
+
}
|
|
340
|
+
}),
|
|
341
|
+
/* @__PURE__ */ jsxs("div", {
|
|
342
|
+
className: "command-palette-strip__side",
|
|
343
|
+
"data-end": "",
|
|
344
|
+
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
345
|
+
label: "Help",
|
|
346
|
+
children: /* @__PURE__ */ jsx(QuestionIcon, {})
|
|
347
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
348
|
+
label: "Notifications",
|
|
349
|
+
children: /* @__PURE__ */ jsx(BellIcon, {})
|
|
350
|
+
})]
|
|
351
|
+
})
|
|
352
|
+
]
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ jsx(Status, {
|
|
355
|
+
last,
|
|
356
|
+
idle: "Open the search pill and try \"whit\", \"1042\" or \"leeds\"."
|
|
357
|
+
}),
|
|
358
|
+
/* @__PURE__ */ jsxs(CommandPalette, {
|
|
359
|
+
open,
|
|
360
|
+
onOpenChange: setOpen,
|
|
361
|
+
value: query,
|
|
362
|
+
onValueChange: setQuery,
|
|
363
|
+
loading,
|
|
364
|
+
children: [
|
|
365
|
+
/* @__PURE__ */ jsx(LocalGroups, { onRun: run }),
|
|
366
|
+
loading && !hasResults ? /* @__PURE__ */ jsx(CommandLoading, { children: "Searching orders, products and customers" }) : null,
|
|
367
|
+
/* @__PURE__ */ jsx(ServerGroups, {
|
|
368
|
+
results,
|
|
369
|
+
onRun: run
|
|
370
|
+
}),
|
|
371
|
+
!loading ? /* @__PURE__ */ jsxs(CommandEmpty, {
|
|
372
|
+
description: "Try an order number, a product name or a customer's email.",
|
|
373
|
+
children: [
|
|
374
|
+
"No results for “",
|
|
375
|
+
query.trim(),
|
|
376
|
+
"”"
|
|
377
|
+
]
|
|
378
|
+
}) : null
|
|
379
|
+
]
|
|
380
|
+
})
|
|
381
|
+
] });
|
|
382
|
+
}
|
|
383
|
+
function PillDemo({ width = 280 }) {
|
|
384
|
+
const [open, setOpen] = useState(false);
|
|
385
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(SearchTrigger, {
|
|
386
|
+
hotkey: false,
|
|
387
|
+
width,
|
|
388
|
+
placeholder: "Search Harbour Desk Co",
|
|
389
|
+
onOpen: () => setOpen(true)
|
|
390
|
+
}), /* @__PURE__ */ jsxs(CommandPalette, {
|
|
391
|
+
open,
|
|
392
|
+
onOpenChange: setOpen,
|
|
393
|
+
children: [/* @__PURE__ */ jsx(LocalGroups, { onRun: () => setOpen(false) }), /* @__PURE__ */ jsx(CommandEmpty, {
|
|
394
|
+
description: "Try a page, like orders or settings.",
|
|
395
|
+
children: "No pages or actions match"
|
|
396
|
+
})]
|
|
397
|
+
})] });
|
|
398
|
+
}
|
|
399
|
+
function OriginsDemo() {
|
|
400
|
+
const [opener, setOpener] = useState(null);
|
|
401
|
+
const [last, setLast] = useState();
|
|
402
|
+
const iconRef = useRef(null);
|
|
403
|
+
const origin = opener === "icon" ? iconRef : opener === "centre" ? null : void 0;
|
|
404
|
+
const run = (what) => {
|
|
405
|
+
setLast(what);
|
|
406
|
+
setOpener(null);
|
|
407
|
+
};
|
|
408
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
409
|
+
/* @__PURE__ */ jsx(SearchTrigger, {
|
|
410
|
+
hotkey: false,
|
|
411
|
+
width: 280,
|
|
412
|
+
onOpen: () => setOpener("pill")
|
|
413
|
+
}),
|
|
414
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
415
|
+
ref: iconRef,
|
|
416
|
+
label: "Search",
|
|
417
|
+
variant: "secondary",
|
|
418
|
+
onClick: () => setOpener("icon"),
|
|
419
|
+
children: /* @__PURE__ */ jsx(MagnifyingGlassIcon, {})
|
|
420
|
+
}),
|
|
421
|
+
/* @__PURE__ */ jsx(Button, {
|
|
422
|
+
onClick: () => setOpener("centre"),
|
|
423
|
+
children: "Open from the centre"
|
|
424
|
+
}),
|
|
425
|
+
/* @__PURE__ */ jsx(Status, {
|
|
426
|
+
last,
|
|
427
|
+
idle: "Open it three ways, then close it with Esc to watch it fold back."
|
|
428
|
+
}),
|
|
429
|
+
/* @__PURE__ */ jsxs(CommandPalette, {
|
|
430
|
+
open: opener !== null,
|
|
431
|
+
onOpenChange: (open) => !open && setOpener(null),
|
|
432
|
+
origin,
|
|
433
|
+
children: [/* @__PURE__ */ jsx(LocalGroups, { onRun: run }), /* @__PURE__ */ jsx(CommandEmpty, {
|
|
434
|
+
description: "Try a page, like orders or settings.",
|
|
435
|
+
children: "No pages or actions match"
|
|
436
|
+
})]
|
|
437
|
+
})
|
|
438
|
+
] });
|
|
439
|
+
}
|
|
440
|
+
function TriggersDemo() {
|
|
441
|
+
const [open, setOpen] = useState(false);
|
|
442
|
+
const show = () => setOpen(true);
|
|
443
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
444
|
+
className: "command-palette-pills",
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ jsxs("div", {
|
|
447
|
+
className: "command-palette-pill-row",
|
|
448
|
+
children: [/* @__PURE__ */ jsx(SearchTrigger, {
|
|
449
|
+
hotkey: false,
|
|
450
|
+
shortcut: true,
|
|
451
|
+
onOpen: show
|
|
452
|
+
}), /* @__PURE__ */ jsx("span", { children: "360px, the default, with the keycaps an app's pill shows" })]
|
|
453
|
+
}),
|
|
454
|
+
/* @__PURE__ */ jsxs("div", {
|
|
455
|
+
className: "command-palette-pill-row",
|
|
456
|
+
children: [/* @__PURE__ */ jsx(SearchTrigger, {
|
|
457
|
+
hotkey: false,
|
|
458
|
+
shortcut: true,
|
|
459
|
+
width: 240,
|
|
460
|
+
onOpen: show
|
|
461
|
+
}), /* @__PURE__ */ jsx("span", { children: "240px: the keycaps go first" })]
|
|
462
|
+
}),
|
|
463
|
+
/* @__PURE__ */ jsxs("div", {
|
|
464
|
+
className: "command-palette-pill-row",
|
|
465
|
+
children: [/* @__PURE__ */ jsx(SearchTrigger, {
|
|
466
|
+
hotkey: false,
|
|
467
|
+
width: 36,
|
|
468
|
+
placeholder: "Search",
|
|
469
|
+
onOpen: show
|
|
470
|
+
}), /* @__PURE__ */ jsx("span", { children: "36px: then the words, leaving a round button" })]
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ jsxs("div", {
|
|
473
|
+
className: "command-palette-pill-row",
|
|
474
|
+
children: [/* @__PURE__ */ jsx(SearchTrigger, {
|
|
475
|
+
hotkey: false,
|
|
476
|
+
width: 240,
|
|
477
|
+
placeholder: "Search products",
|
|
478
|
+
onOpen: show
|
|
479
|
+
}), /* @__PURE__ */ jsx("span", { children: "Own words, and no hotkey, so no keycaps" })]
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ jsxs("div", {
|
|
482
|
+
className: "command-palette-pill-row",
|
|
483
|
+
children: [/* @__PURE__ */ jsx(SearchTrigger, {
|
|
484
|
+
hotkey: false,
|
|
485
|
+
width: 240,
|
|
486
|
+
disabled: true,
|
|
487
|
+
onOpen: show
|
|
488
|
+
}), /* @__PURE__ */ jsx("span", { children: "Disabled" })]
|
|
489
|
+
}),
|
|
490
|
+
/* @__PURE__ */ jsxs(CommandPalette, {
|
|
491
|
+
open,
|
|
492
|
+
onOpenChange: setOpen,
|
|
493
|
+
children: [/* @__PURE__ */ jsx(LocalGroups, { onRun: () => setOpen(false) }), /* @__PURE__ */ jsx(CommandEmpty, {
|
|
494
|
+
description: "Try a page, like orders or settings.",
|
|
495
|
+
children: "No pages or actions match"
|
|
496
|
+
})]
|
|
497
|
+
})
|
|
498
|
+
]
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
function ItemsDemo() {
|
|
502
|
+
const [open, setOpen] = useState(false);
|
|
503
|
+
const [last, setLast] = useState();
|
|
504
|
+
const run = (what) => {
|
|
505
|
+
setLast(what);
|
|
506
|
+
setOpen(false);
|
|
507
|
+
};
|
|
508
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
509
|
+
/* @__PURE__ */ jsx(SearchTrigger, {
|
|
510
|
+
hotkey: false,
|
|
511
|
+
width: 300,
|
|
512
|
+
placeholder: "Search Harbour Desk Co",
|
|
513
|
+
onOpen: () => setOpen(true)
|
|
514
|
+
}),
|
|
515
|
+
/* @__PURE__ */ jsx(Status, {
|
|
516
|
+
last,
|
|
517
|
+
idle: "Try typing an SKU (CHR-ARD) or an email (whitfield)."
|
|
518
|
+
}),
|
|
519
|
+
/* @__PURE__ */ jsxs(CommandPalette, {
|
|
520
|
+
open,
|
|
521
|
+
onOpenChange: setOpen,
|
|
522
|
+
footer: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(CommandHints, {}), /* @__PURE__ */ jsx("span", {
|
|
523
|
+
className: "command-palette-footer-note",
|
|
524
|
+
children: "Searching Harbour Desk Co"
|
|
525
|
+
})] }),
|
|
526
|
+
children: [
|
|
527
|
+
/* @__PURE__ */ jsxs(CommandGroup, {
|
|
528
|
+
heading: "Go to",
|
|
529
|
+
children: [/* @__PURE__ */ jsx(CommandItem, {
|
|
530
|
+
icon: /* @__PURE__ */ jsx(ReceiptIcon, {}),
|
|
531
|
+
shortcut: ["G", "O"],
|
|
532
|
+
onSelect: () => run("Go to orders"),
|
|
533
|
+
children: "Orders"
|
|
534
|
+
}), /* @__PURE__ */ jsx(CommandItem, {
|
|
535
|
+
icon: /* @__PURE__ */ jsx(ChartLineUpIcon, {}),
|
|
536
|
+
hint: "Not on your plan",
|
|
537
|
+
disabled: true,
|
|
538
|
+
children: "Analytics"
|
|
539
|
+
})]
|
|
540
|
+
}),
|
|
541
|
+
/* @__PURE__ */ jsx(CommandGroup, {
|
|
542
|
+
heading: "Products",
|
|
543
|
+
children: /* @__PURE__ */ jsx(CommandItem, {
|
|
544
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {}),
|
|
545
|
+
hint: "£229.00 · 4 in stock",
|
|
546
|
+
keywords: ["CHR-ARD-01"],
|
|
547
|
+
onSelect: () => run("Open Arden ergonomic chair"),
|
|
548
|
+
children: "Arden ergonomic chair"
|
|
549
|
+
})
|
|
550
|
+
}),
|
|
551
|
+
/* @__PURE__ */ jsx(CommandGroup, {
|
|
552
|
+
heading: "Customers",
|
|
553
|
+
children: /* @__PURE__ */ jsx(CommandItem, {
|
|
554
|
+
icon: /* @__PURE__ */ jsx("span", { children: "SW" }),
|
|
555
|
+
hint: "Leeds · 6 orders",
|
|
556
|
+
keywords: ["sarah.whitfield@example.co.uk"],
|
|
557
|
+
onSelect: () => run("Open Sarah Whitfield"),
|
|
558
|
+
children: "Sarah Whitfield"
|
|
559
|
+
})
|
|
560
|
+
}),
|
|
561
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No results" })
|
|
562
|
+
]
|
|
563
|
+
})
|
|
564
|
+
] });
|
|
565
|
+
}
|
|
566
|
+
function SearchStateDemo({ label, query: startQuery, delay }) {
|
|
567
|
+
const [open, setOpen] = useState(false);
|
|
568
|
+
const [query, setQuery] = useState(startQuery);
|
|
569
|
+
const opener = useRef(null);
|
|
570
|
+
const { results, loading } = useServerSearch(open ? query : "", delay);
|
|
571
|
+
const hasResults = countOf(results) > 0;
|
|
572
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
|
|
573
|
+
ref: opener,
|
|
574
|
+
onClick: () => {
|
|
575
|
+
setQuery(startQuery);
|
|
576
|
+
setOpen(true);
|
|
577
|
+
},
|
|
578
|
+
children: label
|
|
579
|
+
}), /* @__PURE__ */ jsxs(CommandPalette, {
|
|
580
|
+
open,
|
|
581
|
+
onOpenChange: setOpen,
|
|
582
|
+
origin: opener,
|
|
583
|
+
value: query,
|
|
584
|
+
onValueChange: setQuery,
|
|
585
|
+
loading,
|
|
586
|
+
shouldFilter: false,
|
|
587
|
+
children: [
|
|
588
|
+
loading && !hasResults ? /* @__PURE__ */ jsx(CommandLoading, { children: "Searching orders, products and customers" }) : null,
|
|
589
|
+
/* @__PURE__ */ jsx(ServerGroups, {
|
|
590
|
+
results,
|
|
591
|
+
onRun: () => setOpen(false)
|
|
592
|
+
}),
|
|
593
|
+
!loading && results ? /* @__PURE__ */ jsxs(CommandEmpty, {
|
|
594
|
+
description: "Try an order number, a product name or a customer's email.",
|
|
595
|
+
children: [
|
|
596
|
+
"No results for “",
|
|
597
|
+
query.trim(),
|
|
598
|
+
"”"
|
|
599
|
+
]
|
|
600
|
+
}) : null
|
|
601
|
+
]
|
|
602
|
+
})] });
|
|
603
|
+
}
|
|
604
|
+
function LanguageDemo() {
|
|
605
|
+
const [open, setOpen] = useState(false);
|
|
606
|
+
const [last, setLast] = useState();
|
|
607
|
+
const run = (what) => {
|
|
608
|
+
setLast(what);
|
|
609
|
+
setOpen(false);
|
|
610
|
+
};
|
|
611
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
612
|
+
/* @__PURE__ */ jsx(SearchTrigger, {
|
|
613
|
+
hotkey: false,
|
|
614
|
+
width: 300,
|
|
615
|
+
placeholder: "Rechercher dans Harbour Desk Co",
|
|
616
|
+
onOpen: () => setOpen(true)
|
|
617
|
+
}),
|
|
618
|
+
/* @__PURE__ */ jsx(Status, {
|
|
619
|
+
last,
|
|
620
|
+
idle: "Opens with every word the palette says itself in French."
|
|
621
|
+
}),
|
|
622
|
+
/* @__PURE__ */ jsxs(CommandPalette, {
|
|
623
|
+
open,
|
|
624
|
+
onOpenChange: setOpen,
|
|
625
|
+
label: "Recherche",
|
|
626
|
+
resultsLabel: "Résultats de recherche",
|
|
627
|
+
closeLabel: "Fermer la recherche",
|
|
628
|
+
escLabel: "Échap",
|
|
629
|
+
cancelLabel: "Annuler",
|
|
630
|
+
hintLabels: {
|
|
631
|
+
move: "pour naviguer",
|
|
632
|
+
open: "pour ouvrir",
|
|
633
|
+
close: "pour fermer"
|
|
634
|
+
},
|
|
635
|
+
children: [/* @__PURE__ */ jsxs(CommandGroup, {
|
|
636
|
+
heading: "Aller à",
|
|
637
|
+
children: [
|
|
638
|
+
/* @__PURE__ */ jsx(CommandItem, {
|
|
639
|
+
icon: /* @__PURE__ */ jsx(ReceiptIcon, {}),
|
|
640
|
+
onSelect: () => run("Commandes"),
|
|
641
|
+
children: "Commandes"
|
|
642
|
+
}),
|
|
643
|
+
/* @__PURE__ */ jsx(CommandItem, {
|
|
644
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {}),
|
|
645
|
+
onSelect: () => run("Produits"),
|
|
646
|
+
children: "Produits"
|
|
647
|
+
}),
|
|
648
|
+
/* @__PURE__ */ jsx(CommandItem, {
|
|
649
|
+
icon: /* @__PURE__ */ jsx(UsersThreeIcon, {}),
|
|
650
|
+
onSelect: () => run("Clients"),
|
|
651
|
+
children: "Clients"
|
|
652
|
+
})
|
|
653
|
+
]
|
|
654
|
+
}), /* @__PURE__ */ jsx(CommandEmpty, {
|
|
655
|
+
description: "Essayez une page, comme les commandes.",
|
|
656
|
+
children: "Aucun résultat"
|
|
657
|
+
})]
|
|
658
|
+
})
|
|
659
|
+
] });
|
|
660
|
+
}
|
|
661
|
+
function HeldOpen() {
|
|
662
|
+
return /* @__PURE__ */ jsx(SpecimenFrame, {
|
|
663
|
+
style: {
|
|
664
|
+
display: "flex",
|
|
665
|
+
justifyContent: "center",
|
|
666
|
+
width: "100%"
|
|
667
|
+
},
|
|
668
|
+
children: /* @__PURE__ */ jsx(PaletteStill, {
|
|
669
|
+
query: "whit",
|
|
670
|
+
groups: [
|
|
671
|
+
{
|
|
672
|
+
heading: "Orders",
|
|
673
|
+
items: [{
|
|
674
|
+
icon: /* @__PURE__ */ jsx(ReceiptIcon, {}),
|
|
675
|
+
label: "#1043 · Sarah Whitfield",
|
|
676
|
+
hint: "Paid · £240.00",
|
|
677
|
+
selected: true
|
|
678
|
+
}, {
|
|
679
|
+
icon: /* @__PURE__ */ jsx(ReceiptIcon, {}),
|
|
680
|
+
label: "#1031 · Sarah Whitfield",
|
|
681
|
+
hint: "Fulfilled · £65.00"
|
|
682
|
+
}]
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
heading: "Products",
|
|
686
|
+
items: [{
|
|
687
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {}),
|
|
688
|
+
label: "White oak side table",
|
|
689
|
+
hint: "£149.00 · 12 in stock"
|
|
690
|
+
}]
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
heading: "Customers",
|
|
694
|
+
items: [{
|
|
695
|
+
icon: /* @__PURE__ */ jsx("span", { children: "SW" }),
|
|
696
|
+
label: "Sarah Whitfield",
|
|
697
|
+
hint: "Leeds · 6 orders"
|
|
698
|
+
}, {
|
|
699
|
+
icon: /* @__PURE__ */ jsx("span", { children: "SW" }),
|
|
700
|
+
label: "Sam Whitaker",
|
|
701
|
+
hint: "York · 3 orders"
|
|
702
|
+
}]
|
|
703
|
+
}
|
|
704
|
+
]
|
|
705
|
+
})
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
function Page() {
|
|
709
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
710
|
+
title: "Command palette",
|
|
711
|
+
status: "stable",
|
|
712
|
+
importNames: [
|
|
713
|
+
"CommandPalette",
|
|
714
|
+
"CommandGroup",
|
|
715
|
+
"CommandItem",
|
|
716
|
+
"SearchTrigger"
|
|
717
|
+
],
|
|
718
|
+
lead: "Search and commands in one place. It grows out of the search pill in the header, finds pages, actions and records as the merchant types, and folds back into the pill when they are done.",
|
|
719
|
+
children: [
|
|
720
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
721
|
+
id: "basics",
|
|
722
|
+
title: "Basics",
|
|
723
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
724
|
+
"A ",
|
|
725
|
+
/* @__PURE__ */ jsx("code", { children: "SearchTrigger" }),
|
|
726
|
+
" in the header opens a ",
|
|
727
|
+
/* @__PURE__ */ jsx("code", { children: "CommandPalette" }),
|
|
728
|
+
". Inside, a",
|
|
729
|
+
" ",
|
|
730
|
+
/* @__PURE__ */ jsx("code", { children: "CommandGroup" }),
|
|
731
|
+
" holds ",
|
|
732
|
+
/* @__PURE__ */ jsx("code", { children: "CommandItem" }),
|
|
733
|
+
"s under a heading. Pages and quick actions are filtered right here as you type; orders, products and customers come from a (simulated) server half a second later, while a comet runs along the field."
|
|
734
|
+
] }),
|
|
735
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
736
|
+
align: "fill",
|
|
737
|
+
surface: "ground",
|
|
738
|
+
code: `
|
|
739
|
+
const [open, setOpen] = useState(false)
|
|
740
|
+
const [query, setQuery] = useState('')
|
|
741
|
+
const { results, loading } = useSearch(query) // your server search
|
|
742
|
+
|
|
743
|
+
<SearchTrigger
|
|
744
|
+
hotkey={false} // on by default; off here because these docs use ⌘K for their own search
|
|
745
|
+
onOpen={() => setOpen(true)}
|
|
746
|
+
/>
|
|
747
|
+
|
|
748
|
+
<CommandPalette open={open} onOpenChange={setOpen} value={query} onValueChange={setQuery} loading={loading}>
|
|
749
|
+
<CommandGroup heading="Pages">
|
|
750
|
+
<CommandItem value="Orders" icon={<ReceiptIcon />} shortcut={['G', 'O']} onSelect={() => go('/orders')}>
|
|
751
|
+
Orders
|
|
752
|
+
</CommandItem>
|
|
753
|
+
…
|
|
754
|
+
</CommandGroup>
|
|
755
|
+
<CommandSeparator />
|
|
756
|
+
<CommandGroup heading="Quick actions">…</CommandGroup>
|
|
757
|
+
|
|
758
|
+
{loading && !results ? <CommandLoading>Searching orders, products and customers</CommandLoading> : null}
|
|
759
|
+
|
|
760
|
+
{results?.orders.length ? (
|
|
761
|
+
<CommandGroup heading="Orders">
|
|
762
|
+
{results.orders.map((order) => (
|
|
763
|
+
<CommandItem
|
|
764
|
+
key={order.number}
|
|
765
|
+
value={\`Order #\${order.number} \${order.customer}\`}
|
|
766
|
+
keywords={[order.status, order.total]}
|
|
767
|
+
icon={<ReceiptIcon />}
|
|
768
|
+
hint={\`\${order.status} · \${order.total}\`}
|
|
769
|
+
onSelect={() => openOrder(order)}
|
|
770
|
+
>
|
|
771
|
+
#{order.number} · {order.customer}
|
|
772
|
+
</CommandItem>
|
|
773
|
+
))}
|
|
774
|
+
</CommandGroup>
|
|
775
|
+
) : null}
|
|
776
|
+
…
|
|
777
|
+
|
|
778
|
+
{!loading ? (
|
|
779
|
+
<CommandEmpty description="Try an order number, a product name or a customer's email.">
|
|
780
|
+
No results for “{query}”
|
|
781
|
+
</CommandEmpty>
|
|
782
|
+
) : null}
|
|
783
|
+
</CommandPalette>`,
|
|
784
|
+
children: /* @__PURE__ */ jsx(HeaderDemo, {})
|
|
785
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
786
|
+
title: "⌘K is on by default",
|
|
787
|
+
children: [
|
|
788
|
+
"In the product, ",
|
|
789
|
+
/* @__PURE__ */ jsx("code", { children: "SearchTrigger" }),
|
|
790
|
+
" listens for ⌘K (Ctrl K on Windows and Linux) anywhere on the page and opens the palette, the same keys close it again, and the pill shows the keycaps. These docs already use ⌘K for their own search, so every trigger on this page passes ",
|
|
791
|
+
/* @__PURE__ */ jsx("code", { children: "hotkey={false}" }),
|
|
792
|
+
", and so shows no keycaps. Leave it on in the app."
|
|
793
|
+
]
|
|
794
|
+
})]
|
|
795
|
+
}),
|
|
796
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
797
|
+
id: "both-themes",
|
|
798
|
+
title: "In both themes",
|
|
799
|
+
description: /* @__PURE__ */ jsx("p", { children: "Held open for review, light above dark: a search for \"whit\" with the first order selected. The panel is 640px wide with 20px corners on the modal shadow. The selected row takes a hover tint, its icon tile turns teal, and a short teal mark on the rim marks it." }),
|
|
800
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
801
|
+
className: "overlays-stack",
|
|
802
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
803
|
+
align: "fill",
|
|
804
|
+
caption: "A still of the open palette, drawn with its own classes so both themes sit side by side. Every palette on the rest of this page is live.",
|
|
805
|
+
children: /* @__PURE__ */ jsx(HeldOpen, {})
|
|
806
|
+
})
|
|
807
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
808
|
+
title: "Open them for real",
|
|
809
|
+
description: /* @__PURE__ */ jsx("p", { children: "Each pill opens the palette in the theme of its own side, and it grows out of that pill." }),
|
|
810
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
811
|
+
minHeight: 150,
|
|
812
|
+
children: /* @__PURE__ */ jsx(PillDemo, { width: 280 })
|
|
813
|
+
})
|
|
814
|
+
})]
|
|
815
|
+
}),
|
|
816
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
817
|
+
id: "morph",
|
|
818
|
+
title: "Growing out of the pill",
|
|
819
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
820
|
+
"Opened from a ",
|
|
821
|
+
/* @__PURE__ */ jsx("code", { children: "SearchTrigger" }),
|
|
822
|
+
", the palette grows out of it: the pill stretches into the panel as it glides to its place near the top of the window, the pill's words carry over into the field, and the results fade up behind them. The pill leaves the header while the palette is out. On closing, the panel folds back into the pill, a little faster and without a wobble."
|
|
823
|
+
] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
824
|
+
"The words hand straight over when the palette's ",
|
|
825
|
+
/* @__PURE__ */ jsx("code", { children: "placeholder" }),
|
|
826
|
+
" matches the pill's, which it does by default. ",
|
|
827
|
+
/* @__PURE__ */ jsx("code", { children: "origin" }),
|
|
828
|
+
" grows it out of any other element, such as a round search button in a phone header, and ",
|
|
829
|
+
/* @__PURE__ */ jsx("code", { children: "origin={null}" }),
|
|
830
|
+
" always scales it up from the centre. With no visible pill, or with reduced motion, it scales up from the centre or crossfades."
|
|
831
|
+
] })] }),
|
|
832
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
833
|
+
align: "start",
|
|
834
|
+
code: `
|
|
835
|
+
<SearchTrigger hotkey={false} onOpen={() => setOpen(true)} /> {/* grows out of the pill */}
|
|
836
|
+
|
|
837
|
+
<IconButton ref={searchButton} label="Search" onClick={() => setOpen(true)}>
|
|
838
|
+
<MagnifyingGlassIcon />
|
|
839
|
+
</IconButton>
|
|
840
|
+
<CommandPalette origin={searchButton} …>…</CommandPalette> {/* out of the round button */}
|
|
841
|
+
|
|
842
|
+
<CommandPalette origin={null} …>…</CommandPalette> {/* up from the centre */}`,
|
|
843
|
+
children: /* @__PURE__ */ jsx(OriginsDemo, {})
|
|
844
|
+
})
|
|
845
|
+
}),
|
|
846
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
847
|
+
id: "search-trigger",
|
|
848
|
+
title: "Search trigger",
|
|
849
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
850
|
+
"The pill in the header. It looks like a field but is a button: pressing it opens the palette. It prefers 360px and shrinks with its container, dropping the keycaps first (below 260px) and then its words (below 96px), leaving a round search button. Its words become its accessible name, so it stays named when they are hidden. The keycaps follow ",
|
|
851
|
+
/* @__PURE__ */ jsx("code", { children: "hotkey" }),
|
|
852
|
+
": a pill that listens for ⌘K shows them and one that does not shows none, so it never advertises keys that do something else. Pass ",
|
|
853
|
+
/* @__PURE__ */ jsx("code", { children: "shortcut" }),
|
|
854
|
+
" to say otherwise, as the first two pills here do to show the keycaps on a page that keeps ⌘K for its own search."
|
|
855
|
+
] }),
|
|
856
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
857
|
+
align: "start",
|
|
858
|
+
surface: "ground",
|
|
859
|
+
code: `
|
|
860
|
+
<SearchTrigger hotkey={false} shortcut onOpen={open} /> {/* the keycaps, drawn here without the hotkey */}
|
|
861
|
+
<SearchTrigger hotkey={false} shortcut width={240} onOpen={open} />
|
|
862
|
+
<SearchTrigger hotkey={false} width={36} placeholder="Search" onOpen={open} />
|
|
863
|
+
<SearchTrigger hotkey={false} width={240} placeholder="Search products" onOpen={open} />
|
|
864
|
+
<SearchTrigger hotkey={false} width={240} disabled onOpen={open} />`,
|
|
865
|
+
children: /* @__PURE__ */ jsx(TriggersDemo, {})
|
|
866
|
+
})
|
|
867
|
+
}),
|
|
868
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
869
|
+
id: "items",
|
|
870
|
+
title: "Items",
|
|
871
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
872
|
+
"A ",
|
|
873
|
+
/* @__PURE__ */ jsx("code", { children: "CommandItem" }),
|
|
874
|
+
" is one result. ",
|
|
875
|
+
/* @__PURE__ */ jsx("code", { children: "icon" }),
|
|
876
|
+
" sits in a rounded tile that turns teal when the row is selected; pass a Phosphor icon, or initials for a person. ",
|
|
877
|
+
/* @__PURE__ */ jsx("code", { children: "hint" }),
|
|
878
|
+
" is quiet text at the end, such as a price or a status, and ",
|
|
879
|
+
/* @__PURE__ */ jsx("code", { children: "shortcut" }),
|
|
880
|
+
" shows keycaps through ",
|
|
881
|
+
/* @__PURE__ */ jsx("code", { children: "Kbd" }),
|
|
882
|
+
", so",
|
|
883
|
+
" ",
|
|
884
|
+
/* @__PURE__ */ jsx("code", { children: "mod" }),
|
|
885
|
+
" is ⌘ on a Mac and Ctrl elsewhere; touch screens leave them out.",
|
|
886
|
+
" ",
|
|
887
|
+
/* @__PURE__ */ jsx("code", { children: "keywords" }),
|
|
888
|
+
" are matched without being shown, like an SKU or an email. ",
|
|
889
|
+
/* @__PURE__ */ jsx("code", { children: "value" }),
|
|
890
|
+
" must be unique in the palette; it defaults to the item's text."
|
|
891
|
+
] }),
|
|
892
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
893
|
+
align: "start",
|
|
894
|
+
code: `
|
|
895
|
+
<CommandGroup heading="Go to">
|
|
896
|
+
<CommandItem icon={<ReceiptIcon />} shortcut={['G', 'O']} onSelect={goToOrders}>Orders</CommandItem>
|
|
897
|
+
<CommandItem icon={<ChartLineUpIcon />} hint="Not on your plan" disabled>Analytics</CommandItem>
|
|
898
|
+
</CommandGroup>
|
|
899
|
+
<CommandGroup heading="Products">
|
|
900
|
+
<CommandItem icon={<PackageIcon />} hint="£229.00 · 4 in stock" keywords={['CHR-ARD-01']} onSelect={…}>
|
|
901
|
+
Arden ergonomic chair
|
|
902
|
+
</CommandItem>
|
|
903
|
+
</CommandGroup>
|
|
904
|
+
<CommandGroup heading="Customers">
|
|
905
|
+
<CommandItem icon={<span>SW</span>} hint="Leeds · 6 orders" keywords={['sarah.whitfield@example.co.uk']} onSelect={…}>
|
|
906
|
+
Sarah Whitfield
|
|
907
|
+
</CommandItem>
|
|
908
|
+
</CommandGroup>`,
|
|
909
|
+
children: /* @__PURE__ */ jsx(ItemsDemo, {})
|
|
910
|
+
}), /* @__PURE__ */ jsx(DocTable, {
|
|
911
|
+
columns: ["Part", "What it does"],
|
|
912
|
+
rows: [
|
|
913
|
+
[/* @__PURE__ */ jsx("code", { children: "CommandGroup" }), /* @__PURE__ */ jsx(Fragment$1, { children: "A titled run of items. Headings are sentence case. A group hides itself when none of its items match." })],
|
|
914
|
+
[/* @__PURE__ */ jsx("code", { children: "CommandSeparator" }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
915
|
+
"A hairline between groups. Hidden while there is a search, unless ",
|
|
916
|
+
/* @__PURE__ */ jsx("code", { children: "alwaysRender" }),
|
|
917
|
+
"."
|
|
918
|
+
] })],
|
|
919
|
+
[/* @__PURE__ */ jsx("code", { children: "CommandKey" }), "The kit's Kbd keycap in the palette's tint, as used in item shortcuts and the footer. A word is a key name (up, enter, mod). Use it in your own footer."],
|
|
920
|
+
[/* @__PURE__ */ jsx("code", { children: "CommandHints" }), "The default footer: arrows to move, Enter to open, Esc to close. Hidden on touch screens."]
|
|
921
|
+
]
|
|
922
|
+
})]
|
|
923
|
+
}),
|
|
924
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
925
|
+
id: "loading-and-empty",
|
|
926
|
+
title: "Loading and empty",
|
|
927
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
928
|
+
"While results are on their way, ",
|
|
929
|
+
/* @__PURE__ */ jsx("code", { children: "loading" }),
|
|
930
|
+
" sends a comet along the bottom of the field and the list is marked busy. Show a ",
|
|
931
|
+
/* @__PURE__ */ jsx("code", { children: "CommandLoading" }),
|
|
932
|
+
" row while there is nothing else to show. Once results have arrived, ",
|
|
933
|
+
/* @__PURE__ */ jsx("code", { children: "CommandEmpty" }),
|
|
934
|
+
" appears by itself when nothing matches: an empty orbit, a line saying so and a ",
|
|
935
|
+
/* @__PURE__ */ jsx("code", { children: "description" }),
|
|
936
|
+
" of what to try. Render it only when loading is done, or it flashes up before the results."
|
|
937
|
+
] }),
|
|
938
|
+
children: [/* @__PURE__ */ jsxs(Example, {
|
|
939
|
+
code: `
|
|
940
|
+
<CommandPalette value={query} onValueChange={setQuery} loading={loading} shouldFilter={false} …>
|
|
941
|
+
{loading && !results ? <CommandLoading>Searching orders, products and customers</CommandLoading> : null}
|
|
942
|
+
{results ? <Results results={results} /> : null}
|
|
943
|
+
{!loading && results ? (
|
|
944
|
+
<CommandEmpty description="Try an order number, a product name or a customer's email.">
|
|
945
|
+
No results for “{query}”
|
|
946
|
+
</CommandEmpty>
|
|
947
|
+
) : null}
|
|
948
|
+
</CommandPalette>`,
|
|
949
|
+
caption: "The first searches a slow server for 2.5 seconds; the second finds nothing.",
|
|
950
|
+
children: [/* @__PURE__ */ jsx(SearchStateDemo, {
|
|
951
|
+
label: "Search a slow server",
|
|
952
|
+
query: "whit",
|
|
953
|
+
delay: 2500
|
|
954
|
+
}), /* @__PURE__ */ jsx(SearchStateDemo, {
|
|
955
|
+
label: "Search for something missing",
|
|
956
|
+
query: "walnut wardrobe",
|
|
957
|
+
delay: 600
|
|
958
|
+
})]
|
|
959
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
960
|
+
title: "Server search",
|
|
961
|
+
children: [
|
|
962
|
+
"When a server does the matching, pass ",
|
|
963
|
+
/* @__PURE__ */ jsx("code", { children: "shouldFilter={false}" }),
|
|
964
|
+
" so the palette shows what it is given instead of filtering it again, and control the query with ",
|
|
965
|
+
/* @__PURE__ */ jsx("code", { children: "value" }),
|
|
966
|
+
" and ",
|
|
967
|
+
/* @__PURE__ */ jsx("code", { children: "onValueChange" }),
|
|
968
|
+
"."
|
|
969
|
+
]
|
|
970
|
+
})]
|
|
971
|
+
}),
|
|
972
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
973
|
+
id: "keyboard",
|
|
974
|
+
title: "Keyboard",
|
|
975
|
+
description: /* @__PURE__ */ jsx("p", { children: "The palette is built to be driven without the mouse." }),
|
|
976
|
+
children: [/* @__PURE__ */ jsx(DocTable, {
|
|
977
|
+
columns: ["Keys", "What happens"],
|
|
978
|
+
rows: [
|
|
979
|
+
[/* @__PURE__ */ jsx(CommandKey, { keys: ["mod", "K"] }), /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
980
|
+
"Opens it from anywhere on the page (",
|
|
981
|
+
/* @__PURE__ */ jsx("code", { children: "hotkey" }),
|
|
982
|
+
" on the ",
|
|
983
|
+
/* @__PURE__ */ jsx("code", { children: "SearchTrigger" }),
|
|
984
|
+
", on by default), and closes it again from inside. That is ⌘K on a Mac and Ctrl K on Windows and Linux."
|
|
985
|
+
] })],
|
|
986
|
+
["Typing", "Filters and ranks the items as you type, matching their text and keywords loosely."],
|
|
987
|
+
[/* @__PURE__ */ jsx(CommandKey, { keys: ["up", "down"] }), "Move the selection, wrapping round at the ends (loop)."],
|
|
988
|
+
[/* @__PURE__ */ jsx(CommandKey, { children: "enter" }), "Runs the selected item's onSelect."],
|
|
989
|
+
[/* @__PURE__ */ jsx(CommandKey, { children: "Esc" }), "Closes it. So does the Esc keycap in the field, which says Cancel on a touch screen."]
|
|
990
|
+
]
|
|
991
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
992
|
+
"When it opens, focus goes straight to the field. When it closes, focus goes back to where it was, usually the pill.",
|
|
993
|
+
"Put the most likely destinations first, and keep the order stable so people learn where things are.",
|
|
994
|
+
"Name items as destinations or actions: \"Orders\", \"Create product\". Put the detail in the hint."
|
|
995
|
+
] })]
|
|
996
|
+
}),
|
|
997
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
998
|
+
id: "language",
|
|
999
|
+
title: "In another language",
|
|
1000
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1001
|
+
"Every word the palette says itself is a prop, so a page in another language keeps the footer of key hints instead of hiding it. ",
|
|
1002
|
+
/* @__PURE__ */ jsx("code", { children: "hintLabels" }),
|
|
1003
|
+
" takes the words after the keys (\"to move\", \"to open\", \"to close\"), and ",
|
|
1004
|
+
/* @__PURE__ */ jsx("code", { children: "escLabel" }),
|
|
1005
|
+
" spells the Esc key in the hints as it does in the field. A word left out stays English. ",
|
|
1006
|
+
/* @__PURE__ */ jsx("code", { children: "CommandHints" }),
|
|
1007
|
+
" takes the same ",
|
|
1008
|
+
/* @__PURE__ */ jsx("code", { children: "labels" }),
|
|
1009
|
+
" and ",
|
|
1010
|
+
/* @__PURE__ */ jsx("code", { children: "escLabel" }),
|
|
1011
|
+
" for a footer of your own."
|
|
1012
|
+
] }),
|
|
1013
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
1014
|
+
align: "start",
|
|
1015
|
+
code: `
|
|
1016
|
+
<CommandPalette
|
|
1017
|
+
open={open}
|
|
1018
|
+
onOpenChange={setOpen}
|
|
1019
|
+
label="Recherche"
|
|
1020
|
+
resultsLabel="Résultats de recherche"
|
|
1021
|
+
closeLabel="Fermer la recherche"
|
|
1022
|
+
escLabel="Échap"
|
|
1023
|
+
cancelLabel="Annuler"
|
|
1024
|
+
hintLabels={{ move: 'pour naviguer', open: 'pour ouvrir', close: 'pour fermer' }}
|
|
1025
|
+
>
|
|
1026
|
+
…
|
|
1027
|
+
</CommandPalette>
|
|
1028
|
+
|
|
1029
|
+
{/* A footer of your own, with the hints in it */}
|
|
1030
|
+
<CommandPalette footer={<><CommandHints labels={hints} escLabel="Échap" /><span>…</span></>} …>`,
|
|
1031
|
+
children: /* @__PURE__ */ jsx(LanguageDemo, {})
|
|
1032
|
+
}), /* @__PURE__ */ jsx(Fragment$1, {})]
|
|
1033
|
+
}),
|
|
1034
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
1035
|
+
id: "accessibility",
|
|
1036
|
+
title: "Accessibility",
|
|
1037
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1038
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1039
|
+
"The palette is a Radix dialog: focus stays inside, the page behind cannot scroll and is hidden from screen readers. It is named by ",
|
|
1040
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
1041
|
+
" (\"Search\" by default), and its list of results by",
|
|
1042
|
+
" ",
|
|
1043
|
+
/* @__PURE__ */ jsx("code", { children: "resultsLabel" }),
|
|
1044
|
+
" (\"Search results\")."
|
|
1045
|
+
] }),
|
|
1046
|
+
"The field is a combobox and the results are a listbox of options, so screen readers announce the selected row as the arrows move (via cmdk).",
|
|
1047
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1048
|
+
"While ",
|
|
1049
|
+
/* @__PURE__ */ jsx("code", { children: "loading" }),
|
|
1050
|
+
", the list is marked ",
|
|
1051
|
+
/* @__PURE__ */ jsx("code", { children: "aria-busy" }),
|
|
1052
|
+
", and ",
|
|
1053
|
+
/* @__PURE__ */ jsx("code", { children: "CommandLoading" }),
|
|
1054
|
+
" is a progress bar named by its text."
|
|
1055
|
+
] }),
|
|
1056
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1057
|
+
/* @__PURE__ */ jsx("code", { children: "SearchTrigger" }),
|
|
1058
|
+
" is a real button named by its words, with ",
|
|
1059
|
+
/* @__PURE__ */ jsx("code", { children: "aria-haspopup=\"dialog\"" }),
|
|
1060
|
+
" and, while the hotkey is on, ",
|
|
1061
|
+
/* @__PURE__ */ jsx("code", { children: "aria-keyshortcuts" }),
|
|
1062
|
+
"."
|
|
1063
|
+
] }),
|
|
1064
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1065
|
+
"The Esc button at the end of the field is named by what it shows and then by what it does, \"Esc (Close search)\", so voice control finds it by its visible word. ",
|
|
1066
|
+
/* @__PURE__ */ jsx("code", { children: "escLabel" }),
|
|
1067
|
+
" changes the keycap and",
|
|
1068
|
+
" ",
|
|
1069
|
+
/* @__PURE__ */ jsx("code", { children: "closeLabel" }),
|
|
1070
|
+
" the words after it. On a touch screen, where a keycap means nothing, it shows",
|
|
1071
|
+
" ",
|
|
1072
|
+
/* @__PURE__ */ jsx("code", { children: "cancelLabel" }),
|
|
1073
|
+
" (\"Cancel\") on a pill a thumb can take, and is named \"Cancel (Close search)\"."
|
|
1074
|
+
] }),
|
|
1075
|
+
"With reduced motion there is no morph: the palette crossfades, the loading comet parks and breathes, and the selection mark jumps instead of sliding."
|
|
1076
|
+
] })
|
|
1077
|
+
}),
|
|
1078
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1079
|
+
id: "props",
|
|
1080
|
+
title: "Props",
|
|
1081
|
+
description: /* @__PURE__ */ jsx("p", { children: "Items, groups, empty and loading also accept the matching cmdk props." }),
|
|
1082
|
+
children: [
|
|
1083
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1084
|
+
title: "CommandPalette",
|
|
1085
|
+
rows: [
|
|
1086
|
+
{
|
|
1087
|
+
name: "open",
|
|
1088
|
+
type: "boolean",
|
|
1089
|
+
required: true,
|
|
1090
|
+
description: "Controlled open state."
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
name: "onOpenChange",
|
|
1094
|
+
type: "(open: boolean) => void",
|
|
1095
|
+
required: true,
|
|
1096
|
+
description: "Called when it opens or closes."
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
name: "value",
|
|
1100
|
+
type: "string",
|
|
1101
|
+
description: "The query, controlled. Use it with onValueChange to search a server."
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
name: "onValueChange",
|
|
1105
|
+
type: "(query: string) => void",
|
|
1106
|
+
description: "Called with the query as it changes."
|
|
1107
|
+
},
|
|
1108
|
+
{
|
|
1109
|
+
name: "loading",
|
|
1110
|
+
type: "boolean",
|
|
1111
|
+
default: "false",
|
|
1112
|
+
description: "Sends the comet along the field and marks the list busy."
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
name: "placeholder",
|
|
1116
|
+
type: "string",
|
|
1117
|
+
description: "The field's placeholder. Defaults to the words of the pill it grows out of."
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
name: "shouldFilter",
|
|
1121
|
+
type: "boolean",
|
|
1122
|
+
default: "true",
|
|
1123
|
+
description: "Set to false when a server does the filtering."
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
name: "filter",
|
|
1127
|
+
type: "(value, search, keywords?) => number",
|
|
1128
|
+
description: "Custom ranking: 0 hides an item, 1 is a perfect match."
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
name: "loop",
|
|
1132
|
+
type: "boolean",
|
|
1133
|
+
default: "true",
|
|
1134
|
+
description: "The arrow keys wrap round the list."
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
name: "footer",
|
|
1138
|
+
type: "ReactNode",
|
|
1139
|
+
description: "Footer content. Defaults to CommandHints; pass null for no footer."
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
name: "hintLabels",
|
|
1143
|
+
type: "Partial<CommandHintsLabels>",
|
|
1144
|
+
description: "The words of the default footer, after each key: { move, open, close }. Any left out stay English."
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
name: "label",
|
|
1148
|
+
type: "string",
|
|
1149
|
+
default: "'Search'",
|
|
1150
|
+
description: "Accessible name of the dialog."
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
name: "resultsLabel",
|
|
1154
|
+
type: "string",
|
|
1155
|
+
default: "label + ' results'",
|
|
1156
|
+
description: "Accessible name of the list of results."
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
name: "closeLabel",
|
|
1160
|
+
type: "string",
|
|
1161
|
+
default: "'Close search'",
|
|
1162
|
+
description: "What the Esc button does, said after its visible word: \"Esc (Close search)\"."
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
name: "escLabel",
|
|
1166
|
+
type: "ReactNode",
|
|
1167
|
+
default: "'Esc'",
|
|
1168
|
+
description: "The Esc keycap's text, for a keyboard that labels the key otherwise (French \"Échap\")."
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
name: "cancelLabel",
|
|
1172
|
+
type: "ReactNode",
|
|
1173
|
+
default: "'Cancel'",
|
|
1174
|
+
description: "The word the Esc button shows on a touch screen instead of the keycap."
|
|
1175
|
+
},
|
|
1176
|
+
{
|
|
1177
|
+
name: "origin",
|
|
1178
|
+
type: "HTMLElement | RefObject<HTMLElement> | null",
|
|
1179
|
+
description: "What it grows out of. Defaults to the SearchTrigger that opened it (or any visible one); null scales it up from the centre."
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
name: "container",
|
|
1183
|
+
type: "HTMLElement | null",
|
|
1184
|
+
default: "document.body",
|
|
1185
|
+
description: "Where the palette is portalled."
|
|
1186
|
+
}
|
|
1187
|
+
]
|
|
1188
|
+
}),
|
|
1189
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1190
|
+
title: "CommandHints",
|
|
1191
|
+
rows: [{
|
|
1192
|
+
name: "labels",
|
|
1193
|
+
type: "Partial<CommandHintsLabels>",
|
|
1194
|
+
default: "{ move: 'to move', open: 'to open', close: 'to close' }",
|
|
1195
|
+
description: "The words after the arrow keys, Enter and Esc."
|
|
1196
|
+
}, {
|
|
1197
|
+
name: "escLabel",
|
|
1198
|
+
type: "ReactNode",
|
|
1199
|
+
default: "'Esc'",
|
|
1200
|
+
description: "The Esc keycap, spelled as the field spells it."
|
|
1201
|
+
}]
|
|
1202
|
+
}),
|
|
1203
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1204
|
+
title: "CommandGroup",
|
|
1205
|
+
rows: [
|
|
1206
|
+
{
|
|
1207
|
+
name: "heading",
|
|
1208
|
+
type: "ReactNode",
|
|
1209
|
+
description: "The group title, in sentence case."
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
name: "value",
|
|
1213
|
+
type: "string",
|
|
1214
|
+
description: "A unique value for the group. Needed when there is no heading."
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
name: "forceMount",
|
|
1218
|
+
type: "boolean",
|
|
1219
|
+
default: "false",
|
|
1220
|
+
description: "Show it whatever the search."
|
|
1221
|
+
}
|
|
1222
|
+
]
|
|
1223
|
+
}),
|
|
1224
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1225
|
+
title: "CommandItem",
|
|
1226
|
+
rows: [
|
|
1227
|
+
{
|
|
1228
|
+
name: "children",
|
|
1229
|
+
type: "ReactNode",
|
|
1230
|
+
required: true,
|
|
1231
|
+
description: "The label."
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
name: "onSelect",
|
|
1235
|
+
type: "(value: string) => void",
|
|
1236
|
+
description: "Runs on Enter or a click."
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
name: "value",
|
|
1240
|
+
type: "string",
|
|
1241
|
+
description: "Unique in the palette. Defaults to the text of children."
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
name: "keywords",
|
|
1245
|
+
type: "string[]",
|
|
1246
|
+
description: "Matched while searching but not shown, e.g. an SKU or an email."
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
name: "icon",
|
|
1250
|
+
type: "ReactNode",
|
|
1251
|
+
description: "Shown in a rounded tile at the start. An icon, or initials."
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
name: "hint",
|
|
1255
|
+
type: "ReactNode",
|
|
1256
|
+
description: "Quiet trailing text, e.g. a price or \"12 in stock\"."
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
name: "shortcut",
|
|
1260
|
+
type: "string[]",
|
|
1261
|
+
description: "Keycaps at the end via Kbd, e.g. ['G', 'O'] or ['mod', 'K']. Hidden on touch screens."
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
name: "disabled",
|
|
1265
|
+
type: "boolean",
|
|
1266
|
+
default: "false",
|
|
1267
|
+
description: "Dimmed, and cannot be selected."
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
name: "forceMount",
|
|
1271
|
+
type: "boolean",
|
|
1272
|
+
default: "false",
|
|
1273
|
+
description: "Show it whatever the search."
|
|
1274
|
+
}
|
|
1275
|
+
]
|
|
1276
|
+
}),
|
|
1277
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1278
|
+
title: "CommandEmpty",
|
|
1279
|
+
rows: [
|
|
1280
|
+
{
|
|
1281
|
+
name: "children",
|
|
1282
|
+
type: "ReactNode",
|
|
1283
|
+
default: "'No results'",
|
|
1284
|
+
description: "The line saying nothing matched."
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
name: "description",
|
|
1288
|
+
type: "ReactNode",
|
|
1289
|
+
description: "A quieter second line: what to try instead."
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
name: "icon",
|
|
1293
|
+
type: "ReactNode",
|
|
1294
|
+
description: "Replaces the empty-orbit glyph. Pass null for none."
|
|
1295
|
+
}
|
|
1296
|
+
]
|
|
1297
|
+
}),
|
|
1298
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1299
|
+
title: "CommandLoading",
|
|
1300
|
+
rows: [
|
|
1301
|
+
{
|
|
1302
|
+
name: "children",
|
|
1303
|
+
type: "ReactNode",
|
|
1304
|
+
default: "'Searching'",
|
|
1305
|
+
description: "What is being loaded, beside an orbit spinner."
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
name: "label",
|
|
1309
|
+
type: "string",
|
|
1310
|
+
description: "Accessible name of the progress bar. Defaults to the text of children."
|
|
1311
|
+
},
|
|
1312
|
+
{
|
|
1313
|
+
name: "progress",
|
|
1314
|
+
type: "number",
|
|
1315
|
+
description: "How far along the load is, when you know."
|
|
1316
|
+
}
|
|
1317
|
+
]
|
|
1318
|
+
}),
|
|
1319
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1320
|
+
title: "CommandSeparator",
|
|
1321
|
+
rows: [{
|
|
1322
|
+
name: "alwaysRender",
|
|
1323
|
+
type: "boolean",
|
|
1324
|
+
default: "false",
|
|
1325
|
+
description: "Show it while there is a search too."
|
|
1326
|
+
}]
|
|
1327
|
+
}),
|
|
1328
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1329
|
+
title: "CommandKey",
|
|
1330
|
+
rows: [{
|
|
1331
|
+
name: "children",
|
|
1332
|
+
type: "ReactNode",
|
|
1333
|
+
description: "One key. A word is read as a key name, like Kbd: \"up\" is ↑ and is said \"Up arrow\", \"mod\" is ⌘ or Ctrl."
|
|
1334
|
+
}, {
|
|
1335
|
+
name: "keys",
|
|
1336
|
+
type: "string[]",
|
|
1337
|
+
description: "A shortcut of several keys, e.g. ['mod', 'K']. Accepts every kbd attribute."
|
|
1338
|
+
}]
|
|
1339
|
+
}),
|
|
1340
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1341
|
+
title: "SearchTrigger",
|
|
1342
|
+
rows: [
|
|
1343
|
+
{
|
|
1344
|
+
name: "onOpen",
|
|
1345
|
+
type: "() => void",
|
|
1346
|
+
description: "Called on a press and on the hotkey. Open the palette here."
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
name: "placeholder",
|
|
1350
|
+
type: "string",
|
|
1351
|
+
default: "'Search orders, products, customers'",
|
|
1352
|
+
description: "The words in the pill, and its accessible name. The palette takes them as its placeholder."
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
name: "hotkey",
|
|
1356
|
+
type: "boolean",
|
|
1357
|
+
default: "true",
|
|
1358
|
+
description: "Listen for ⌘K (Ctrl K elsewhere) anywhere on the page."
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
name: "shortcut",
|
|
1362
|
+
type: "boolean",
|
|
1363
|
+
default: "hotkey",
|
|
1364
|
+
description: "Show the ⌘ K or Ctrl K keycaps. Follows hotkey, so the pill shows them only while it listens for them."
|
|
1365
|
+
},
|
|
1366
|
+
{
|
|
1367
|
+
name: "width",
|
|
1368
|
+
type: "number | string",
|
|
1369
|
+
default: "360",
|
|
1370
|
+
description: "Preferred width in px or any CSS length. It shrinks with its container."
|
|
1371
|
+
},
|
|
1372
|
+
{
|
|
1373
|
+
name: "disabled",
|
|
1374
|
+
type: "boolean",
|
|
1375
|
+
default: "false",
|
|
1376
|
+
description: "Native disabled. Also accepts every other button attribute."
|
|
1377
|
+
}
|
|
1378
|
+
]
|
|
1379
|
+
})
|
|
1380
|
+
]
|
|
1381
|
+
})
|
|
1382
|
+
]
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
//#endregion
|
|
1386
|
+
export { Page, Preview };
|