@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.
Files changed (232) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +6 -2
  3. package/dist/docs.css +20787 -0
  4. package/dist/index.d.ts +33 -0
  5. package/dist/index.js +308 -0
  6. package/dist/pages/Playground-Mk1yIWXb.js +129 -0
  7. package/dist/pages/_address-data-L9BR499w.js +161 -0
  8. package/dist/pages/_builder-demo-C0eJUmPU.js +282 -0
  9. package/dist/pages/_card-art-0be5ncyV.js +18 -0
  10. package/dist/pages/_conversation-samples-Bq7cn-4d.js +70 -0
  11. package/dist/pages/_figures-data-DaDvB7Nm.js +606 -0
  12. package/dist/pages/_foundations-blXWyYh8.js +30 -0
  13. package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
  14. package/dist/pages/_overlays-specimens-bawR331Z.js +320 -0
  15. package/dist/pages/_preview-specimens-DKQC9HAo.js +153 -0
  16. package/dist/pages/accordion-Sg0TUqxB.js +1036 -0
  17. package/dist/pages/address-autocomplete-DP0PUOlK.js +360 -0
  18. package/dist/pages/address-block-BZOOOPA9.js +368 -0
  19. package/dist/pages/address-fields-CwSqro3W.js +277 -0
  20. package/dist/pages/ai-highlight-D3x2vD83.js +642 -0
  21. package/dist/pages/alert-D3i7xZTU.js +914 -0
  22. package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
  23. package/dist/pages/app-shell-D4hdlHps.js +1558 -0
  24. package/dist/pages/area-chart-BEWFwiB2.js +718 -0
  25. package/dist/pages/avatar-BFEqQViw.js +895 -0
  26. package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
  27. package/dist/pages/badge-0-PyMrih.js +1035 -0
  28. package/dist/pages/bar-chart-DkLogYlt.js +1060 -0
  29. package/dist/pages/bar-fold-B-3XeIDZ.js +360 -0
  30. package/dist/pages/board-card-D2tZY_mU.js +415 -0
  31. package/dist/pages/brand-mark-BqiLvFSR.js +417 -0
  32. package/dist/pages/button-DAyfssDY.js +715 -0
  33. package/dist/pages/calendar-Ds7KsgSI.js +682 -0
  34. package/dist/pages/canvas-stage-1KiPspkX.js +472 -0
  35. package/dist/pages/card-CQEM1_wc.js +1567 -0
  36. package/dist/pages/caret-suggestions-oHI6QvqW.js +526 -0
  37. package/dist/pages/chart-legend-B20AbakD.js +724 -0
  38. package/dist/pages/chat-composer-CwzUJYIa.js +437 -0
  39. package/dist/pages/checkbox-BG9Zkb6j.js +1581 -0
  40. package/dist/pages/checklist-card-DEyykVFS.js +783 -0
  41. package/dist/pages/chip-Ck-o3Ui6.js +839 -0
  42. package/dist/pages/chip-list-k1LxXuCi.js +414 -0
  43. package/dist/pages/clamp-text-n-iE8RDR.js +203 -0
  44. package/dist/pages/coachmark-Be2ghobT.js +366 -0
  45. package/dist/pages/code-block-Dv_Y5GYq.js +622 -0
  46. package/dist/pages/collab-field-CfqqK7d2.js +696 -0
  47. package/dist/pages/color-field-CZpfcA-A.js +1127 -0
  48. package/dist/pages/colour-q2ntvI0w.js +1974 -0
  49. package/dist/pages/column-mapper-TsTG39cl.js +502 -0
  50. package/dist/pages/combobox-DvK2j5tI.js +1334 -0
  51. package/dist/pages/command-palette-CJ7uBA04.js +1386 -0
  52. package/dist/pages/comment-box-CDSGYhr5.js +346 -0
  53. package/dist/pages/composer-D4B0NgpA.js +689 -0
  54. package/dist/pages/condition-builder-BZy2ZGXe.js +715 -0
  55. package/dist/pages/conflict-chooser-C--_9UIS.js +210 -0
  56. package/dist/pages/context-menu-F9DV30ia.js +487 -0
  57. package/dist/pages/copy-button-Cn7WiKRF.js +568 -0
  58. package/dist/pages/copy-field-D3Xt3Jq6.js +511 -0
  59. package/dist/pages/danger-zone-Db_UUeiP.js +564 -0
  60. package/dist/pages/date-input-GOW067EB.js +956 -0
  61. package/dist/pages/date-picker-GdBciR99.js +1569 -0
  62. package/dist/pages/date-time-BLKCXtVZ.js +678 -0
  63. package/dist/pages/delta-CNAGv8JY.js +779 -0
  64. package/dist/pages/description-list-BPeXn1eW.js +1268 -0
  65. package/dist/pages/device-switcher-BCaN99c1.js +554 -0
  66. package/dist/pages/dialog-CRpkRC98.js +3164 -0
  67. package/dist/pages/docs-lM2UBSir.js +520 -0
  68. package/dist/pages/doodle-nzkqi2UI.js +201 -0
  69. package/dist/pages/drag-ghost-B6kpzC3O.js +426 -0
  70. package/dist/pages/drill-menu-cskH5mol.js +490 -0
  71. package/dist/pages/dropzone-DOY_Rhw0.js +1069 -0
  72. package/dist/pages/element-toolbar-DZIhXlCJ.js +498 -0
  73. package/dist/pages/emoji-picker-CqaWaffD.js +235 -0
  74. package/dist/pages/empty-state-4U2txFpI.js +1113 -0
  75. package/dist/pages/facet-filters-McbBeY9e.js +353 -0
  76. package/dist/pages/figure-D-HF5vCj.js +563 -0
  77. package/dist/pages/figure-strip-BB3mNl7D.js +1364 -0
  78. package/dist/pages/figure-tabs-QOeQMY6N.js +578 -0
  79. package/dist/pages/file-chip-DMDjtlqQ.js +738 -0
  80. package/dist/pages/filter-pill-DzqNOsD4.js +1295 -0
  81. package/dist/pages/font-picker-Bqhu0QMh.js +416 -0
  82. package/dist/pages/form-grid-BfWCVlie.js +692 -0
  83. package/dist/pages/gallery-BBk2EOri.js +453 -0
  84. package/dist/pages/gif-picker-CnoDTCaL.js +270 -0
  85. package/dist/pages/gradient-editor-Bqxp7Fxj.js +378 -0
  86. package/dist/pages/grouped-checklist-gNZ0tBKU.js +477 -0
  87. package/dist/pages/heatmap-BohgIcNk.js +507 -0
  88. package/dist/pages/highlight-text-BfxzfmvS.js +287 -0
  89. package/dist/pages/home-dashboard-CxPmvduE.js +962 -0
  90. package/dist/pages/host-B6znjEgQ.js +109 -0
  91. package/dist/pages/hosted-embed-Jef3aIMP.js +163 -0
  92. package/dist/pages/hosted-field-BLh-53AE.js +208 -0
  93. package/dist/pages/hosted-field-DEpI4lVS.js +514 -0
  94. package/dist/pages/icon-button-Bu4Gj5sy.js +1200 -0
  95. package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
  96. package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
  97. package/dist/pages/icons-CJ9Aar3d.js +736 -0
  98. package/dist/pages/image-cropper-NyougqLH.js +466 -0
  99. package/dist/pages/image-field-7knBv4mJ.js +567 -0
  100. package/dist/pages/import-result-CmTtGXW_.js +486 -0
  101. package/dist/pages/inline-confirm-CEcI5Lxo.js +327 -0
  102. package/dist/pages/inline-edit-Ba39SzhM.js +1125 -0
  103. package/dist/pages/input-CzLCzfyx.js +2372 -0
  104. package/dist/pages/installation-C3UcpQJT.js +528 -0
  105. package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
  106. package/dist/pages/kanban-Dy9sPAI0.js +740 -0
  107. package/dist/pages/kbd-UNj4zqxn.js +545 -0
  108. package/dist/pages/layout-primitives-CPRaZeyt.js +483 -0
  109. package/dist/pages/line-chart-CntWxeMF.js +1117 -0
  110. package/dist/pages/link-CXqvAg9z.js +689 -0
  111. package/dist/pages/link-picker-BMFGCC67.js +478 -0
  112. package/dist/pages/link-row-x8yaUuWc.js +595 -0
  113. package/dist/pages/live-globe-95ROMhGQ.js +715 -0
  114. package/dist/pages/loading-overlay-BeGuXM9G.js +456 -0
  115. package/dist/pages/loading-state-BNbCo51C.js +556 -0
  116. package/dist/pages/log-viewer-BQz8I_a2.js +503 -0
  117. package/dist/pages/logo-B38rnzoq.js +571 -0
  118. package/dist/pages/lottie_light-CxEH8eiR.js +9116 -0
  119. package/dist/pages/markdown-Ied72vMT.js +237 -0
  120. package/dist/pages/markdown-field-BfnIEKZH.js +193 -0
  121. package/dist/pages/media-banner-DkStCia0.js +233 -0
  122. package/dist/pages/menu-NrLYKqKp.js +2132 -0
  123. package/dist/pages/message-thread-Bo4zbxqu.js +731 -0
  124. package/dist/pages/meta-line-D5p2TycR.js +371 -0
  125. package/dist/pages/model-viewer-BfokvHoc.js +60288 -0
  126. package/dist/pages/model-viewer-C8PFO8wk.js +577 -0
  127. package/dist/pages/month-calendar-T1vw9Rup.js +457 -0
  128. package/dist/pages/motion-CrXtiBvA.js +865 -0
  129. package/dist/pages/number-input-CuyMZg18.js +968 -0
  130. package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
  131. package/dist/pages/orbit-spinner-Dxv5qAhr.js +348 -0
  132. package/dist/pages/otp-input-CVRoX1mw.js +591 -0
  133. package/dist/pages/overview-LA9XRhZc.js +130 -0
  134. package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
  135. package/dist/pages/pagination-C1EgVtW4.js +294 -0
  136. package/dist/pages/palette-tile-X9ZXu2Z0.js +414 -0
  137. package/dist/pages/password-field-DHEQKyUC.js +912 -0
  138. package/dist/pages/person-cell-BmjbADBz.js +564 -0
  139. package/dist/pages/phone-input-B3G7Qpb2.js +747 -0
  140. package/dist/pages/plan-card-DRaA6RuB.js +621 -0
  141. package/dist/pages/plan-card-DtloWvMh.js +258 -0
  142. package/dist/pages/plan-comparison-BVIGTtbd.js +559 -0
  143. package/dist/pages/plan-grid-cfPVTB5V.js +251 -0
  144. package/dist/pages/point-list-BbPmZjsm.js +222 -0
  145. package/dist/pages/popover-C3Oar9D5.js +1198 -0
  146. package/dist/pages/presence-avatars-CRZIk8n9.js +328 -0
  147. package/dist/pages/preview-frame-Bcwk0y_Q.js +1631 -0
  148. package/dist/pages/price-CRBLoa9h.js +604 -0
  149. package/dist/pages/principles-pnDyfHpK.js +483 -0
  150. package/dist/pages/print-page-BkLv6bW8.js +513 -0
  151. package/dist/pages/profile-hero-CC9dUzuN.js +498 -0
  152. package/dist/pages/progress-CP_awmo4.js +904 -0
  153. package/dist/pages/progress-ring-JuOAwk2T.js +576 -0
  154. package/dist/pages/radio-group-C-4tg6FS.js +1639 -0
  155. package/dist/pages/radius-control-B2kRA2Ch.js +441 -0
  156. package/dist/pages/rating-CweKN2SX.js +471 -0
  157. package/dist/pages/record-layout-DUP_X0RL.js +719 -0
  158. package/dist/pages/record-pager-y9D7JFgb.js +278 -0
  159. package/dist/pages/registry-BZg-xAbi.js +594 -0
  160. package/dist/pages/release-Cs6tl16C.js +16 -0
  161. package/dist/pages/repeater-BRZYKRQa.js +1351 -0
  162. package/dist/pages/reply-feedback-BDnHprla.js +192 -0
  163. package/dist/pages/reveal-BygENBbL.js +460 -0
  164. package/dist/pages/rich-text-DOFQZEpT.js +156 -0
  165. package/dist/pages/rich-text-editor-BhIM20JI.js +1265 -0
  166. package/dist/pages/rolldown-runtime-CbKu08Hx.js +25 -0
  167. package/dist/pages/rolling-number-GR3Cyfpz.js +529 -0
  168. package/dist/pages/row-list-Dl6CYhC-.js +1565 -0
  169. package/dist/pages/rule-list-DTCmIMpT.js +648 -0
  170. package/dist/pages/save-status-B5KkyMZP.js +378 -0
  171. package/dist/pages/schedule-YycI95O1.js +243 -0
  172. package/dist/pages/scroll-area-B2sGm23Q.js +423 -0
  173. package/dist/pages/search-field-D1uG7R6A.js +693 -0
  174. package/dist/pages/search-menu-DMuXyUUW.js +580 -0
  175. package/dist/pages/secret-field-Dj9x3LL8.js +337 -0
  176. package/dist/pages/section-rail-BtTCETS5.js +637 -0
  177. package/dist/pages/section-v2Pubup9.js +639 -0
  178. package/dist/pages/segmented-control-D-FB1K1T.js +1190 -0
  179. package/dist/pages/select-DZ43NpOm.js +1434 -0
  180. package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
  181. package/dist/pages/separator-CFwqRvfO.js +428 -0
  182. package/dist/pages/serp-preview-BGwORjmo.js +346 -0
  183. package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
  184. package/dist/pages/shape-DzniHAVT.js +627 -0
  185. package/dist/pages/share-list-D4wgBxKN.js +926 -0
  186. package/dist/pages/side-panel-CCtkrZjs.js +811 -0
  187. package/dist/pages/site-preview-Dj1hM2Yo.js +353 -0
  188. package/dist/pages/skeleton-C1F5HkAu.js +1325 -0
  189. package/dist/pages/skip-link-BxznhSkz.js +252 -0
  190. package/dist/pages/slider-CAoPURKD.js +774 -0
  191. package/dist/pages/sortable-card-Sr44uCpI.js +424 -0
  192. package/dist/pages/sortable-list-DUAleYE1.js +1298 -0
  193. package/dist/pages/sortable-tree-BLzK-hTE.js +737 -0
  194. package/dist/pages/spacing-box-CtuvzxQu.js +550 -0
  195. package/dist/pages/sparkline-D3aavCly.js +947 -0
  196. package/dist/pages/split-bar-DYgZnFID.js +414 -0
  197. package/dist/pages/split-button-Be08-VI-.js +335 -0
  198. package/dist/pages/split-pane-lSNZgTKt.js +523 -0
  199. package/dist/pages/status-badge-DOdNhmzn.js +1074 -0
  200. package/dist/pages/status-checklist-CWkjCZIC.js +1152 -0
  201. package/dist/pages/status-dot-D99gAGsV.js +567 -0
  202. package/dist/pages/stepper-CxKTbEA-.js +1093 -0
  203. package/dist/pages/success-mark-CqFTOBEu.js +142 -0
  204. package/dist/pages/swatch-H_kNvHuC.js +565 -0
  205. package/dist/pages/switch-C93K6j9h.js +617 -0
  206. package/dist/pages/table-CL0vomno.js +3225 -0
  207. package/dist/pages/tabs-Dh0mUsLw.js +1690 -0
  208. package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
  209. package/dist/pages/task-card-Dv0sR1-w.js +295 -0
  210. package/dist/pages/textarea-CCM-SnGN.js +949 -0
  211. package/dist/pages/thumbnail-DwFJL_k1.js +1147 -0
  212. package/dist/pages/time-input-CA9-uZAa.js +442 -0
  213. package/dist/pages/time-zone-select-CEtMXVYO.js +296 -0
  214. package/dist/pages/timeline-BsMUTlpR.js +1798 -0
  215. package/dist/pages/toast-zXLRiMRT.js +1391 -0
  216. package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
  217. package/dist/pages/toolbar-B9l_fHKy.js +754 -0
  218. package/dist/pages/tooltip-LHtCUkF-.js +826 -0
  219. package/dist/pages/translation-field-CTRXiF2N.js +251 -0
  220. package/dist/pages/tree-checklist-CJj3OcLg.js +451 -0
  221. package/dist/pages/tree-select-DU1qXHy_.js +492 -0
  222. package/dist/pages/tree-view-g_RjLtAb.js +739 -0
  223. package/dist/pages/typography-BSijtiRl.js +876 -0
  224. package/dist/pages/unit-input-Dml4fjmK.js +659 -0
  225. package/dist/pages/upload-rules-yozEzSah.js +419 -0
  226. package/dist/pages/url-upload-input-SSnMgfpA.js +307 -0
  227. package/dist/pages/value-change-CnubDKyO.js +489 -0
  228. package/dist/pages/weekly-hours-i2EpsmTx.js +287 -0
  229. package/dist/pages/widget-preview-CUJMyZ_k.js +625 -0
  230. package/dist/pages/working-status-CENemSsw.js +389 -0
  231. package/manifest.json +13001 -0
  232. package/package.json +35 -4
