@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,526 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { d as Section$1, i as DocPage, l as Note, o as Example, p as SubSection, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
3
|
+
import { useMemo, useRef, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Button, CaretSuggestions, Link, Textarea, matchSuggestions } from "@orbitcommerce/constellation";
|
|
6
|
+
import { ChatTextIcon, LightningIcon, PackageIcon, ShoppingCartIcon, UserIcon } from "@orbitcommerce/constellation/icons";
|
|
7
|
+
//#region src/pages/components/caret-suggestions.tsx
|
|
8
|
+
var SAVED_REPLIES = [
|
|
9
|
+
{
|
|
10
|
+
id: "refund",
|
|
11
|
+
label: "Refund on its way",
|
|
12
|
+
shortcut: "refund",
|
|
13
|
+
description: "Your refund has been sent and should reach you in 3 to 5 working days.",
|
|
14
|
+
body: "Hi Priya, your refund for order #10482 has been sent and should reach you in 3 to 5 working days."
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "delivery",
|
|
18
|
+
label: "Delivery times",
|
|
19
|
+
shortcut: "delivery",
|
|
20
|
+
description: "Most orders arrive in 2 to 4 working days.",
|
|
21
|
+
body: "Most orders arrive in 2 to 4 working days. You will get a tracking link by email once it leaves our warehouse."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "returns",
|
|
25
|
+
label: "How to return an item",
|
|
26
|
+
shortcut: "returns",
|
|
27
|
+
description: "Start a return from your account within 30 days.",
|
|
28
|
+
body: "You can start a return from your account within 30 days of delivery. We will email you a label."
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "assembly",
|
|
32
|
+
label: "Assembly help",
|
|
33
|
+
shortcut: "assembly",
|
|
34
|
+
description: "Arden chairs take about 15 minutes to put together.",
|
|
35
|
+
body: "The Arden chair takes about 15 minutes to assemble. The guide is in the box and on the product page."
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
var RECORDS = [
|
|
39
|
+
{
|
|
40
|
+
id: "p1",
|
|
41
|
+
kind: "product",
|
|
42
|
+
label: "Arden ergonomic chair",
|
|
43
|
+
description: "Product · Active",
|
|
44
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {})
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "p2",
|
|
48
|
+
kind: "product",
|
|
49
|
+
label: "Harbour standing desk",
|
|
50
|
+
description: "Product · Active",
|
|
51
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {})
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "o1",
|
|
55
|
+
kind: "order",
|
|
56
|
+
label: "#10482",
|
|
57
|
+
description: "Order · Awaiting stock",
|
|
58
|
+
icon: /* @__PURE__ */ jsx(ShoppingCartIcon, {})
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "o2",
|
|
62
|
+
kind: "order",
|
|
63
|
+
label: "#10491",
|
|
64
|
+
description: "Order · Dispatched",
|
|
65
|
+
icon: /* @__PURE__ */ jsx(ShoppingCartIcon, {})
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "c1",
|
|
69
|
+
kind: "customer",
|
|
70
|
+
label: "Priya Shah",
|
|
71
|
+
description: "priya@harbourdesk.co.uk",
|
|
72
|
+
icon: /* @__PURE__ */ jsx(UserIcon, {})
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "c2",
|
|
76
|
+
kind: "customer",
|
|
77
|
+
label: "Rhys Evans",
|
|
78
|
+
description: "rhys@ardenoffice.co.uk",
|
|
79
|
+
icon: /* @__PURE__ */ jsx(UserIcon, {})
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
var wait = (ms, signal) => new Promise((resolve, reject) => {
|
|
83
|
+
const timer = setTimeout(resolve, ms);
|
|
84
|
+
signal?.addEventListener("abort", () => {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
/** The saved replies: filtered at once, each rendered for the conversation "on the server" when picked. */
|
|
90
|
+
function savedReplies() {
|
|
91
|
+
return {
|
|
92
|
+
trigger: "/",
|
|
93
|
+
at: "start",
|
|
94
|
+
label: "Saved replies",
|
|
95
|
+
search: (query) => matchSuggestions(SAVED_REPLIES, query).map((reply) => ({
|
|
96
|
+
...reply,
|
|
97
|
+
icon: /* @__PURE__ */ jsx(LightningIcon, {})
|
|
98
|
+
})),
|
|
99
|
+
onSelect: async (reply) => {
|
|
100
|
+
await wait(450);
|
|
101
|
+
return reply.body;
|
|
102
|
+
},
|
|
103
|
+
empty: "No saved replies yet.",
|
|
104
|
+
noMatch: "No saved reply matches.",
|
|
105
|
+
footer: /* @__PURE__ */ jsx(Link, {
|
|
106
|
+
href: "#saved-replies",
|
|
107
|
+
children: "Manage saved replies"
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** A search across products, orders and customers, from two characters, after a pause. */
|
|
112
|
+
var MENTIONS = {
|
|
113
|
+
trigger: "@",
|
|
114
|
+
label: "Mention a product, order or customer",
|
|
115
|
+
minQuery: 2,
|
|
116
|
+
debounce: 250,
|
|
117
|
+
search: async (query, { signal }) => {
|
|
118
|
+
await wait(350, signal);
|
|
119
|
+
const q = query.toLowerCase();
|
|
120
|
+
return RECORDS.filter((record) => record.label.toLowerCase().includes(q) || String(record.description).toLowerCase().includes(q));
|
|
121
|
+
},
|
|
122
|
+
hint: "Type to search products, orders and customers",
|
|
123
|
+
noMatch: "No matches"
|
|
124
|
+
};
|
|
125
|
+
function SavedRepliesDemo() {
|
|
126
|
+
const field = useRef(null);
|
|
127
|
+
const [draft, setDraft] = useState("");
|
|
128
|
+
const sources = useMemo(() => [savedReplies()], []);
|
|
129
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
130
|
+
className: "caret-demo",
|
|
131
|
+
children: [/* @__PURE__ */ jsx(Textarea, {
|
|
132
|
+
ref: field,
|
|
133
|
+
"aria-label": "Reply",
|
|
134
|
+
placeholder: "Type \"/\" for a saved reply",
|
|
135
|
+
value: draft,
|
|
136
|
+
onChange: (e) => setDraft(e.target.value),
|
|
137
|
+
rows: 3
|
|
138
|
+
}), /* @__PURE__ */ jsx(CaretSuggestions, {
|
|
139
|
+
field,
|
|
140
|
+
sources
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function MentionsDemo() {
|
|
145
|
+
const field = useRef(null);
|
|
146
|
+
const [draft, setDraft] = useState("");
|
|
147
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
148
|
+
className: "caret-demo",
|
|
149
|
+
children: [/* @__PURE__ */ jsx(Textarea, {
|
|
150
|
+
ref: field,
|
|
151
|
+
"aria-label": "Ask Nebula",
|
|
152
|
+
placeholder: "Ask about an order: type \"@\" and two letters",
|
|
153
|
+
value: draft,
|
|
154
|
+
onChange: (e) => setDraft(e.target.value),
|
|
155
|
+
rows: 3
|
|
156
|
+
}), /* @__PURE__ */ jsx(CaretSuggestions, {
|
|
157
|
+
field,
|
|
158
|
+
sources: [MENTIONS],
|
|
159
|
+
anchor: "caret"
|
|
160
|
+
})]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function ButtonDemo() {
|
|
164
|
+
const field = useRef(null);
|
|
165
|
+
const list = useRef(null);
|
|
166
|
+
const [draft, setDraft] = useState("Thanks for getting in touch. ");
|
|
167
|
+
const sources = useMemo(() => [savedReplies()], []);
|
|
168
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
169
|
+
className: "caret-demo",
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ jsx(Textarea, {
|
|
172
|
+
ref: field,
|
|
173
|
+
"aria-label": "Reply",
|
|
174
|
+
value: draft,
|
|
175
|
+
onChange: (e) => setDraft(e.target.value),
|
|
176
|
+
rows: 3
|
|
177
|
+
}),
|
|
178
|
+
/* @__PURE__ */ jsx("div", {
|
|
179
|
+
className: "caret-demo__tools",
|
|
180
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
181
|
+
size: "sm",
|
|
182
|
+
variant: "secondary",
|
|
183
|
+
icon: /* @__PURE__ */ jsx(ChatTextIcon, {}),
|
|
184
|
+
onClick: () => list.current?.open("/"),
|
|
185
|
+
children: "Saved replies"
|
|
186
|
+
})
|
|
187
|
+
}),
|
|
188
|
+
/* @__PURE__ */ jsx(CaretSuggestions, {
|
|
189
|
+
ref: list,
|
|
190
|
+
field,
|
|
191
|
+
sources
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function Preview() {
|
|
197
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
198
|
+
className: "caret-preview",
|
|
199
|
+
"aria-hidden": "true",
|
|
200
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
201
|
+
className: "o-caret-suggestions caret-preview__sheet",
|
|
202
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
203
|
+
className: "o-caret-suggestions__option",
|
|
204
|
+
"data-active": "",
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ jsx("span", {
|
|
207
|
+
className: "o-caret-suggestions__icon",
|
|
208
|
+
children: /* @__PURE__ */ jsx(LightningIcon, {})
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ jsxs("span", {
|
|
211
|
+
className: "o-caret-suggestions__text",
|
|
212
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
213
|
+
className: "o-caret-suggestions__title",
|
|
214
|
+
children: "Refund on its way"
|
|
215
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
216
|
+
className: "o-caret-suggestions__description",
|
|
217
|
+
children: "Sent, 3 to 5 working days"
|
|
218
|
+
})]
|
|
219
|
+
}),
|
|
220
|
+
/* @__PURE__ */ jsx("span", {
|
|
221
|
+
className: "o-caret-suggestions__shortcut",
|
|
222
|
+
children: "/refund"
|
|
223
|
+
})
|
|
224
|
+
]
|
|
225
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
226
|
+
className: "o-caret-suggestions__option",
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ jsx("span", {
|
|
229
|
+
className: "o-caret-suggestions__icon",
|
|
230
|
+
children: /* @__PURE__ */ jsx(LightningIcon, {})
|
|
231
|
+
}),
|
|
232
|
+
/* @__PURE__ */ jsx("span", {
|
|
233
|
+
className: "o-caret-suggestions__text",
|
|
234
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
235
|
+
className: "o-caret-suggestions__title",
|
|
236
|
+
children: "Delivery times"
|
|
237
|
+
})
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ jsx("span", {
|
|
240
|
+
className: "o-caret-suggestions__shortcut",
|
|
241
|
+
children: "/delivery"
|
|
242
|
+
})
|
|
243
|
+
]
|
|
244
|
+
})]
|
|
245
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
246
|
+
className: "caret-preview__field",
|
|
247
|
+
children: "/re"
|
|
248
|
+
})]
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function Page() {
|
|
252
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
253
|
+
title: "Caret suggestions",
|
|
254
|
+
status: "new",
|
|
255
|
+
importNames: ["CaretSuggestions", "matchSuggestions"],
|
|
256
|
+
lead: "A list of suggestions for a text field it does not own: saved replies after a \"/\", a product, order or customer after an \"@\". Focus never leaves the field, so typing goes on as the list narrows.",
|
|
257
|
+
children: [
|
|
258
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
259
|
+
id: "saved-replies",
|
|
260
|
+
title: "Saved replies",
|
|
261
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
262
|
+
"Point it at the field with ",
|
|
263
|
+
/* @__PURE__ */ jsx("code", { children: "field" }),
|
|
264
|
+
" and give it a source per trigger. A ",
|
|
265
|
+
/* @__PURE__ */ jsx("code", { children: "start" }),
|
|
266
|
+
" trigger counts only as the draft's first character while the draft is one token, so \"/refund\" opens it and \"/refund please\" is a message. The arrows walk the rows round the ends, Enter picks, Shift and Enter still adds a line, and Escape closes it without closing a dialog round it. Here a pick is rendered for the conversation first (an async ",
|
|
267
|
+
/* @__PURE__ */ jsx("code", { children: "onSelect" }),
|
|
268
|
+
"), the row spinning meanwhile, and the reply takes the token's place, still editable."
|
|
269
|
+
] }),
|
|
270
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
271
|
+
align: "fill",
|
|
272
|
+
minHeight: 380,
|
|
273
|
+
code: `const replies: CaretSuggestionSource<SavedReply> = {
|
|
274
|
+
trigger: '/',
|
|
275
|
+
at: 'start',
|
|
276
|
+
label: 'Saved replies',
|
|
277
|
+
search: (query) => matchSuggestions(savedReplies, query),
|
|
278
|
+
onSelect: (reply) => renderForConversation(reply.id),
|
|
279
|
+
empty: 'No saved replies yet.',
|
|
280
|
+
noMatch: 'No saved reply matches.',
|
|
281
|
+
footer: <Link href="/live-chat/saved-replies">Manage saved replies</Link>,
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
<Textarea ref={field} value={draft} onChange={(e) => setDraft(e.target.value)} />
|
|
285
|
+
<CaretSuggestions field={field} sources={[replies]} />`,
|
|
286
|
+
children: /* @__PURE__ */ jsx(SavedRepliesDemo, {})
|
|
287
|
+
}), /* @__PURE__ */ jsxs(Note, { children: [/* @__PURE__ */ jsx("code", { children: "matchSuggestions" }), " ranks rows as a saved-reply list does: shortcuts that start with the query first, then titles that contain it, at most 8."] })]
|
|
288
|
+
}),
|
|
289
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
290
|
+
id: "search",
|
|
291
|
+
title: "A search, at the caret",
|
|
292
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
293
|
+
"A source whose ",
|
|
294
|
+
/* @__PURE__ */ jsx("code", { children: "search" }),
|
|
295
|
+
" returns a promise is a search: it waits for ",
|
|
296
|
+
/* @__PURE__ */ jsx("code", { children: "minQuery" }),
|
|
297
|
+
" characters (the ",
|
|
298
|
+
/* @__PURE__ */ jsx("code", { children: "hint" }),
|
|
299
|
+
" shows until then), runs ",
|
|
300
|
+
/* @__PURE__ */ jsx("code", { children: "debounce" }),
|
|
301
|
+
" milliseconds after the last keystroke, shows a loading line while it has nothing yet, and a newer search drops an older one (its ",
|
|
302
|
+
/* @__PURE__ */ jsx("code", { children: "signal" }),
|
|
303
|
+
" is aborted). ",
|
|
304
|
+
/* @__PURE__ */ jsx("code", { children: "anchor=\"caret\"" }),
|
|
305
|
+
" puts the list at the start of the token rather than over the field. By default a pick puts in the row's label, with a space unless one follows."
|
|
306
|
+
] }),
|
|
307
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
308
|
+
align: "fill",
|
|
309
|
+
minHeight: 380,
|
|
310
|
+
code: `const mentions: CaretSuggestionSource = {
|
|
311
|
+
trigger: '@',
|
|
312
|
+
label: 'Mention a product, order or customer',
|
|
313
|
+
minQuery: 2,
|
|
314
|
+
debounce: 250,
|
|
315
|
+
search: (query, { signal }) => searchRecords(query, { signal }),
|
|
316
|
+
hint: 'Type to search products, orders and customers',
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
<CaretSuggestions field={field} sources={[mentions]} anchor="caret" />`,
|
|
320
|
+
children: /* @__PURE__ */ jsx(MentionsDemo, {})
|
|
321
|
+
})
|
|
322
|
+
}),
|
|
323
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
324
|
+
id: "button",
|
|
325
|
+
title: "Opened from a button",
|
|
326
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
327
|
+
/* @__PURE__ */ jsx("code", { children: "open(trigger)" }),
|
|
328
|
+
" on the handle opens a source from a toolbar button. The whole draft is then the query, focus goes to the field (the caret where it was), and a pick goes in at the caret, a space either side where it would touch a word. If nothing matches the draft, a list opened this way closes rather than sit empty over the composer (",
|
|
329
|
+
/* @__PURE__ */ jsx("code", { children: "closeWhenEmpty" }),
|
|
330
|
+
")."
|
|
331
|
+
] }),
|
|
332
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
333
|
+
align: "fill",
|
|
334
|
+
minHeight: 380,
|
|
335
|
+
code: `const list = useRef<CaretSuggestionsHandle>(null)
|
|
336
|
+
|
|
337
|
+
<Button icon={<ChatTextIcon />} onClick={() => list.current?.open('/')}>Saved replies</Button>
|
|
338
|
+
<CaretSuggestions ref={list} field={field} sources={[replies]} />`,
|
|
339
|
+
children: /* @__PURE__ */ jsx(ButtonDemo, {})
|
|
340
|
+
})
|
|
341
|
+
}),
|
|
342
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
343
|
+
id: "guidelines",
|
|
344
|
+
title: "Guidelines",
|
|
345
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
346
|
+
"Use \"/\" at the start of the draft for things that replace it (a saved reply, a skill) and \"@\" inside a sentence for things that go into it (a mention).",
|
|
347
|
+
"Search records only from two characters and after a pause: one letter matches too much to help.",
|
|
348
|
+
"Say what to do on an empty list: \"No saved replies yet.\" with a Manage link, not a blank sheet.",
|
|
349
|
+
"Keep the field yours: the list writes into it as typing does, so a controlled field stays the one source of the draft."
|
|
350
|
+
] })
|
|
351
|
+
}),
|
|
352
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
353
|
+
id: "accessibility",
|
|
354
|
+
title: "Accessibility",
|
|
355
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
356
|
+
"Focus stays in the field. While the list is open the field points at it (aria-controls) and at the highlighted row (aria-activedescendant), with aria-autocomplete=\"list\", and lets go of both when it closes.",
|
|
357
|
+
"The list is a listbox named for its source; rows are options with aria-selected, a row that is off is aria-disabled and passed over, and a row being picked is aria-busy.",
|
|
358
|
+
"A polite status that is in the page from the start says how many rows there are (\"3 suggestions\"), or the empty or no-match line.",
|
|
359
|
+
"Escape closes the list and goes no further, so a dialog or sheet round the composer stays open; the list then stays shut until the draft or the caret moves."
|
|
360
|
+
] })
|
|
361
|
+
}),
|
|
362
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
363
|
+
id: "props",
|
|
364
|
+
title: "Props",
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
367
|
+
title: "CaretSuggestions",
|
|
368
|
+
rows: [
|
|
369
|
+
{
|
|
370
|
+
name: "field",
|
|
371
|
+
type: "RefObject<HTMLTextAreaElement | HTMLInputElement>",
|
|
372
|
+
required: true,
|
|
373
|
+
description: "The field it serves, which keeps focus."
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
name: "sources",
|
|
377
|
+
type: "CaretSuggestionSource[]",
|
|
378
|
+
required: true,
|
|
379
|
+
description: "One per trigger."
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
name: "anchor",
|
|
383
|
+
type: "'field' | 'caret' | RefObject<Element>",
|
|
384
|
+
default: "'field'",
|
|
385
|
+
description: "What the list sits against: the field, the token at the caret, or an element of yours (a composer card)."
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
name: "side",
|
|
389
|
+
type: "'top' | 'bottom'",
|
|
390
|
+
default: "'top'",
|
|
391
|
+
description: "The side it prefers. It flips when there is no room."
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
name: "width",
|
|
395
|
+
type: "number | 'anchor'",
|
|
396
|
+
description: "As wide as the anchor (the default against an element), or that many px (320 at the caret)."
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: "disabled",
|
|
400
|
+
type: "boolean",
|
|
401
|
+
default: "false",
|
|
402
|
+
description: "Opens nothing."
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "container",
|
|
406
|
+
type: "HTMLElement | null",
|
|
407
|
+
description: "Where it portals. Default the dialog or sheet it is in, else the page."
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "onOpenChange",
|
|
411
|
+
type: "(open: boolean) => void",
|
|
412
|
+
description: "Told as it opens and closes."
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
name: "labels",
|
|
416
|
+
type: "Partial<CaretSuggestionsLabels>",
|
|
417
|
+
description: "loading, noMatch, failed, results(count)."
|
|
418
|
+
}
|
|
419
|
+
]
|
|
420
|
+
}),
|
|
421
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
422
|
+
title: "CaretSuggestionSource",
|
|
423
|
+
children: /* @__PURE__ */ jsx(PropsTable, { rows: [
|
|
424
|
+
{
|
|
425
|
+
name: "trigger",
|
|
426
|
+
type: "string",
|
|
427
|
+
required: true,
|
|
428
|
+
description: "The character that opens it."
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
name: "at",
|
|
432
|
+
type: "'start' | 'word'",
|
|
433
|
+
default: "'word'",
|
|
434
|
+
description: "The draft’s first character only, or the start of any word."
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: "label",
|
|
438
|
+
type: "string",
|
|
439
|
+
required: true,
|
|
440
|
+
description: "Names the list."
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: "search",
|
|
444
|
+
type: "(query, { signal, opened }) => T[] | Promise<T[]>",
|
|
445
|
+
required: true,
|
|
446
|
+
description: "The rows for a query: at once, or a search."
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
name: "minQuery",
|
|
450
|
+
type: "number",
|
|
451
|
+
default: "0",
|
|
452
|
+
description: "The fewest characters to search on."
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: "debounce",
|
|
456
|
+
type: "number",
|
|
457
|
+
default: "0",
|
|
458
|
+
description: "The pause after the last keystroke, in ms."
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
name: "onSelect",
|
|
462
|
+
type: "(item, pick) => string | void | Promise<string | void>",
|
|
463
|
+
description: "The text to put in, or nothing when you wrote it yourself. Default the label and a space."
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
name: "hint, empty, noMatch, loading",
|
|
467
|
+
type: "ReactNode",
|
|
468
|
+
description: "The lines for too short a query, nothing at all, nothing matching, a search under way."
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
name: "footer",
|
|
472
|
+
type: "ReactNode",
|
|
473
|
+
description: "Under those lines: a Manage link."
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
name: "closeWhenEmpty",
|
|
477
|
+
type: "boolean",
|
|
478
|
+
default: "true",
|
|
479
|
+
description: "A list opened from a button closes when nothing matches."
|
|
480
|
+
}
|
|
481
|
+
] })
|
|
482
|
+
}),
|
|
483
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
484
|
+
title: "CaretSuggestion",
|
|
485
|
+
children: /* @__PURE__ */ jsx(PropsTable, { rows: [
|
|
486
|
+
{
|
|
487
|
+
name: "id",
|
|
488
|
+
type: "string",
|
|
489
|
+
required: true,
|
|
490
|
+
description: "Unique within the source."
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
name: "label",
|
|
494
|
+
type: "string",
|
|
495
|
+
required: true,
|
|
496
|
+
description: "The title, and what a pick puts in by default."
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
name: "description",
|
|
500
|
+
type: "ReactNode",
|
|
501
|
+
description: "A quiet second line."
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: "shortcut",
|
|
505
|
+
type: "string",
|
|
506
|
+
description: "Drawn at the end after the trigger: \"/refund\"."
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
name: "icon",
|
|
510
|
+
type: "ReactNode",
|
|
511
|
+
description: "A leading icon."
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
name: "disabled",
|
|
515
|
+
type: "boolean",
|
|
516
|
+
description: "Drawn, passed over and not picked."
|
|
517
|
+
}
|
|
518
|
+
] })
|
|
519
|
+
})
|
|
520
|
+
]
|
|
521
|
+
})
|
|
522
|
+
]
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
//#endregion
|
|
526
|
+
export { Page, Preview };
|