@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,693 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
import { a as DocTable, d as Section$1, i as DocPage, m as ThemePair, o as Example, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
4
|
+
import { t as Playground } from "./Playground-Mk1yIWXb.js";
|
|
5
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Badge, Button, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Field, SearchField } from "@orbitcommerce/constellation";
|
|
8
|
+
//#region src/pages/components/search-field.tsx
|
|
9
|
+
function Preview() {
|
|
10
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11
|
+
style: {
|
|
12
|
+
display: "grid",
|
|
13
|
+
gap: 10,
|
|
14
|
+
width: 220
|
|
15
|
+
},
|
|
16
|
+
children: [/* @__PURE__ */ jsx(SearchField, {
|
|
17
|
+
"aria-label": "Search products",
|
|
18
|
+
placeholder: "Search products",
|
|
19
|
+
shortcut: ["/"]
|
|
20
|
+
}), /* @__PURE__ */ jsx(SearchField, {
|
|
21
|
+
"aria-label": "Search customers",
|
|
22
|
+
defaultValue: "Priya"
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
var quote = (v) => String(v).replace(/"/g, """);
|
|
27
|
+
var SHORTCUTS = {
|
|
28
|
+
none: void 0,
|
|
29
|
+
"/": ["/"],
|
|
30
|
+
"mod K": ["mod", "K"]
|
|
31
|
+
};
|
|
32
|
+
var PLAYGROUND = [
|
|
33
|
+
{
|
|
34
|
+
prop: "aria-label",
|
|
35
|
+
type: "text",
|
|
36
|
+
default: "Search products",
|
|
37
|
+
toAttr: (v) => `aria-label="${quote(v)}"`
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
prop: "placeholder",
|
|
41
|
+
type: "text",
|
|
42
|
+
default: "Search by name or SKU",
|
|
43
|
+
toAttr: (v) => v ? `placeholder="${quote(v)}"` : null
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
prop: "size",
|
|
47
|
+
type: "select",
|
|
48
|
+
options: ["sm", "md"],
|
|
49
|
+
default: "md"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
prop: "shortcut",
|
|
53
|
+
type: "select",
|
|
54
|
+
options: Object.keys(SHORTCUTS),
|
|
55
|
+
default: "none",
|
|
56
|
+
toAttr: (v) => {
|
|
57
|
+
const keys = SHORTCUTS[String(v)];
|
|
58
|
+
return keys ? `shortcut={[${keys.map((k) => `'${k}'`).join(", ")}]}` : null;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
prop: "disabled",
|
|
63
|
+
type: "boolean",
|
|
64
|
+
default: false
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
var PRODUCTS = [
|
|
68
|
+
{
|
|
69
|
+
name: "Arden ergonomic chair, black",
|
|
70
|
+
sku: "ARD-CHR-BLK",
|
|
71
|
+
stock: 14
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "Arden ergonomic chair, grey",
|
|
75
|
+
sku: "ARD-CHR-GRY",
|
|
76
|
+
stock: 3
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "Harbour oak desk, 140cm",
|
|
80
|
+
sku: "HBR-DSK-140",
|
|
81
|
+
stock: 6
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "Harbour oak desk, 160cm",
|
|
85
|
+
sku: "HBR-DSK-160",
|
|
86
|
+
stock: 0
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "Linen desk mat",
|
|
90
|
+
sku: "LIN-MAT-001",
|
|
91
|
+
stock: 42
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "Brass task lamp",
|
|
95
|
+
sku: "BRS-LMP-002",
|
|
96
|
+
stock: 9
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "Walnut monitor stand",
|
|
100
|
+
sku: "WAL-STD-001",
|
|
101
|
+
stock: 17
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "Cable tidy tray",
|
|
105
|
+
sku: "CBL-TRY-001",
|
|
106
|
+
stock: 58
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
function matches(product, query) {
|
|
110
|
+
const q = query.trim().toLowerCase();
|
|
111
|
+
return !q || product.name.toLowerCase().includes(q) || product.sku.toLowerCase().includes(q);
|
|
112
|
+
}
|
|
113
|
+
function Stock({ count }) {
|
|
114
|
+
return count === 0 ? /* @__PURE__ */ jsx(Badge, {
|
|
115
|
+
tone: "warning",
|
|
116
|
+
size: "sm",
|
|
117
|
+
children: "Out of stock"
|
|
118
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
119
|
+
className: "search-field-item__stock",
|
|
120
|
+
children: [count, " in stock"]
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/** True when a key press belongs to something the person is typing into. */
|
|
124
|
+
function isTyping(target) {
|
|
125
|
+
const el = target;
|
|
126
|
+
return !!el && (el.isContentEditable || !!el.closest("input, textarea, select, [role=\"dialog\"]"));
|
|
127
|
+
}
|
|
128
|
+
function ProductFilter() {
|
|
129
|
+
const [query, setQuery] = useState("");
|
|
130
|
+
const searchRef = useRef(null);
|
|
131
|
+
const shown = PRODUCTS.filter((p) => matches(p, query));
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
const onKeyDown = (event) => {
|
|
134
|
+
if (event.key !== "/" || event.metaKey || event.ctrlKey || event.altKey || isTyping(event.target)) return;
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
searchRef.current?.focus();
|
|
137
|
+
};
|
|
138
|
+
window.addEventListener("keydown", onKeyDown);
|
|
139
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
140
|
+
}, []);
|
|
141
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
142
|
+
className: "search-field-filter",
|
|
143
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
144
|
+
className: "search-field-filter__bar",
|
|
145
|
+
children: [/* @__PURE__ */ jsx(SearchField, {
|
|
146
|
+
ref: searchRef,
|
|
147
|
+
"aria-label": "Search products",
|
|
148
|
+
placeholder: "Search by name or SKU",
|
|
149
|
+
shortcut: ["/"],
|
|
150
|
+
value: query,
|
|
151
|
+
onValueChange: setQuery
|
|
152
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
153
|
+
role: "status",
|
|
154
|
+
className: "search-field-count",
|
|
155
|
+
children: [
|
|
156
|
+
shown.length,
|
|
157
|
+
" of ",
|
|
158
|
+
PRODUCTS.length,
|
|
159
|
+
" products"
|
|
160
|
+
]
|
|
161
|
+
})]
|
|
162
|
+
}), shown.length ? /* @__PURE__ */ jsx("ul", {
|
|
163
|
+
className: "search-field-list",
|
|
164
|
+
"aria-label": "Products",
|
|
165
|
+
children: shown.map((p) => /* @__PURE__ */ jsxs("li", {
|
|
166
|
+
className: "search-field-item",
|
|
167
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
168
|
+
className: "search-field-item__text",
|
|
169
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
170
|
+
className: "search-field-item__name",
|
|
171
|
+
children: p.name
|
|
172
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
173
|
+
className: "search-field-item__sku",
|
|
174
|
+
children: p.sku
|
|
175
|
+
})]
|
|
176
|
+
}), /* @__PURE__ */ jsx(Stock, { count: p.stock })]
|
|
177
|
+
}, p.sku))
|
|
178
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
179
|
+
className: "search-field-empty",
|
|
180
|
+
children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
181
|
+
"No products match \"",
|
|
182
|
+
query.trim(),
|
|
183
|
+
"\"."
|
|
184
|
+
] }), /* @__PURE__ */ jsx(Button, {
|
|
185
|
+
size: "sm",
|
|
186
|
+
variant: "ghost",
|
|
187
|
+
onClick: () => {
|
|
188
|
+
setQuery("");
|
|
189
|
+
searchRef.current?.focus();
|
|
190
|
+
},
|
|
191
|
+
children: "Clear search"
|
|
192
|
+
})]
|
|
193
|
+
})]
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function ProductPicker() {
|
|
197
|
+
const [open, setOpen] = useState(false);
|
|
198
|
+
const [query, setQuery] = useState("");
|
|
199
|
+
const [chosen, setChosen] = useState();
|
|
200
|
+
const shown = PRODUCTS.filter((p) => matches(p, query));
|
|
201
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
202
|
+
className: "search-field-picked",
|
|
203
|
+
children: [/* @__PURE__ */ jsxs("span", { children: ["Featured product: ", /* @__PURE__ */ jsx("strong", { children: chosen ? chosen.name : "None" })] }), /* @__PURE__ */ jsxs(Dialog, {
|
|
204
|
+
open,
|
|
205
|
+
onOpenChange: (next) => {
|
|
206
|
+
setOpen(next);
|
|
207
|
+
if (!next) setQuery("");
|
|
208
|
+
},
|
|
209
|
+
children: [/* @__PURE__ */ jsx(DialogTrigger, {
|
|
210
|
+
asChild: true,
|
|
211
|
+
children: /* @__PURE__ */ jsx(Button, { children: chosen ? "Change product" : "Choose product" })
|
|
212
|
+
}), /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
213
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Choose a product" }), /* @__PURE__ */ jsx(DialogDescription, { children: "Type to narrow the list. Escape clears the search first, then closes this dialog." })] }),
|
|
214
|
+
/* @__PURE__ */ jsxs(DialogBody, {
|
|
215
|
+
className: "search-field-dialog-body",
|
|
216
|
+
children: [/* @__PURE__ */ jsx(SearchField, {
|
|
217
|
+
"aria-label": "Search products",
|
|
218
|
+
placeholder: "Search by name or SKU",
|
|
219
|
+
value: query,
|
|
220
|
+
onValueChange: setQuery
|
|
221
|
+
}), shown.length ? /* @__PURE__ */ jsx("ul", {
|
|
222
|
+
className: "search-field-options",
|
|
223
|
+
"aria-label": "Products",
|
|
224
|
+
children: shown.map((p) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
|
|
225
|
+
type: "button",
|
|
226
|
+
className: "search-field-option",
|
|
227
|
+
onClick: () => {
|
|
228
|
+
setChosen(p);
|
|
229
|
+
setOpen(false);
|
|
230
|
+
setQuery("");
|
|
231
|
+
},
|
|
232
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
233
|
+
className: "search-field-item__text",
|
|
234
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
235
|
+
className: "search-field-item__name",
|
|
236
|
+
children: p.name
|
|
237
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
238
|
+
className: "search-field-item__sku",
|
|
239
|
+
children: p.sku
|
|
240
|
+
})]
|
|
241
|
+
}), /* @__PURE__ */ jsx(Stock, { count: p.stock })]
|
|
242
|
+
}) }, p.sku))
|
|
243
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
244
|
+
className: "search-field-empty",
|
|
245
|
+
children: /* @__PURE__ */ jsxs("p", { children: [
|
|
246
|
+
"No products match \"",
|
|
247
|
+
query.trim(),
|
|
248
|
+
"\"."
|
|
249
|
+
] })
|
|
250
|
+
})]
|
|
251
|
+
}),
|
|
252
|
+
/* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsx(DialogClose, {
|
|
253
|
+
asChild: true,
|
|
254
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Cancel" })
|
|
255
|
+
}) })
|
|
256
|
+
] })]
|
|
257
|
+
})]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function Page() {
|
|
261
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
262
|
+
title: "Search field",
|
|
263
|
+
status: "stable",
|
|
264
|
+
importNames: ["SearchField"],
|
|
265
|
+
lead: "A pill-shaped search input that filters what is already on screen: a list of orders, a product picker, a menu of options. To search the whole of Orbit, people use the command palette instead.",
|
|
266
|
+
children: [
|
|
267
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
268
|
+
id: "playground",
|
|
269
|
+
title: "Playground",
|
|
270
|
+
description: /* @__PURE__ */ jsx("p", { children: "Change the props, then type into the pill: the keycaps fade and a clear button pops in where they were." }),
|
|
271
|
+
children: /* @__PURE__ */ jsx(Playground, {
|
|
272
|
+
component: "SearchField",
|
|
273
|
+
controls: PLAYGROUND,
|
|
274
|
+
render: (v) => /* @__PURE__ */ jsx("div", {
|
|
275
|
+
className: "search-field-stage",
|
|
276
|
+
children: /* @__PURE__ */ jsx(SearchField, {
|
|
277
|
+
"aria-label": String(v["aria-label"]),
|
|
278
|
+
placeholder: v.placeholder ? String(v.placeholder) : void 0,
|
|
279
|
+
size: v.size,
|
|
280
|
+
shortcut: SHORTCUTS[String(v.shortcut)],
|
|
281
|
+
disabled: Boolean(v.disabled)
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
287
|
+
id: "filtering",
|
|
288
|
+
title: "Filtering a list",
|
|
289
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
290
|
+
"Control the query with ",
|
|
291
|
+
/* @__PURE__ */ jsx("code", { children: "value" }),
|
|
292
|
+
" and ",
|
|
293
|
+
/* @__PURE__ */ jsx("code", { children: "onValueChange" }),
|
|
294
|
+
", and filter as people type. Say how many results match, and when nothing does, repeat the query and offer a way back."
|
|
295
|
+
] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
296
|
+
"The ",
|
|
297
|
+
/* @__PURE__ */ jsx("code", { children: "shortcut" }),
|
|
298
|
+
" caps are only a hint, shown while the field is empty and idle. Bind the key yourself: this example binds ",
|
|
299
|
+
/* @__PURE__ */ jsx("code", { children: "/" }),
|
|
300
|
+
", so press it anywhere on the page."
|
|
301
|
+
] })] }),
|
|
302
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
303
|
+
align: "fill",
|
|
304
|
+
code: `
|
|
305
|
+
const [query, setQuery] = useState('')
|
|
306
|
+
const searchRef = useRef<HTMLInputElement>(null)
|
|
307
|
+
const shown = products.filter((p) => matches(p, query))
|
|
308
|
+
|
|
309
|
+
<SearchField
|
|
310
|
+
ref={searchRef}
|
|
311
|
+
aria-label="Search products"
|
|
312
|
+
placeholder="Search by name or SKU"
|
|
313
|
+
shortcut={['/']}
|
|
314
|
+
value={query}
|
|
315
|
+
onValueChange={setQuery}
|
|
316
|
+
/>
|
|
317
|
+
<p role="status">{shown.length} of {products.length} products</p>
|
|
318
|
+
|
|
319
|
+
// The caps are only a hint: bind the key yourself.
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
322
|
+
if (event.key !== '/' || isTyping(event.target)) return
|
|
323
|
+
event.preventDefault()
|
|
324
|
+
searchRef.current?.focus()
|
|
325
|
+
}
|
|
326
|
+
window.addEventListener('keydown', onKeyDown)
|
|
327
|
+
return () => window.removeEventListener('keydown', onKeyDown)
|
|
328
|
+
}, [])`,
|
|
329
|
+
children: /* @__PURE__ */ jsx(ProductFilter, {})
|
|
330
|
+
})
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
333
|
+
id: "clearing",
|
|
334
|
+
title: "Clearing",
|
|
335
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
336
|
+
"Once there is a query, a round clear button pops in where the keycaps were. Pressing it empties the field, calls ",
|
|
337
|
+
/* @__PURE__ */ jsx("code", { children: "onValueChange('')" }),
|
|
338
|
+
" and then ",
|
|
339
|
+
/* @__PURE__ */ jsx("code", { children: "onClear" }),
|
|
340
|
+
", and puts focus back in the field."
|
|
341
|
+
] }), /* @__PURE__ */ jsx("p", { children: "Escape does the same from the keyboard, and it clears before anything else hears it. Inside a dialog or popover, the first Escape clears the search and only the next one closes the dialog. Open the dialog, type and press Escape twice." })] }),
|
|
342
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
343
|
+
minHeight: 220,
|
|
344
|
+
code: `
|
|
345
|
+
<Dialog>
|
|
346
|
+
<DialogTrigger asChild>
|
|
347
|
+
<Button>Choose product</Button>
|
|
348
|
+
</DialogTrigger>
|
|
349
|
+
<DialogContent>
|
|
350
|
+
<DialogHeader>
|
|
351
|
+
<DialogTitle>Choose a product</DialogTitle>
|
|
352
|
+
<DialogDescription>Type to narrow the list. Escape clears the search first, then closes this dialog.</DialogDescription>
|
|
353
|
+
</DialogHeader>
|
|
354
|
+
<DialogBody>
|
|
355
|
+
<SearchField aria-label="Search products" placeholder="Search by name or SKU" value={query} onValueChange={setQuery} />
|
|
356
|
+
{/* The matching products */}
|
|
357
|
+
</DialogBody>
|
|
358
|
+
<DialogFooter>
|
|
359
|
+
<DialogClose asChild>
|
|
360
|
+
<Button>Cancel</Button>
|
|
361
|
+
</DialogClose>
|
|
362
|
+
</DialogFooter>
|
|
363
|
+
</DialogContent>
|
|
364
|
+
</Dialog>`,
|
|
365
|
+
children: /* @__PURE__ */ jsx(ProductPicker, {})
|
|
366
|
+
})
|
|
367
|
+
}),
|
|
368
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
369
|
+
id: "keyboard",
|
|
370
|
+
title: "Keyboard",
|
|
371
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
372
|
+
columns: ["Key", "What it does"],
|
|
373
|
+
rows: [
|
|
374
|
+
["Escape", "With a query: clears it and stops there, even inside a dialog. With an empty field: passes on, so it can close the dialog or popover around it."],
|
|
375
|
+
["Enter", "Nothing built in. Inside a form it submits the form, like any search input. Phone keyboards label the key Search."],
|
|
376
|
+
["Tab", "The clear button is left out of the Tab order: Escape does its job from the keyboard."],
|
|
377
|
+
["Your shortcut", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
378
|
+
"Only drawn, never bound. Bind it in your page, as the list example binds ",
|
|
379
|
+
/* @__PURE__ */ jsx("code", { children: "/" }),
|
|
380
|
+
"."
|
|
381
|
+
] })]
|
|
382
|
+
]
|
|
383
|
+
})
|
|
384
|
+
}),
|
|
385
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
386
|
+
id: "sizes",
|
|
387
|
+
title: "Sizes",
|
|
388
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
389
|
+
/* @__PURE__ */ jsx("code", { children: "md" }),
|
|
390
|
+
" 36px (default) and ",
|
|
391
|
+
/* @__PURE__ */ jsx("code", { children: "sm" }),
|
|
392
|
+
" 30px, the same heights as buttons, so a search sits in a toolbar row with them. There is no large search."
|
|
393
|
+
] }),
|
|
394
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
395
|
+
align: "fill",
|
|
396
|
+
code: `
|
|
397
|
+
<SearchField size="sm" aria-label="Search orders" placeholder="Search orders" />
|
|
398
|
+
<Button size="sm">Export</Button>
|
|
399
|
+
|
|
400
|
+
<SearchField aria-label="Search orders" placeholder="Search orders" />
|
|
401
|
+
<Button>Export</Button>`,
|
|
402
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
403
|
+
className: "search-field-rows",
|
|
404
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
405
|
+
className: "search-field-row",
|
|
406
|
+
children: [/* @__PURE__ */ jsx(SearchField, {
|
|
407
|
+
size: "sm",
|
|
408
|
+
"aria-label": "Search orders",
|
|
409
|
+
placeholder: "Search orders"
|
|
410
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
411
|
+
size: "sm",
|
|
412
|
+
children: "Export"
|
|
413
|
+
})]
|
|
414
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
415
|
+
className: "search-field-row",
|
|
416
|
+
children: [/* @__PURE__ */ jsx(SearchField, {
|
|
417
|
+
"aria-label": "Search orders",
|
|
418
|
+
placeholder: "Search orders"
|
|
419
|
+
}), /* @__PURE__ */ jsx(Button, { children: "Export" })]
|
|
420
|
+
})]
|
|
421
|
+
})
|
|
422
|
+
})
|
|
423
|
+
}),
|
|
424
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
425
|
+
id: "in-a-field",
|
|
426
|
+
title: "With a label",
|
|
427
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
428
|
+
"Most searches are named by what sits around them, so an ",
|
|
429
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
430
|
+
" is enough. When a visible label helps, as in a filter panel, put the search in a ",
|
|
431
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
432
|
+
to: "/components/input",
|
|
433
|
+
children: "Field"
|
|
434
|
+
}),
|
|
435
|
+
": it picks up the label and the hint."
|
|
436
|
+
] }),
|
|
437
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
438
|
+
code: `
|
|
439
|
+
<Field label="Customer" hint="Name, email or postcode">
|
|
440
|
+
<SearchField size="sm" placeholder="Search customers" />
|
|
441
|
+
</Field>`,
|
|
442
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
443
|
+
className: "search-field-stage",
|
|
444
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
445
|
+
label: "Customer",
|
|
446
|
+
hint: "Name, email or postcode",
|
|
447
|
+
children: /* @__PURE__ */ jsx(SearchField, {
|
|
448
|
+
size: "sm",
|
|
449
|
+
placeholder: "Search customers"
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
})
|
|
453
|
+
})
|
|
454
|
+
}),
|
|
455
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
456
|
+
id: "ground",
|
|
457
|
+
title: "On the ground",
|
|
458
|
+
description: /* @__PURE__ */ jsx("p", { children: "On the app's ground, as in a side panel, the pill still stands off the surface, and so does its focus halo." }),
|
|
459
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
460
|
+
surface: "ground",
|
|
461
|
+
code: `<SearchField aria-label="Search customers" placeholder="Search customers" shortcut={['/']} />`,
|
|
462
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
463
|
+
className: "search-field-stage",
|
|
464
|
+
children: /* @__PURE__ */ jsx(SearchField, {
|
|
465
|
+
"aria-label": "Search customers",
|
|
466
|
+
placeholder: "Search customers",
|
|
467
|
+
shortcut: ["/"]
|
|
468
|
+
})
|
|
469
|
+
})
|
|
470
|
+
})
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
473
|
+
id: "command-palette",
|
|
474
|
+
title: "Search field or command palette?",
|
|
475
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
476
|
+
"They look alike on purpose, and they do different jobs. The header's ",
|
|
477
|
+
/* @__PURE__ */ jsx("code", { children: "SearchTrigger" }),
|
|
478
|
+
" is a button that opens the ",
|
|
479
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
480
|
+
to: "/components/command-palette",
|
|
481
|
+
children: "command palette"
|
|
482
|
+
}),
|
|
483
|
+
"; SearchField is a real input that filters in place."
|
|
484
|
+
] }),
|
|
485
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
486
|
+
columns: [
|
|
487
|
+
/* @__PURE__ */ jsx("span", {
|
|
488
|
+
className: "o-sr-only",
|
|
489
|
+
children: "Question"
|
|
490
|
+
}),
|
|
491
|
+
"SearchField",
|
|
492
|
+
"SearchTrigger"
|
|
493
|
+
],
|
|
494
|
+
rows: [
|
|
495
|
+
[
|
|
496
|
+
"What it is",
|
|
497
|
+
"A text input.",
|
|
498
|
+
"A button shaped like a search pill."
|
|
499
|
+
],
|
|
500
|
+
[
|
|
501
|
+
"When you type",
|
|
502
|
+
"Filters what is on this page as you type.",
|
|
503
|
+
"Opens a panel that searches the whole of Orbit and jumps to the result."
|
|
504
|
+
],
|
|
505
|
+
[
|
|
506
|
+
"Where it goes",
|
|
507
|
+
"Above a list or table, in pickers, popovers and dialogs.",
|
|
508
|
+
"Once, in the app header."
|
|
509
|
+
],
|
|
510
|
+
[
|
|
511
|
+
"Shortcut",
|
|
512
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
513
|
+
"Optional caps, often ",
|
|
514
|
+
/* @__PURE__ */ jsx("code", { children: "/" }),
|
|
515
|
+
". You bind the key."
|
|
516
|
+
] }),
|
|
517
|
+
"⌘K on a Mac, Ctrl K elsewhere, bound for you."
|
|
518
|
+
]
|
|
519
|
+
]
|
|
520
|
+
})
|
|
521
|
+
}),
|
|
522
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
523
|
+
id: "loading",
|
|
524
|
+
title: "While results load",
|
|
525
|
+
description: /* @__PURE__ */ jsx("p", { children: "SearchField has no loading state. When results come from the server, show the wait where the results will appear, with skeleton rows or a spinner in the list, and keep the field free to type in." })
|
|
526
|
+
}),
|
|
527
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
528
|
+
id: "both-themes",
|
|
529
|
+
title: "In both themes",
|
|
530
|
+
description: /* @__PURE__ */ jsx("p", { children: "Empty with a shortcut, with a query, small and disabled, light and dark side by side." }),
|
|
531
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
532
|
+
align: "fill",
|
|
533
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
534
|
+
className: "search-field-stack",
|
|
535
|
+
children: [
|
|
536
|
+
/* @__PURE__ */ jsx(SearchField, {
|
|
537
|
+
"aria-label": "Search products",
|
|
538
|
+
placeholder: "Search products",
|
|
539
|
+
shortcut: ["/"]
|
|
540
|
+
}),
|
|
541
|
+
/* @__PURE__ */ jsx(SearchField, {
|
|
542
|
+
"aria-label": "Search customers",
|
|
543
|
+
defaultValue: "Priya"
|
|
544
|
+
}),
|
|
545
|
+
/* @__PURE__ */ jsx(SearchField, {
|
|
546
|
+
size: "sm",
|
|
547
|
+
"aria-label": "Search orders",
|
|
548
|
+
placeholder: "Search orders"
|
|
549
|
+
}),
|
|
550
|
+
/* @__PURE__ */ jsx(SearchField, {
|
|
551
|
+
"aria-label": "Search suppliers",
|
|
552
|
+
placeholder: "Search suppliers",
|
|
553
|
+
disabled: true
|
|
554
|
+
})
|
|
555
|
+
]
|
|
556
|
+
})
|
|
557
|
+
})
|
|
558
|
+
}),
|
|
559
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
560
|
+
id: "guidelines",
|
|
561
|
+
title: "Guidelines",
|
|
562
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
563
|
+
do: {
|
|
564
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
565
|
+
style: {
|
|
566
|
+
width: "100%",
|
|
567
|
+
maxWidth: 260
|
|
568
|
+
},
|
|
569
|
+
children: /* @__PURE__ */ jsx(SearchField, {
|
|
570
|
+
"aria-label": "Search orders",
|
|
571
|
+
placeholder: "Order number or customer"
|
|
572
|
+
})
|
|
573
|
+
}),
|
|
574
|
+
caption: "Filter as people type, and say in the placeholder what can be searched."
|
|
575
|
+
},
|
|
576
|
+
dont: {
|
|
577
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
578
|
+
className: "search-field-row",
|
|
579
|
+
style: { maxWidth: 300 },
|
|
580
|
+
children: [/* @__PURE__ */ jsx(SearchField, {
|
|
581
|
+
"aria-label": "Search orders",
|
|
582
|
+
placeholder: "Search"
|
|
583
|
+
}), /* @__PURE__ */ jsx(Button, { children: "Search" })]
|
|
584
|
+
}),
|
|
585
|
+
caption: "A Search button makes people do the work twice, and \"Search\" does not say what they can find."
|
|
586
|
+
}
|
|
587
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
588
|
+
"Give it a name as well as a placeholder: an aria-label or a Field label. A placeholder is not a name.",
|
|
589
|
+
"Show how many results match, and an empty state that repeats the query.",
|
|
590
|
+
"For searches that go to the server, wait for a short pause in typing before asking.",
|
|
591
|
+
"Never put a SearchField in the app header for searching everything: that is the command palette."
|
|
592
|
+
] })]
|
|
593
|
+
}),
|
|
594
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
595
|
+
id: "accessibility",
|
|
596
|
+
title: "Accessibility",
|
|
597
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
598
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
599
|
+
"Renders ",
|
|
600
|
+
/* @__PURE__ */ jsx("code", { children: "input type=\"search\"" }),
|
|
601
|
+
", announced as a search field. Name it with",
|
|
602
|
+
" ",
|
|
603
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
604
|
+
" or a Field label."
|
|
605
|
+
] }),
|
|
606
|
+
"The magnifier and the shortcut caps are hidden from assistive tech.",
|
|
607
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
608
|
+
"The clear button is named by ",
|
|
609
|
+
/* @__PURE__ */ jsx("code", { children: "clearLabel" }),
|
|
610
|
+
" (\"Clear search\"), is hidden from assistive tech while the field is empty and is left out of the Tab order. After clearing, focus goes back to the field."
|
|
611
|
+
] }),
|
|
612
|
+
"Escape clears before any dialog or popover hears it, so clearing a search never throws someone out of the dialog.",
|
|
613
|
+
"Autocomplete and spellcheck are off; phone keyboards show a Search key.",
|
|
614
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
615
|
+
"Result counts are not announced for you. Put them in a ",
|
|
616
|
+
/* @__PURE__ */ jsx("code", { children: "role=\"status\"" }),
|
|
617
|
+
" element, as the list example does."
|
|
618
|
+
] }),
|
|
619
|
+
"Focus shows as a teal edge and soft halo round the pill. Under reduced motion the clear button fades in without the pop."
|
|
620
|
+
] })
|
|
621
|
+
}),
|
|
622
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
623
|
+
id: "props",
|
|
624
|
+
title: "Props",
|
|
625
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
626
|
+
"Other native input attributes, and the ",
|
|
627
|
+
/* @__PURE__ */ jsx("code", { children: "ref" }),
|
|
628
|
+
", go to the ",
|
|
629
|
+
/* @__PURE__ */ jsx("code", { children: "input" }),
|
|
630
|
+
".",
|
|
631
|
+
" ",
|
|
632
|
+
/* @__PURE__ */ jsx("code", { children: "className" }),
|
|
633
|
+
" and ",
|
|
634
|
+
/* @__PURE__ */ jsx("code", { children: "style" }),
|
|
635
|
+
" go to the pill."
|
|
636
|
+
] }),
|
|
637
|
+
children: /* @__PURE__ */ jsx(PropsTable, { rows: [
|
|
638
|
+
{
|
|
639
|
+
name: "value",
|
|
640
|
+
type: "string",
|
|
641
|
+
description: "The query, when you control it."
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
name: "defaultValue",
|
|
645
|
+
type: "string",
|
|
646
|
+
default: "''",
|
|
647
|
+
description: "The starting query when uncontrolled."
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
name: "onValueChange",
|
|
651
|
+
type: "(value: string) => void",
|
|
652
|
+
description: "Called with the query on every keystroke, and with an empty string on clear."
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
name: "onClear",
|
|
656
|
+
type: "() => void",
|
|
657
|
+
description: "Called after the clear button or Escape empties the field."
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
name: "size",
|
|
661
|
+
type: "'sm' | 'md'",
|
|
662
|
+
default: "'md'",
|
|
663
|
+
description: "30 or 36px tall."
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
name: "shortcut",
|
|
667
|
+
type: "string[]",
|
|
668
|
+
description: "Keycaps shown while empty and idle, e.g. ['/'] or ['mod', 'K']. Drawn only: bind the keys yourself."
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: "placeholder",
|
|
672
|
+
type: "string",
|
|
673
|
+
default: "'Search'",
|
|
674
|
+
description: "What can be searched. Not a name."
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
name: "clearLabel",
|
|
678
|
+
type: "string",
|
|
679
|
+
default: "'Clear search'",
|
|
680
|
+
description: "The clear button's accessible name."
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
name: "disabled",
|
|
684
|
+
type: "boolean",
|
|
685
|
+
description: "Sinks into the well; the field and its clear button stop responding."
|
|
686
|
+
}
|
|
687
|
+
] })
|
|
688
|
+
})
|
|
689
|
+
]
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
//#endregion
|
|
693
|
+
export { Page, Preview };
|