@@ -0,0 +1,1069 @@
1
+ "use client";
2
+ import { a as DocTable, d as Section$1, i as DocPage, m as ThemePair, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
3
+ import { useState } from "react";
4
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
+ import { Button, Dropzone, Field, FileChip, formatFileSize, useFileDrop } from "@orbitcommerce/constellation";
6
+ import { FileCsvIcon, ImageSquareIcon, UploadSimpleIcon } from "@orbitcommerce/constellation/icons";
7
+ //#region src/pages/components/dropzone.tsx
8
+ var MB = 1048576;
9
+ function Preview() {
10
+ return /* @__PURE__ */ jsx("div", {
11
+ className: "dropzone-preview",
12
+ children: /* @__PURE__ */ jsx(Dropzone, {
13
+ icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
14
+ title: "Drop a file here",
15
+ action: "Add file",
16
+ onFiles: () => {}
17
+ })
18
+ });
19
+ }
20
+ /** The import pattern: a zone until a file is chosen, then the chip that stands for it. */
21
+ function ImportDemo({ variant = "well" }) {
22
+ const [file, setFile] = useState();
23
+ const [message, setMessage] = useState();
24
+ const [removed, setRemoved] = useState(false);
25
+ return /* @__PURE__ */ jsx("div", {
26
+ className: "dropzone-frame",
27
+ children: file ? /* @__PURE__ */ jsxs("div", {
28
+ className: "dropzone-stack",
29
+ children: [/* @__PURE__ */ jsx(FileChip, {
30
+ autoFocus: true,
31
+ name: file.name,
32
+ size: file.size,
33
+ accept: ".csv,.xls,.xlsx",
34
+ maxSize: 5 * MB,
35
+ onReplace: (next) => {
36
+ setFile(next);
37
+ setMessage(void 0);
38
+ },
39
+ onReject: ([first]) => setMessage(first?.message),
40
+ onRemove: () => {
41
+ setFile(void 0);
42
+ setMessage(void 0);
43
+ setRemoved(true);
44
+ }
45
+ }), message ? /* @__PURE__ */ jsx("ul", {
46
+ className: "dropzone-refusals",
47
+ role: "alert",
48
+ children: /* @__PURE__ */ jsx("li", { children: message })
49
+ }) : null]
50
+ }) : /* @__PURE__ */ jsx(Dropzone, {
51
+ autoFocus: removed,
52
+ variant,
53
+ icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
54
+ title: "Drop your products file here",
55
+ action: "Add file",
56
+ hint: "CSV or Excel, up to 5 MB",
57
+ accept: ".csv,.xls,.xlsx",
58
+ maxSize: 5 * MB,
59
+ onFiles: ([first]) => setFile(first)
60
+ })
61
+ });
62
+ }
63
+ /** Several images, three at most, 1 MB each: the rules and what is said about the files they turn away. */
64
+ function RulesDemo() {
65
+ const [files, setFiles] = useState([]);
66
+ const [refused, setRefused] = useState([]);
67
+ return /* @__PURE__ */ jsxs("div", {
68
+ className: "dropzone-stack",
69
+ children: [
70
+ /* @__PURE__ */ jsx(Dropzone, {
71
+ icon: /* @__PURE__ */ jsx(ImageSquareIcon, {}),
72
+ title: "Add up to three images",
73
+ action: "Choose images",
74
+ hint: "PNG, JPEG or WebP, up to 1 MB each",
75
+ accept: "image/png,image/jpeg,image/webp",
76
+ maxSize: MB,
77
+ maxFiles: 3,
78
+ count: files.length,
79
+ onFiles: (next) => {
80
+ setFiles((list) => [...list, ...next]);
81
+ setRefused([]);
82
+ },
83
+ onReject: setRefused
84
+ }),
85
+ refused.length > 0 ? /* @__PURE__ */ jsx("ul", {
86
+ className: "dropzone-refusals",
87
+ role: "alert",
88
+ children: refused.map((item) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("span", {
89
+ className: "dropzone-refusals__reason",
90
+ children: item.reason
91
+ }), item.message] }, `${item.file.name}-${item.reason}`))
92
+ }) : null,
93
+ files.length > 0 ? /* @__PURE__ */ jsx("ul", {
94
+ className: "dropzone-readout",
95
+ children: files.map((file, index) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(FileChip, {
96
+ variant: "row",
97
+ name: file.name,
98
+ size: file.size,
99
+ icon: /* @__PURE__ */ jsx(ImageSquareIcon, {}),
100
+ onRemove: () => setFiles((list) => list.filter((_, i) => i !== index))
101
+ }) }, `${file.name}-${index}`))
102
+ }) : /* @__PURE__ */ jsx("p", {
103
+ className: "dropzone-readout",
104
+ "data-empty": "",
105
+ children: "No images added yet. Try a PDF, or a fourth image."
106
+ })
107
+ ]
108
+ });
109
+ }
110
+ /** The zone leaves what it refused to say in its own hint line, because this demo gives it no onReject. */
111
+ function SaysItselfDemo() {
112
+ return /* @__PURE__ */ jsx("div", {
113
+ className: "dropzone-frame",
114
+ children: /* @__PURE__ */ jsx(Dropzone, {
115
+ icon: /* @__PURE__ */ jsx(FileCsvIcon, {}),
116
+ title: "Drop a CSV",
117
+ hint: "CSV only, up to 100 KB",
118
+ accept: ".csv",
119
+ maxSize: 102400,
120
+ onFiles: () => {}
121
+ })
122
+ });
123
+ }
124
+ /** Every refusal handed over with its reason, to show as the page likes. */
125
+ function OnRejectDemo() {
126
+ const [refused, setRefused] = useState([]);
127
+ return /* @__PURE__ */ jsxs("div", {
128
+ className: "dropzone-stack",
129
+ children: [/* @__PURE__ */ jsx(Dropzone, {
130
+ icon: /* @__PURE__ */ jsx(ImageSquareIcon, {}),
131
+ title: "Drop images here",
132
+ hint: "PNG or JPEG, up to 1 MB each",
133
+ accept: "image/png,image/jpeg",
134
+ maxSize: MB,
135
+ multiple: true,
136
+ onFiles: () => setRefused([]),
137
+ onReject: setRefused
138
+ }), refused.length > 0 ? /* @__PURE__ */ jsx("ul", {
139
+ className: "dropzone-refusals",
140
+ role: "alert",
141
+ children: refused.map((item) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("span", {
142
+ className: "dropzone-refusals__reason",
143
+ children: item.reason
144
+ }), item.message] }, `${item.file.name}-${item.reason}`))
145
+ }) : null]
146
+ });
147
+ }
148
+ /** A rule of the zone's own: the file's name has to say what it is. */
149
+ function ValidateDemo() {
150
+ const [taken, setTaken] = useState();
151
+ return /* @__PURE__ */ jsx("div", {
152
+ className: "dropzone-frame",
153
+ children: /* @__PURE__ */ jsx(Dropzone, {
154
+ variant: "dashed",
155
+ size: "compact",
156
+ icon: /* @__PURE__ */ jsx(FileCsvIcon, {}),
157
+ title: taken ? `Took ${taken}` : "Drop a file named products-…",
158
+ hint: "The name has to start with products-",
159
+ accept: ".csv",
160
+ validate: (file) => file.name.startsWith("products-") ? void 0 : `Rename ${file.name} to start with products-.`,
161
+ onFiles: ([first]) => setTaken(first?.name)
162
+ })
163
+ });
164
+ }
165
+ /** A Field around a zone: the label names it, the hint and the error are read with it. */
166
+ function FieldDemo() {
167
+ const [file, setFile] = useState();
168
+ const [tried, setTried] = useState(false);
169
+ const [removed, setRemoved] = useState(false);
170
+ return /* @__PURE__ */ jsxs("div", {
171
+ className: "dropzone-stack",
172
+ children: [/* @__PURE__ */ jsx(Field, {
173
+ label: "Supplier price list",
174
+ hint: "CSV, up to 5 MB.",
175
+ error: tried && !file ? "Add the price list before you continue." : void 0,
176
+ children: file ? /* @__PURE__ */ jsx(FileChip, {
177
+ autoFocus: true,
178
+ name: file.name,
179
+ size: file.size,
180
+ onRemove: () => {
181
+ setFile(void 0);
182
+ setRemoved(true);
183
+ }
184
+ }) : /* @__PURE__ */ jsx(Dropzone, {
185
+ autoFocus: removed,
186
+ size: "compact",
187
+ icon: /* @__PURE__ */ jsx(FileCsvIcon, {}),
188
+ title: "Drop the price list here",
189
+ action: "Add file",
190
+ accept: ".csv",
191
+ maxSize: 5 * MB,
192
+ onFiles: ([first]) => setFile(first)
193
+ })
194
+ }), /* @__PURE__ */ jsx("div", {
195
+ className: "dropzone-actions",
196
+ children: /* @__PURE__ */ jsx(Button, {
197
+ variant: "primary",
198
+ size: "sm",
199
+ onClick: () => setTried(true),
200
+ children: "Continue"
201
+ })
202
+ })]
203
+ });
204
+ }
205
+ /** A surface of the page's own, taking drops with the hook. */
206
+ function SurfaceDemo() {
207
+ const [names, setNames] = useState([]);
208
+ const drop = useFileDrop({
209
+ accept: "image/*",
210
+ multiple: true,
211
+ onFiles: (files) => setNames(files.map((file) => file.name))
212
+ });
213
+ const { ref: inputRef, ...input } = drop.inputProps;
214
+ return /* @__PURE__ */ jsxs("div", {
215
+ className: "dropzone-surface",
216
+ "data-over": drop.dragging ? "" : void 0,
217
+ ...drop.dropProps,
218
+ children: [
219
+ /* @__PURE__ */ jsx("p", {
220
+ className: "dropzone-surface__title",
221
+ children: drop.dragging ? "Let go to add them" : "Drop images anywhere on this panel"
222
+ }),
223
+ /* @__PURE__ */ jsx(Button, {
224
+ size: "sm",
225
+ onClick: drop.open,
226
+ children: "Browse images"
227
+ }),
228
+ /* @__PURE__ */ jsx("p", {
229
+ className: "dropzone-surface__names",
230
+ children: names.length > 0 ? names.join(", ") : "Nothing added yet"
231
+ }),
232
+ /* @__PURE__ */ jsx("input", {
233
+ ...input,
234
+ ref: inputRef
235
+ })
236
+ ]
237
+ });
238
+ }
239
+ var STATE_COPY = {
240
+ icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
241
+ title: "Drop your products file here",
242
+ action: "Add file",
243
+ hint: "CSV or Excel, up to 5 MB"
244
+ };
245
+ function Still({ name, note, variant, size, ...state }) {
246
+ return /* @__PURE__ */ jsxs("figure", {
247
+ className: "dropzone-state",
248
+ children: [/* @__PURE__ */ jsx(Dropzone, {
249
+ variant,
250
+ size,
251
+ onFiles: () => {},
252
+ ...STATE_COPY,
253
+ ...state
254
+ }), /* @__PURE__ */ jsxs("figcaption", { children: [/* @__PURE__ */ jsx("span", {
255
+ className: "dropzone-state__name",
256
+ children: name
257
+ }), note ? /* @__PURE__ */ jsxs("span", {
258
+ className: "dropzone-state__note",
259
+ children: [" ", note]
260
+ }) : null] })]
261
+ });
262
+ }
263
+ function States({ variant, size }) {
264
+ return /* @__PURE__ */ jsxs("div", {
265
+ className: "dropzone-states",
266
+ children: [
267
+ /* @__PURE__ */ jsx(Still, {
268
+ variant,
269
+ size,
270
+ name: "Resting"
271
+ }),
272
+ /* @__PURE__ */ jsx(Still, {
273
+ variant,
274
+ size,
275
+ name: "File over it",
276
+ dragging: true,
277
+ draggingTitle: "Let go to upload"
278
+ }),
279
+ /* @__PURE__ */ jsx(Still, {
280
+ variant,
281
+ size,
282
+ name: "Invalid",
283
+ invalid: true,
284
+ hint: "Your storage is full. Remove a file to add another."
285
+ }),
286
+ /* @__PURE__ */ jsx(Still, {
287
+ variant,
288
+ size,
289
+ name: "Busy",
290
+ busy: true,
291
+ hint: "Uploading products.csv"
292
+ }),
293
+ /* @__PURE__ */ jsx(Still, {
294
+ variant,
295
+ size,
296
+ name: "Disabled",
297
+ disabled: true
298
+ }),
299
+ /* @__PURE__ */ jsx(Still, {
300
+ variant,
301
+ size,
302
+ name: "Full",
303
+ maxFiles: 3,
304
+ count: 3,
305
+ title: "Add up to three files",
306
+ hint: "CSV, up to 5 MB each"
307
+ })
308
+ ]
309
+ });
310
+ }
311
+ function Page() {
312
+ return /* @__PURE__ */ jsxs(DocPage, {
313
+ title: "Dropzone",
314
+ status: "new",
315
+ importNames: [
316
+ "Dropzone",
317
+ "useFileDrop",
318
+ "formatFileSize"
319
+ ],
320
+ lead: "A place to put files, by dropping them on it or by clicking to browse. It holds every file to the rules you set, and says what it turned away, so nobody finds out by watching nothing happen.",
321
+ children: [
322
+ /* @__PURE__ */ jsxs(Section$1, {
323
+ id: "import",
324
+ title: "Choosing a file",
325
+ description: /* @__PURE__ */ jsxs("p", { children: [
326
+ "The zone is one control: Tab to it, press Enter or Space, or drop a file on it. It hands the files that passed to ",
327
+ /* @__PURE__ */ jsx("code", { children: "onFiles" }),
328
+ ". Once a file is chosen, put a ",
329
+ /* @__PURE__ */ jsx("code", { children: "FileChip" }),
330
+ " where the zone was, and let it offer Replace. Give the chip ",
331
+ /* @__PURE__ */ jsx("code", { children: "autoFocus" }),
332
+ " so the keyboard user's place moves with the swap, and the zone the same when it comes back. Nothing on this page is uploaded: a file only gets as far as its name."
333
+ ] }),
334
+ children: [/* @__PURE__ */ jsx(Example, {
335
+ align: "fill",
336
+ code: `
337
+ const [file, setFile] = useState<File>()
338
+
339
+ {file ? (
340
+ <FileChip
341
+ autoFocus
342
+ name={file.name}
343
+ size={file.size}
344
+ accept=".csv,.xls,.xlsx"
345
+ maxSize={5 * 1024 * 1024}
346
+ onReplace={setFile}
347
+ onRemove={() => {
348
+ setFile(undefined)
349
+ setRemoved(true)
350
+ }}
351
+ />
352
+ ) : (
353
+ <Dropzone
354
+ autoFocus={removed}
355
+ icon={<UploadSimpleIcon />}
356
+ title="Drop your products file here"
357
+ action="Add file"
358
+ hint="CSV or Excel, up to 5 MB"
359
+ accept=".csv,.xls,.xlsx"
360
+ maxSize={5 * 1024 * 1024}
361
+ onFiles={([first]) => setFile(first)}
362
+ />
363
+ )}`,
364
+ caption: "Drop a file, or choose one. Then try Replace with a PNG: the chip says why it was not taken.",
365
+ children: /* @__PURE__ */ jsx(ImportDemo, {})
366
+ }), /* @__PURE__ */ jsx(Fragment$1, {})]
367
+ }),
368
+ /* @__PURE__ */ jsx(Section$1, {
369
+ id: "variants",
370
+ title: "Variants",
371
+ description: /* @__PURE__ */ jsxs("p", { children: [
372
+ /* @__PURE__ */ jsx("code", { children: "well" }),
373
+ " is a sunken fill with a hairline dashed edge: it belongs in a dialog or a form, where it sits on a surface. ",
374
+ /* @__PURE__ */ jsx("code", { children: "dashed" }),
375
+ " is a firmer 1.5px line on the page itself with no fill, which lifts to the accent on hover: it belongs where the zone is the main thing, such as an empty media library."
376
+ ] }),
377
+ children: /* @__PURE__ */ jsx(Example, {
378
+ align: "fill",
379
+ code: `
380
+ <Dropzone variant="well" icon={<UploadSimpleIcon />} title="Drop your products file here" action="Add file" hint="CSV or Excel, up to 5 MB" onFiles={add} />
381
+
382
+ <Dropzone variant="dashed" icon={<UploadSimpleIcon />} title="Drop images here" action="Choose images" hint="PNG or JPEG, up to 5 MB" onFiles={add} />`,
383
+ children: /* @__PURE__ */ jsxs("div", {
384
+ className: "dropzone-stack",
385
+ children: [/* @__PURE__ */ jsx(Dropzone, {
386
+ variant: "well",
387
+ icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
388
+ title: "Drop your products file here",
389
+ action: "Add file",
390
+ hint: "CSV or Excel, up to 5 MB",
391
+ onFiles: () => {}
392
+ }), /* @__PURE__ */ jsx(Dropzone, {
393
+ variant: "dashed",
394
+ icon: /* @__PURE__ */ jsx(ImageSquareIcon, {}),
395
+ title: "Drop images here",
396
+ action: "Choose images",
397
+ hint: "PNG or JPEG, up to 5 MB",
398
+ onFiles: () => {}
399
+ })]
400
+ })
401
+ })
402
+ }),
403
+ /* @__PURE__ */ jsx(Section$1, {
404
+ id: "sizes",
405
+ title: "Sizes",
406
+ description: /* @__PURE__ */ jsxs("p", { children: [
407
+ /* @__PURE__ */ jsx("code", { children: "default" }),
408
+ " stacks the icon, title, pill and hint and centres them. ",
409
+ /* @__PURE__ */ jsx("code", { children: "compact" }),
410
+ " sets them in a row with less padding: a strip above a list, or a zone inside a picker. ",
411
+ /* @__PURE__ */ jsx("code", { children: "minimal" }),
412
+ " is a line of text for a gap in a form. Every part is optional, so a zone can be as plain as a pill and a hint."
413
+ ] }),
414
+ children: /* @__PURE__ */ jsx(Example, {
415
+ align: "fill",
416
+ code: `
417
+ <Dropzone icon={<UploadSimpleIcon />} title="Drop your products file here" action="Add file" hint="CSV or Excel, up to 5 MB" onFiles={add} />
418
+
419
+ <Dropzone size="compact" icon={<UploadSimpleIcon />} title="Drop files to upload" hint="Up to 100 MB each" action="Browse" onFiles={add} />
420
+
421
+ <Dropzone size="minimal" icon={<UploadSimpleIcon />} title="Drop a file or" action="browse" onFiles={add} />
422
+
423
+ {/* Only what you pass is drawn */}
424
+ <Dropzone action="Add file" hint="CSV or Excel, up to 5 MB" onFiles={add} />`,
425
+ children: /* @__PURE__ */ jsxs("div", {
426
+ className: "dropzone-stack",
427
+ children: [
428
+ /* @__PURE__ */ jsx(Dropzone, {
429
+ icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
430
+ title: "Drop your products file here",
431
+ action: "Add file",
432
+ hint: "CSV or Excel, up to 5 MB",
433
+ onFiles: () => {}
434
+ }),
435
+ /* @__PURE__ */ jsx(Dropzone, {
436
+ size: "compact",
437
+ icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
438
+ title: "Drop files to upload",
439
+ hint: "Up to 100 MB each",
440
+ action: "Browse",
441
+ onFiles: () => {}
442
+ }),
443
+ /* @__PURE__ */ jsx(Dropzone, {
444
+ size: "minimal",
445
+ icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
446
+ title: "Drop a file or",
447
+ action: "browse",
448
+ onFiles: () => {}
449
+ }),
450
+ /* @__PURE__ */ jsx(Dropzone, {
451
+ action: "Add file",
452
+ hint: "CSV or Excel, up to 5 MB",
453
+ onFiles: () => {}
454
+ })
455
+ ]
456
+ })
457
+ })
458
+ }),
459
+ /* @__PURE__ */ jsxs(Section$1, {
460
+ id: "states",
461
+ title: "States",
462
+ description: /* @__PURE__ */ jsxs("p", { children: [
463
+ "Hover lifts the edge. While a file is over the zone it takes the accent, scales up 1% and, with",
464
+ " ",
465
+ /* @__PURE__ */ jsx("code", { children: "draggingTitle" }),
466
+ ", changes its words; the zone knows by itself, and only for files (a dragged link or line of text does not count). ",
467
+ /* @__PURE__ */ jsx("code", { children: "invalid" }),
468
+ " turns the edge and the hint red, for your own rule (a full quota); ",
469
+ /* @__PURE__ */ jsx("code", { children: "busy" }),
470
+ " swaps the icon for a spinner and takes nothing until the work is done, while staying in the tab order; ",
471
+ /* @__PURE__ */ jsx("code", { children: "disabled" }),
472
+ " dims it and takes it out of the tab order. A zone whose",
473
+ " ",
474
+ /* @__PURE__ */ jsx("code", { children: "maxFiles" }),
475
+ " is reached says so and stops. The focus ring shows for keyboard focus only."
476
+ ] }),
477
+ children: [/* @__PURE__ */ jsx(Example, {
478
+ align: "fill",
479
+ code: `
480
+ <Dropzone {...copy} dragging draggingTitle="Let go to upload" onFiles={add} /> {/* forced; drops set it by themselves */}
481
+ <Dropzone {...copy} invalid hint="Your storage is full. Remove a file to add another." onFiles={add} />
482
+ <Dropzone {...copy} busy hint="Uploading products.csv" onFiles={add} />
483
+ <Dropzone {...copy} disabled onFiles={add} />
484
+ <Dropzone {...copy} maxFiles={3} count={3} title="Add up to three files" onFiles={add} />`,
485
+ caption: "The states are held in place. The first zone is live: drag a file over it.",
486
+ children: /* @__PURE__ */ jsx(States, {})
487
+ }), /* @__PURE__ */ jsx(SubSection, {
488
+ title: "Dashed",
489
+ description: /* @__PURE__ */ jsx("p", { children: "The same states on the page itself. Hover also lifts the line to the accent." }),
490
+ children: /* @__PURE__ */ jsx(Example, {
491
+ align: "fill",
492
+ children: /* @__PURE__ */ jsx(States, { variant: "dashed" })
493
+ })
494
+ })]
495
+ }),
496
+ /* @__PURE__ */ jsxs(Section$1, {
497
+ id: "rules",
498
+ title: "Rules and refusals",
499
+ description: /* @__PURE__ */ jsxs("p", { children: [
500
+ /* @__PURE__ */ jsx("code", { children: "accept" }),
501
+ " reads like an ",
502
+ /* @__PURE__ */ jsx("code", { children: "<input accept>" }),
503
+ ": extensions, MIME types and wildcards, comma separated. The browser only filters its own chooser, so the zone checks a drop against the same list. Name data and office files by extension (",
504
+ /* @__PURE__ */ jsx("code", { children: ".csv,.xlsx" }),
505
+ "): a browser may report another MIME type for the same file, or none, and a list of types alone then turns away files its own chooser offered.",
506
+ " ",
507
+ /* @__PURE__ */ jsx("code", { children: "maxSize" }),
508
+ " is in bytes. A file that breaks a rule is turned away alone, for its first broken rule, and the rest of the batch goes through. A dropped folder is always turned away, with or without",
509
+ " ",
510
+ /* @__PURE__ */ jsx("code", { children: "accept" }),
511
+ ". Whatever was turned away is said: pass",
512
+ " ",
513
+ /* @__PURE__ */ jsx("code", { children: "onReject" }),
514
+ " to show it your way, or leave it out and the zone says the first refusal in its hint line, turns invalid until the next choice, and announces it."
515
+ ] }),
516
+ children: [
517
+ /* @__PURE__ */ jsx(Example, {
518
+ align: "fill",
519
+ code: `
520
+ <Dropzone
521
+ icon={<FileCsvIcon />}
522
+ title="Drop a CSV"
523
+ hint="CSV only, up to 100 KB"
524
+ accept=".csv"
525
+ maxSize={100 * 1024}
526
+ onFiles={add}
527
+ />`,
528
+ caption: "No onReject here. Drop a PNG, or a CSV over 100 KB.",
529
+ children: /* @__PURE__ */ jsx(SaysItselfDemo, {})
530
+ }),
531
+ /* @__PURE__ */ jsxs(SubSection, {
532
+ title: "Saying it your way",
533
+ description: /* @__PURE__ */ jsxs("p", { children: [
534
+ /* @__PURE__ */ jsx("code", { children: "onReject" }),
535
+ " gets every refused file in one call, each with its ",
536
+ /* @__PURE__ */ jsx("code", { children: "reason" }),
537
+ " and a",
538
+ " ",
539
+ /* @__PURE__ */ jsx("code", { children: "message" }),
540
+ " that names the file and says what to do. Show them as a toast, an alert or a list. The zone then says nothing of its own."
541
+ ] }),
542
+ children: [/* @__PURE__ */ jsx(DocTable, {
543
+ columns: [
544
+ "Reason",
545
+ "When",
546
+ "Message"
547
+ ],
548
+ rows: [
549
+ [
550
+ /* @__PURE__ */ jsx("code", { children: "type" }),
551
+ "The file is not on the accept list.",
552
+ "photo.png is not a supported file type. Use PNG, JPEG or WebP."
553
+ ],
554
+ [
555
+ /* @__PURE__ */ jsx("code", { children: "size" }),
556
+ "The file is over maxSize.",
557
+ "scan.png is over the 1 MB limit."
558
+ ],
559
+ [
560
+ /* @__PURE__ */ jsx("code", { children: "custom" }),
561
+ "Your validate function returned a reason.",
562
+ "Whatever validate returned, as it is."
563
+ ],
564
+ [
565
+ /* @__PURE__ */ jsx("code", { children: "count" }),
566
+ "More files than there is room for.",
567
+ "fourth.png was not added. The limit is 3 files."
568
+ ],
569
+ [
570
+ /* @__PURE__ */ jsx("code", { children: "folder" }),
571
+ "A folder was dropped. Only files can be uploaded.",
572
+ "Photos is a folder. Drop files, not folders."
573
+ ]
574
+ ]
575
+ }), /* @__PURE__ */ jsx(Example, {
576
+ align: "fill",
577
+ code: `
578
+ <Dropzone
579
+ icon={<ImageSquareIcon />}
580
+ title="Drop images here"
581
+ hint="PNG or JPEG, up to 1 MB each"
582
+ accept="image/png,image/jpeg"
583
+ maxSize={1024 * 1024}
584
+ multiple
585
+ onFiles={() => setRefused([])}
586
+ onReject={(rejections) => setRefused(rejections)}
587
+ />
588
+
589
+ {refused.map((item) => <p key={item.file.name}>{item.reason}: {item.message}</p>)}`,
590
+ caption: "Drop a PDF and a PNG over 1 MB together. Each is judged alone, with its own reason.",
591
+ children: /* @__PURE__ */ jsx(OnRejectDemo, {})
592
+ })]
593
+ }),
594
+ /* @__PURE__ */ jsx(SubSection, {
595
+ title: "Your own rule",
596
+ description: /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "validate" }), " runs on each file that passed type and size. Return the reason to turn it away, in words the person can act on, or nothing to take it."] }),
597
+ children: /* @__PURE__ */ jsx(Example, {
598
+ align: "fill",
599
+ code: `
600
+ <Dropzone
601
+ variant="dashed"
602
+ size="compact"
603
+ accept=".csv"
604
+ title="Drop a file named products-…"
605
+ validate={(file) => (file.name.startsWith('products-') ? undefined : \`Rename \${file.name} to start with products-.\`)}
606
+ onFiles={([first]) => setTaken(first.name)}
607
+ />`,
608
+ children: /* @__PURE__ */ jsx(ValidateDemo, {})
609
+ })
610
+ }),
611
+ /* @__PURE__ */ jsx(SubSection, {
612
+ title: "Words",
613
+ description: /* @__PURE__ */ jsxs("p", { children: [
614
+ "The sentences are replaceable. ",
615
+ /* @__PURE__ */ jsx("code", { children: "labels" }),
616
+ " takes any of ",
617
+ /* @__PURE__ */ jsx("code", { children: "rejectType" }),
618
+ ",",
619
+ " ",
620
+ /* @__PURE__ */ jsx("code", { children: "rejectSize" }),
621
+ ", ",
622
+ /* @__PURE__ */ jsx("code", { children: "rejectCount" }),
623
+ ", ",
624
+ /* @__PURE__ */ jsx("code", { children: "rejectFolder" }),
625
+ ", ",
626
+ /* @__PURE__ */ jsx("code", { children: "moreRejected" }),
627
+ " and the zone's own ",
628
+ /* @__PURE__ */ jsx("code", { children: "chooseFile" }),
629
+ ", ",
630
+ /* @__PURE__ */ jsx("code", { children: "chooseFiles" }),
631
+ ", ",
632
+ /* @__PURE__ */ jsx("code", { children: "busy" }),
633
+ " and",
634
+ " ",
635
+ /* @__PURE__ */ jsx("code", { children: "full" }),
636
+ ". The size limit reaches ",
637
+ /* @__PURE__ */ jsx("code", { children: "rejectSize" }),
638
+ " already formatted:",
639
+ " ",
640
+ /* @__PURE__ */ jsx("code", { children: "formatFileSize(1_500_000)" }),
641
+ " is ",
642
+ formatFileSize(15e5),
643
+ ". ",
644
+ /* @__PURE__ */ jsx("code", { children: "rejectType" }),
645
+ " is given the formats in words (\"CSV, XLS, XLSX\") as well as the raw list, so a translation can name them, and",
646
+ " ",
647
+ /* @__PURE__ */ jsx("code", { children: "rejectCount" }),
648
+ " is told how much room there was and the most files there may be."
649
+ ] })
650
+ })
651
+ ]
652
+ }),
653
+ /* @__PURE__ */ jsx(Section$1, {
654
+ id: "several",
655
+ title: "Several files",
656
+ description: /* @__PURE__ */ jsxs("p", { children: [
657
+ /* @__PURE__ */ jsx("code", { children: "maxFiles" }),
658
+ " above 1 lets the zone take a batch (or set ",
659
+ /* @__PURE__ */ jsx("code", { children: "multiple" }),
660
+ "). Tell it how many you already hold with ",
661
+ /* @__PURE__ */ jsx("code", { children: "count" }),
662
+ " and it leaves the right room, and goes ",
663
+ /* @__PURE__ */ jsx("code", { children: "full" }),
664
+ " when there is none, until a file is removed. A ",
665
+ /* @__PURE__ */ jsx("code", { children: "maxFiles" }),
666
+ " of 1 is the replace-in-place zone: it is never full, and a new file takes the old one's place."
667
+ ] }),
668
+ children: /* @__PURE__ */ jsx(Example, {
669
+ align: "fill",
670
+ code: `
671
+ <Dropzone
672
+ icon={<ImageSquareIcon />}
673
+ title="Add up to three images"
674
+ action="Choose images"
675
+ hint="PNG, JPEG or WebP, up to 1 MB each"
676
+ accept="image/png,image/jpeg,image/webp"
677
+ maxSize={1024 * 1024}
678
+ maxFiles={3}
679
+ count={files.length}
680
+ onFiles={(next) => setFiles((list) => [...list, ...next])}
681
+ />
682
+
683
+ {files.map((file, index) => (
684
+ <FileChip key={index} variant="row" name={file.name} size={file.size} onRemove={() => remove(index)} />
685
+ ))}`,
686
+ caption: "Drop four files at once: three are added and the fourth is turned away. Remove one and the zone has room again.",
687
+ children: /* @__PURE__ */ jsx(RulesDemo, {})
688
+ })
689
+ }),
690
+ /* @__PURE__ */ jsx(Section$1, {
691
+ id: "field",
692
+ title: "In a Field",
693
+ description: /* @__PURE__ */ jsxs("p", { children: [
694
+ "Inside a ",
695
+ /* @__PURE__ */ jsx("code", { children: "Field" }),
696
+ " the zone is named by the label as well as its own words, is described by the Field's hint or error, and turns invalid when the Field has an error. The Field's ",
697
+ /* @__PURE__ */ jsx("code", { children: "id" }),
698
+ " ",
699
+ "reaches the zone."
700
+ ] }),
701
+ children: /* @__PURE__ */ jsx(Example, {
702
+ align: "fill",
703
+ code: `
704
+ <Field label="Supplier price list" hint="CSV, up to 5 MB." error={tried && !file ? 'Add the price list before you continue.' : undefined}>
705
+ <Dropzone size="compact" icon={<FileCsvIcon />} title="Drop the price list here" action="Add file" accept=".csv" onFiles={([first]) => setFile(first)} />
706
+ </Field>`,
707
+ caption: "Press Continue with no file.",
708
+ children: /* @__PURE__ */ jsx(FieldDemo, {})
709
+ })
710
+ }),
711
+ /* @__PURE__ */ jsxs(Section$1, {
712
+ id: "hook",
713
+ title: "A surface of your own",
714
+ description: /* @__PURE__ */ jsxs("p", { children: [
715
+ "The behaviour is a hook, ",
716
+ /* @__PURE__ */ jsx("code", { children: "useFileDrop" }),
717
+ ", and the zone is its look. Use the hook for a page that takes a drop anywhere, a chat box, or a paste target. It judges files by the same rules and words, and keeps the drag count right when the pointer crosses the surface's children."
718
+ ] }),
719
+ children: [/* @__PURE__ */ jsx(Example, {
720
+ align: "fill",
721
+ code: `
722
+ const drop = useFileDrop({ accept: 'image/*', multiple: true, onFiles: add })
723
+ const { ref, ...input } = drop.inputProps
724
+
725
+ <div {...drop.dropProps} data-over={drop.dragging || undefined}>
726
+ <Button onClick={drop.open}>Browse images</Button>
727
+ <input {...input} ref={ref} />
728
+ </div>`,
729
+ children: /* @__PURE__ */ jsx(SurfaceDemo, {})
730
+ }), /* @__PURE__ */ jsx(DocTable, {
731
+ columns: ["Returns", "What it is"],
732
+ rows: [
733
+ [/* @__PURE__ */ jsx("code", { children: "dragging" }), "A file is over the surface. A dragged link or text does not count."],
734
+ [/* @__PURE__ */ jsx("code", { children: "dropProps" }), "Spread on the surface: the four drag handlers."],
735
+ [/* @__PURE__ */ jsx("code", { children: "inputProps" }), "Spread on a file input: type, accept, multiple, hidden, a ref, and a change handler that clears the input so the same file can be chosen again. Put the input beside your control, not inside it, and call open() from the control."],
736
+ [/* @__PURE__ */ jsx("code", { children: "open()" }), "Opens the file chooser. Call it from a click or key press."],
737
+ [/* @__PURE__ */ jsx("code", { children: "take(files)" }), "Holds files that came some other way, such as a paste, to the same rules."],
738
+ [/* @__PURE__ */ jsx("code", { children: "rejections" }), "The files the last choice turned away, with reasons and messages. Empty when it turned none away."],
739
+ [/* @__PURE__ */ jsx("code", { children: "clearRejections()" }), "Forget them."]
740
+ ]
741
+ })]
742
+ }),
743
+ /* @__PURE__ */ jsx(Section$1, {
744
+ id: "both-themes",
745
+ title: "In both themes",
746
+ description: /* @__PURE__ */ jsx("p", { children: "The looks of both variants and the states that change colour, light and dark side by side. The zones are compact here to keep the pair short." }),
747
+ children: /* @__PURE__ */ jsx(ThemePair, {
748
+ align: "fill",
749
+ children: /* @__PURE__ */ jsxs("div", {
750
+ className: "dropzone-stack",
751
+ children: [
752
+ /* @__PURE__ */ jsx(Still, {
753
+ name: "Well",
754
+ size: "compact"
755
+ }),
756
+ /* @__PURE__ */ jsx(Still, {
757
+ name: "Well, file over it",
758
+ size: "compact",
759
+ dragging: true,
760
+ draggingTitle: "Let go to upload"
761
+ }),
762
+ /* @__PURE__ */ jsx(Still, {
763
+ name: "Dashed",
764
+ variant: "dashed",
765
+ size: "compact"
766
+ }),
767
+ /* @__PURE__ */ jsx(Still, {
768
+ name: "Dashed, file over it",
769
+ variant: "dashed",
770
+ size: "compact",
771
+ dragging: true,
772
+ draggingTitle: "Let go to upload"
773
+ }),
774
+ /* @__PURE__ */ jsx(Still, {
775
+ name: "Invalid",
776
+ size: "compact",
777
+ invalid: true,
778
+ hint: "Your storage is full."
779
+ }),
780
+ /* @__PURE__ */ jsx(Still, {
781
+ name: "Busy",
782
+ size: "compact",
783
+ busy: true,
784
+ hint: "Uploading products.csv"
785
+ }),
786
+ /* @__PURE__ */ jsx(Still, {
787
+ name: "Disabled",
788
+ size: "compact",
789
+ disabled: true
790
+ })
791
+ ]
792
+ })
793
+ })
794
+ }),
795
+ /* @__PURE__ */ jsxs(Section$1, {
796
+ id: "guidelines",
797
+ title: "Guidelines",
798
+ children: [/* @__PURE__ */ jsx(DoDont, {
799
+ do: {
800
+ children: /* @__PURE__ */ jsx(Dropzone, {
801
+ size: "compact",
802
+ icon: /* @__PURE__ */ jsx(FileCsvIcon, {}),
803
+ title: "Drop your products file here",
804
+ hint: "CSV or Excel, up to 5 MB",
805
+ onFiles: () => {}
806
+ }),
807
+ caption: "Say what is accepted and how big. People should not learn the rules by breaking them."
808
+ },
809
+ dont: {
810
+ children: /* @__PURE__ */ jsx(Dropzone, {
811
+ size: "compact",
812
+ icon: /* @__PURE__ */ jsx(FileCsvIcon, {}),
813
+ title: "Drop a file here",
814
+ onFiles: () => {}
815
+ }),
816
+ caption: "A bare invitation, with rules that only show up as a refusal after the drop."
817
+ }
818
+ }), /* @__PURE__ */ jsx(Guidelines, { items: [
819
+ "Put a FileChip where the zone was once a file is chosen, with Replace and Remove, and give it autoFocus. Do not leave the zone up beside a chosen file.",
820
+ "When the chip goes, give the zone that takes its place autoFocus too. Without it the focus falls to the top of the page. autoFocus takes focus only when nothing else has it, and only as the zone appears: never set it on a zone drawn with the page.",
821
+ "Keep the zone the width of the form or dialog it sits in. It is a target: the wider, the easier to hit.",
822
+ "Use the well in dialogs and forms and the dashed variant on the page itself. One of each is plenty on a screen.",
823
+ "Do not put a link or a button inside a zone you give children to. The zone is a button.",
824
+ "Use invalid for a rule of yours that the zone cannot know about, such as a full storage quota, and say why in the hint.",
825
+ "Show what an upload is doing on the FileChip (uploading, failed), and set busy on the zone only when it stays on screen while work runs."
826
+ ] })]
827
+ }),
828
+ /* @__PURE__ */ jsx(Section$1, {
829
+ id: "accessibility",
830
+ title: "Accessibility",
831
+ children: /* @__PURE__ */ jsx(Guidelines, { items: [
832
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
833
+ "The zone is a single ",
834
+ /* @__PURE__ */ jsx("code", { children: "button" }),
835
+ " in the tab order, named by its title and pill (and the Field's label). Enter opens the chooser on key down and Space on key up, as a button does, and Space does not scroll the page. Holding Enter asks for the chooser once. With no words of its own it is named \"Choose a file\"."
836
+ ] }),
837
+ /* @__PURE__ */ jsx(Fragment$1, { children: "The hint is the zone's description, so it is read with the zone, along with a Field's hint or error. What the zone says out loud (a refusal, that it is busy, that it is full) goes through an invisible polite status beside the button. It is in the page from the first render, empty, so a screen reader is already listening when it fills, and outside the button, whose children a screen reader does not read as live. The same refusal twice is said twice. That the zone is busy or full is said when it becomes so: a zone that appears busy or full says nothing in the status, and a full one has the sentence as its description." }),
838
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
839
+ "The file input is ",
840
+ /* @__PURE__ */ jsx("code", { children: "hidden" }),
841
+ " and stands beside the button, never inside it: a button that holds a focusable control fails automated checks (axe-core's ",
842
+ /* @__PURE__ */ jsx("code", { children: "nested-interactive" }),
843
+ "), even one with",
844
+ " ",
845
+ /* @__PURE__ */ jsx("code", { children: "tabindex=\"-1\"" }),
846
+ " or ",
847
+ /* @__PURE__ */ jsx("code", { children: "aria-hidden" }),
848
+ ". A ",
849
+ /* @__PURE__ */ jsx("code", { children: "hidden" }),
850
+ " input is not focusable, and beside the button it is not in the way either, so there is one control to find, not two. The chooser it opens is the browser's own."
851
+ ] }),
852
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
853
+ "A busy zone is ",
854
+ /* @__PURE__ */ jsx("code", { children: "aria-busy" }),
855
+ ", and the status says ",
856
+ /* @__PURE__ */ jsx("code", { children: "labels.busy" }),
857
+ ". A disabled, busy or full zone is ",
858
+ /* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
859
+ " and does not react to a drop (it still stops the browser opening the file in its place). A disabled zone leaves the tab order; a busy or full one stays in it, as a loading Button does, so a keyboard user who tabs away during an upload can come back to it. A full zone keeps its sentence at full strength and dims only the parts that invite a drop."
860
+ ] }),
861
+ "A dropped folder is recognised and refused with its own sentence. A folder chosen in the chooser cannot happen: the chooser only lists files.",
862
+ "The focus ring shows for keyboard focus only. Under reduced motion the zone keeps its colour changes and drops the lift.",
863
+ "Dragging is an extra way in, never the only one: the same files can always be chosen with the keyboard."
864
+ ] })
865
+ }),
866
+ /* @__PURE__ */ jsxs(Section$1, {
867
+ id: "props",
868
+ title: "Props",
869
+ children: [
870
+ /* @__PURE__ */ jsx(PropsTable, {
871
+ title: "Dropzone",
872
+ rows: [
873
+ {
874
+ name: "onFiles",
875
+ type: "(files: File[]) => void",
876
+ required: true,
877
+ description: "The files that passed the rules. Never called with an empty list."
878
+ },
879
+ {
880
+ name: "onReject",
881
+ type: "(rejections: FileRejection[]) => void",
882
+ description: "The files that did not, once per choice or drop, each with its reason and a sentence to say. Without it the zone says the first refusal in its hint line and turns invalid."
883
+ },
884
+ {
885
+ name: "accept",
886
+ type: "string",
887
+ description: "What is taken, as <input accept> reads it: .csv, image/png, image/*, comma separated. Checked on drops too. Prefer extensions for data and office files."
888
+ },
889
+ {
890
+ name: "maxSize",
891
+ type: "number",
892
+ description: "The largest file, in bytes."
893
+ },
894
+ {
895
+ name: "maxFiles",
896
+ type: "number",
897
+ description: "The most files there may be in all, counting the ones in count. 1 makes it a replace-in-place zone that is never full."
898
+ },
899
+ {
900
+ name: "count",
901
+ type: "number",
902
+ default: "0",
903
+ description: "How many files you hold already, so maxFiles leaves the right room."
904
+ },
905
+ {
906
+ name: "multiple",
907
+ type: "boolean",
908
+ description: "Take several files at once. Defaults to true when maxFiles is above 1; otherwise only the first of a batch is taken."
909
+ },
910
+ {
911
+ name: "validate",
912
+ type: "(file: File) => string | void",
913
+ description: "One more rule of your own: return the reason to refuse a file, or nothing to take it."
914
+ },
915
+ {
916
+ name: "variant",
917
+ type: "'well' | 'dashed'",
918
+ default: "'well'",
919
+ description: "A sunken fill for dialogs and forms, or a bolder outline on the page itself."
920
+ },
921
+ {
922
+ name: "size",
923
+ type: "'default' | 'compact' | 'minimal'",
924
+ default: "'default'",
925
+ description: "Stacked and centred, one row, or a line of text."
926
+ },
927
+ {
928
+ name: "icon",
929
+ type: "ReactNode",
930
+ description: "A glyph above the words (beside them when compact). Replaced by a spinner while busy."
931
+ },
932
+ {
933
+ name: "title",
934
+ type: "ReactNode",
935
+ description: "The main line."
936
+ },
937
+ {
938
+ name: "draggingTitle",
939
+ type: "ReactNode",
940
+ description: "Shown instead of the title while a file is over the zone."
941
+ },
942
+ {
943
+ name: "hint",
944
+ type: "ReactNode",
945
+ description: "A quieter line: what is accepted and how big. Turns red when invalid. A refusal the zone says itself replaces it."
946
+ },
947
+ {
948
+ name: "action",
949
+ type: "ReactNode",
950
+ description: "The words of a small pill that stands for the click. The whole zone is the control, not the pill."
951
+ },
952
+ {
953
+ name: "children",
954
+ type: "ReactNode",
955
+ description: "Your own content in place of the icon, title, pill and hint. Keep it non-interactive. A refusal, or that the zone is full, is still said under it."
956
+ },
957
+ {
958
+ name: "disabled",
959
+ type: "boolean",
960
+ default: "false",
961
+ description: "Takes nothing. Dimmed, out of the tab order."
962
+ },
963
+ {
964
+ name: "busy",
965
+ type: "boolean",
966
+ default: "false",
967
+ description: "Work is under way: a spinner, and nothing is taken until it is done. It stays in the tab order, aria-disabled."
968
+ },
969
+ {
970
+ name: "invalid",
971
+ type: "boolean",
972
+ description: "The error look. Inside a Field, follows the Field."
973
+ },
974
+ {
975
+ name: "dragging",
976
+ type: "boolean",
977
+ description: "Forces the dragging look. Otherwise the zone knows by itself."
978
+ },
979
+ {
980
+ name: "inputRef",
981
+ type: "Ref<HTMLInputElement>",
982
+ description: "The hidden file input, for inputRef.current?.click() or a form."
983
+ },
984
+ {
985
+ name: "autoFocus",
986
+ type: "boolean",
987
+ description: "Focuses the zone when it appears, if nothing else holds focus. For a zone that comes back in the place of a FileChip, so a keyboard user keeps their place. Focus the person put in another field is left alone."
988
+ },
989
+ {
990
+ name: "labels",
991
+ type: "Partial<DropzoneLabels>",
992
+ description: "Reword the sentences the zone says: chooseFile, chooseFiles, busy, full, rejectType, rejectSize, rejectCount, rejectFolder, moreRejected. dropzoneLabels is the English set."
993
+ }
994
+ ]
995
+ }),
996
+ /* @__PURE__ */ jsxs("p", {
997
+ className: "doc-section__description",
998
+ children: [
999
+ "Dropzone also accepts the native div attributes, except the drag handlers, title and onChange. It renders three siblings, not one element: the button (the element ",
1000
+ /* @__PURE__ */ jsx("code", { children: "ref" }),
1001
+ ", ",
1002
+ /* @__PURE__ */ jsx("code", { children: "className" }),
1003
+ ", ",
1004
+ /* @__PURE__ */ jsx("code", { children: "style" }),
1005
+ ",",
1006
+ " ",
1007
+ /* @__PURE__ */ jsx("code", { children: "id" }),
1008
+ " and those attributes reach), the hidden file input (",
1009
+ /* @__PURE__ */ jsx("code", { children: "inputRef" }),
1010
+ ") and an invisible status. Spacing in a flex, grid or Field parent is unaffected, since the input takes no room and the status is out of flow."
1011
+ ]
1012
+ }),
1013
+ /* @__PURE__ */ jsx(PropsTable, {
1014
+ title: "FileRejection",
1015
+ rows: [
1016
+ {
1017
+ name: "file",
1018
+ type: "File",
1019
+ required: true,
1020
+ description: "The file that was turned away."
1021
+ },
1022
+ {
1023
+ name: "reason",
1024
+ type: "'type' | 'size' | 'count' | 'custom' | 'folder'",
1025
+ required: true,
1026
+ description: "The first rule it broke, or folder for a dropped folder (which has no rule: it is never taken)."
1027
+ },
1028
+ {
1029
+ name: "message",
1030
+ type: "string",
1031
+ required: true,
1032
+ description: "Ready to show: names the file and says what to do."
1033
+ }
1034
+ ]
1035
+ }),
1036
+ /* @__PURE__ */ jsx(PropsTable, {
1037
+ title: "useFileDrop(options)",
1038
+ rows: [
1039
+ {
1040
+ name: "onFiles",
1041
+ type: "(files: File[]) => void",
1042
+ required: true,
1043
+ description: "The files that passed."
1044
+ },
1045
+ {
1046
+ name: "onReject",
1047
+ type: "(rejections: FileRejection[]) => void",
1048
+ description: "The files that did not. Without it, read rejections yourself."
1049
+ },
1050
+ {
1051
+ name: "disabled",
1052
+ type: "boolean",
1053
+ default: "false",
1054
+ description: "Nothing is taken: no drops, no chooser."
1055
+ },
1056
+ {
1057
+ name: "accept, maxSize, maxFiles, count, multiple, validate, labels",
1058
+ type: "as Dropzone",
1059
+ description: "The same rules, the same words."
1060
+ }
1061
+ ]
1062
+ })
1063
+ ]
1064
+ })
1065
+ ]
1066
+ });
1067
+ }
1068
+ //#endregion
1069
+ export { Page, Preview };