@orbitcommerce/constellation-docs 1.0.0 → 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/dist/docs.css +14764 -2237
- package/dist/index.js +2 -2
- package/dist/pages/{Playground-CNbBbErC.js → Playground-Mk1yIWXb.js} +2 -2
- 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-BDmScEny.js → _figures-data-DaDvB7Nm.js} +5 -5
- package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
- package/dist/pages/{_overlays-specimens-Dpn6oiyH.js → _overlays-specimens-bawR331Z.js} +33 -23
- 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-BD4e6QTh.js → alert-D3i7xZTU.js} +195 -50
- package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
- package/dist/pages/{app-shell-KbA-nRqZ.js → app-shell-D4hdlHps.js} +133 -54
- package/dist/pages/{area-chart-B91dLcGo.js → area-chart-BEWFwiB2.js} +183 -27
- package/dist/pages/{avatar-DPPHXJAu.js → avatar-BFEqQViw.js} +194 -12
- package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
- package/dist/pages/{badge-C9JR0thI.js → badge-0-PyMrih.js} +441 -135
- 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-D3V912P4.js → button-DAyfssDY.js} +276 -79
- package/dist/pages/{calendar-DSDZ9nRH.js → calendar-Ds7KsgSI.js} +69 -17
- 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-BwuO8xAv.js → colour-q2ntvI0w.js} +496 -20
- package/dist/pages/column-mapper-TsTG39cl.js +502 -0
- package/dist/pages/combobox-DvK2j5tI.js +1334 -0
- package/dist/pages/{command-palette-xAD7fOg6.js → command-palette-CJ7uBA04.js} +201 -58
- 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-BYSa816m.js → date-picker-GdBciR99.js} +186 -38
- package/dist/pages/date-time-BLKCXtVZ.js +678 -0
- package/dist/pages/{delta-CtAo0eIM.js → delta-CNAGv8JY.js} +266 -61
- 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-BNOb7AqR.js → docs-lM2UBSir.js} +20 -15
- 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-CoPFzzKz.js → figure-tabs-QOeQMY6N.js} +153 -35
- 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-CFQwDtC9.js → home-dashboard-CxPmvduE.js} +21 -18
- 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-C9eSVPPW.js → icon-button-Bu4Gj5sy.js} +370 -31
- package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
- package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
- package/dist/pages/{icons-sxkTs5Ob.js → icons-CJ9Aar3d.js} +315 -52
- 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-DpsX8G_n.js → installation-C3UcpQJT.js} +112 -29
- package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
- package/dist/pages/kanban-Dy9sPAI0.js +740 -0
- package/dist/pages/{kbd-cNfDoikz.js → kbd-UNj4zqxn.js} +15 -14
- 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-ClvLn9Lb.js → live-globe-95ROMhGQ.js} +191 -47
- 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-BfGF1Pq9.js → logo-B38rnzoq.js} +13 -13
- 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-by2sgQ09.js → menu-NrLYKqKp.js} +623 -109
- 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-BvTGc2Dk.js → motion-CrXtiBvA.js} +20 -10
- package/dist/pages/number-input-CuyMZg18.js +968 -0
- package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
- package/dist/pages/{orbit-spinner-Dil1Z3Oy.js → orbit-spinner-Dxv5qAhr.js} +30 -14
- package/dist/pages/otp-input-CVRoX1mw.js +591 -0
- package/dist/pages/{overview-BPEbZQ6g.js → overview-LA9XRhZc.js} +4 -4
- package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
- package/dist/pages/{pagination-BBUnGvv5.js → pagination-C1EgVtW4.js} +74 -29
- 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-Db1gLDpb.js → popover-C3Oar9D5.js} +76 -14
- 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-CeAIOIdt.js → principles-pnDyfHpK.js} +9 -9
- 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-CkdBWWfG.js → radio-group-C-4tg6FS.js} +580 -18
- 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-Dvo684UJ.js → release-Cs6tl16C.js} +4 -1
- 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-qmvH84Mq.js → rolling-number-GR3Cyfpz.js} +12 -12
- 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-BN7MWGQ4.js → search-field-D1uG7R6A.js} +15 -15
- 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-CTbIpRBW.js → segmented-control-D-FB1K1T.js} +450 -37
- package/dist/pages/{select-DguELoRR.js → select-DZ43NpOm.js} +22 -17
- package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
- package/dist/pages/{separator-CPZub9pv.js → separator-CFwqRvfO.js} +99 -22
- package/dist/pages/serp-preview-BGwORjmo.js +346 -0
- package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
- package/dist/pages/{shape-DKvA0YKr.js → shape-DzniHAVT.js} +10 -10
- 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-DMMYGbHn.js → sparkline-D3aavCly.js} +301 -22
- 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-B-Qe4kcT.js → switch-C93K6j9h.js} +151 -51
- package/dist/pages/table-CL0vomno.js +3225 -0
- package/dist/pages/{tabs-B4M-usCV.js → tabs-Dh0mUsLw.js} +256 -21
- package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
- package/dist/pages/task-card-Dv0sR1-w.js +295 -0
- package/dist/pages/{textarea-fTuUZRQb.js → textarea-CCM-SnGN.js} +271 -15
- 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-CKP03zjy.js → toast-zXLRiMRT.js} +240 -25
- package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
- package/dist/pages/toolbar-B9l_fHKy.js +754 -0
- package/dist/pages/{tooltip-CBYil3kt.js → tooltip-LHtCUkF-.js} +162 -33
- 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-PCbg8Bhg.js → typography-BSijtiRl.js} +153 -12
- 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 +10984 -1108
- package/package.json +2 -2
- package/dist/pages/card-DUggbis3.js +0 -659
- package/dist/pages/checkbox-DwimQaK3.js +0 -365
- package/dist/pages/dialog-BRAf4LMh.js +0 -1451
- package/dist/pages/empty-state-C-mLrXW2.js +0 -417
- package/dist/pages/input-KF9Gkawf.js +0 -1093
- package/dist/pages/registry-CroHzK9I.js +0 -244
- package/dist/pages/skeleton-DLuBhP46.js +0 -561
- package/dist/pages/table-AMoODng4.js +0 -607
|
@@ -0,0 +1,788 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as DocTable, d as Section$1, i as DocPage, l as Note, n as CodeBlock$1, o as Example, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
import { IconButton, Switch, Tooltip, useAnchoredOverlay, useThemeScope } from "@orbitcommerce/constellation";
|
|
7
|
+
import { CaretDownIcon, CaretUpIcon, CopyIcon, DotsSixVerticalIcon, TrashIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/anchored-overlay.tsx
|
|
9
|
+
var PAGE = [
|
|
10
|
+
{
|
|
11
|
+
id: "announcement",
|
|
12
|
+
name: "Announcement bar",
|
|
13
|
+
kind: "announcement"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "header",
|
|
17
|
+
name: "Header",
|
|
18
|
+
kind: "header"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "hero",
|
|
22
|
+
name: "Hero banner",
|
|
23
|
+
kind: "hero"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "best-sellers",
|
|
27
|
+
name: "Best sellers",
|
|
28
|
+
kind: "grid"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "newsletter",
|
|
32
|
+
name: "Newsletter sign-up",
|
|
33
|
+
kind: "newsletter"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "footer",
|
|
37
|
+
name: "Footer",
|
|
38
|
+
kind: "footer"
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
/** The block's look on the canvas: drawn shapes, no images. */
|
|
42
|
+
function BlockShapes({ kind }) {
|
|
43
|
+
if (kind === "announcement") return /* @__PURE__ */ jsx("span", {
|
|
44
|
+
className: "anchored-overlay-shape",
|
|
45
|
+
"data-w": "40",
|
|
46
|
+
"data-centre": ""
|
|
47
|
+
});
|
|
48
|
+
if (kind === "header") return /* @__PURE__ */ jsxs("span", {
|
|
49
|
+
className: "anchored-overlay-shapes",
|
|
50
|
+
"data-row": "",
|
|
51
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
52
|
+
className: "anchored-overlay-shape",
|
|
53
|
+
"data-w": "20",
|
|
54
|
+
"data-strong": ""
|
|
55
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: "anchored-overlay-shape",
|
|
57
|
+
"data-w": "40"
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
if (kind === "hero") return /* @__PURE__ */ jsxs("span", {
|
|
61
|
+
className: "anchored-overlay-shapes",
|
|
62
|
+
"data-hero": "",
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ jsx("span", {
|
|
65
|
+
className: "anchored-overlay-shape",
|
|
66
|
+
"data-w": "60",
|
|
67
|
+
"data-strong": "",
|
|
68
|
+
"data-tall": ""
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ jsx("span", {
|
|
71
|
+
className: "anchored-overlay-shape",
|
|
72
|
+
"data-w": "40"
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ jsx("span", {
|
|
75
|
+
className: "anchored-overlay-shape",
|
|
76
|
+
"data-w": "20",
|
|
77
|
+
"data-pill": ""
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
if (kind === "grid") return /* @__PURE__ */ jsx("span", {
|
|
82
|
+
className: "anchored-overlay-tiles",
|
|
83
|
+
children: [
|
|
84
|
+
0,
|
|
85
|
+
1,
|
|
86
|
+
2,
|
|
87
|
+
3
|
|
88
|
+
].map((tile) => /* @__PURE__ */ jsx("span", { className: "anchored-overlay-tile" }, tile))
|
|
89
|
+
});
|
|
90
|
+
if (kind === "newsletter") return /* @__PURE__ */ jsxs("span", {
|
|
91
|
+
className: "anchored-overlay-shapes",
|
|
92
|
+
"data-row": "",
|
|
93
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
94
|
+
className: "anchored-overlay-shape",
|
|
95
|
+
"data-w": "40",
|
|
96
|
+
"data-strong": ""
|
|
97
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
98
|
+
className: "anchored-overlay-shape",
|
|
99
|
+
"data-w": "20",
|
|
100
|
+
"data-pill": ""
|
|
101
|
+
})]
|
|
102
|
+
});
|
|
103
|
+
return /* @__PURE__ */ jsx("span", {
|
|
104
|
+
className: "anchored-overlay-shapes",
|
|
105
|
+
"data-columns": "",
|
|
106
|
+
children: [
|
|
107
|
+
0,
|
|
108
|
+
1,
|
|
109
|
+
2
|
|
110
|
+
].map((column) => /* @__PURE__ */ jsxs("span", {
|
|
111
|
+
className: "anchored-overlay-shapes",
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsx("span", {
|
|
114
|
+
className: "anchored-overlay-shape",
|
|
115
|
+
"data-w": "60",
|
|
116
|
+
"data-strong": ""
|
|
117
|
+
}),
|
|
118
|
+
/* @__PURE__ */ jsx("span", {
|
|
119
|
+
className: "anchored-overlay-shape",
|
|
120
|
+
"data-w": "40"
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ jsx("span", {
|
|
123
|
+
className: "anchored-overlay-shape",
|
|
124
|
+
"data-w": "40"
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
}, column))
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function Preview() {
|
|
131
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
132
|
+
className: "anchored-overlay-preview",
|
|
133
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
134
|
+
className: "anchored-overlay-toolbar",
|
|
135
|
+
"data-still": "",
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ jsx("span", {
|
|
138
|
+
className: "anchored-overlay-toolbar__grip",
|
|
139
|
+
"aria-hidden": "true",
|
|
140
|
+
children: /* @__PURE__ */ jsx(DotsSixVerticalIcon, { weight: "bold" })
|
|
141
|
+
}),
|
|
142
|
+
/* @__PURE__ */ jsx("span", {
|
|
143
|
+
className: "anchored-overlay-toolbar__name",
|
|
144
|
+
children: "Hero banner"
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ jsx("span", {
|
|
147
|
+
className: "anchored-overlay-toolbar__glyph",
|
|
148
|
+
"aria-hidden": "true",
|
|
149
|
+
children: /* @__PURE__ */ jsx(CopyIcon, {})
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ jsx("span", {
|
|
152
|
+
className: "anchored-overlay-toolbar__glyph",
|
|
153
|
+
"aria-hidden": "true",
|
|
154
|
+
children: /* @__PURE__ */ jsx(TrashIcon, {})
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
158
|
+
className: "anchored-overlay-block",
|
|
159
|
+
"data-kind": "hero",
|
|
160
|
+
"data-selected": "",
|
|
161
|
+
children: /* @__PURE__ */ jsx(BlockShapes, { kind: "hero" })
|
|
162
|
+
})]
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function BuilderCanvas() {
|
|
166
|
+
const theme = useThemeScope();
|
|
167
|
+
const [blocks, setBlocks] = useState(PAGE);
|
|
168
|
+
const [selectedId, setSelectedId] = useState("hero");
|
|
169
|
+
const [hoveredId, setHoveredId] = useState(null);
|
|
170
|
+
const [canvas, setCanvas] = useState(null);
|
|
171
|
+
const panel = useRef(null);
|
|
172
|
+
const elements = useRef(/* @__PURE__ */ new Map());
|
|
173
|
+
const selected = blocks.find((block) => block.id === selectedId) ?? null;
|
|
174
|
+
const hovered = blocks.find((block) => block.id === hoveredId) ?? null;
|
|
175
|
+
const elementOf = (id) => id ? elements.current.get(id) ?? null : null;
|
|
176
|
+
const toolbar = useAnchoredOverlay(elementOf(selectedId), {
|
|
177
|
+
open: selected !== null && canvas !== null,
|
|
178
|
+
boundary: canvas ?? void 0,
|
|
179
|
+
avoid: [panel]
|
|
180
|
+
});
|
|
181
|
+
const tag = useAnchoredOverlay(elementOf(hoveredId), {
|
|
182
|
+
open: hovered !== null && hoveredId !== selectedId && canvas !== null,
|
|
183
|
+
boundary: canvas ?? void 0,
|
|
184
|
+
avoid: [panel]
|
|
185
|
+
});
|
|
186
|
+
const index = selected ? blocks.indexOf(selected) : -1;
|
|
187
|
+
const move = (by) => setBlocks((all) => {
|
|
188
|
+
const next = [...all];
|
|
189
|
+
const [block] = next.splice(index, 1);
|
|
190
|
+
next.splice(index + by, 0, block);
|
|
191
|
+
return next;
|
|
192
|
+
});
|
|
193
|
+
const duplicate = () => {
|
|
194
|
+
if (!selected) return;
|
|
195
|
+
const copy = {
|
|
196
|
+
...selected,
|
|
197
|
+
id: `${selected.id}-${Date.now()}`,
|
|
198
|
+
name: `${selected.name} copy`
|
|
199
|
+
};
|
|
200
|
+
setBlocks((all) => [
|
|
201
|
+
...all.slice(0, index + 1),
|
|
202
|
+
copy,
|
|
203
|
+
...all.slice(index + 1)
|
|
204
|
+
]);
|
|
205
|
+
setSelectedId(copy.id);
|
|
206
|
+
};
|
|
207
|
+
const remove = () => {
|
|
208
|
+
if (!selected) return;
|
|
209
|
+
const next = blocks[index + 1] ?? blocks[index - 1] ?? null;
|
|
210
|
+
setBlocks((all) => all.filter((block) => block.id !== selected.id));
|
|
211
|
+
setSelectedId(next?.id ?? null);
|
|
212
|
+
requestAnimationFrame(() => next ? elements.current.get(next.id)?.focus() : canvas?.focus());
|
|
213
|
+
};
|
|
214
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
215
|
+
className: "anchored-overlay-builder",
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ jsxs("div", {
|
|
218
|
+
className: "anchored-overlay-builder__bar",
|
|
219
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
220
|
+
className: "anchored-overlay-builder__title",
|
|
221
|
+
children: "Home page"
|
|
222
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
223
|
+
className: "anchored-overlay-builder__meta",
|
|
224
|
+
children: "Draft"
|
|
225
|
+
})]
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ jsxs("div", {
|
|
228
|
+
className: "anchored-overlay-builder__body",
|
|
229
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
230
|
+
ref: setCanvas,
|
|
231
|
+
className: "anchored-overlay-canvas",
|
|
232
|
+
tabIndex: -1,
|
|
233
|
+
onPointerLeave: () => setHoveredId(null),
|
|
234
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
235
|
+
className: "anchored-overlay-page",
|
|
236
|
+
children: blocks.map((block) => /* @__PURE__ */ jsx("button", {
|
|
237
|
+
ref: (element) => {
|
|
238
|
+
if (element) elements.current.set(block.id, element);
|
|
239
|
+
else elements.current.delete(block.id);
|
|
240
|
+
},
|
|
241
|
+
type: "button",
|
|
242
|
+
className: "anchored-overlay-block",
|
|
243
|
+
"data-kind": block.kind,
|
|
244
|
+
"data-selected": block.id === selectedId ? "" : void 0,
|
|
245
|
+
"aria-pressed": block.id === selectedId,
|
|
246
|
+
"aria-label": block.name,
|
|
247
|
+
onClick: () => setSelectedId(block.id),
|
|
248
|
+
onPointerEnter: () => setHoveredId(block.id),
|
|
249
|
+
children: /* @__PURE__ */ jsx(BlockShapes, { kind: block.kind })
|
|
250
|
+
}, block.id))
|
|
251
|
+
})
|
|
252
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
253
|
+
ref: panel,
|
|
254
|
+
className: "anchored-overlay-panel",
|
|
255
|
+
"aria-hidden": "true",
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ jsx("span", {
|
|
258
|
+
className: "anchored-overlay-panel__title",
|
|
259
|
+
children: selected?.name ?? "Page"
|
|
260
|
+
}),
|
|
261
|
+
/* @__PURE__ */ jsx("span", {
|
|
262
|
+
className: "anchored-overlay-shape",
|
|
263
|
+
"data-w": "60"
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ jsx("span", {
|
|
266
|
+
className: "anchored-overlay-shape",
|
|
267
|
+
"data-w": "40"
|
|
268
|
+
}),
|
|
269
|
+
/* @__PURE__ */ jsx("span", { className: "anchored-overlay-panel__field" }),
|
|
270
|
+
/* @__PURE__ */ jsx("span", {
|
|
271
|
+
className: "anchored-overlay-shape",
|
|
272
|
+
"data-w": "60"
|
|
273
|
+
}),
|
|
274
|
+
/* @__PURE__ */ jsx("span", { className: "anchored-overlay-panel__field" })
|
|
275
|
+
]
|
|
276
|
+
})]
|
|
277
|
+
}),
|
|
278
|
+
selected && canvas ? createPortal(/* @__PURE__ */ jsxs("div", {
|
|
279
|
+
ref: toolbar.ref,
|
|
280
|
+
className: "anchored-overlay-toolbar",
|
|
281
|
+
"data-o-theme": theme,
|
|
282
|
+
role: "toolbar",
|
|
283
|
+
"aria-label": `${selected.name} actions`,
|
|
284
|
+
children: [
|
|
285
|
+
/* @__PURE__ */ jsx("span", {
|
|
286
|
+
className: "anchored-overlay-toolbar__grip",
|
|
287
|
+
"aria-hidden": "true",
|
|
288
|
+
children: /* @__PURE__ */ jsx(DotsSixVerticalIcon, { weight: "bold" })
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ jsx("span", {
|
|
291
|
+
className: "anchored-overlay-toolbar__name",
|
|
292
|
+
children: selected.name
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ jsx(ToolbarButton$1, {
|
|
295
|
+
label: "Move up",
|
|
296
|
+
disabled: index <= 0,
|
|
297
|
+
onClick: () => move(-1),
|
|
298
|
+
children: /* @__PURE__ */ jsx(CaretUpIcon, {})
|
|
299
|
+
}),
|
|
300
|
+
/* @__PURE__ */ jsx(ToolbarButton$1, {
|
|
301
|
+
label: "Move down",
|
|
302
|
+
disabled: index >= blocks.length - 1,
|
|
303
|
+
onClick: () => move(1),
|
|
304
|
+
children: /* @__PURE__ */ jsx(CaretDownIcon, {})
|
|
305
|
+
}),
|
|
306
|
+
/* @__PURE__ */ jsx(ToolbarButton$1, {
|
|
307
|
+
label: "Duplicate",
|
|
308
|
+
onClick: duplicate,
|
|
309
|
+
children: /* @__PURE__ */ jsx(CopyIcon, {})
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ jsx(ToolbarButton$1, {
|
|
312
|
+
label: "Delete",
|
|
313
|
+
onClick: remove,
|
|
314
|
+
children: /* @__PURE__ */ jsx(TrashIcon, {})
|
|
315
|
+
})
|
|
316
|
+
]
|
|
317
|
+
}), document.body) : null,
|
|
318
|
+
hovered && hoveredId !== selectedId && canvas ? createPortal(/* @__PURE__ */ jsx("div", {
|
|
319
|
+
ref: tag.ref,
|
|
320
|
+
className: "anchored-overlay-tag",
|
|
321
|
+
"data-o-theme": theme,
|
|
322
|
+
"aria-hidden": "true",
|
|
323
|
+
children: hovered.name
|
|
324
|
+
}), document.body) : null
|
|
325
|
+
]
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function ToolbarButton$1({ label, disabled, onClick, children }) {
|
|
329
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
330
|
+
content: label,
|
|
331
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
332
|
+
label,
|
|
333
|
+
size: "xs",
|
|
334
|
+
variant: "ghost",
|
|
335
|
+
disabled,
|
|
336
|
+
onClick,
|
|
337
|
+
children
|
|
338
|
+
})
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
var PRODUCTS = [
|
|
342
|
+
"Arden ergonomic chair",
|
|
343
|
+
"Harbour standing desk",
|
|
344
|
+
"Linden monitor arm",
|
|
345
|
+
"Coast desk lamp",
|
|
346
|
+
"Fell filing cabinet"
|
|
347
|
+
];
|
|
348
|
+
function CoverRing() {
|
|
349
|
+
const theme = useThemeScope();
|
|
350
|
+
const [on, setOn] = useState(true);
|
|
351
|
+
const [list, setList] = useState(null);
|
|
352
|
+
const [target, setTarget] = useState(null);
|
|
353
|
+
const ring = useAnchoredOverlay(target, {
|
|
354
|
+
open: on,
|
|
355
|
+
side: "cover",
|
|
356
|
+
offset: 3,
|
|
357
|
+
boundary: list ?? void 0
|
|
358
|
+
});
|
|
359
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
360
|
+
className: "anchored-overlay-cover",
|
|
361
|
+
children: [
|
|
362
|
+
/* @__PURE__ */ jsx(Switch, {
|
|
363
|
+
checked: on,
|
|
364
|
+
onCheckedChange: setOn,
|
|
365
|
+
label: "Rewriting the second product"
|
|
366
|
+
}),
|
|
367
|
+
/* @__PURE__ */ jsx("div", {
|
|
368
|
+
ref: setList,
|
|
369
|
+
className: "anchored-overlay-cover__list",
|
|
370
|
+
tabIndex: 0,
|
|
371
|
+
"aria-label": "Products",
|
|
372
|
+
children: PRODUCTS.map((name, i) => /* @__PURE__ */ jsxs("div", {
|
|
373
|
+
ref: i === 1 ? setTarget : void 0,
|
|
374
|
+
className: "anchored-overlay-cover__card",
|
|
375
|
+
children: [/* @__PURE__ */ jsx("span", { className: "anchored-overlay-tile" }), /* @__PURE__ */ jsx("span", {
|
|
376
|
+
className: "anchored-overlay-cover__name",
|
|
377
|
+
children: name
|
|
378
|
+
})]
|
|
379
|
+
}, name))
|
|
380
|
+
}),
|
|
381
|
+
on && target ? createPortal(/* @__PURE__ */ jsx("div", {
|
|
382
|
+
ref: ring.ref,
|
|
383
|
+
className: "anchored-overlay-ring",
|
|
384
|
+
"data-o-theme": theme,
|
|
385
|
+
"aria-hidden": "true"
|
|
386
|
+
}), document.body) : null
|
|
387
|
+
]
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
var WEEK = [
|
|
391
|
+
{
|
|
392
|
+
day: "Monday",
|
|
393
|
+
orders: 18
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
day: "Tuesday",
|
|
397
|
+
orders: 24
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
day: "Wednesday",
|
|
401
|
+
orders: 21
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
day: "Thursday",
|
|
405
|
+
orders: 32
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
day: "Friday",
|
|
409
|
+
orders: 40
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
day: "Saturday",
|
|
413
|
+
orders: 29
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
day: "Sunday",
|
|
417
|
+
orders: 12
|
|
418
|
+
}
|
|
419
|
+
];
|
|
420
|
+
function PointReadout() {
|
|
421
|
+
const theme = useThemeScope();
|
|
422
|
+
const [point, setPoint] = useState(null);
|
|
423
|
+
const [focused, setFocused] = useState(null);
|
|
424
|
+
const [day, setDay] = useState(0);
|
|
425
|
+
const strip = useRef(null);
|
|
426
|
+
const anchor = point ?? focused;
|
|
427
|
+
const readout = useAnchoredOverlay(anchor, {
|
|
428
|
+
open: anchor !== null,
|
|
429
|
+
side: "top",
|
|
430
|
+
align: "center",
|
|
431
|
+
offset: 10,
|
|
432
|
+
boundary: "viewport"
|
|
433
|
+
});
|
|
434
|
+
const track = (event) => {
|
|
435
|
+
const box = event.currentTarget.getBoundingClientRect();
|
|
436
|
+
const at = Math.min(WEEK.length - 1, Math.max(0, Math.floor((event.clientX - box.left) / box.width * WEEK.length)));
|
|
437
|
+
setDay(at);
|
|
438
|
+
setPoint({
|
|
439
|
+
x: event.clientX,
|
|
440
|
+
y: event.clientY,
|
|
441
|
+
contextElement: event.currentTarget
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
445
|
+
ref: strip,
|
|
446
|
+
className: "anchored-overlay-week",
|
|
447
|
+
onPointerMove: track,
|
|
448
|
+
onPointerLeave: () => setPoint(null),
|
|
449
|
+
children: WEEK.map((entry, i) => /* @__PURE__ */ jsx("button", {
|
|
450
|
+
type: "button",
|
|
451
|
+
className: "anchored-overlay-week__bar",
|
|
452
|
+
style: { "--anchored-overlay-bar": `${entry.orders / 40 * 100}%` },
|
|
453
|
+
"aria-label": `${entry.day}, ${entry.orders} orders`,
|
|
454
|
+
"data-active": anchor && day === i ? "" : void 0,
|
|
455
|
+
onFocus: (event) => {
|
|
456
|
+
setDay(i);
|
|
457
|
+
setFocused(event.currentTarget);
|
|
458
|
+
},
|
|
459
|
+
onBlur: () => setFocused(null)
|
|
460
|
+
}, entry.day))
|
|
461
|
+
}), anchor ? createPortal(/* @__PURE__ */ jsxs("div", {
|
|
462
|
+
ref: readout.ref,
|
|
463
|
+
className: "anchored-overlay-readout",
|
|
464
|
+
"data-o-theme": theme,
|
|
465
|
+
"aria-hidden": "true",
|
|
466
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
467
|
+
className: "anchored-overlay-readout__day",
|
|
468
|
+
children: WEEK[day].day
|
|
469
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
470
|
+
className: "anchored-overlay-readout__value",
|
|
471
|
+
children: [WEEK[day].orders, " orders"]
|
|
472
|
+
})]
|
|
473
|
+
}), document.body) : null] });
|
|
474
|
+
}
|
|
475
|
+
function Page() {
|
|
476
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
477
|
+
title: "Anchored overlay",
|
|
478
|
+
status: "new",
|
|
479
|
+
importNames: ["useAnchoredOverlay", "placeAnchoredOverlay"],
|
|
480
|
+
lead: "Pins an overlay to an element anywhere on the page: a builder's toolbar over the selected block, a name tag on the one under the pointer, a ring round an element being rewritten, a readout at the pointer. It follows the element every frame and stays inside the part of the canvas you can see.",
|
|
481
|
+
children: [
|
|
482
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
483
|
+
id: "basics",
|
|
484
|
+
title: "Basics",
|
|
485
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
486
|
+
"Call ",
|
|
487
|
+
/* @__PURE__ */ jsx("code", { children: "useAnchoredOverlay(element, options)" }),
|
|
488
|
+
" and put the ",
|
|
489
|
+
/* @__PURE__ */ jsx("code", { children: "ref" }),
|
|
490
|
+
" it returns on the overlay. The hook positions it, shows it once it is placed and hides it while the element is scrolled out of view. Here, a page on a builder's canvas: choose a block and its toolbar sits just above it. Scroll the canvas, move a block up or down, duplicate or delete it: the toolbar keeps up, without a scroll or resize listener. Hovering another block pins its name tag the same way. The toolbar stays out from under the inspector panel that lies over the canvas's end."
|
|
491
|
+
] }),
|
|
492
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
493
|
+
align: "fill",
|
|
494
|
+
code: `
|
|
495
|
+
const [selected, setSelected] = useState<HTMLElement | null>(null)
|
|
496
|
+
const toolbar = useAnchoredOverlay<HTMLDivElement>(selected, {
|
|
497
|
+
open: selected !== null,
|
|
498
|
+
avoid: [inspectorRef], // a panel that lies over the canvas
|
|
499
|
+
})
|
|
500
|
+
|
|
501
|
+
{selected
|
|
502
|
+
? createPortal(
|
|
503
|
+
<div ref={toolbar.ref} role="toolbar" aria-label="Hero banner actions" className="block-toolbar">
|
|
504
|
+
<span className="block-toolbar__name">Hero banner</span>
|
|
505
|
+
<IconButton label="Move up" size="xs" onClick={moveUp}><CaretUpIcon /></IconButton>
|
|
506
|
+
<IconButton label="Duplicate" size="xs" onClick={duplicate}><CopyIcon /></IconButton>
|
|
507
|
+
<IconButton label="Delete" size="xs" onClick={remove}><TrashIcon /></IconButton>
|
|
508
|
+
</div>,
|
|
509
|
+
document.body,
|
|
510
|
+
)
|
|
511
|
+
: null}`,
|
|
512
|
+
children: /* @__PURE__ */ jsx(BuilderCanvas, {})
|
|
513
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
514
|
+
title: "Positioned without re-rendering",
|
|
515
|
+
children: [
|
|
516
|
+
"The hook writes the overlay's ",
|
|
517
|
+
/* @__PURE__ */ jsx("code", { children: "top" }),
|
|
518
|
+
" and ",
|
|
519
|
+
/* @__PURE__ */ jsx("code", { children: "left" }),
|
|
520
|
+
" straight to its style every frame, never through React state, so following an element at 60 frames a second re-renders nothing. It reads nothing from the layout while it is closed, and stops when the overlay leaves the page."
|
|
521
|
+
]
|
|
522
|
+
})]
|
|
523
|
+
}),
|
|
524
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
525
|
+
id: "placement",
|
|
526
|
+
title: "Where it goes",
|
|
527
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
528
|
+
"Just outside the element on the side you ask for (",
|
|
529
|
+
/* @__PURE__ */ jsx("code", { children: "side" }),
|
|
530
|
+
", above by default), lined up with its start edge (",
|
|
531
|
+
/* @__PURE__ */ jsx("code", { children: "align" }),
|
|
532
|
+
": ",
|
|
533
|
+
/* @__PURE__ */ jsx("code", { children: "start" }),
|
|
534
|
+
", ",
|
|
535
|
+
/* @__PURE__ */ jsx("code", { children: "center" }),
|
|
536
|
+
" or ",
|
|
537
|
+
/* @__PURE__ */ jsx("code", { children: "end" }),
|
|
538
|
+
", the start on the right in a right-to-left page), 2px away. When that side has no room, a short element takes the overlay on its other side, so the overlay never covers what it is for; a tall one takes it just inside its edge, where it stays as the element scrolls past. Then it is clamped inside the visible canvas. The overlay is marked with where it ended up, ",
|
|
539
|
+
/* @__PURE__ */ jsx("code", { children: "data-o-placement" }),
|
|
540
|
+
", for an arrow or a tail to turn by, and",
|
|
541
|
+
" ",
|
|
542
|
+
/* @__PURE__ */ jsx("code", { children: "data-o-anchor-hidden" }),
|
|
543
|
+
" while its element is out of view: attributes of the kit's own, so a",
|
|
544
|
+
" ",
|
|
545
|
+
/* @__PURE__ */ jsx("code", { children: "data-placement" }),
|
|
546
|
+
" of yours is left alone. The page's direction is read each time it places, so a page turned right-to-left while it is open is followed."
|
|
547
|
+
] }),
|
|
548
|
+
children: [/* @__PURE__ */ jsx(DocTable, {
|
|
549
|
+
columns: ["data-o-placement", "When"],
|
|
550
|
+
rows: [
|
|
551
|
+
["top", "Above the element: the side asked for, or the other side of a short element when below had no room."],
|
|
552
|
+
["bottom", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
553
|
+
"Below the element: the side asked for, or the other side of a short element (120px or less, ",
|
|
554
|
+
/* @__PURE__ */ jsx("code", { children: "shortHeight" }),
|
|
555
|
+
")."
|
|
556
|
+
] })],
|
|
557
|
+
["inside", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
558
|
+
"Inside the edge of a tall element (4px in, ",
|
|
559
|
+
/* @__PURE__ */ jsx("code", { children: "inset" }),
|
|
560
|
+
"), when the side asked for had no room. Pinned to the canvas edge while the element scrolls under it."
|
|
561
|
+
] })],
|
|
562
|
+
["cover", /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
563
|
+
"Laid over the element, its own size (",
|
|
564
|
+
/* @__PURE__ */ jsx("code", { children: "side=\"cover\"" }),
|
|
565
|
+
")."
|
|
566
|
+
] })]
|
|
567
|
+
]
|
|
568
|
+
}), /* @__PURE__ */ jsx(DocTable, {
|
|
569
|
+
columns: [
|
|
570
|
+
"Option",
|
|
571
|
+
"Default",
|
|
572
|
+
"What it does"
|
|
573
|
+
],
|
|
574
|
+
rows: [
|
|
575
|
+
[
|
|
576
|
+
"offset",
|
|
577
|
+
"2",
|
|
578
|
+
"The gap between the element and the overlay. With side=\"cover\", how far it reaches past the element (default 0)."
|
|
579
|
+
],
|
|
580
|
+
[
|
|
581
|
+
"inset",
|
|
582
|
+
"4",
|
|
583
|
+
"Inside a tall element, the gap from its edge."
|
|
584
|
+
],
|
|
585
|
+
[
|
|
586
|
+
"shortHeight",
|
|
587
|
+
"120",
|
|
588
|
+
"An element this tall or shorter takes the overlay on its other side rather than inside."
|
|
589
|
+
],
|
|
590
|
+
[
|
|
591
|
+
"margin",
|
|
592
|
+
"2",
|
|
593
|
+
"The room kept between the overlay and the canvas edges."
|
|
594
|
+
]
|
|
595
|
+
]
|
|
596
|
+
})]
|
|
597
|
+
}),
|
|
598
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
599
|
+
id: "cover",
|
|
600
|
+
title: "Over the element",
|
|
601
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
602
|
+
/* @__PURE__ */ jsx("code", { children: "side=\"cover\"" }),
|
|
603
|
+
" lays the overlay over the element, sized to it and grown by ",
|
|
604
|
+
/* @__PURE__ */ jsx("code", { children: "offset" }),
|
|
605
|
+
" ",
|
|
606
|
+
"on every side: a selection ring, a glow while an assistant rewrites it, a tint with an Edit button over a header preview. Where the element runs out of the canvas, the overlay is clipped at the canvas edge, so it never draws over the bar or a panel. Scroll the list."
|
|
607
|
+
] }),
|
|
608
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
609
|
+
align: "fill",
|
|
610
|
+
code: `
|
|
611
|
+
const ring = useAnchoredOverlay<HTMLDivElement>(card, { open: rewriting, side: 'cover', offset: 3 })
|
|
612
|
+
|
|
613
|
+
{rewriting ? createPortal(<div ref={ring.ref} className="rewrite-ring" aria-hidden="true" />, document.body) : null}`,
|
|
614
|
+
children: /* @__PURE__ */ jsx(CoverRing, {})
|
|
615
|
+
})
|
|
616
|
+
}),
|
|
617
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
618
|
+
id: "point",
|
|
619
|
+
title: "At a point",
|
|
620
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
621
|
+
"Pass a point, ",
|
|
622
|
+
/* @__PURE__ */ jsx("code", { children: "{ x, y }" }),
|
|
623
|
+
" in window pixels, to pin to the pointer or a caret; it is placed as a short element would be. Give it the ",
|
|
624
|
+
/* @__PURE__ */ jsx("code", { children: "contextElement" }),
|
|
625
|
+
" it sits in so the overlay knows which canvas to keep inside. Anything with a ",
|
|
626
|
+
/* @__PURE__ */ jsx("code", { children: "getBoundingClientRect()" }),
|
|
627
|
+
", a text selection's range say, works too. Move over the week below, or tab to a day: from the keyboard the readout pins to the focused bar instead."
|
|
628
|
+
] }),
|
|
629
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
630
|
+
align: "fill",
|
|
631
|
+
code: `
|
|
632
|
+
const [point, setPoint] = useState<AnchorPoint | null>(null)
|
|
633
|
+
const readout = useAnchoredOverlay<HTMLDivElement>(point ?? focusedBar, {
|
|
634
|
+
open: point !== null || focusedBar !== null,
|
|
635
|
+
align: 'center',
|
|
636
|
+
offset: 10,
|
|
637
|
+
})
|
|
638
|
+
|
|
639
|
+
<div
|
|
640
|
+
onPointerMove={(event) => setPoint({ x: event.clientX, y: event.clientY, contextElement: event.currentTarget })}
|
|
641
|
+
onPointerLeave={() => setPoint(null)}
|
|
642
|
+
>…</div>`,
|
|
643
|
+
children: /* @__PURE__ */ jsx(PointReadout, {})
|
|
644
|
+
})
|
|
645
|
+
}),
|
|
646
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
647
|
+
id: "boundary",
|
|
648
|
+
title: "Keeping inside the canvas",
|
|
649
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
650
|
+
"By default the overlay stays inside the element's outermost scrolling ancestor, a builder's canvas, cut by every box that clips it and by the window. Boxes that clip inside the canvas, such as a section with rounded corners on the page being edited, do not count. A bar above the canvas is outside it already; a panel or a bar that lies over it goes in ",
|
|
651
|
+
/* @__PURE__ */ jsx("code", { children: "avoid" }),
|
|
652
|
+
", and each takes the strip it covers off the side that leaves the most room."
|
|
653
|
+
] }),
|
|
654
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
655
|
+
columns: ["boundary", "Keeps it inside"],
|
|
656
|
+
rows: [
|
|
657
|
+
["auto", "The anchor’s outermost scrolling ancestor, cut by every box that clips it and by the window. Right for a builder whose canvas is the page’s scroller."],
|
|
658
|
+
["an element", "The part of that element on screen. For a canvas inside a page that scrolls itself, as on this page."],
|
|
659
|
+
["viewport", "The window."],
|
|
660
|
+
["() => OverlayRect", "A box you work out each frame."]
|
|
661
|
+
]
|
|
662
|
+
})
|
|
663
|
+
}),
|
|
664
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
665
|
+
id: "own-loop",
|
|
666
|
+
title: "Your own loop",
|
|
667
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
668
|
+
"The decision is a pure function, for a host that already runs a frame loop or measures elsewhere:",
|
|
669
|
+
" ",
|
|
670
|
+
/* @__PURE__ */ jsx("code", { children: "placeAnchoredOverlay(anchor, size, boundary, options)" }),
|
|
671
|
+
" returns where the overlay goes.",
|
|
672
|
+
" ",
|
|
673
|
+
/* @__PURE__ */ jsx("code", { children: "visibleArea" }),
|
|
674
|
+
" cuts a canvas by the boxes that clip it and the window, and",
|
|
675
|
+
" ",
|
|
676
|
+
/* @__PURE__ */ jsx("code", { children: "boundaryWithout" }),
|
|
677
|
+
" takes the boxes to avoid off it."
|
|
678
|
+
] }),
|
|
679
|
+
children: /* @__PURE__ */ jsx(CodeBlock$1, { code: `
|
|
680
|
+
const boundary = boundaryWithout(visibleArea([scroller.getBoundingClientRect()], windowBox), [bar.getBoundingClientRect()])
|
|
681
|
+
const { top, left, placement, visible } = placeAnchoredOverlay(
|
|
682
|
+
element.getBoundingClientRect(),
|
|
683
|
+
{ width: overlay.offsetWidth, height: overlay.offsetHeight },
|
|
684
|
+
boundary,
|
|
685
|
+
{ side: 'top', align: 'start' },
|
|
686
|
+
)` })
|
|
687
|
+
}),
|
|
688
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
689
|
+
id: "accessibility",
|
|
690
|
+
title: "Accessibility",
|
|
691
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
692
|
+
"The hook only places the overlay. What it holds is yours to name: a toolbar is role=\"toolbar\" with a label naming the element it acts on, as above.",
|
|
693
|
+
"An overlay portalled to the end of the page sits at the end of the tab order. Give keyboard users a way to it next to its element: a shortcut that moves focus into it, or a portal into the canvas’s own layer.",
|
|
694
|
+
"When an action removes the control that had focus (Delete here), move focus to what took its place, never to the page.",
|
|
695
|
+
"A hidden overlay is visibility: hidden, so it cannot be focused or read while its element is out of view.",
|
|
696
|
+
"Name tags and rings that only repeat what is on the page are aria-hidden."
|
|
697
|
+
] })
|
|
698
|
+
}),
|
|
699
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
700
|
+
id: "props",
|
|
701
|
+
title: "Options and return",
|
|
702
|
+
children: /* @__PURE__ */ jsx(PropsTable, { rows: [
|
|
703
|
+
{
|
|
704
|
+
name: "anchor",
|
|
705
|
+
type: "Element | AnchorPoint | VirtualAnchor | null",
|
|
706
|
+
description: "The first argument: what to pin to. Nothing (null) keeps the overlay hidden."
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
name: "open",
|
|
710
|
+
type: "boolean",
|
|
711
|
+
default: "true",
|
|
712
|
+
description: "Whether the overlay shows. While false it is hidden and nothing is measured."
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
name: "side",
|
|
716
|
+
type: "'top' | 'bottom' | 'cover'",
|
|
717
|
+
default: "'top'",
|
|
718
|
+
description: "The side to prefer, or cover to lie over the element."
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
name: "align",
|
|
722
|
+
type: "'start' | 'center' | 'end'",
|
|
723
|
+
default: "'start'",
|
|
724
|
+
description: "Where along the element it lines up. Start is the right edge in a right-to-left page."
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
name: "offset",
|
|
728
|
+
type: "number",
|
|
729
|
+
default: "2 (cover: 0)",
|
|
730
|
+
description: "The gap from the element, or how far a cover reaches past it."
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
name: "inset",
|
|
734
|
+
type: "number",
|
|
735
|
+
default: "4",
|
|
736
|
+
description: "The gap from the edge when placed inside a tall element."
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
name: "shortHeight",
|
|
740
|
+
type: "number",
|
|
741
|
+
default: "120",
|
|
742
|
+
description: "The height up to which an element is short."
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
name: "margin",
|
|
746
|
+
type: "number",
|
|
747
|
+
default: "2",
|
|
748
|
+
description: "The room kept from the canvas edges."
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
name: "boundary",
|
|
752
|
+
type: "'auto' | 'viewport' | Element | () => OverlayRect",
|
|
753
|
+
default: "'auto'",
|
|
754
|
+
description: "What to keep the overlay inside."
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
name: "avoid",
|
|
758
|
+
type: "Array<Element | RefObject | null>",
|
|
759
|
+
description: "Bars and panels over the canvas to keep off."
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
name: "strategy",
|
|
763
|
+
type: "'fixed' | 'absolute'",
|
|
764
|
+
default: "'fixed'",
|
|
765
|
+
description: "Fixed in the window, or absolute against the overlay’s offset parent."
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
name: "onPlace",
|
|
769
|
+
type: "(position: AnchoredPosition) => void",
|
|
770
|
+
description: "Called when the overlay changes side or shows or hides, not every frame."
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
name: "returns.ref",
|
|
774
|
+
type: "RefCallback<T>",
|
|
775
|
+
description: "Put on the overlay’s element."
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
name: "returns.update",
|
|
779
|
+
type: "() => void",
|
|
780
|
+
description: "Places the overlay now, outside the frame loop."
|
|
781
|
+
}
|
|
782
|
+
] })
|
|
783
|
+
})
|
|
784
|
+
]
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
//#endregion
|
|
788
|
+
export { Page, Preview };
|