@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,424 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
import { d as Section$1, i as DocPage, l as Note, m as ThemePair, o as Example, p as SubSection, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Badge, IconButton, Input, SortableCard, SortableList, Switch, moveItem } from "@orbitcommerce/constellation";
|
|
7
|
+
import { CopyIcon, DotsSixVerticalIcon, TrashIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/sortable-card.tsx
|
|
9
|
+
/** A trade supplier's pricing rules, first match wins, so their order is the point. */
|
|
10
|
+
var RULES = [
|
|
11
|
+
{
|
|
12
|
+
id: "trade",
|
|
13
|
+
name: "Trade customers",
|
|
14
|
+
summary: "Flat · 3 conditions",
|
|
15
|
+
conditions: [
|
|
16
|
+
"Customer group is Trade",
|
|
17
|
+
"Brand is Arden",
|
|
18
|
+
"Quantity is 5 or more"
|
|
19
|
+
],
|
|
20
|
+
on: true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "clearance",
|
|
24
|
+
name: "Clearance lines",
|
|
25
|
+
summary: "20% off · 1 condition",
|
|
26
|
+
conditions: ["Tag is Clearance"],
|
|
27
|
+
on: true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "everyone",
|
|
31
|
+
name: "Everyone else",
|
|
32
|
+
summary: "List price · every product",
|
|
33
|
+
conditions: [],
|
|
34
|
+
on: false
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
/** One rule's body: what it applies to, as plain rows. */
|
|
38
|
+
function RuleBody({ rule }) {
|
|
39
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
40
|
+
className: "sortable-card-body",
|
|
41
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
42
|
+
className: "sortable-card-body__heading",
|
|
43
|
+
children: "Applies to"
|
|
44
|
+
}), rule.conditions.length ? /* @__PURE__ */ jsx("ul", {
|
|
45
|
+
className: "sortable-card-body__list",
|
|
46
|
+
children: rule.conditions.map((condition) => /* @__PURE__ */ jsx("li", { children: condition }, condition))
|
|
47
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
48
|
+
className: "sortable-card-body__empty",
|
|
49
|
+
children: "Every product"
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** The rule list: cards that open, reorder, fold while one moves. */
|
|
54
|
+
function Rules({ startOpen = true }) {
|
|
55
|
+
const [rules, setRules] = useState(RULES);
|
|
56
|
+
const set = (id, patch) => setRules((was) => was.map((rule) => rule.id === id ? {
|
|
57
|
+
...rule,
|
|
58
|
+
...patch
|
|
59
|
+
} : rule));
|
|
60
|
+
return /* @__PURE__ */ jsx("div", {
|
|
61
|
+
className: "sortable-card-stage",
|
|
62
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
63
|
+
"aria-label": "Pricing rules",
|
|
64
|
+
variant: "plain",
|
|
65
|
+
handlePlacement: "inside",
|
|
66
|
+
items: rules,
|
|
67
|
+
getKey: (rule) => rule.id,
|
|
68
|
+
getLabel: (rule) => rule.name,
|
|
69
|
+
onReorder: (from, to) => setRules((was) => moveItem(was, from, to)),
|
|
70
|
+
renderItem: (rule, state) => /* @__PURE__ */ jsx(SortableCard, {
|
|
71
|
+
handle: state.handle,
|
|
72
|
+
folded: state.sorting,
|
|
73
|
+
defaultOpen: startOpen && state.index === 0,
|
|
74
|
+
leading: /* @__PURE__ */ jsx("span", {
|
|
75
|
+
className: "sortable-card-place",
|
|
76
|
+
children: state.position + 1
|
|
77
|
+
}),
|
|
78
|
+
title: rule.name,
|
|
79
|
+
summary: rule.summary,
|
|
80
|
+
actions: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Switch, {
|
|
81
|
+
size: "sm",
|
|
82
|
+
checked: rule.on,
|
|
83
|
+
onCheckedChange: (on) => set(rule.id, { on }),
|
|
84
|
+
"aria-label": `${rule.name} on`
|
|
85
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
86
|
+
size: "sm",
|
|
87
|
+
variant: "ghost",
|
|
88
|
+
label: `Duplicate ${rule.name}`,
|
|
89
|
+
children: /* @__PURE__ */ jsx(CopyIcon, {
|
|
90
|
+
size: 16,
|
|
91
|
+
"aria-hidden": "true"
|
|
92
|
+
})
|
|
93
|
+
})] }),
|
|
94
|
+
children: /* @__PURE__ */ jsx(RuleBody, { rule })
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** A product's options: the title is a field, so the card is named by `label`. */
|
|
100
|
+
function Options() {
|
|
101
|
+
const [options, setOptions] = useState([{
|
|
102
|
+
id: "finish",
|
|
103
|
+
name: "Finish",
|
|
104
|
+
values: [
|
|
105
|
+
"Oak",
|
|
106
|
+
"Walnut",
|
|
107
|
+
"White"
|
|
108
|
+
]
|
|
109
|
+
}, {
|
|
110
|
+
id: "size",
|
|
111
|
+
name: "Size",
|
|
112
|
+
values: [
|
|
113
|
+
"1200mm",
|
|
114
|
+
"1400mm",
|
|
115
|
+
"1600mm"
|
|
116
|
+
]
|
|
117
|
+
}]);
|
|
118
|
+
return /* @__PURE__ */ jsx("div", {
|
|
119
|
+
className: "sortable-card-stage",
|
|
120
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
121
|
+
"aria-label": "Product options",
|
|
122
|
+
variant: "plain",
|
|
123
|
+
handlePlacement: "inside",
|
|
124
|
+
items: options,
|
|
125
|
+
getKey: (option) => option.id,
|
|
126
|
+
getLabel: (option) => option.name || "Untitled option",
|
|
127
|
+
onReorder: (from, to) => setOptions((was) => moveItem(was, from, to)),
|
|
128
|
+
renderItem: (option, state) => /* @__PURE__ */ jsx(SortableCard, {
|
|
129
|
+
handle: state.handle,
|
|
130
|
+
folded: state.dragging || state.lifted,
|
|
131
|
+
label: option.name || "Untitled option",
|
|
132
|
+
title: /* @__PURE__ */ jsx(Input, {
|
|
133
|
+
size: "sm",
|
|
134
|
+
"aria-label": "Option name",
|
|
135
|
+
value: option.name,
|
|
136
|
+
onChange: (event) => setOptions((was) => was.map((o) => o.id === option.id ? {
|
|
137
|
+
...o,
|
|
138
|
+
name: event.target.value
|
|
139
|
+
} : o))
|
|
140
|
+
}),
|
|
141
|
+
summary: `${option.values.length} values`,
|
|
142
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
143
|
+
className: "sortable-card-values",
|
|
144
|
+
children: option.values.map((value) => /* @__PURE__ */ jsx(Badge, {
|
|
145
|
+
size: "md",
|
|
146
|
+
children: value
|
|
147
|
+
}, value))
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/** Rows with nothing to open: a card designer's rows, a kind and a remove. */
|
|
154
|
+
function DesignerRows() {
|
|
155
|
+
const [rows, setRows] = useState([
|
|
156
|
+
"Image",
|
|
157
|
+
"Name",
|
|
158
|
+
"Price",
|
|
159
|
+
"SKU"
|
|
160
|
+
]);
|
|
161
|
+
return /* @__PURE__ */ jsx("div", {
|
|
162
|
+
className: "sortable-card-stage",
|
|
163
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
164
|
+
"aria-label": "Card rows",
|
|
165
|
+
variant: "plain",
|
|
166
|
+
handlePlacement: "inside",
|
|
167
|
+
items: rows,
|
|
168
|
+
getKey: (row) => row,
|
|
169
|
+
getLabel: (row) => row,
|
|
170
|
+
onReorder: (from, to) => setRows((was) => moveItem(was, from, to)),
|
|
171
|
+
renderItem: (row, state) => /* @__PURE__ */ jsx(SortableCard, {
|
|
172
|
+
handle: state.handle,
|
|
173
|
+
title: row,
|
|
174
|
+
actions: /* @__PURE__ */ jsx(IconButton, {
|
|
175
|
+
size: "sm",
|
|
176
|
+
variant: "ghost",
|
|
177
|
+
label: `Remove ${row}`,
|
|
178
|
+
onClick: () => setRows((was) => was.filter((r) => r !== row)),
|
|
179
|
+
children: /* @__PURE__ */ jsx(TrashIcon, {
|
|
180
|
+
size: 16,
|
|
181
|
+
"aria-hidden": "true"
|
|
182
|
+
})
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function Preview() {
|
|
189
|
+
return /* @__PURE__ */ jsx("div", {
|
|
190
|
+
className: "sortable-card-preview",
|
|
191
|
+
children: RULES.slice(0, 2).map((rule, index) => /* @__PURE__ */ jsx(SortableCard, {
|
|
192
|
+
handle: /* @__PURE__ */ jsx("span", {
|
|
193
|
+
className: "o-sortable-list__handle",
|
|
194
|
+
"aria-hidden": "true",
|
|
195
|
+
children: /* @__PURE__ */ jsx(DotsSixVerticalIcon, { size: 16 })
|
|
196
|
+
}),
|
|
197
|
+
title: rule.name,
|
|
198
|
+
summary: rule.summary,
|
|
199
|
+
defaultOpen: index === 0,
|
|
200
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
201
|
+
className: "sortable-card-body__empty",
|
|
202
|
+
children: rule.conditions[0]
|
|
203
|
+
})
|
|
204
|
+
}, rule.id))
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function Page() {
|
|
208
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
209
|
+
title: "Sortable card",
|
|
210
|
+
status: "new",
|
|
211
|
+
importNames: ["SortableCard", "sortableCardLabels"],
|
|
212
|
+
lead: "A card row of a sortable list that opens to show its body: a pricing rule, a product option, a row of a card designer. Its header holds the list's handle, a disclosure, the card's title over a one-line summary, and its actions; while the list moves, it folds to its header.",
|
|
213
|
+
children: [
|
|
214
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
215
|
+
id: "basics",
|
|
216
|
+
title: "Basics",
|
|
217
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
218
|
+
"Put the cards in a ",
|
|
219
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
220
|
+
to: "/components/sortable-list",
|
|
221
|
+
children: "Sortable list"
|
|
222
|
+
}),
|
|
223
|
+
" with",
|
|
224
|
+
" ",
|
|
225
|
+
/* @__PURE__ */ jsx("code", { children: "handlePlacement=\"inside\"" }),
|
|
226
|
+
" and ",
|
|
227
|
+
/* @__PURE__ */ jsx("code", { children: "variant=\"plain\"" }),
|
|
228
|
+
", and pass each card the list's",
|
|
229
|
+
" ",
|
|
230
|
+
/* @__PURE__ */ jsx("code", { children: "state.handle" }),
|
|
231
|
+
" as ",
|
|
232
|
+
/* @__PURE__ */ jsx("code", { children: "handle" }),
|
|
233
|
+
": the card draws its own surface, and the handle sits on its header line. The disclosure opens and closes the body; the summary reads the card in one line whether it is open or not. Reorder by the handle with the pointer, or lift it from the keyboard as any sortable row."
|
|
234
|
+
] }),
|
|
235
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
236
|
+
align: "fill",
|
|
237
|
+
caption: "Drag a rule by its handle, or tab to it and press Space: every card folds to its header while one moves.",
|
|
238
|
+
code: `
|
|
239
|
+
<SortableList
|
|
240
|
+
aria-label="Pricing rules"
|
|
241
|
+
variant="plain"
|
|
242
|
+
handlePlacement="inside"
|
|
243
|
+
items={rules}
|
|
244
|
+
getKey={(rule) => rule.id}
|
|
245
|
+
getLabel={(rule) => rule.name}
|
|
246
|
+
onReorder={(from, to) => setRules((was) => moveItem(was, from, to))}
|
|
247
|
+
renderItem={(rule, state) => (
|
|
248
|
+
<SortableCard
|
|
249
|
+
handle={state.handle}
|
|
250
|
+
folded={state.sorting}
|
|
251
|
+
leading={<span className="sortable-card-place">{state.position + 1}</span>}
|
|
252
|
+
title={rule.name}
|
|
253
|
+
summary={rule.summary}
|
|
254
|
+
actions={<Switch size="sm" checked={rule.on} onCheckedChange={...} aria-label={\`\${rule.name} on\`} />}
|
|
255
|
+
>
|
|
256
|
+
<RuleBody rule={rule} />
|
|
257
|
+
</SortableCard>
|
|
258
|
+
)}
|
|
259
|
+
/>`,
|
|
260
|
+
children: /* @__PURE__ */ jsx(Rules, {})
|
|
261
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
262
|
+
title: "Folding while the list moves",
|
|
263
|
+
children: [
|
|
264
|
+
"With ",
|
|
265
|
+
/* @__PURE__ */ jsxs("code", { children: ["folded=", "{state.sorting}"] }),
|
|
266
|
+
" every card folds to its header the moment one is picked up, at once and with no animation, so the list is short, every place is a header's height, and the places the list measured as the drag began hold. Pass ",
|
|
267
|
+
/* @__PURE__ */ jsx("code", { children: "state.dragging || state.lifted" }),
|
|
268
|
+
" to fold only the card that moves. The cards open again where they were once it drops."
|
|
269
|
+
]
|
|
270
|
+
})]
|
|
271
|
+
}),
|
|
272
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
273
|
+
id: "variants",
|
|
274
|
+
title: "A field for a title, and a card with nothing to open",
|
|
275
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
276
|
+
"The title can be a field, as a product option's name is; give the card a ",
|
|
277
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
278
|
+
" then, which names the disclosure (\"Expand Finish\"). A card with no body has no disclosure: a card designer's rows are a kind and a remove button."
|
|
279
|
+
] }),
|
|
280
|
+
children: [/* @__PURE__ */ jsx(SubSection, {
|
|
281
|
+
title: "A field for a title",
|
|
282
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
283
|
+
align: "fill",
|
|
284
|
+
code: `
|
|
285
|
+
<SortableCard
|
|
286
|
+
handle={state.handle}
|
|
287
|
+
folded={state.dragging || state.lifted}
|
|
288
|
+
label={option.name}
|
|
289
|
+
title={<Input size="sm" aria-label="Option name" value={option.name} onChange={...} />}
|
|
290
|
+
summary={\`\${option.values.length} values\`}
|
|
291
|
+
>
|
|
292
|
+
{option.values.map((value) => <Badge key={value}>{value}</Badge>)}
|
|
293
|
+
</SortableCard>`,
|
|
294
|
+
children: /* @__PURE__ */ jsx(Options, {})
|
|
295
|
+
})
|
|
296
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
297
|
+
title: "Nothing to open",
|
|
298
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
299
|
+
align: "fill",
|
|
300
|
+
code: `
|
|
301
|
+
<SortableCard
|
|
302
|
+
handle={state.handle}
|
|
303
|
+
title={row}
|
|
304
|
+
actions={<IconButton size="sm" variant="ghost" label={\`Remove \${row}\`} onClick={...}><TrashIcon size={16} aria-hidden="true" /></IconButton>}
|
|
305
|
+
/>`,
|
|
306
|
+
children: /* @__PURE__ */ jsx(DesignerRows, {})
|
|
307
|
+
})
|
|
308
|
+
})]
|
|
309
|
+
}),
|
|
310
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
311
|
+
id: "both-themes",
|
|
312
|
+
title: "In both themes",
|
|
313
|
+
description: /* @__PURE__ */ jsx("p", { children: "Closed cards, light and dark side by side. Open one, or lift one to see them fold." }),
|
|
314
|
+
children: /* @__PURE__ */ jsx(ThemePair, { children: /* @__PURE__ */ jsx(Rules, { startOpen: false }) })
|
|
315
|
+
}),
|
|
316
|
+
/* @__PURE__ */ jsx(Fragment$1, {}),
|
|
317
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
318
|
+
id: "guidelines",
|
|
319
|
+
title: "Guidelines",
|
|
320
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
321
|
+
"Write the summary as the card reads in one line: \"Flat · 3 conditions\", \"20% off · 1 condition\". It shows open or closed.",
|
|
322
|
+
"Fold the cards while the list moves. A list of open cards is too tall to carry a card across.",
|
|
323
|
+
"Keep the actions few: a switch and one button, or a menu. More belongs in the body.",
|
|
324
|
+
"Place the handle in every card. With handlePlacement=\"inside\" the list draws none of its own, and it is the keyboard's way in."
|
|
325
|
+
] })
|
|
326
|
+
}),
|
|
327
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
328
|
+
id: "accessibility",
|
|
329
|
+
title: "Accessibility",
|
|
330
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
331
|
+
"The disclosure is a button with ",
|
|
332
|
+
/* @__PURE__ */ jsx("code", { children: "aria-expanded" }),
|
|
333
|
+
" and ",
|
|
334
|
+
/* @__PURE__ */ jsx("code", { children: "aria-controls" }),
|
|
335
|
+
", named \"Expand\" or \"Collapse\" and the card's label. A closed body is ",
|
|
336
|
+
/* @__PURE__ */ jsx("code", { children: "inert" }),
|
|
337
|
+
" and hidden from assistive technology, so nothing in it takes focus. The handle is the list's own, with its instructions and announcements."
|
|
338
|
+
] })
|
|
339
|
+
}),
|
|
340
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
341
|
+
id: "props",
|
|
342
|
+
title: "Props",
|
|
343
|
+
description: /* @__PURE__ */ jsx("p", { children: "SortableCard also accepts every native attribute of its root element." }),
|
|
344
|
+
children: /* @__PURE__ */ jsx(PropsTable, {
|
|
345
|
+
title: "SortableCard",
|
|
346
|
+
rows: [
|
|
347
|
+
{
|
|
348
|
+
name: "handle",
|
|
349
|
+
type: "ReactNode",
|
|
350
|
+
description: "The list's handle for the row: state.handle, with handlePlacement=\"inside\"."
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "title",
|
|
354
|
+
type: "ReactNode",
|
|
355
|
+
required: true,
|
|
356
|
+
description: "The header's main line: the card's name, or a field to rename it in."
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: "label",
|
|
360
|
+
type: "string",
|
|
361
|
+
default: "title, when it is a string",
|
|
362
|
+
description: "Words for the card, in the disclosure's name."
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
name: "summary",
|
|
366
|
+
type: "ReactNode",
|
|
367
|
+
description: "One line that reads the card, under the title."
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
name: "leading",
|
|
371
|
+
type: "ReactNode",
|
|
372
|
+
description: "Before the title: a place number, an icon."
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "actions",
|
|
376
|
+
type: "ReactNode",
|
|
377
|
+
description: "At the header's end: a switch, a count, a menu."
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: "open",
|
|
381
|
+
type: "boolean",
|
|
382
|
+
description: "Open, controlled."
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "defaultOpen",
|
|
386
|
+
type: "boolean",
|
|
387
|
+
default: "true",
|
|
388
|
+
description: "Open at first, uncontrolled."
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: "onOpenChange",
|
|
392
|
+
type: "(open) => void",
|
|
393
|
+
description: "Called as the disclosure is pressed."
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
name: "folded",
|
|
397
|
+
type: "boolean",
|
|
398
|
+
default: "false",
|
|
399
|
+
description: "Fold to the header at once, whatever open says: state.sorting, or state.dragging || state.lifted."
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
name: "children",
|
|
403
|
+
type: "ReactNode",
|
|
404
|
+
description: "The body. A card with none has no disclosure."
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
name: "labels",
|
|
408
|
+
type: "Partial<SortableCardLabels>",
|
|
409
|
+
default: "English defaults",
|
|
410
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
411
|
+
/* @__PURE__ */ jsx("code", { children: "expand: (label) => `Expand ${label}`" }),
|
|
412
|
+
", ",
|
|
413
|
+
/* @__PURE__ */ jsx("code", { children: "collapse: (label) => `Collapse ${label}`" }),
|
|
414
|
+
"."
|
|
415
|
+
] })
|
|
416
|
+
}
|
|
417
|
+
]
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
//#endregion
|
|
424
|
+
export { Page, Preview };
|