@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,1334 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
import { a as DocTable, d as Section$1, i as DocPage, l as Note, m as ThemePair, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
4
|
+
import { t as Playground } from "./Playground-Mk1yIWXb.js";
|
|
5
|
+
import { useRef, useState } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Button, Combobox, Field } from "@orbitcommerce/constellation";
|
|
8
|
+
//#region src/pages/components/combobox.tsx
|
|
9
|
+
var COUNTRIES = [
|
|
10
|
+
[
|
|
11
|
+
"gb",
|
|
12
|
+
"United Kingdom",
|
|
13
|
+
"+44"
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
"ie",
|
|
17
|
+
"Ireland",
|
|
18
|
+
"+353"
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
"fr",
|
|
22
|
+
"France",
|
|
23
|
+
"+33"
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
"de",
|
|
27
|
+
"Germany",
|
|
28
|
+
"+49"
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"es",
|
|
32
|
+
"Spain",
|
|
33
|
+
"+34"
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"it",
|
|
37
|
+
"Italy",
|
|
38
|
+
"+39"
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
"nl",
|
|
42
|
+
"Netherlands",
|
|
43
|
+
"+31"
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
"be",
|
|
47
|
+
"Belgium",
|
|
48
|
+
"+32"
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
"pt",
|
|
52
|
+
"Portugal",
|
|
53
|
+
"+351"
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"se",
|
|
57
|
+
"Sweden",
|
|
58
|
+
"+46"
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
"no",
|
|
62
|
+
"Norway",
|
|
63
|
+
"+47"
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
"dk",
|
|
67
|
+
"Denmark",
|
|
68
|
+
"+45"
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
"fi",
|
|
72
|
+
"Finland",
|
|
73
|
+
"+358"
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"pl",
|
|
77
|
+
"Poland",
|
|
78
|
+
"+48"
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
"at",
|
|
82
|
+
"Austria",
|
|
83
|
+
"+43"
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
"ch",
|
|
87
|
+
"Switzerland",
|
|
88
|
+
"+41"
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
"us",
|
|
92
|
+
"United States",
|
|
93
|
+
"+1"
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
"ca",
|
|
97
|
+
"Canada",
|
|
98
|
+
"+1"
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
"au",
|
|
102
|
+
"Australia",
|
|
103
|
+
"+61"
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
"nz",
|
|
107
|
+
"New Zealand",
|
|
108
|
+
"+64"
|
|
109
|
+
]
|
|
110
|
+
].map(([value, label, dial]) => ({
|
|
111
|
+
value,
|
|
112
|
+
label,
|
|
113
|
+
keywords: `${value} ${dial}`,
|
|
114
|
+
aside: dial
|
|
115
|
+
}));
|
|
116
|
+
var CATEGORIES = [
|
|
117
|
+
"Apparel",
|
|
118
|
+
"Camp Kitchen",
|
|
119
|
+
"Drinkware",
|
|
120
|
+
"Outdoor",
|
|
121
|
+
"Packs & Bags",
|
|
122
|
+
"Shelter",
|
|
123
|
+
"Sleeping",
|
|
124
|
+
"Lighting"
|
|
125
|
+
].map((label) => ({
|
|
126
|
+
value: label.toLowerCase().replace(/\W+/g, "-"),
|
|
127
|
+
label
|
|
128
|
+
}));
|
|
129
|
+
/** Categories, some of them added by a rule: those cannot be taken away here. */
|
|
130
|
+
var SMART = [
|
|
131
|
+
{
|
|
132
|
+
value: "camping",
|
|
133
|
+
label: "Camping"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
value: "cooking",
|
|
137
|
+
label: "Cooking"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
value: "sleeping",
|
|
141
|
+
label: "Sleeping"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
value: "on-sale",
|
|
145
|
+
label: "On sale",
|
|
146
|
+
removable: false,
|
|
147
|
+
tone: "warning"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
value: "new-in",
|
|
151
|
+
label: "New in",
|
|
152
|
+
removable: false,
|
|
153
|
+
tone: "warning"
|
|
154
|
+
}
|
|
155
|
+
];
|
|
156
|
+
var TIMEZONES = [
|
|
157
|
+
[
|
|
158
|
+
"utc",
|
|
159
|
+
"UTC",
|
|
160
|
+
""
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
"lon",
|
|
164
|
+
"London",
|
|
165
|
+
"Europe"
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
"par",
|
|
169
|
+
"Paris",
|
|
170
|
+
"Europe"
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
"ber",
|
|
174
|
+
"Berlin",
|
|
175
|
+
"Europe"
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
"mad",
|
|
179
|
+
"Madrid",
|
|
180
|
+
"Europe"
|
|
181
|
+
],
|
|
182
|
+
[
|
|
183
|
+
"nyc",
|
|
184
|
+
"New York",
|
|
185
|
+
"Americas"
|
|
186
|
+
],
|
|
187
|
+
[
|
|
188
|
+
"chi",
|
|
189
|
+
"Chicago",
|
|
190
|
+
"Americas"
|
|
191
|
+
],
|
|
192
|
+
[
|
|
193
|
+
"lax",
|
|
194
|
+
"Los Angeles",
|
|
195
|
+
"Americas"
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
"tok",
|
|
199
|
+
"Tokyo",
|
|
200
|
+
"Asia"
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
"sin",
|
|
204
|
+
"Singapore",
|
|
205
|
+
"Asia"
|
|
206
|
+
],
|
|
207
|
+
[
|
|
208
|
+
"syd",
|
|
209
|
+
"Sydney",
|
|
210
|
+
"Pacific"
|
|
211
|
+
]
|
|
212
|
+
].map(([value, label, group]) => ({
|
|
213
|
+
value,
|
|
214
|
+
label,
|
|
215
|
+
group: group || void 0
|
|
216
|
+
}));
|
|
217
|
+
/** A picture without a file: a muted tile with the initials, which also shows in dark. */
|
|
218
|
+
var tile = (text, hue) => `data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="72" height="72"><rect width="72" height="72" fill="hsl(${hue} 14% 38%)"/><text x="36" y="42" font-family="sans-serif" font-size="15" text-anchor="middle" fill="white">${text}</text></svg>`)}`;
|
|
219
|
+
var PRODUCTS = [
|
|
220
|
+
"Camp Cook Set",
|
|
221
|
+
"Camp Griddle Pan",
|
|
222
|
+
"Trail Stove",
|
|
223
|
+
"Enamel Mug",
|
|
224
|
+
"Insulated Bottle",
|
|
225
|
+
"Coffee Press",
|
|
226
|
+
"Folding Table",
|
|
227
|
+
"Camp Chair",
|
|
228
|
+
"Dry Bag 20L",
|
|
229
|
+
"Day Pack",
|
|
230
|
+
"Roll-top Pack",
|
|
231
|
+
"Duffel 60L",
|
|
232
|
+
"Two-person Tent",
|
|
233
|
+
"Tarp 3 x 3",
|
|
234
|
+
"Ground Sheet",
|
|
235
|
+
"Down Sleeping Bag",
|
|
236
|
+
"Sleeping Mat",
|
|
237
|
+
"Pillow",
|
|
238
|
+
"Head Torch",
|
|
239
|
+
"Lantern",
|
|
240
|
+
"Fire Starter",
|
|
241
|
+
"Rain Jacket",
|
|
242
|
+
"Fleece",
|
|
243
|
+
"Walking Socks",
|
|
244
|
+
"Gloves",
|
|
245
|
+
"Beanie",
|
|
246
|
+
"Water Filter"
|
|
247
|
+
].map((name, i) => ({
|
|
248
|
+
value: `p${i}`,
|
|
249
|
+
label: name,
|
|
250
|
+
image: tile(name.split(" ").map((word) => word[0]).join("").slice(0, 3), i * 47 % 360),
|
|
251
|
+
description: i % 3 === 0 ? "Cookware" : i % 3 === 1 ? "Outdoor" : "Packs and bags",
|
|
252
|
+
aside: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("span", { children: ["£", (18 + i * 7 % 60).toFixed(2)] }), /* @__PURE__ */ jsxs("span", { children: [i * 5 % 40, " in stock"] })] })
|
|
253
|
+
}));
|
|
254
|
+
var wait = (ms, signal) => new Promise((resolve, reject) => {
|
|
255
|
+
const timer = window.setTimeout(resolve, ms);
|
|
256
|
+
signal.addEventListener("abort", () => {
|
|
257
|
+
window.clearTimeout(timer);
|
|
258
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
/** A server: 450ms away, a page at a time, and it can be made to fail. */
|
|
262
|
+
async function searchProducts({ term, page, pageSize, signal }, fail) {
|
|
263
|
+
await wait(450, signal);
|
|
264
|
+
if (fail) throw new Error("The server did not answer");
|
|
265
|
+
const needle = term.trim().toLowerCase();
|
|
266
|
+
const matches = PRODUCTS.filter((p) => p.label.toLowerCase().includes(needle));
|
|
267
|
+
const start = (page - 1) * pageSize;
|
|
268
|
+
return {
|
|
269
|
+
options: matches.slice(start, start + pageSize),
|
|
270
|
+
total: matches.length
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function Preview() {
|
|
274
|
+
return /* @__PURE__ */ jsx("div", {
|
|
275
|
+
style: { width: 232 },
|
|
276
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
277
|
+
"aria-label": "Category",
|
|
278
|
+
size: "sm",
|
|
279
|
+
options: CATEGORIES,
|
|
280
|
+
defaultValue: "outdoor"
|
|
281
|
+
})
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
var PLAYGROUND = [
|
|
285
|
+
{
|
|
286
|
+
prop: "multiple",
|
|
287
|
+
type: "boolean",
|
|
288
|
+
default: false
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
prop: "searchable",
|
|
292
|
+
type: "boolean",
|
|
293
|
+
default: true,
|
|
294
|
+
toAttr: (v) => v ? null : "searchable={false}"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
prop: "clearable",
|
|
298
|
+
type: "boolean",
|
|
299
|
+
default: true,
|
|
300
|
+
toAttr: (v) => v ? null : "clearable={false}"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
prop: "presentation",
|
|
304
|
+
type: "select",
|
|
305
|
+
options: ["attached", "popover"],
|
|
306
|
+
default: "attached"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
prop: "size",
|
|
310
|
+
type: "select",
|
|
311
|
+
options: [
|
|
312
|
+
"sm",
|
|
313
|
+
"md",
|
|
314
|
+
"lg"
|
|
315
|
+
],
|
|
316
|
+
default: "md"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
prop: "openOnFocus",
|
|
320
|
+
type: "boolean",
|
|
321
|
+
default: true,
|
|
322
|
+
toAttr: (v) => v ? null : "openOnFocus={false}"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
prop: "invalid",
|
|
326
|
+
type: "boolean",
|
|
327
|
+
default: false
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
prop: "disabled",
|
|
331
|
+
type: "boolean",
|
|
332
|
+
default: false
|
|
333
|
+
}
|
|
334
|
+
];
|
|
335
|
+
function Country() {
|
|
336
|
+
const [country, setCountry] = useState("gb");
|
|
337
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
338
|
+
className: "combo-stack",
|
|
339
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
340
|
+
label: "Country",
|
|
341
|
+
hint: "Where you ship from",
|
|
342
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
343
|
+
options: COUNTRIES,
|
|
344
|
+
placeholder: "Search countries",
|
|
345
|
+
value: country,
|
|
346
|
+
onValueChange: setCountry
|
|
347
|
+
})
|
|
348
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
349
|
+
className: "combo-note",
|
|
350
|
+
children: ["Chosen: ", /* @__PURE__ */ jsx("code", { children: country === null ? "null" : `"${country}"` })]
|
|
351
|
+
})]
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function Categories() {
|
|
355
|
+
const [picked, setPicked] = useState(["outdoor", "shelter"]);
|
|
356
|
+
return /* @__PURE__ */ jsx("div", {
|
|
357
|
+
className: "combo-stack",
|
|
358
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
359
|
+
label: "Categories",
|
|
360
|
+
hint: "Pick as many as fit",
|
|
361
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
362
|
+
multiple: true,
|
|
363
|
+
options: CATEGORIES,
|
|
364
|
+
placeholder: "Search categories",
|
|
365
|
+
value: picked,
|
|
366
|
+
onValueChange: setPicked
|
|
367
|
+
})
|
|
368
|
+
})
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function Smart() {
|
|
372
|
+
const [picked, setPicked] = useState([
|
|
373
|
+
"camping",
|
|
374
|
+
"cooking",
|
|
375
|
+
"on-sale",
|
|
376
|
+
"new-in"
|
|
377
|
+
]);
|
|
378
|
+
return /* @__PURE__ */ jsx("div", {
|
|
379
|
+
className: "combo-stack",
|
|
380
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
381
|
+
label: "Categories",
|
|
382
|
+
hint: "Categories a rule added have no remove button: they stay when you remove the rest.",
|
|
383
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
384
|
+
multiple: true,
|
|
385
|
+
options: SMART,
|
|
386
|
+
placeholder: "Search categories",
|
|
387
|
+
value: picked,
|
|
388
|
+
onValueChange: setPicked
|
|
389
|
+
})
|
|
390
|
+
})
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
function Linked() {
|
|
394
|
+
const [picked, setPicked] = useState([]);
|
|
395
|
+
return /* @__PURE__ */ jsx("div", {
|
|
396
|
+
className: "combo-stack",
|
|
397
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
398
|
+
label: "Cross-sells",
|
|
399
|
+
description: "Products you promote in the cart",
|
|
400
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
401
|
+
multiple: true,
|
|
402
|
+
selectedDisplay: "rows",
|
|
403
|
+
options: PRODUCTS,
|
|
404
|
+
placeholder: "Search for products",
|
|
405
|
+
notFoundMessage: "No products found",
|
|
406
|
+
value: picked,
|
|
407
|
+
onValueChange: setPicked
|
|
408
|
+
})
|
|
409
|
+
})
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function Server() {
|
|
413
|
+
const [picked, setPicked] = useState(["p2", "p19"]);
|
|
414
|
+
const [fail, setFail] = useState(false);
|
|
415
|
+
const failing = useRef(false);
|
|
416
|
+
failing.current = fail;
|
|
417
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
418
|
+
className: "combo-stack",
|
|
419
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
420
|
+
label: "Linked products",
|
|
421
|
+
hint: "Searched on a server, eight at a time",
|
|
422
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
423
|
+
multiple: true,
|
|
424
|
+
pageSize: 8,
|
|
425
|
+
placeholder: "Search for products",
|
|
426
|
+
notFoundMessage: "No products found",
|
|
427
|
+
value: picked,
|
|
428
|
+
onValueChange: setPicked,
|
|
429
|
+
onSearch: (query) => searchProducts(query, failing.current),
|
|
430
|
+
onFetchByIds: async (ids) => PRODUCTS.filter((p) => ids.includes(p.value))
|
|
431
|
+
})
|
|
432
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
433
|
+
size: "sm",
|
|
434
|
+
variant: "secondary",
|
|
435
|
+
onClick: () => setFail((f) => !f),
|
|
436
|
+
children: fail ? "Let the next search work" : "Make the next search fail"
|
|
437
|
+
})]
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
function Brand() {
|
|
441
|
+
const [brands, setBrands] = useState([option("harbour", "Harbour Desk"), option("arden", "Arden")]);
|
|
442
|
+
const [brand, setBrand] = useState(null);
|
|
443
|
+
const [tags, setTags] = useState([option("new", "New in"), option("sale", "Sale")]);
|
|
444
|
+
const [picked, setPicked] = useState(["sale"]);
|
|
445
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
446
|
+
className: "combo-stack",
|
|
447
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
448
|
+
label: "Brand",
|
|
449
|
+
hint: "Type a brand that is not there to add it",
|
|
450
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
451
|
+
options: brands,
|
|
452
|
+
placeholder: "Search or create brand",
|
|
453
|
+
value: brand,
|
|
454
|
+
onValueChange: setBrand,
|
|
455
|
+
onCreate: (text) => {
|
|
456
|
+
const made = option(text.toLowerCase().replace(/\W+/g, "-"), text);
|
|
457
|
+
setBrands((list) => [...list, made]);
|
|
458
|
+
return made;
|
|
459
|
+
}
|
|
460
|
+
})
|
|
461
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
462
|
+
label: "Tags",
|
|
463
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
464
|
+
multiple: true,
|
|
465
|
+
options: tags,
|
|
466
|
+
placeholder: "Search or create tags",
|
|
467
|
+
value: picked,
|
|
468
|
+
onValueChange: setPicked,
|
|
469
|
+
onCreate: (text) => {
|
|
470
|
+
const made = option(text.toLowerCase().replace(/\W+/g, "-"), text);
|
|
471
|
+
setTags((list) => [...list, made]);
|
|
472
|
+
return made;
|
|
473
|
+
}
|
|
474
|
+
})
|
|
475
|
+
})]
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
var option = (value, label) => ({
|
|
479
|
+
value,
|
|
480
|
+
label
|
|
481
|
+
});
|
|
482
|
+
var COLLECTIONS = [
|
|
483
|
+
option("summer", "Summer sale"),
|
|
484
|
+
option("office", "Home office"),
|
|
485
|
+
option("new", "New in")
|
|
486
|
+
];
|
|
487
|
+
var PAGES = [
|
|
488
|
+
option("/pages/about", "About us"),
|
|
489
|
+
option("/pages/delivery", "Delivery and returns"),
|
|
490
|
+
option("/collections/all", "All products")
|
|
491
|
+
];
|
|
492
|
+
function NoMatch() {
|
|
493
|
+
const [suppliers, setSuppliers] = useState([option("arden", "Arden Seating"), option("harbour", "Harbour Desk Co")]);
|
|
494
|
+
const [supplier, setSupplier] = useState(null);
|
|
495
|
+
const [asked, setAsked] = useState(null);
|
|
496
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
497
|
+
className: "combo-stack",
|
|
498
|
+
children: [
|
|
499
|
+
/* @__PURE__ */ jsx(Field, {
|
|
500
|
+
label: "Collection",
|
|
501
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
502
|
+
options: COLLECTIONS,
|
|
503
|
+
placeholder: "Search collections",
|
|
504
|
+
noMatchHint: true,
|
|
505
|
+
createHref: "#no-match",
|
|
506
|
+
closeOnError: true
|
|
507
|
+
})
|
|
508
|
+
}),
|
|
509
|
+
/* @__PURE__ */ jsx(Field, {
|
|
510
|
+
label: "Menu link",
|
|
511
|
+
hint: "Pick a page, or type a web address",
|
|
512
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
513
|
+
options: PAGES,
|
|
514
|
+
placeholder: "Search pages or paste a link",
|
|
515
|
+
canCreate: (text) => /^https?:\/\/\S+\.\S+/.test(text),
|
|
516
|
+
onCreate: (text) => option(text, text)
|
|
517
|
+
})
|
|
518
|
+
}),
|
|
519
|
+
/* @__PURE__ */ jsx(Field, {
|
|
520
|
+
label: "Supplier",
|
|
521
|
+
hint: asked !== null ? `The Add a supplier dialog would open here${asked ? `, starting from "${asked}"` : ""}.` : void 0,
|
|
522
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
523
|
+
options: suppliers,
|
|
524
|
+
placeholder: "Search suppliers",
|
|
525
|
+
value: supplier,
|
|
526
|
+
onValueChange: setSupplier,
|
|
527
|
+
action: {
|
|
528
|
+
label: "Add a supplier",
|
|
529
|
+
onSelect: (term) => {
|
|
530
|
+
setAsked(term);
|
|
531
|
+
if (term) {
|
|
532
|
+
const made = option(term.toLowerCase().replace(/\W+/g, "-"), term);
|
|
533
|
+
setSuppliers((list) => [...list, made]);
|
|
534
|
+
setSupplier(made.value);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
})
|
|
539
|
+
})
|
|
540
|
+
]
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function Timezone() {
|
|
544
|
+
const [zone, setZone] = useState("lon");
|
|
545
|
+
return /* @__PURE__ */ jsx("div", {
|
|
546
|
+
className: "combo-stack",
|
|
547
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
548
|
+
label: "Timezone",
|
|
549
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
550
|
+
options: TIMEZONES,
|
|
551
|
+
value: zone,
|
|
552
|
+
onValueChange: setZone,
|
|
553
|
+
placeholder: "Search timezones"
|
|
554
|
+
})
|
|
555
|
+
})
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
function Narrow() {
|
|
559
|
+
return /* @__PURE__ */ jsx("div", {
|
|
560
|
+
className: "combo-narrow",
|
|
561
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
562
|
+
label: "Dial code",
|
|
563
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
564
|
+
options: COUNTRIES,
|
|
565
|
+
placeholder: "Code",
|
|
566
|
+
defaultValue: "gb"
|
|
567
|
+
})
|
|
568
|
+
})
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function Held({ children }) {
|
|
572
|
+
return /* @__PURE__ */ jsx("div", {
|
|
573
|
+
className: "combo-held",
|
|
574
|
+
children: children({
|
|
575
|
+
open: true,
|
|
576
|
+
onOpenChange: () => {}
|
|
577
|
+
})
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
function Page() {
|
|
581
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
582
|
+
title: "Combobox",
|
|
583
|
+
status: "new",
|
|
584
|
+
importNames: ["Combobox"],
|
|
585
|
+
lead: "The searchable select: a field that is the search box, with the results unfolding from under it. Pick one or several, from a list you hold or a server that answers a page at a time, create what is not there, and show rows with a picture, a second line and a figure.",
|
|
586
|
+
children: [
|
|
587
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
588
|
+
id: "playground",
|
|
589
|
+
title: "Playground",
|
|
590
|
+
description: /* @__PURE__ */ jsx("p", { children: "Open the field, type to filter, and use the arrow keys, Enter and Escape. Change the props to see each variant." }),
|
|
591
|
+
children: /* @__PURE__ */ jsx(Playground, {
|
|
592
|
+
component: "Combobox",
|
|
593
|
+
controls: PLAYGROUND,
|
|
594
|
+
minHeight: 540,
|
|
595
|
+
extraCode: (v) => ["options={countries}", ...v.multiple ? [] : ["value={country}", "onValueChange={setCountry}"]],
|
|
596
|
+
render: (v) => {
|
|
597
|
+
const props = {
|
|
598
|
+
multiple: Boolean(v.multiple),
|
|
599
|
+
options: COUNTRIES,
|
|
600
|
+
"aria-label": "Country",
|
|
601
|
+
placeholder: "Search countries",
|
|
602
|
+
searchable: Boolean(v.searchable),
|
|
603
|
+
clearable: Boolean(v.clearable),
|
|
604
|
+
presentation: v.presentation,
|
|
605
|
+
size: v.size,
|
|
606
|
+
openOnFocus: Boolean(v.openOnFocus),
|
|
607
|
+
invalid: Boolean(v.invalid),
|
|
608
|
+
disabled: Boolean(v.disabled),
|
|
609
|
+
defaultValue: v.multiple ? ["gb", "ie"] : "gb"
|
|
610
|
+
};
|
|
611
|
+
return /* @__PURE__ */ jsx("div", {
|
|
612
|
+
className: "combo-stage",
|
|
613
|
+
children: /* @__PURE__ */ jsx(Combobox, { ...props }, String(v.multiple))
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
})
|
|
617
|
+
}),
|
|
618
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
619
|
+
id: "single",
|
|
620
|
+
title: "Pick one",
|
|
621
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("p", { children: "The field shows the choice. Focus it and the choice becomes the placeholder over an empty search box; type to filter, press Enter or click to pick, and the list closes. The clear button empties it again." }), /* @__PURE__ */ jsxs("p", { children: [
|
|
622
|
+
"The value is a string, or ",
|
|
623
|
+
/* @__PURE__ */ jsx("code", { children: "null" }),
|
|
624
|
+
" for nothing chosen. Pass ",
|
|
625
|
+
/* @__PURE__ */ jsx("code", { children: "value" }),
|
|
626
|
+
" and",
|
|
627
|
+
" ",
|
|
628
|
+
/* @__PURE__ */ jsx("code", { children: "onValueChange" }),
|
|
629
|
+
", or ",
|
|
630
|
+
/* @__PURE__ */ jsx("code", { children: "defaultValue" }),
|
|
631
|
+
" to let it keep its own."
|
|
632
|
+
] })] }),
|
|
633
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
634
|
+
align: "start",
|
|
635
|
+
minHeight: 570,
|
|
636
|
+
code: `
|
|
637
|
+
const [country, setCountry] = useState<string | null>('gb')
|
|
638
|
+
|
|
639
|
+
<Field label="Country" hint="Where you ship from">
|
|
640
|
+
<Combobox
|
|
641
|
+
options={countries}
|
|
642
|
+
placeholder="Search countries"
|
|
643
|
+
value={country}
|
|
644
|
+
onValueChange={setCountry}
|
|
645
|
+
/>
|
|
646
|
+
</Field>`,
|
|
647
|
+
children: /* @__PURE__ */ jsx(Country, {})
|
|
648
|
+
})
|
|
649
|
+
}),
|
|
650
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
651
|
+
id: "multiple",
|
|
652
|
+
title: "Pick several",
|
|
653
|
+
description: /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "multiple" }), " keeps the list open as you pick, puts a check on each row, and shows the picks under the field as pills, with \"Remove all\" from two and \"Undo\" after it. A pill in the field counts them. The value is an array, in the order picked."] }),
|
|
654
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
655
|
+
align: "start",
|
|
656
|
+
minHeight: 490,
|
|
657
|
+
code: `
|
|
658
|
+
const [picked, setPicked] = useState(['outdoor', 'shelter'])
|
|
659
|
+
|
|
660
|
+
<Field label="Categories" hint="Pick as many as fit">
|
|
661
|
+
<Combobox
|
|
662
|
+
multiple
|
|
663
|
+
options={categories}
|
|
664
|
+
placeholder="Search categories"
|
|
665
|
+
value={picked}
|
|
666
|
+
onValueChange={setPicked}
|
|
667
|
+
/>
|
|
668
|
+
</Field>`,
|
|
669
|
+
children: /* @__PURE__ */ jsx(Categories, {})
|
|
670
|
+
})
|
|
671
|
+
}),
|
|
672
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
673
|
+
id: "locked",
|
|
674
|
+
title: "Picks the rules own",
|
|
675
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
676
|
+
"Set ",
|
|
677
|
+
/* @__PURE__ */ jsx("code", { children: "removable: false" }),
|
|
678
|
+
" on an option that is not the person's to take away: a category a rule adds, a plan's default. Its pill has no remove button, \"Remove all\" leaves it (and does not count it towards the two picks that offer it), and pressing its row in the list does nothing, so it cannot be removed from there either. In a single field it hides the clear button; the choice can still be changed."
|
|
679
|
+
] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
680
|
+
/* @__PURE__ */ jsx("code", { children: "tone" }),
|
|
681
|
+
" colours the pill with one of the ",
|
|
682
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
683
|
+
to: "/components/badge",
|
|
684
|
+
children: "Badge"
|
|
685
|
+
}),
|
|
686
|
+
"'s tones. Colour is not the only sign, and should not be the one you name: a locked pill has no remove button, so say that in the field's hint, as here."
|
|
687
|
+
] })] }),
|
|
688
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
689
|
+
align: "start",
|
|
690
|
+
minHeight: 420,
|
|
691
|
+
code: `
|
|
692
|
+
<Combobox
|
|
693
|
+
multiple
|
|
694
|
+
options={[
|
|
695
|
+
{ value: 'camping', label: 'Camping' },
|
|
696
|
+
{ value: 'on-sale', label: 'On sale', removable: false, tone: 'warning' },
|
|
697
|
+
]}
|
|
698
|
+
value={picked}
|
|
699
|
+
onValueChange={setPicked}
|
|
700
|
+
/>`,
|
|
701
|
+
children: /* @__PURE__ */ jsx(Smart, {})
|
|
702
|
+
})
|
|
703
|
+
}),
|
|
704
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
705
|
+
id: "rich",
|
|
706
|
+
title: "Rows with a picture and figures",
|
|
707
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
708
|
+
"An option can carry ",
|
|
709
|
+
/* @__PURE__ */ jsx("code", { children: "image" }),
|
|
710
|
+
", ",
|
|
711
|
+
/* @__PURE__ */ jsx("code", { children: "description" }),
|
|
712
|
+
" and ",
|
|
713
|
+
/* @__PURE__ */ jsx("code", { children: "aside" }),
|
|
714
|
+
" (a price, \"36 in stock\"). Rows then grow to 52px with a 36px thumbnail; an option with no picture gets a neutral tile so the labels line up. ",
|
|
715
|
+
/* @__PURE__ */ jsx("code", { children: "selectedDisplay=\"rows\"" }),
|
|
716
|
+
" lists the picks under the field with the same details and a remove button each. For anything else, ",
|
|
717
|
+
/* @__PURE__ */ jsx("code", { children: "renderOption" }),
|
|
718
|
+
" draws the row's content."
|
|
719
|
+
] }),
|
|
720
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
721
|
+
align: "start",
|
|
722
|
+
minHeight: 590,
|
|
723
|
+
code: `
|
|
724
|
+
const products = items.map((item) => ({
|
|
725
|
+
value: item.id,
|
|
726
|
+
label: item.name,
|
|
727
|
+
image: item.thumbnail,
|
|
728
|
+
description: item.category,
|
|
729
|
+
aside: (<><span>{money(item.price)}</span><span>{item.stock} in stock</span></>),
|
|
730
|
+
}))
|
|
731
|
+
|
|
732
|
+
<Combobox multiple selectedDisplay="rows" options={products} placeholder="Search for products" />`,
|
|
733
|
+
children: /* @__PURE__ */ jsx(Linked, {})
|
|
734
|
+
})
|
|
735
|
+
}),
|
|
736
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
737
|
+
id: "server",
|
|
738
|
+
title: "Search a server",
|
|
739
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
740
|
+
"Give it ",
|
|
741
|
+
/* @__PURE__ */ jsx("code", { children: "onSearch" }),
|
|
742
|
+
" instead of ",
|
|
743
|
+
/* @__PURE__ */ jsx("code", { children: "options" }),
|
|
744
|
+
". It is asked for the first page when the list opens, a new first page 300ms after the typing stops, and the next page as the end of the list scrolls into view (or the arrow keys run out of rows). Return ",
|
|
745
|
+
/* @__PURE__ */ jsx("code", { children: "{ options, total }" }),
|
|
746
|
+
". The rows' shapes show while the first page loads, and the rows already there dim during a new search. An answer to a question that has been replaced is thrown away, and its ",
|
|
747
|
+
/* @__PURE__ */ jsx("code", { children: "signal" }),
|
|
748
|
+
" is aborted."
|
|
749
|
+
] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
750
|
+
"Picks that are not on the page it has loaded (the two saved here) are asked for by id with",
|
|
751
|
+
" ",
|
|
752
|
+
/* @__PURE__ */ jsx("code", { children: "onFetchByIds" }),
|
|
753
|
+
", so their pills have a name. Make a search fail to see the error, and \"Try again\". A first page that fails takes the rows away, since they belonged to the last search; a later page that fails keeps the rows that came, and \"Try again\" asks for that page."
|
|
754
|
+
] })] }),
|
|
755
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
756
|
+
align: "start",
|
|
757
|
+
minHeight: 570,
|
|
758
|
+
code: `
|
|
759
|
+
<Combobox
|
|
760
|
+
multiple
|
|
761
|
+
pageSize={8}
|
|
762
|
+
value={picked}
|
|
763
|
+
onValueChange={setPicked}
|
|
764
|
+
onSearch={async ({ term, page, pageSize, signal }) => {
|
|
765
|
+
const res = await fetch(\`/api/products?q=\${term}&page=\${page}&limit=\${pageSize}\`, { signal })
|
|
766
|
+
const { items, total } = await res.json()
|
|
767
|
+
return { options: items.map(toOption), total }
|
|
768
|
+
}}
|
|
769
|
+
onFetchByIds={async (ids) => (await getProducts(ids)).map(toOption)}
|
|
770
|
+
/>`,
|
|
771
|
+
children: /* @__PURE__ */ jsx(Server, {})
|
|
772
|
+
})
|
|
773
|
+
}),
|
|
774
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
775
|
+
id: "create",
|
|
776
|
+
title: "Create as you type",
|
|
777
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
778
|
+
/* @__PURE__ */ jsx("code", { children: "onCreate" }),
|
|
779
|
+
" puts an ",
|
|
780
|
+
/* @__PURE__ */ jsx("code", { children: "Add \"…\"" }),
|
|
781
|
+
" row first in the list when what was typed matches no option exactly, so Enter creates it. Return the new option and it is picked; return nothing and what happens next is yours. The list closes and the search clears. This is also how a typed value stands in for a choice, such as a county the list does not hold."
|
|
782
|
+
] }),
|
|
783
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
784
|
+
align: "start",
|
|
785
|
+
minHeight: 440,
|
|
786
|
+
code: `
|
|
787
|
+
<Combobox
|
|
788
|
+
options={brands}
|
|
789
|
+
value={brand}
|
|
790
|
+
onValueChange={setBrand}
|
|
791
|
+
onCreate={(text) => {
|
|
792
|
+
const made = { value: slug(text), label: text }
|
|
793
|
+
setBrands((list) => [...list, made])
|
|
794
|
+
return made
|
|
795
|
+
}}
|
|
796
|
+
/>`,
|
|
797
|
+
children: /* @__PURE__ */ jsx(Brand, {})
|
|
798
|
+
})
|
|
799
|
+
}),
|
|
800
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
801
|
+
id: "no-match",
|
|
802
|
+
title: "When nothing matches",
|
|
803
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
804
|
+
"Where a list cannot create what it lacks, say so under the field. ",
|
|
805
|
+
/* @__PURE__ */ jsx("code", { children: "noMatchHint" }),
|
|
806
|
+
" adds a line while what is typed matches nothing: \"This does not exist yet.\", or your own words. ",
|
|
807
|
+
/* @__PURE__ */ jsx("code", { children: "createHref" }),
|
|
808
|
+
" ",
|
|
809
|
+
"adds \"Create one\", a link to the page where it can be made, opened in a new tab so the form being filled is kept. Tab from the field keeps the line, so the keyboard reaches the link. ",
|
|
810
|
+
/* @__PURE__ */ jsx("code", { children: "closeOnError" }),
|
|
811
|
+
" ",
|
|
812
|
+
"folds the list away while nothing matches, so the line is all there is to read; it comes back as soon as something does."
|
|
813
|
+
] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
814
|
+
/* @__PURE__ */ jsx("code", { children: "canCreate" }),
|
|
815
|
+
" gates the Add row, for lists where only some text can be made (a menu link must be a web address). ",
|
|
816
|
+
/* @__PURE__ */ jsx("code", { children: "action" }),
|
|
817
|
+
" ends the list with a row that is always there, whatever is typed: \"Add a supplier\", opening a dialog. It is picked like an option and is handed what was typed."
|
|
818
|
+
] })] }),
|
|
819
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
820
|
+
align: "start",
|
|
821
|
+
minHeight: 420,
|
|
822
|
+
code: `
|
|
823
|
+
<Field label="Collection">
|
|
824
|
+
<Combobox options={collections} noMatchHint createHref="/collections/new" closeOnError />
|
|
825
|
+
</Field>
|
|
826
|
+
<Field label="Menu link" hint="Pick a page, or type a web address">
|
|
827
|
+
<Combobox
|
|
828
|
+
options={pages}
|
|
829
|
+
canCreate={(text) => /^https?:\/\/\S+\.\S+/.test(text)}
|
|
830
|
+
onCreate={(text) => ({ value: text, label: text })}
|
|
831
|
+
/>
|
|
832
|
+
</Field>
|
|
833
|
+
<Field label="Supplier">
|
|
834
|
+
<Combobox options={suppliers} action={{ label: 'Add a supplier', onSelect: openSupplierDialog }} />
|
|
835
|
+
</Field>`,
|
|
836
|
+
children: /* @__PURE__ */ jsx(NoMatch, {})
|
|
837
|
+
})
|
|
838
|
+
}),
|
|
839
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
840
|
+
id: "groups",
|
|
841
|
+
title: "Groups",
|
|
842
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
843
|
+
"Options with the same ",
|
|
844
|
+
/* @__PURE__ */ jsx("code", { children: "group" }),
|
|
845
|
+
" sit together under a quiet heading, after any with no group. The arrow keys move through them in the order they are drawn, and the groups are named for assistive tech."
|
|
846
|
+
] }),
|
|
847
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
848
|
+
align: "start",
|
|
849
|
+
minHeight: 570,
|
|
850
|
+
code: `<Combobox options={[{ value: 'lon', label: 'London', group: 'Europe' }, …]} />`,
|
|
851
|
+
children: /* @__PURE__ */ jsx(Timezone, {})
|
|
852
|
+
})
|
|
853
|
+
}),
|
|
854
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
855
|
+
id: "presentation",
|
|
856
|
+
title: "Where the results hang",
|
|
857
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
858
|
+
/* @__PURE__ */ jsx("code", { children: "attached" }),
|
|
859
|
+
" (the default) makes the field the top of the list: the field squares its lower corners and the list unfolds from its edge at its width, with a hairline between. ",
|
|
860
|
+
/* @__PURE__ */ jsx("code", { children: "popover" }),
|
|
861
|
+
" always floats a sheet 6px below the field instead."
|
|
862
|
+
] }), /* @__PURE__ */ jsx("p", { children: "A field under 280px wide cannot lend the list its width, so it floats a sheet either way. The sheet is at least 280px wide. Here the field is 180px. A field in the right of its card lines the sheet up with its own right edge, so the sheet stays over the card instead of hanging off its side." })] }),
|
|
863
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
864
|
+
align: "start",
|
|
865
|
+
minHeight: 570,
|
|
866
|
+
code: `<Combobox presentation="popover" options={options} />`,
|
|
867
|
+
children: /* @__PURE__ */ jsx(Narrow, {})
|
|
868
|
+
})
|
|
869
|
+
}),
|
|
870
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
871
|
+
id: "states",
|
|
872
|
+
title: "States",
|
|
873
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
874
|
+
"Closed, open, loading, empty, failed, with picks (some locked and toned), invalid, disabled and read-only (",
|
|
875
|
+
/* @__PURE__ */ jsxs("code", { children: ["searchable=", "{false}"] }),
|
|
876
|
+
"), in both themes. The lists here are held open so you can see them."
|
|
877
|
+
] }),
|
|
878
|
+
children: [
|
|
879
|
+
/* @__PURE__ */ jsx(ThemePair, {
|
|
880
|
+
align: "start",
|
|
881
|
+
minHeight: 450,
|
|
882
|
+
children: /* @__PURE__ */ jsx(Held, { children: (open) => /* @__PURE__ */ jsx(Combobox, {
|
|
883
|
+
"aria-label": "Category, open",
|
|
884
|
+
options: CATEGORIES,
|
|
885
|
+
defaultValue: "outdoor",
|
|
886
|
+
placeholder: "Search categories",
|
|
887
|
+
...open
|
|
888
|
+
}) })
|
|
889
|
+
}),
|
|
890
|
+
/* @__PURE__ */ jsx(ThemePair, {
|
|
891
|
+
align: "start",
|
|
892
|
+
minHeight: 520,
|
|
893
|
+
children: /* @__PURE__ */ jsx(Held, { children: (open) => /* @__PURE__ */ jsx(Combobox, {
|
|
894
|
+
multiple: true,
|
|
895
|
+
"aria-label": "Products, open",
|
|
896
|
+
options: PRODUCTS,
|
|
897
|
+
defaultValue: ["p0", "p3"],
|
|
898
|
+
selectedDisplay: "rows",
|
|
899
|
+
placeholder: "Search for products",
|
|
900
|
+
...open
|
|
901
|
+
}) })
|
|
902
|
+
}),
|
|
903
|
+
/* @__PURE__ */ jsx(ThemePair, {
|
|
904
|
+
align: "start",
|
|
905
|
+
minHeight: 330,
|
|
906
|
+
children: /* @__PURE__ */ jsx(Held, { children: (open) => /* @__PURE__ */ jsx(Combobox, {
|
|
907
|
+
"aria-label": "Products, loading",
|
|
908
|
+
placeholder: "Search for products",
|
|
909
|
+
onSearch: () => new Promise(() => {}),
|
|
910
|
+
...open
|
|
911
|
+
}) })
|
|
912
|
+
}),
|
|
913
|
+
/* @__PURE__ */ jsx(ThemePair, {
|
|
914
|
+
align: "start",
|
|
915
|
+
minHeight: 300,
|
|
916
|
+
children: /* @__PURE__ */ jsx(Held, { children: (open) => /* @__PURE__ */ jsx(Combobox, {
|
|
917
|
+
"aria-label": "Products, empty",
|
|
918
|
+
options: [],
|
|
919
|
+
placeholder: "Search for products",
|
|
920
|
+
notFoundMessage: "No products found",
|
|
921
|
+
...open
|
|
922
|
+
}) })
|
|
923
|
+
}),
|
|
924
|
+
/* @__PURE__ */ jsx(ThemePair, {
|
|
925
|
+
align: "start",
|
|
926
|
+
minHeight: 300,
|
|
927
|
+
children: /* @__PURE__ */ jsx(Held, { children: (open) => /* @__PURE__ */ jsx(Combobox, {
|
|
928
|
+
"aria-label": "Products, failed",
|
|
929
|
+
placeholder: "Search for products",
|
|
930
|
+
onSearch: () => Promise.reject(/* @__PURE__ */ new Error("The server did not answer")),
|
|
931
|
+
...open
|
|
932
|
+
}) })
|
|
933
|
+
}),
|
|
934
|
+
/* @__PURE__ */ jsx(ThemePair, {
|
|
935
|
+
align: "fill",
|
|
936
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
937
|
+
className: "combo-states",
|
|
938
|
+
children: [
|
|
939
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
940
|
+
"aria-label": "Locked picks",
|
|
941
|
+
multiple: true,
|
|
942
|
+
options: SMART,
|
|
943
|
+
defaultValue: ["camping", "on-sale"]
|
|
944
|
+
}),
|
|
945
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
946
|
+
"aria-label": "Empty",
|
|
947
|
+
options: CATEGORIES,
|
|
948
|
+
placeholder: "Search categories"
|
|
949
|
+
}),
|
|
950
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
951
|
+
"aria-label": "Chosen",
|
|
952
|
+
options: CATEGORIES,
|
|
953
|
+
defaultValue: "outdoor"
|
|
954
|
+
}),
|
|
955
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
956
|
+
"aria-label": "Several",
|
|
957
|
+
multiple: true,
|
|
958
|
+
options: CATEGORIES,
|
|
959
|
+
defaultValue: [
|
|
960
|
+
"apparel",
|
|
961
|
+
"outdoor",
|
|
962
|
+
"shelter"
|
|
963
|
+
]
|
|
964
|
+
}),
|
|
965
|
+
/* @__PURE__ */ jsx(Field, {
|
|
966
|
+
label: "Invalid",
|
|
967
|
+
error: "Choose a category",
|
|
968
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
969
|
+
options: CATEGORIES,
|
|
970
|
+
placeholder: "Search categories"
|
|
971
|
+
})
|
|
972
|
+
}),
|
|
973
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
974
|
+
"aria-label": "Disabled",
|
|
975
|
+
options: CATEGORIES,
|
|
976
|
+
defaultValue: "outdoor",
|
|
977
|
+
disabled: true
|
|
978
|
+
}),
|
|
979
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
980
|
+
"aria-label": "Read-only",
|
|
981
|
+
options: CATEGORIES,
|
|
982
|
+
defaultValue: "outdoor",
|
|
983
|
+
searchable: false
|
|
984
|
+
}),
|
|
985
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
986
|
+
"aria-label": "Small",
|
|
987
|
+
size: "sm",
|
|
988
|
+
options: CATEGORIES,
|
|
989
|
+
placeholder: "Small"
|
|
990
|
+
}),
|
|
991
|
+
/* @__PURE__ */ jsx(Combobox, {
|
|
992
|
+
"aria-label": "Large",
|
|
993
|
+
size: "lg",
|
|
994
|
+
options: CATEGORIES,
|
|
995
|
+
placeholder: "Large"
|
|
996
|
+
})
|
|
997
|
+
]
|
|
998
|
+
})
|
|
999
|
+
})
|
|
1000
|
+
]
|
|
1001
|
+
}),
|
|
1002
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1003
|
+
id: "guidelines",
|
|
1004
|
+
title: "Guidelines",
|
|
1005
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
1006
|
+
do: {
|
|
1007
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1008
|
+
className: "combo-narrow combo-narrow--wide",
|
|
1009
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
1010
|
+
"aria-label": "Brand",
|
|
1011
|
+
size: "sm",
|
|
1012
|
+
options: CATEGORIES,
|
|
1013
|
+
defaultValue: "outdoor"
|
|
1014
|
+
})
|
|
1015
|
+
}),
|
|
1016
|
+
caption: "Use it where there are more than a handful of choices, or the choices are searched for. The field says what is chosen."
|
|
1017
|
+
},
|
|
1018
|
+
dont: {
|
|
1019
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1020
|
+
className: "combo-narrow combo-narrow--wide",
|
|
1021
|
+
children: /* @__PURE__ */ jsx(Combobox, {
|
|
1022
|
+
"aria-label": "Yes or no",
|
|
1023
|
+
size: "sm",
|
|
1024
|
+
options: [{
|
|
1025
|
+
value: "y",
|
|
1026
|
+
label: "Yes"
|
|
1027
|
+
}, {
|
|
1028
|
+
value: "n",
|
|
1029
|
+
label: "No"
|
|
1030
|
+
}],
|
|
1031
|
+
defaultValue: "y"
|
|
1032
|
+
})
|
|
1033
|
+
}),
|
|
1034
|
+
caption: "Two or three choices are a segmented control or a select. Searching a list of two is a detour."
|
|
1035
|
+
}
|
|
1036
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1037
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1038
|
+
"For a short fixed list with no search, a ",
|
|
1039
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
1040
|
+
to: "/components/select",
|
|
1041
|
+
children: "Select"
|
|
1042
|
+
}),
|
|
1043
|
+
" is lighter. Reach for a Combobox when people look an option up, when the list is long or comes from a server, or when they can add to it."
|
|
1044
|
+
] }),
|
|
1045
|
+
"Label the field in a Field. The label names the field and its list, and the placeholder says what to type.",
|
|
1046
|
+
"Give the rows what tells them apart: a picture for products, the price or stock as a figure, the category as a second line.",
|
|
1047
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1048
|
+
"Send ",
|
|
1049
|
+
/* @__PURE__ */ jsx("code", { children: "total" }),
|
|
1050
|
+
" from a server so the footer can say \"Showing 10 of 27\", and make the search match what people type, not only the start of a word."
|
|
1051
|
+
] }),
|
|
1052
|
+
"Keep the number of picks in a multiple field to what fits under it. For hundreds, pick in a dialog.",
|
|
1053
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1054
|
+
"Say what an empty search means in ",
|
|
1055
|
+
/* @__PURE__ */ jsx("code", { children: "notFoundMessage" }),
|
|
1056
|
+
" (\"No products found\"), and offer",
|
|
1057
|
+
" ",
|
|
1058
|
+
/* @__PURE__ */ jsx("code", { children: "onCreate" }),
|
|
1059
|
+
" only where adding is allowed."
|
|
1060
|
+
] })
|
|
1061
|
+
] })]
|
|
1062
|
+
}),
|
|
1063
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
1064
|
+
id: "accessibility",
|
|
1065
|
+
title: "Accessibility",
|
|
1066
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1067
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1068
|
+
"It follows the ARIA 1.2 combobox: the input has ",
|
|
1069
|
+
/* @__PURE__ */ jsx("code", { children: "role=\"combobox\"" }),
|
|
1070
|
+
", ",
|
|
1071
|
+
/* @__PURE__ */ jsx("code", { children: "aria-expanded" }),
|
|
1072
|
+
",",
|
|
1073
|
+
" ",
|
|
1074
|
+
/* @__PURE__ */ jsx("code", { children: "aria-controls" }),
|
|
1075
|
+
" (the listbox, while open), ",
|
|
1076
|
+
/* @__PURE__ */ jsx("code", { children: "aria-autocomplete=\"list\"" }),
|
|
1077
|
+
" and",
|
|
1078
|
+
" ",
|
|
1079
|
+
/* @__PURE__ */ jsx("code", { children: "aria-activedescendant" }),
|
|
1080
|
+
" (the keyboard's row). The results are a ",
|
|
1081
|
+
/* @__PURE__ */ jsx("code", { children: "listbox" }),
|
|
1082
|
+
" of",
|
|
1083
|
+
" ",
|
|
1084
|
+
/* @__PURE__ */ jsx("code", { children: "option" }),
|
|
1085
|
+
"s with ",
|
|
1086
|
+
/* @__PURE__ */ jsx("code", { children: "aria-selected" }),
|
|
1087
|
+
", ",
|
|
1088
|
+
/* @__PURE__ */ jsx("code", { children: "aria-multiselectable" }),
|
|
1089
|
+
" when several can be picked, and ",
|
|
1090
|
+
/* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
|
|
1091
|
+
" where an option cannot. The sheet around the list is not a dialog."
|
|
1092
|
+
] }),
|
|
1093
|
+
"Focus never leaves the field. Arrow keys move the active row and skip disabled ones, Enter picks (or creates), Escape closes (and clears what was typed, but not a chosen value: the clear button does that), Tab closes and goes on. Home and End move the caret, unless the field is read only, where they move through the rows. Presses inside the list do not take the caret.",
|
|
1094
|
+
"Tab takes the sheet away at once, so from the last control on a page focus never lands on a part of the sheet or on nothing. The sheet's Done and Try again are out of the tab order for that reason: Escape or Tab does what Done does, and the down arrow past the last row (or Enter, with nothing to pick) asks a failed search again, which the status says.",
|
|
1095
|
+
"While a new search is on its way the rows from the last one are dimmed and not for picking: Enter and clicks wait, the Add row included (an exact match may be on its way, so it is marked unavailable too), and no row is the active descendant until the answer lands. A create is the same: a second Enter does nothing while it is pending, and a refusal is said in the status and under the list.",
|
|
1096
|
+
/* @__PURE__ */ jsx(Fragment$1, { children: "One polite status, in the page from the start, says how many results there are as they change (\"5 results available\"), that they are loading (or that more are), that the search failed, or that nothing matched, and each pick and removal (\"Outdoor selected\", said as the list closes on a single pick). It is not the footer, which is drawn for the eye." }),
|
|
1097
|
+
"The label of a Field names the field and the list. The clear button and the pills' remove buttons say what they remove (\"Clear Brand\", \"Remove Apparel\"), and \"Remove all\" puts the focus on \"Undo\".",
|
|
1098
|
+
"Picks are listed under the field as a list, so a screen reader counts them; the pill inside the field is decoration.",
|
|
1099
|
+
"The check and the tick are drawn, not announced: aria-selected carries the state. Row words are 14px ink; the active row takes a quiet highlight, and a picked row is marked by its tick (or its check) rather than by a colour.",
|
|
1100
|
+
"Under reduced motion the list fades in instead of unfolding and a new pick does not open its space."
|
|
1101
|
+
] })
|
|
1102
|
+
}),
|
|
1103
|
+
/* @__PURE__ */ jsx(Fragment$1, {}),
|
|
1104
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1105
|
+
id: "props",
|
|
1106
|
+
title: "Props",
|
|
1107
|
+
children: [
|
|
1108
|
+
/* @__PURE__ */ jsx(PropsTable, { rows: [
|
|
1109
|
+
{
|
|
1110
|
+
name: "options",
|
|
1111
|
+
type: "ComboboxOption[]",
|
|
1112
|
+
description: "The list, for one you hold: a search filters it as you type. With onSearch it is not searched, but still names picks."
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
name: "onSearch",
|
|
1116
|
+
type: "(query: ComboboxQuery) => Promise<ComboboxPage>",
|
|
1117
|
+
description: "Asks a server instead: the first page on open, a new one after the typing pauses, the next on scrolling."
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
name: "pageSize, searchDelay",
|
|
1121
|
+
type: "number",
|
|
1122
|
+
default: "10, 300",
|
|
1123
|
+
description: "Options per page, and how long the typing must pause (ms)."
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
name: "onFetchByIds",
|
|
1127
|
+
type: "(values: string[]) => Promise<ComboboxOption[]>",
|
|
1128
|
+
description: "Names the picks that are not among the options it has loaded. Until it answers they are shapes; one it could not name shows its value, with a remove button, and a failed lookup is asked again when the list opens."
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
name: "loading",
|
|
1132
|
+
type: "boolean",
|
|
1133
|
+
description: "The options you hold are on their way: skeleton rows show."
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
name: "filter",
|
|
1137
|
+
type: "(option, term) => boolean",
|
|
1138
|
+
description: "How a term matches. Default: what was typed, as one piece, anywhere in the label or keywords, any case; defaultComboboxFilter is exported to build on."
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
name: "multiple",
|
|
1142
|
+
type: "boolean",
|
|
1143
|
+
default: "false",
|
|
1144
|
+
description: "Pick several. The value is then an array."
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
name: "value, defaultValue",
|
|
1148
|
+
type: "string | null, or string[] with multiple",
|
|
1149
|
+
description: "Controlled, or the starting value."
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
name: "onValueChange",
|
|
1153
|
+
type: "(value, option?) => void",
|
|
1154
|
+
description: "Called with the new value and the option picked, removed or created."
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
name: "selectedDisplay",
|
|
1158
|
+
type: "'chips' | 'rows' | 'none'",
|
|
1159
|
+
default: "'chips'",
|
|
1160
|
+
description: "With multiple: how the picks show under the field."
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
name: "searchable",
|
|
1164
|
+
type: "boolean",
|
|
1165
|
+
default: "true",
|
|
1166
|
+
description: "false makes the field read only: a select that unfolds under itself."
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
name: "clearable",
|
|
1170
|
+
type: "boolean",
|
|
1171
|
+
default: "true",
|
|
1172
|
+
description: "The clear button of a single field, and \"Remove all\" and the pills' remove buttons of a multiple one."
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
name: "placeholder",
|
|
1176
|
+
type: "string",
|
|
1177
|
+
description: "The empty field. A single field's choice shows here while open."
|
|
1178
|
+
},
|
|
1179
|
+
{
|
|
1180
|
+
name: "notFoundMessage",
|
|
1181
|
+
type: "ReactNode",
|
|
1182
|
+
default: "'No results found'",
|
|
1183
|
+
description: "Under the list when nothing matches. The polite status says it too: a string as it is, anything else as labels.notFound."
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
name: "onCreate",
|
|
1187
|
+
type: "(term) => ComboboxOption | void | Promise<…>",
|
|
1188
|
+
description: "Puts an Add row first when nothing on show matches exactly (with onSearch, the pages loaded so far); Enter creates. Return the option to have it picked. A second Enter does nothing while it is pending; if it rejects, the list and the text stay and say so, with the error's message."
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
name: "canCreate",
|
|
1192
|
+
type: "(term) => boolean",
|
|
1193
|
+
description: "Offers the Add row only for text that passes: a menu link that must be a web address."
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
name: "noMatchHint",
|
|
1197
|
+
type: "boolean | ReactNode",
|
|
1198
|
+
description: "A line under the field while what is typed matches nothing and cannot be created: \"This does not exist yet.\", or your words."
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
name: "createHref",
|
|
1202
|
+
type: "string",
|
|
1203
|
+
description: "Adds \"Create one\" to that line: a link, in a new tab, to where it can be made."
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
name: "closeOnError",
|
|
1207
|
+
type: "boolean",
|
|
1208
|
+
default: "false",
|
|
1209
|
+
description: "Folds the list away while nothing matches, leaving the text and the line."
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
name: "action",
|
|
1213
|
+
type: "{ label, icon?, onSelect(term) }",
|
|
1214
|
+
description: "A row that ends the list whatever is typed: \"Add a supplier\". Picked like an option; closes the list."
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
name: "presentation",
|
|
1218
|
+
type: "'attached' | 'popover'",
|
|
1219
|
+
default: "'attached'",
|
|
1220
|
+
description: "Unfolds from the field, or floats a sheet below it. Under 280px wide it floats either way."
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
name: "openOnFocus",
|
|
1224
|
+
type: "boolean",
|
|
1225
|
+
default: "true",
|
|
1226
|
+
description: "Opens when the field gets focus. false: a click or an arrow opens it."
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
name: "footer",
|
|
1230
|
+
type: "boolean",
|
|
1231
|
+
default: "true",
|
|
1232
|
+
description: "\"Showing 10 of 27\" and Done."
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
name: "open, defaultOpen, onOpenChange",
|
|
1236
|
+
type: "boolean, boolean, (open) => void",
|
|
1237
|
+
description: "Controlled open state."
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
name: "onSearchTermChange",
|
|
1241
|
+
type: "(term: string) => void",
|
|
1242
|
+
description: "What is typed, and an empty string on close."
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
name: "renderOption",
|
|
1246
|
+
type: "(option, { selected, active }) => ReactNode",
|
|
1247
|
+
description: "Draws the content of a row."
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
name: "labels",
|
|
1251
|
+
type: "Partial<ComboboxLabels>",
|
|
1252
|
+
description: "Words for another language. Anything left out stays English; comboboxLabels is the English set."
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
name: "name",
|
|
1256
|
+
type: "string",
|
|
1257
|
+
description: "For a form: a hidden input for each picked value (a single field sends an empty one when nothing is picked)."
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
name: "size, invalid, disabled, required",
|
|
1261
|
+
type: "as Input",
|
|
1262
|
+
description: "The field is an Input. required is said to assistive tech; the browser does not validate it."
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
name: "popoverContainer",
|
|
1266
|
+
type: "HTMLElement | null",
|
|
1267
|
+
description: "Where the list is portalled. Default the layer of the dialog or sheet the field is in, else the body; null keeps it on the page."
|
|
1268
|
+
}
|
|
1269
|
+
] }),
|
|
1270
|
+
/* @__PURE__ */ jsxs("p", {
|
|
1271
|
+
className: "doc-section__description",
|
|
1272
|
+
children: [
|
|
1273
|
+
/* @__PURE__ */ jsx("code", { children: "ref" }),
|
|
1274
|
+
" goes to the input. ",
|
|
1275
|
+
/* @__PURE__ */ jsx("code", { children: "className" }),
|
|
1276
|
+
", ",
|
|
1277
|
+
/* @__PURE__ */ jsx("code", { children: "style" }),
|
|
1278
|
+
" and ",
|
|
1279
|
+
/* @__PURE__ */ jsx("code", { children: "data-*" }),
|
|
1280
|
+
" go to the wrapper. ",
|
|
1281
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
1282
|
+
", ",
|
|
1283
|
+
/* @__PURE__ */ jsx("code", { children: "aria-labelledby" }),
|
|
1284
|
+
" and ",
|
|
1285
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
|
|
1286
|
+
" go to the input, and name the list too. Put it in a ",
|
|
1287
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
1288
|
+
to: "/components/input#field",
|
|
1289
|
+
children: "Field"
|
|
1290
|
+
}),
|
|
1291
|
+
"."
|
|
1292
|
+
]
|
|
1293
|
+
}),
|
|
1294
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
1295
|
+
title: "ComboboxOption",
|
|
1296
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
1297
|
+
columns: ["Field", "Meaning"],
|
|
1298
|
+
rows: [
|
|
1299
|
+
[/* @__PURE__ */ jsx("code", { children: "value" }, "1"), "Unique among the options, and never an empty string."],
|
|
1300
|
+
[/* @__PURE__ */ jsx("code", { children: "label" }, "2"), "Plain text: the closed field, the pills and a search use it."],
|
|
1301
|
+
[/* @__PURE__ */ jsx("code", { children: "description" }, "3"), "A quieter second line."],
|
|
1302
|
+
[/* @__PURE__ */ jsx("code", { children: "aside" }, "4"), "A figure at the end of the row. A column: its first line reads at the label's size, and the rest hide in a narrow list."],
|
|
1303
|
+
[/* @__PURE__ */ jsx("code", { children: "image" }, "5"), "A thumbnail URL. Once any option has one, every row keeps a tile; null gets a neutral placeholder."],
|
|
1304
|
+
[/* @__PURE__ */ jsx("code", { children: "icon" }, "6"), "A 16px mark before the label."],
|
|
1305
|
+
[/* @__PURE__ */ jsx("code", { children: "disabled" }, "7"), "Drawn, but not pickable, and skipped by the arrow keys."],
|
|
1306
|
+
[/* @__PURE__ */ jsx("code", { children: "removable" }, "11"), "false locks the pick: no remove button, kept by \"Remove all\", and its row in the list does not unpick it. In a single field it hides the clear button."],
|
|
1307
|
+
[/* @__PURE__ */ jsx("code", { children: "tone" }, "12"), "The pill's tone, one of the Badge's: accent, positive, negative, warning, info (neutral is the plain pill). Say what it means in words too."],
|
|
1308
|
+
[/* @__PURE__ */ jsx("code", { children: "group" }, "8"), "Rows with the same group sit under a quiet heading."],
|
|
1309
|
+
[/* @__PURE__ */ jsx("code", { children: "keywords" }, "9"), "Extra words a search matches: a code, a synonym."],
|
|
1310
|
+
[/* @__PURE__ */ jsx("code", { children: "data" }, "10"), "Your own record, handed back untouched."]
|
|
1311
|
+
]
|
|
1312
|
+
})
|
|
1313
|
+
}),
|
|
1314
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
1315
|
+
title: "ComboboxQuery and ComboboxPage",
|
|
1316
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
1317
|
+
columns: ["Field", "Meaning"],
|
|
1318
|
+
rows: [
|
|
1319
|
+
[/* @__PURE__ */ jsx("code", { children: "term, page, pageSize" }, "1"), "What was typed (empty when the list opens), 1 for a new search then 2, 3 as it scrolls, and how many to return."],
|
|
1320
|
+
[/* @__PURE__ */ jsx("code", { children: "signal" }, "2"), "Aborted when a newer search replaces this one or the list closes. Pass it to fetch."],
|
|
1321
|
+
[/* @__PURE__ */ jsx("code", { children: "options" }, "3"), "This page's options."],
|
|
1322
|
+
[/* @__PURE__ */ jsx("code", { children: "total" }, "4"), "How many there are in all: \"Showing 10 of 27\", and whether there is another page."],
|
|
1323
|
+
[/* @__PURE__ */ jsx("code", { children: "hasMore" }, "5"), "Overrides what total and the page size say about another page."]
|
|
1324
|
+
]
|
|
1325
|
+
})
|
|
1326
|
+
}),
|
|
1327
|
+
/* @__PURE__ */ jsx(Note, { children: "Combobox is a client component. Its list opens on focus, so a long form has a list open for each field the keyboard passes: Tab closes it and goes on." })
|
|
1328
|
+
]
|
|
1329
|
+
})
|
|
1330
|
+
]
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
//#endregion
|
|
1334
|
+
export { Page, Preview };
|