@drawbridge/components 0.1.34 → 0.1.36

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 (328) hide show
  1. package/components/styles.css +68 -355
  2. package/dist/advertisement.js +15 -20
  3. package/dist/advertisement.mjs +15 -20
  4. package/dist/bridge/advertisements.js +4 -2
  5. package/dist/bridge/advertisements.mjs +5 -3
  6. package/dist/bridge/fields.js +89 -6
  7. package/dist/bridge/fields.mjs +89 -7
  8. package/dist/bridge/form-subdomain-agreement.js +165 -0
  9. package/dist/bridge/form-subdomain-agreement.mjs +132 -0
  10. package/dist/bridge/form-subdomain-embed.js +5 -1
  11. package/dist/bridge/form-subdomain-embed.mjs +5 -1
  12. package/dist/bridge/form-subdomain-header.js +21 -14
  13. package/dist/bridge/form-subdomain-header.mjs +20 -14
  14. package/dist/bridge/form-subdomain-issue.js +17 -8
  15. package/dist/bridge/form-subdomain-issue.mjs +17 -8
  16. package/dist/bridge/form-subdomain-missions.js +58 -52
  17. package/dist/bridge/form-subdomain-missions.mjs +60 -54
  18. package/dist/bridge/form-subdomain.js +223 -94
  19. package/dist/bridge/form-subdomain.mjs +222 -96
  20. package/dist/bridge/lib/entry.js +61 -6
  21. package/dist/bridge/lib/entry.mjs +51 -5
  22. package/dist/bridge/lib/order.js +23 -0
  23. package/dist/bridge/lib/order.mjs +20 -0
  24. package/dist/bridge/template-layout.js +5 -2
  25. package/dist/bridge/template-layout.mjs +6 -3
  26. package/dist/bridge/template-modal.js +82 -15
  27. package/dist/bridge/template-modal.mjs +83 -16
  28. package/dist/bridge/template-subdomain-gallery.js +126 -75
  29. package/dist/bridge/template-subdomain-gallery.mjs +122 -75
  30. package/dist/bridge/template-subdomain.js +16 -14
  31. package/dist/bridge/template-subdomain.mjs +17 -15
  32. package/dist/dashboard/avatar.js +5 -0
  33. package/dist/dashboard/avatar.mjs +5 -0
  34. package/dist/dashboard/campaign-form.js +1798 -0
  35. package/dist/dashboard/campaign-form.mjs +1769 -0
  36. package/dist/dashboard/card-affiliate.js +3 -2
  37. package/dist/dashboard/card-affiliate.mjs +3 -2
  38. package/dist/dashboard/card-campaign-agreement.js +172 -0
  39. package/dist/dashboard/card-campaign-agreement.mjs +139 -0
  40. package/dist/dashboard/card-campaign-switch.js +34 -9
  41. package/dist/dashboard/card-campaign-switch.mjs +32 -8
  42. package/dist/dashboard/card-order.js +6 -14
  43. package/dist/dashboard/card-order.mjs +6 -14
  44. package/dist/dashboard/card-section.js +69 -26
  45. package/dist/dashboard/card-section.mjs +65 -26
  46. package/dist/dashboard/card-shortcut.js +181 -0
  47. package/dist/dashboard/card-shortcut.mjs +152 -0
  48. package/dist/dashboard/card-tile.js +3 -35
  49. package/dist/dashboard/card-tile.mjs +3 -34
  50. package/dist/dashboard/document-blocks.js +305 -0
  51. package/dist/dashboard/document-blocks.mjs +270 -0
  52. package/dist/dashboard/drawer-subscription.js +52 -14
  53. package/dist/dashboard/drawer-subscription.mjs +52 -14
  54. package/dist/dashboard/drawer.js +20 -3
  55. package/dist/dashboard/drawer.mjs +21 -4
  56. package/dist/dashboard/dropdown.js +6 -2
  57. package/dist/dashboard/dropdown.mjs +6 -2
  58. package/dist/dashboard/form-admin-subscription-custom.js +72 -8
  59. package/dist/dashboard/form-admin-subscription-custom.mjs +72 -8
  60. package/dist/dashboard/form-ai.js +0 -148
  61. package/dist/dashboard/form-ai.mjs +1 -148
  62. package/dist/dashboard/form-filters-analytics.js +88 -37
  63. package/dist/dashboard/form-filters-analytics.mjs +85 -38
  64. package/dist/dashboard/form-organization-brand.js +30 -13
  65. package/dist/dashboard/form-organization-brand.mjs +30 -13
  66. package/dist/dashboard/form-organization-campaign-advertisement.js +38 -112
  67. package/dist/dashboard/form-organization-campaign-advertisement.mjs +38 -112
  68. package/dist/dashboard/form-organization-campaign-advertisements.js +374 -0
  69. package/dist/dashboard/form-organization-campaign-advertisements.mjs +345 -0
  70. package/dist/dashboard/form-organization-campaign-agreement.js +402 -210
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +398 -211
  72. package/dist/dashboard/form-organization-campaign-design.js +258 -0
  73. package/dist/dashboard/form-organization-campaign-design.mjs +223 -0
  74. package/dist/dashboard/form-organization-campaign-field-item.js +585 -0
  75. package/dist/dashboard/form-organization-campaign-field-item.mjs +552 -0
  76. package/dist/dashboard/form-organization-campaign-field-number.js +48 -7
  77. package/dist/dashboard/form-organization-campaign-field-number.mjs +48 -7
  78. package/dist/dashboard/form-organization-campaign-field-select.js +15 -4
  79. package/dist/dashboard/form-organization-campaign-field-select.mjs +15 -4
  80. package/dist/dashboard/form-organization-campaign-field-skill.js +359 -0
  81. package/dist/dashboard/form-organization-campaign-field-skill.mjs +330 -0
  82. package/dist/dashboard/form-organization-campaign-field-text.js +46 -6
  83. package/dist/dashboard/form-organization-campaign-field-text.mjs +46 -6
  84. package/dist/dashboard/form-organization-campaign-field-textarea.js +22 -13
  85. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +22 -13
  86. package/dist/dashboard/form-organization-campaign-footer.js +178 -0
  87. package/dist/dashboard/form-organization-campaign-footer.mjs +149 -0
  88. package/dist/dashboard/form-organization-campaign-integration-age.js +2 -35
  89. package/dist/dashboard/form-organization-campaign-integration-age.mjs +2 -35
  90. package/dist/dashboard/form-organization-campaign-integration-geocode.js +4 -1
  91. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +4 -1
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +1 -1
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +1 -1
  94. package/dist/dashboard/form-organization-campaign-page-preview.js +1 -2
  95. package/dist/dashboard/form-organization-campaign-page-preview.mjs +1 -2
  96. package/dist/dashboard/form-organization-campaign-page-qr.js +2 -2
  97. package/dist/dashboard/form-organization-campaign-page-qr.mjs +2 -2
  98. package/dist/dashboard/form-organization-campaign-page-share.js +5 -5
  99. package/dist/dashboard/form-organization-campaign-page-share.mjs +5 -5
  100. package/dist/dashboard/form-organization-campaign-page-slug.js +2 -3
  101. package/dist/dashboard/form-organization-campaign-page-slug.mjs +2 -3
  102. package/dist/dashboard/form-organization-campaign-page.js +168 -265
  103. package/dist/dashboard/form-organization-campaign-page.mjs +170 -266
  104. package/dist/dashboard/form-organization-campaign-section.js +125 -107
  105. package/dist/dashboard/form-organization-campaign-section.mjs +121 -107
  106. package/dist/dashboard/form-organization-campaign.js +119 -9
  107. package/dist/dashboard/form-organization-campaign.mjs +118 -9
  108. package/dist/dashboard/form-organization-file-frame.js +7 -1
  109. package/dist/dashboard/form-organization-file-frame.mjs +7 -1
  110. package/dist/dashboard/form-organization-workflow.js +587 -530
  111. package/dist/dashboard/form-organization-workflow.mjs +588 -531
  112. package/dist/dashboard/form-organization.js +22 -0
  113. package/dist/dashboard/form-organization.mjs +22 -0
  114. package/dist/dashboard/form-reposition.js +396 -0
  115. package/dist/dashboard/form-reposition.mjs +359 -0
  116. package/dist/dashboard/form-support.js +189 -0
  117. package/dist/dashboard/form-support.mjs +160 -0
  118. package/dist/dashboard/form-tests.js +683 -0
  119. package/dist/dashboard/form-tests.mjs +646 -0
  120. package/dist/dashboard/form-verify-prize.js +114 -34
  121. package/dist/dashboard/form-verify-prize.mjs +111 -34
  122. package/dist/dashboard/google.js +8 -1
  123. package/dist/dashboard/google.mjs +8 -1
  124. package/dist/dashboard/input-array.js +2 -0
  125. package/dist/dashboard/input-array.mjs +2 -0
  126. package/dist/dashboard/input-editor.js +17 -6
  127. package/dist/dashboard/input-editor.mjs +17 -6
  128. package/dist/dashboard/input-fields.js +287 -437
  129. package/dist/dashboard/input-fields.mjs +287 -436
  130. package/dist/dashboard/input-file.js +70 -2
  131. package/dist/dashboard/input-file.mjs +70 -2
  132. package/dist/dashboard/input-font.js +64 -55
  133. package/dist/dashboard/input-font.mjs +64 -55
  134. package/dist/dashboard/input-resource.js +4 -1
  135. package/dist/dashboard/input-resource.mjs +4 -1
  136. package/dist/dashboard/lib/ab-tests.js +130 -0
  137. package/dist/dashboard/lib/ab-tests.mjs +94 -0
  138. package/dist/dashboard/lib/features.js +1 -1
  139. package/dist/dashboard/lib/features.mjs +1 -1
  140. package/dist/dashboard/lib/focus.js +93 -0
  141. package/dist/dashboard/lib/focus.mjs +69 -0
  142. package/dist/dashboard/lib/form-page.js +203 -0
  143. package/dist/dashboard/lib/form-page.mjs +155 -0
  144. package/dist/dashboard/lib/item-list.js +0 -15
  145. package/dist/dashboard/lib/item-list.mjs +0 -14
  146. package/dist/dashboard/lib/rail.js +16 -17
  147. package/dist/dashboard/lib/rail.mjs +15 -16
  148. package/dist/dashboard/lib/sms.js +8 -2
  149. package/dist/dashboard/lib/sms.mjs +6 -1
  150. package/dist/dashboard/list-resource.js +2 -0
  151. package/dist/dashboard/list-resource.mjs +2 -0
  152. package/dist/dashboard/menu.js +54 -5
  153. package/dist/dashboard/menu.mjs +53 -5
  154. package/dist/dashboard/modal.js +19 -4
  155. package/dist/dashboard/modal.mjs +20 -5
  156. package/dist/dashboard/order-sections.js +4 -0
  157. package/dist/dashboard/order-sections.mjs +4 -0
  158. package/dist/dashboard/preview.js +838 -324
  159. package/dist/dashboard/preview.mjs +826 -324
  160. package/dist/dashboard/provider-ui.js +20 -12
  161. package/dist/dashboard/provider-ui.mjs +21 -13
  162. package/dist/dashboard/recharts.js +53 -28
  163. package/dist/dashboard/recharts.mjs +53 -28
  164. package/dist/dashboard/swatch.js +35 -0
  165. package/dist/dashboard/swatch.mjs +31 -0
  166. package/dist/dashboard/table-contacts.js +6 -10
  167. package/dist/dashboard/table-contacts.mjs +6 -10
  168. package/dist/dashboard/table.js +10 -3
  169. package/dist/dashboard/table.mjs +9 -3
  170. package/dist/dashboard/template-dashboard.js +12 -7
  171. package/dist/dashboard/template-dashboard.mjs +11 -7
  172. package/dist/dashboard/template-design.js +564 -0
  173. package/dist/dashboard/template-design.mjs +531 -0
  174. package/dist/dashboard/template-rail.js +198 -126
  175. package/dist/dashboard/template-rail.mjs +196 -125
  176. package/dist/dashboard/template-socket.js +0 -3
  177. package/dist/dashboard/template-socket.mjs +0 -3
  178. package/dist/dashboard/template-test-page.js +436 -0
  179. package/dist/dashboard/template-test-page.mjs +407 -0
  180. package/dist/dashboard/template-tests.js +141 -0
  181. package/dist/dashboard/template-tests.mjs +112 -0
  182. package/dist/dashboard/template-ui.js +20 -11
  183. package/dist/dashboard/template-ui.mjs +22 -13
  184. package/dist/dashboard/template-variant.js +185 -0
  185. package/dist/dashboard/template-variant.mjs +156 -0
  186. package/dist/icons/arrow-down-long.js +47 -0
  187. package/dist/icons/arrow-down-long.mjs +28 -0
  188. package/dist/icons/arrows-pointing-out.js +46 -0
  189. package/dist/icons/arrows-pointing-out.mjs +27 -0
  190. package/dist/icons/beaker.js +46 -0
  191. package/dist/icons/beaker.mjs +27 -0
  192. package/dist/icons/identification.js +46 -0
  193. package/dist/icons/identification.mjs +27 -0
  194. package/dist/icons/lifebuoy.js +46 -0
  195. package/dist/icons/lifebuoy.mjs +27 -0
  196. package/dist/icons/rectangle-group.js +46 -0
  197. package/dist/icons/rectangle-group.mjs +27 -0
  198. package/dist/icons/rectangle-stack.js +46 -0
  199. package/dist/icons/rectangle-stack.mjs +27 -0
  200. package/dist/icons/shopping-bag.js +46 -0
  201. package/dist/icons/shopping-bag.mjs +27 -0
  202. package/dist/icons/swatch.js +46 -0
  203. package/dist/icons/swatch.mjs +27 -0
  204. package/dist/icons/window.js +46 -0
  205. package/dist/icons/window.mjs +27 -0
  206. package/dist/icons/zoom-in.js +46 -0
  207. package/dist/icons/zoom-in.mjs +27 -0
  208. package/dist/input-answer.js +60 -0
  209. package/dist/input-answer.mjs +27 -0
  210. package/dist/input-checkbox.js +7 -1
  211. package/dist/input-checkbox.mjs +7 -1
  212. package/dist/input-name.js +3 -3
  213. package/dist/input-name.mjs +3 -3
  214. package/dist/input-select.js +3 -1
  215. package/dist/input-select.mjs +3 -1
  216. package/dist/provider-font.js +4 -3
  217. package/dist/provider-font.mjs +4 -3
  218. package/dist/shared/badge.js +15 -0
  219. package/dist/shared/badge.mjs +11 -0
  220. package/dist/shared/carousel.js +11 -7
  221. package/dist/shared/carousel.mjs +11 -7
  222. package/dist/shared/document-pieces.js +295 -0
  223. package/dist/shared/document-pieces.mjs +260 -0
  224. package/dist/shared/lib/campaign.js +3 -9
  225. package/dist/shared/lib/campaign.mjs +3 -9
  226. package/dist/shared/lib/helpers.js +24 -0
  227. package/dist/shared/lib/helpers.mjs +22 -0
  228. package/dist/shared/lib/video.js +6 -0
  229. package/dist/shared/lib/video.mjs +5 -0
  230. package/dist/shared/sortable.js +27 -10
  231. package/dist/shared/sortable.mjs +27 -10
  232. package/dist/shared/tabs.js +1 -1
  233. package/dist/shared/tabs.mjs +1 -1
  234. package/dist/video.js +127 -9
  235. package/dist/video.mjs +125 -11
  236. package/package.json +176 -20
  237. package/types/bridge/fields.d.ts +6 -1
  238. package/types/bridge/form-subdomain-agreement.d.ts +27 -0
  239. package/types/bridge/form-subdomain-missions.d.ts +2 -0
  240. package/types/bridge/form-subdomain.d.ts +62 -3
  241. package/types/bridge/lib/entry.d.ts +44 -7
  242. package/types/bridge/lib/order.d.ts +13 -2
  243. package/types/bridge/subdomain-content.d.ts +1 -0
  244. package/types/bridge/template-subdomain-gallery.d.ts +13 -1
  245. package/types/dashboard/campaign-form.d.ts +42 -0
  246. package/types/dashboard/card-campaign-agreement.d.ts +26 -0
  247. package/types/dashboard/card-campaign-switch.d.ts +20 -1
  248. package/types/dashboard/card-order.d.ts +2 -2
  249. package/types/dashboard/card-section.d.ts +9 -1
  250. package/types/dashboard/card-shortcut.d.ts +38 -0
  251. package/types/dashboard/card-tile.d.ts +4 -9
  252. package/types/dashboard/document-blocks.d.ts +14 -0
  253. package/types/dashboard/drawer.d.ts +3 -0
  254. package/types/dashboard/form-ai.d.ts +0 -17
  255. package/types/dashboard/form-organization-brand.d.ts +3 -0
  256. package/types/dashboard/form-organization-campaign-advertisements.d.ts +15 -0
  257. package/types/dashboard/form-organization-campaign-agreement.d.ts +53 -10
  258. package/types/dashboard/form-organization-campaign-design.d.ts +46 -0
  259. package/types/dashboard/form-organization-campaign-field-item.d.ts +36 -0
  260. package/types/dashboard/form-organization-campaign-field-number.d.ts +4 -1
  261. package/types/dashboard/form-organization-campaign-field-select.d.ts +6 -1
  262. package/types/dashboard/form-organization-campaign-field-skill.d.ts +36 -0
  263. package/types/dashboard/form-organization-campaign-field-text.d.ts +5 -1
  264. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +4 -1
  265. package/types/dashboard/form-organization-campaign-footer.d.ts +23 -0
  266. package/types/dashboard/form-organization-campaign-integration-age.d.ts +2 -1
  267. package/types/dashboard/form-organization-campaign-integration-geocode.d.ts +2 -0
  268. package/types/dashboard/form-organization-campaign-page.d.ts +9 -15
  269. package/types/dashboard/form-organization-campaign-section.d.ts +24 -8
  270. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  271. package/types/dashboard/form-organization-workflow.d.ts +3 -0
  272. package/types/dashboard/form-organization.d.ts +2 -2
  273. package/types/dashboard/form-reposition.d.ts +29 -0
  274. package/types/dashboard/form-support.d.ts +14 -0
  275. package/types/dashboard/form-tests.d.ts +78 -0
  276. package/types/dashboard/form-verify-prize.d.ts +30 -3
  277. package/types/dashboard/input-editor.d.ts +9 -0
  278. package/types/dashboard/input-fields.d.ts +8 -5
  279. package/types/dashboard/input-file.d.ts +4 -0
  280. package/types/dashboard/input-resource.d.ts +1 -0
  281. package/types/dashboard/lib/ab-tests.d.ts +50 -0
  282. package/types/dashboard/lib/escape.d.ts +4 -0
  283. package/types/dashboard/lib/focus.d.ts +16 -0
  284. package/types/dashboard/lib/form-page.d.ts +25 -0
  285. package/types/dashboard/lib/item-list.d.ts +10 -5
  286. package/types/dashboard/lib/rail.d.ts +0 -1
  287. package/types/dashboard/lib/sms.d.ts +7 -0
  288. package/types/dashboard/modal.d.ts +3 -1
  289. package/types/dashboard/preview.d.ts +65 -10
  290. package/types/dashboard/recharts.d.ts +3 -0
  291. package/types/dashboard/swatch.d.ts +4 -0
  292. package/types/dashboard/template-dashboard.d.ts +3 -0
  293. package/types/dashboard/template-design.d.ts +30 -0
  294. package/types/dashboard/template-test-page.d.ts +69 -0
  295. package/types/dashboard/template-tests.d.ts +30 -0
  296. package/types/dashboard/template-variant.d.ts +18 -0
  297. package/types/icons/arrow-down-long.d.ts +5 -0
  298. package/types/icons/arrows-pointing-out.d.ts +5 -0
  299. package/types/icons/beaker.d.ts +5 -0
  300. package/types/icons/identification.d.ts +5 -0
  301. package/types/icons/lifebuoy.d.ts +5 -0
  302. package/types/icons/rectangle-group.d.ts +5 -0
  303. package/types/icons/rectangle-stack.d.ts +5 -0
  304. package/types/icons/shopping-bag.d.ts +5 -0
  305. package/types/icons/swatch.d.ts +5 -0
  306. package/types/icons/window.d.ts +5 -0
  307. package/types/icons/zoom-in.d.ts +5 -0
  308. package/types/input-answer.d.ts +15 -0
  309. package/types/input-select.d.ts +2 -0
  310. package/types/shared/button.d.ts +1 -1
  311. package/types/shared/document-pieces.d.ts +34 -0
  312. package/types/shared/lib/helpers.d.ts +22 -1
  313. package/types/shared/lib/motion.d.ts +2 -0
  314. package/types/shared/lib/video.d.ts +3 -0
  315. package/types/shared/sortable.d.ts +6 -0
  316. package/types/video.d.ts +18 -2
  317. package/dist/bridge/template-preview.js +0 -208
  318. package/dist/bridge/template-preview.mjs +0 -173
  319. package/dist/dashboard/device.js +0 -95
  320. package/dist/dashboard/device.mjs +0 -72
  321. package/dist/dashboard/form-organization-campaign-field-list.js +0 -425
  322. package/dist/dashboard/form-organization-campaign-field-list.mjs +0 -396
  323. package/dist/dashboard/item-row.js +0 -92
  324. package/dist/dashboard/item-row.mjs +0 -63
  325. package/types/bridge/template-preview.d.ts +0 -10
  326. package/types/dashboard/device.d.ts +0 -12
  327. package/types/dashboard/form-organization-campaign-field-list.d.ts +0 -36
  328. package/types/dashboard/item-row.d.ts +0 -25
@@ -28,11 +28,23 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var preview_exports = {};
30
30
  __export(preview_exports, {
31
+ CHIP: () => CHIP,
32
+ Mail: () => Mail,
33
+ NoPreview: () => NoPreview,
31
34
  PreviewPage: () => PreviewPage,
32
- clamp: () => clamp,
35
+ SIZES: () => SIZES,
36
+ Slider: () => Slider,
37
+ SliderLayout: () => SliderLayout,
38
+ States: () => States,
39
+ ZOOMS: () => ZOOMS,
33
40
  default: () => preview_default,
41
+ fillHeight: () => fillHeight,
34
42
  fitScale: () => fitScale,
35
- scroller: () => scroller
43
+ fitZoom: () => fitZoom,
44
+ pressScrolls: () => pressScrolls,
45
+ scrollTarget: () => scrollTarget,
46
+ useCard: () => useCard,
47
+ useFill: () => useFill
36
48
  });
37
49
  module.exports = __toCommonJS(preview_exports);
38
50
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -40,349 +52,753 @@ var import_react = require("react");
40
52
  var import_react_dom = require("react-dom");
41
53
  var import_button = __toESM(require("../shared/button"));
42
54
  var import_loader = __toESM(require("../shared/loader"));
43
- var import_input_combobox = __toESM(require("./input-combobox"));
44
- var import_device = __toESM(require("./device"));
55
+ var import_dropdown = __toESM(require("./dropdown"));
56
+ var import_escape = require("./lib/escape");
57
+ var import_focus = require("./lib/focus");
58
+ var import_check = __toESM(require("../icons/check"));
59
+ var import_chevron_left = __toESM(require("../icons/chevron-left"));
60
+ var import_chevron_right = __toESM(require("../icons/chevron-right"));
45
61
  var import_desktop = __toESM(require("../icons/desktop"));
46
62
  var import_phone = __toESM(require("../icons/phone"));
47
- var import_tablet = __toESM(require("../icons/tablet"));
48
- const DEVICES = {
49
- desktop: { icon: import_desktop.default, label: "Desktop" },
50
- tablet: { icon: import_tablet.default, label: "Tablet" },
51
- phone: { icon: import_phone.default, label: "Phone" }
52
- };
53
- const HEIGHT = 520;
63
+ var import_zoom_in = __toESM(require("../icons/zoom-in"));
54
64
  const GUTTER = 24;
55
- const NARROW = 486;
65
+ const OFFSET = 20;
56
66
  const ZOOMS = [
57
67
  { key: "Fit", value: "fit" },
58
68
  { key: "25%", value: 0.25 },
59
69
  { key: "50%", value: 0.5 },
60
70
  { key: "100%", value: 1 },
61
- { key: "150%", value: 1.5 },
62
- { key: "200%", value: 2 }
71
+ { key: "150%", value: 1.5 }
72
+ ];
73
+ const SIZES = [
74
+ { height: 844, icon: import_phone.default, key: "phone", label: "Phone", width: 390 },
75
+ { height: 800, icon: import_desktop.default, key: "desktop", label: "Desktop", width: 1280 }
63
76
  ];
64
- const clamp = (value, limit) => Math.min(limit, Math.max(-limit, value));
65
- const fitScale = (space, size) => space.width && size.width ? Math.min(1, (space.width - GUTTER) / size.width, (space.height - GUTTER) / size.height) : 1;
66
- const scroller = (node) => {
67
- for (const iframe of (node == null ? void 0 : node.querySelectorAll("iframe")) || []) {
68
- const doc = iframe.contentDocument;
69
- const element = doc == null ? void 0 : doc.scrollingElement;
70
- if (element && element.scrollHeight > element.clientHeight) return element;
71
- const inner = doc && scroller(doc);
72
- if (inner) return inner;
77
+ const MAIL = 600;
78
+ const WIDE = "(min-width: 1280px)";
79
+ const fitScale = (space, size) => (space == null ? void 0 : space.width) && (size == null ? void 0 : size.width) ? Math.min(1, (space.width - GUTTER * 2) / size.width, (space.height - GUTTER * 2) / size.height) : 1;
80
+ const fitZoom = (room, natural) => room > 0 && natural > 0 ? Math.min(1, room / natural) : 1;
81
+ const CONTROL = 'a[href], button, input, select, textarea, label, summary, [contenteditable], [role="button"], [role="switch"], [role="checkbox"], [role="menuitem"], [role="option"], [role="tab"], [tabindex]:not([tabindex="-1"])';
82
+ const pressScrolls = (target, card) => {
83
+ var _a, _b;
84
+ const control = (_a = target == null ? void 0 : target.closest) == null ? void 0 : _a.call(target, CONTROL + ', [aria-roledescription="sortable"]');
85
+ return !(control && control !== card && ((_b = card == null ? void 0 : card.contains) == null ? void 0 : _b.call(card, control)));
86
+ };
87
+ const scrollTarget = ({ node, page, scrollTop }) => scrollTop + node - page - OFFSET;
88
+ const nests = (option) => {
89
+ var _a;
90
+ return ((_a = option == null ? void 0 : option.options) == null ? void 0 : _a.length) > 1;
91
+ };
92
+ const States = ({
93
+ align,
94
+ onChange,
95
+ options = [],
96
+ value
97
+ }) => {
98
+ const [inside, setInside] = (0, import_react.useState)(null);
99
+ const nested = options.some(nests);
100
+ const [top, child] = [].concat(value ?? []);
101
+ const shown = options.find((option) => option.value === top);
102
+ const picked = nests(shown) ? shown.options.find((option) => option.value === child) : null;
103
+ const group = options.find((option) => option.value === inside);
104
+ const stay = (next) => (event) => {
105
+ event.preventDefault();
106
+ setInside(next);
107
+ };
108
+ const keys = (event) => {
109
+ var _a;
110
+ const row = (_a = document.getElementById(event.currentTarget.getAttribute("aria-activedescendant"))) == null ? void 0 : _a.querySelector("[data-drill]");
111
+ const press = event.key === "Enter" || event.key === " ";
112
+ if (row && (press || event.key === "ArrowRight" && row.dataset.drill !== "")) {
113
+ event.preventDefault();
114
+ setInside(row.dataset.drill || null);
115
+ } else if (group && event.key === "ArrowLeft") {
116
+ event.preventDefault();
117
+ setInside(null);
118
+ }
119
+ };
120
+ const items = group ? [
121
+ {
122
+ element: "button",
123
+ onClick: stay(null),
124
+ title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
125
+ "span",
126
+ {
127
+ ...{
128
+ className: "flex items-center gap-2"
129
+ },
130
+ children: [
131
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
132
+ import_chevron_left.default,
133
+ {
134
+ ...{
135
+ "aria-hidden": true,
136
+ className: "w-4 h-4"
137
+ }
138
+ }
139
+ ),
140
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
+ "span",
142
+ {
143
+ ...{
144
+ className: "sr-only"
145
+ },
146
+ children: "Back from "
147
+ }
148
+ ),
149
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
+ "span",
151
+ {
152
+ ...{
153
+ "data-drill": ""
154
+ },
155
+ children: group.key
156
+ }
157
+ )
158
+ ]
159
+ }
160
+ )
161
+ },
162
+ ...group.options.map((option) => ({
163
+ ...group.value === top && option.value === child && {
164
+ "aria-current": true,
165
+ icon: import_check.default
166
+ },
167
+ element: "button",
168
+ onClick: () => {
169
+ setInside(null);
170
+ onChange([group.value, option.value]);
171
+ },
172
+ title: option.key
173
+ }))
174
+ ] : options.map((option) => nests(option) ? {
175
+ "aria-haspopup": "menu",
176
+ element: "button",
177
+ icon: import_chevron_right.default,
178
+ onClick: stay(option.value),
179
+ title: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
180
+ "span",
181
+ {
182
+ ...{
183
+ "data-drill": option.value
184
+ },
185
+ children: option.key
186
+ }
187
+ )
188
+ } : {
189
+ element: "button",
190
+ onClick: () => onChange(nested ? [option.value] : option.value),
191
+ title: option.key
192
+ });
193
+ return (options.length > 1 || nested) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
194
+ import_dropdown.default,
195
+ {
196
+ ...{
197
+ anchor: "bottom " + (align || "end"),
198
+ button: {
199
+ // Every open starts at the top, by pointer or by key.
200
+ onClick: () => setInside(null),
201
+ onKeyDown: () => setInside(null),
202
+ variant: "link"
203
+ },
204
+ chevron: true,
205
+ className: "flex [&>button]:h-9 " + (align === "start" ? "justify-start" : "justify-end"),
206
+ classNameMenu: "w-56",
207
+ items,
208
+ onKeyDownMenu: keys
209
+ },
210
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
211
+ shown == null ? void 0 : shown.key,
212
+ picked && " \xB7 ",
213
+ picked && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
214
+ "span",
215
+ {
216
+ ...{
217
+ className: "text-gray-dark"
218
+ },
219
+ children: picked.key
220
+ }
221
+ )
222
+ ] })
223
+ }
224
+ );
225
+ };
226
+ const SQUARE = "flex [&>button]:h-7 [&>button]:w-7 [&>button]:rounded [&>button:hover]:bg-gray-light";
227
+ const SHIFT = (28 + 4 + 28 + 4 + 28) / 2 - 28 / 2;
228
+ const View = ({
229
+ onSize,
230
+ onZoom,
231
+ size,
232
+ zoom,
233
+ zooms
234
+ }) => {
235
+ var _a;
236
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
237
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
238
+ import_dropdown.default,
239
+ {
240
+ ...{
241
+ anchor: onSize ? {
242
+ offset: SHIFT,
243
+ to: "bottom"
244
+ } : "bottom",
245
+ button: {
246
+ "aria-label": "Zoom, " + ((_a = zooms.find((option) => option.value === zoom)) == null ? void 0 : _a.key),
247
+ icon: import_zoom_in.default,
248
+ variant: "link"
249
+ },
250
+ className: SQUARE,
251
+ classNameMenu: "w-24",
252
+ items: zooms.map((option) => ({
253
+ ...option.value === zoom && {
254
+ "aria-current": true,
255
+ icon: import_check.default
256
+ },
257
+ element: "button",
258
+ onClick: () => onZoom(option.value),
259
+ title: option.key
260
+ }))
261
+ }
262
+ }
263
+ ),
264
+ onSize && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
265
+ "div",
266
+ {
267
+ ...{
268
+ "aria-label": "Screen size",
269
+ className: "flex items-center gap-1",
270
+ role: "group"
271
+ },
272
+ children: SIZES.map(({ icon, key, label }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
273
+ "span",
274
+ {
275
+ ...{
276
+ className: SQUARE + (size === key ? " text-black [&>button]:bg-gray" : " text-gray-dark")
277
+ },
278
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
279
+ import_button.default,
280
+ {
281
+ ...{
282
+ "aria-label": label,
283
+ "aria-pressed": size === key,
284
+ icon,
285
+ inline: true,
286
+ onClick: () => onSize(key),
287
+ variant: "link"
288
+ }
289
+ }
290
+ )
291
+ },
292
+ key
293
+ ))
294
+ }
295
+ )
296
+ ] });
297
+ };
298
+ const NoPreview = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
299
+ "div",
300
+ {
301
+ ...{
302
+ className: "flex flex-col items-center justify-center gap-3"
303
+ },
304
+ children: [
305
+ children,
306
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "No preview available" })
307
+ ]
308
+ }
309
+ );
310
+ const usePeek = () => {
311
+ const [open, setOpen] = (0, import_react.useState)(false);
312
+ const close = (0, import_react.useRef)(null);
313
+ const pane = (0, import_react.useRef)(null);
314
+ const hide = () => setOpen(false);
315
+ (0, import_escape.useEscape)(open, close);
316
+ (0, import_focus.useTrap)(open, pane);
317
+ (0, import_react.useEffect)(() => {
318
+ if (!open) return void 0;
319
+ const wide = window.matchMedia(WIDE);
320
+ const onWide = (event) => event.matches && hide();
321
+ wide.addEventListener("change", onWide);
322
+ return () => wide.removeEventListener("change", onWide);
323
+ }, [open]);
324
+ return {
325
+ close,
326
+ hide,
327
+ open,
328
+ pane,
329
+ show: () => setOpen(true)
330
+ };
331
+ };
332
+ const PeekButton = ({ peek }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
333
+ "div",
334
+ {
335
+ ...{
336
+ // At the top of the cards, where it covers nothing.
337
+ className: "xl:hidden flex justify-end pb-4"
338
+ },
339
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
340
+ import_button.default,
341
+ {
342
+ ...{
343
+ // Lighter than the page's Save, at the cards' right.
344
+ inline: true,
345
+ // Focused first: a browser that does not focus a pressed button would
346
+ // have nothing to hand focus back to.
347
+ onClick: (event) => {
348
+ event.currentTarget.focus();
349
+ peek.show();
350
+ },
351
+ variant: "secondary"
352
+ },
353
+ children: "Preview"
354
+ }
355
+ )
356
+ }
357
+ );
358
+ const CHIP = "flex h-9 items-center rounded-full bg-white text-black shadow-sm";
359
+ const Pane = ({
360
+ children,
361
+ className,
362
+ left,
363
+ peek,
364
+ right,
365
+ style,
366
+ ...rest
367
+ }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
368
+ "div",
369
+ {
370
+ ...{
371
+ ...rest,
372
+ className: "overflow-hidden bg-gray " + (peek.open ? "fixed inset-0 z-50 xl:inset-x-auto xl:bottom-auto xl:z-auto " : "hidden xl:block ") + className,
373
+ ref: peek.pane,
374
+ ...peek.open && {
375
+ "aria-label": "Preview",
376
+ "aria-modal": true,
377
+ role: "dialog"
378
+ },
379
+ style
380
+ },
381
+ children: [
382
+ left && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
383
+ "div",
384
+ {
385
+ ...{
386
+ // A chip whose pickers all have a single option holds nothing to press, and hides.
387
+ className: CHIP + " gap-4 px-3 absolute left-4 z-10 [&:not(:has(button,a))]:hidden " + (peek.open ? "top-16" : "top-4")
388
+ },
389
+ children: left
390
+ }
391
+ ),
392
+ right && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
393
+ "div",
394
+ {
395
+ ...{
396
+ className: CHIP + " gap-1 px-1.5 absolute right-4 z-10 " + (peek.open ? "top-16" : "top-4")
397
+ },
398
+ children: right
399
+ }
400
+ ),
401
+ peek.open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
402
+ "div",
403
+ {
404
+ ...{
405
+ className: "absolute top-3 left-1/2 -translate-x-1/2 z-20"
406
+ },
407
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
408
+ import_button.default,
409
+ {
410
+ ...{
411
+ autoFocus: true,
412
+ onClick: peek.hide,
413
+ ref: peek.close,
414
+ size: "small",
415
+ variant: "secondary"
416
+ },
417
+ children: "Close preview"
418
+ }
419
+ )
420
+ }
421
+ ),
422
+ children
423
+ ]
73
424
  }
74
- ;
75
- return null;
425
+ );
426
+ const useFit = (node, zoom) => (0, import_react.useEffect)(() => {
427
+ if (!node) return;
428
+ const fit = () => {
429
+ var _a;
430
+ const holder = node.firstElementChild;
431
+ const step = holder == null ? void 0 : holder.firstElementChild;
432
+ if (!step) return;
433
+ resize.observe(step);
434
+ const { paddingBottom, paddingTop } = getComputedStyle(node);
435
+ const natural = step.offsetHeight;
436
+ const reads = (_a = step.firstElementChild) == null ? void 0 : _a.getAttribute("data-reads");
437
+ if (reads) {
438
+ node.setAttribute("aria-label", reads);
439
+ node.setAttribute("role", "region");
440
+ node.tabIndex = 0;
441
+ } else {
442
+ ["aria-label", "role", "tabindex"].forEach((name) => node.removeAttribute(name));
443
+ }
444
+ const scale = zoom === "fit" ? reads ? 1 : fitZoom(node.clientHeight - parseFloat(paddingTop) - parseFloat(paddingBottom), natural) : zoom;
445
+ const life = scale === 1;
446
+ step.style.transform = life ? "" : "scale(" + scale + ")";
447
+ step.style.transformOrigin = "top left";
448
+ step.style.width = life ? "" : node.clientWidth + "px";
449
+ holder.style.height = life ? "" : natural * scale + "px";
450
+ holder.style.width = life ? "" : node.clientWidth * scale + "px";
451
+ };
452
+ let frame;
453
+ const later = () => {
454
+ cancelAnimationFrame(frame);
455
+ frame = requestAnimationFrame(fit);
456
+ };
457
+ const resize = new ResizeObserver(later);
458
+ const mutation = new MutationObserver(later);
459
+ resize.observe(node);
460
+ mutation.observe(node, {
461
+ childList: true
462
+ });
463
+ fit();
464
+ return () => {
465
+ cancelAnimationFrame(frame);
466
+ resize.disconnect();
467
+ mutation.disconnect();
468
+ };
469
+ }, [node, zoom]);
470
+ const stepBox = "flex flex-col h-full overflow-auto pb-8 [&>*]:m-auto [&>*]:w-full [&>*]:shrink-0";
471
+ const scrollerOf = (node) => {
472
+ let page = node == null ? void 0 : node.parentElement;
473
+ while (page && !/(auto|scroll)/.test(getComputedStyle(page).overflowY)) page = page.parentElement;
474
+ return page || null;
475
+ };
476
+ const fillHeight = ({ foot, gap, top }) => Math.max(0, Math.floor(foot - top - gap));
477
+ const useFill = (box, open) => (0, import_react.useEffect)(() => {
478
+ const node = box.current;
479
+ const page = scrollerOf(node);
480
+ if (open || !node || !page) return void 0;
481
+ const wide = window.matchMedia(WIDE);
482
+ const gap = parseFloat(getComputedStyle(page).paddingBottom) || 0;
483
+ let frame;
484
+ const read = () => {
485
+ node.style.height = wide.matches ? fillHeight({
486
+ foot: page.getBoundingClientRect().bottom,
487
+ gap,
488
+ top: node.getBoundingClientRect().top
489
+ }) + "px" : "";
490
+ };
491
+ const measure = () => {
492
+ cancelAnimationFrame(frame);
493
+ frame = requestAnimationFrame(read);
494
+ };
495
+ const observer = new ResizeObserver(measure);
496
+ read();
497
+ observer.observe(page);
498
+ [...page.children].forEach((child) => observer.observe(child));
499
+ wide.addEventListener("change", measure);
500
+ page.addEventListener("scroll", measure, {
501
+ passive: true
502
+ });
503
+ return () => {
504
+ cancelAnimationFrame(frame);
505
+ observer.disconnect();
506
+ wide.removeEventListener("change", measure);
507
+ page.removeEventListener("scroll", measure);
508
+ node.style.height = "";
509
+ };
510
+ }, [open]);
511
+ const Slider = (0, import_react.createContext)(null);
512
+ const useCard = (id) => {
513
+ const slider = (0, import_react.useContext)(Slider);
514
+ if (!slider) return {
515
+ className: "",
516
+ props: {}
517
+ };
518
+ return {
519
+ className: slider.current === id ? " xl:shadow-lg" : " cursor-pointer",
520
+ props: {
521
+ "data-slide": id,
522
+ // The card's step is drawn in the panel through a portal, whose events
523
+ // still reach the card: a press or focus there is not one on the card.
524
+ onFocusCapture: (event) => event.currentTarget.contains(event.target) && slider.select(id),
525
+ // A press on a control or one that starts a drag shows the step but
526
+ // leaves the page still, so what was pressed stays under the pointer.
527
+ onPointerDownCapture: (event) => event.currentTarget.contains(event.target) && slider.select(id, event.currentTarget, event.target)
528
+ }
529
+ };
76
530
  };
77
- const PreviewFrame = ({
531
+ const SliderLayout = ({
532
+ blank,
78
533
  children,
79
- states
534
+ last,
535
+ plain,
536
+ slides = [],
537
+ style,
538
+ zooms = ZOOMS
80
539
  }) => {
81
- var _a;
82
- const [device, setDevice] = (0, import_react.useState)("phone");
83
- const [zoom, setZoom] = (0, import_react.useState)("fit");
84
- const [space, setSpace] = (0, import_react.useState)({ height: 0, width: 0 });
85
- const [frameSize, setFrameSize] = (0, import_react.useState)({ device: null, height: 0, width: 0 });
86
- const [offset, setOffset] = (0, import_react.useState)({ x: 0, y: 0 });
87
- const [ease, setEase] = (0, import_react.useState)(false);
88
- const [dragging, setDragging] = (0, import_react.useState)(false);
89
- const area = (0, import_react.useRef)(null);
90
- const frame = (0, import_react.useRef)(null);
91
- const drag = (0, import_react.useRef)(null);
92
- const scale = zoom === "fit" ? fitScale(space, frameSize) : zoom;
93
- const reach = {
94
- x: Math.max(0, (frameSize.width * scale - space.width) / 2),
95
- y: Math.max(0, (frameSize.height * scale - space.height) / 2)
540
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
541
+ const [nodes, setNodes] = (0, import_react.useState)({});
542
+ const [picked, setPicked] = (0, import_react.useState)(null);
543
+ const [states, setStates] = (0, import_react.useState)({});
544
+ const [zoom, setZoom] = (0, import_react.useState)(zooms[0].value);
545
+ const peek = usePeek();
546
+ const layout = (0, import_react.useRef)(null);
547
+ const cards = (0, import_react.useRef)(null);
548
+ const current = slides.find((slide) => slide.id === picked) || slides[0];
549
+ const shown = nodes[current == null ? void 0 : current.id];
550
+ const select = (id, node, target) => {
551
+ if (!slides.some((slide) => slide.id === id)) return;
552
+ setPicked(id);
553
+ const page = scrollerOf(node);
554
+ if (!page || !node || !pressScrolls(target, node) || !window.matchMedia(WIDE).matches) return;
555
+ page.scrollTo({
556
+ behavior: "smooth",
557
+ top: scrollTarget({
558
+ node: node.getBoundingClientRect().top,
559
+ page: page.getBoundingClientRect().top,
560
+ scrollTop: page.scrollTop
561
+ })
562
+ });
96
563
  };
97
- const larger = reach.x > 0 || reach.y > 0;
98
- const narrow = space.width > 0 && space.width < NARROW;
99
- const hasStates = ((_a = states == null ? void 0 : states.options) == null ? void 0 : _a.length) > 1;
100
- const ready = space.width > 0 && frameSize.device === device;
101
- const x = (space.width - frameSize.width * scale) / 2 + clamp(offset.x, reach.x);
102
- const y = (space.height - frameSize.height * scale) / 2 + clamp(offset.y, reach.y);
103
- (0, import_react.useLayoutEffect)(() => {
104
- const measure = () => setSpace({ height: area.current.clientHeight, width: area.current.clientWidth });
105
- const observer = new ResizeObserver(measure);
106
- measure();
107
- observer.observe(area.current);
108
- return () => observer.disconnect();
109
- }, []);
110
- (0, import_react.useLayoutEffect)(() => {
111
- const measure = () => setFrameSize({ device, height: frame.current.offsetHeight, width: frame.current.offsetWidth });
112
- const observer = new ResizeObserver(measure);
113
- measure();
114
- observer.observe(frame.current);
115
- return () => observer.disconnect();
116
- }, [device]);
117
- (0, import_react.useLayoutEffect)(() => {
118
- setOffset({ x: 0, y: 0 });
119
- }, [device, zoom]);
564
+ useFill(peek.pane, peek.open);
565
+ useFit(blank ? null : shown, zoom);
120
566
  (0, import_react.useEffect)(() => {
121
- const node = area.current;
122
- const { screen, viewport } = import_device.DEVICE_TYPES[device];
123
- const ratio = scale * screen.width / viewport;
124
- const onWheel = (event) => {
125
- const element = scroller(frame.current);
126
- if (!element || !event.deltaY) return;
127
- const top = element.scrollTop;
128
- element.scrollTop = top + event.deltaY * (event.deltaMode === 1 ? 16 : 1) / ratio;
129
- if (element.scrollTop !== top) event.preventDefault();
567
+ if (cards.current) cards.current.inert = peek.open;
568
+ }, [peek.open]);
569
+ const register = (0, import_react.useCallback)((id, own) => setStates((list) => {
570
+ var _a2, _b2;
571
+ return ((_a2 = list[id]) == null ? void 0 : _a2.value) === (own == null ? void 0 : own.value) && ((_b2 = list[id]) == null ? void 0 : _b2.options) === (own == null ? void 0 : own.options) ? list : {
572
+ ...list,
573
+ [id]: own
130
574
  };
131
- node.addEventListener("wheel", onWheel, { passive: false });
132
- return () => node.removeEventListener("wheel", onWheel);
133
- }, [device, scale]);
134
- (0, import_react.useEffect)(() => {
135
- if (!ease) return;
136
- const timer = setTimeout(() => setEase(false), 200);
137
- return () => clearTimeout(timer);
138
- }, [ease]);
139
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
140
- "div",
575
+ }), []);
576
+ const keep = (id) => (node) => node && setNodes((list) => list[id] === node ? list : {
577
+ ...list,
578
+ [id]: node
579
+ });
580
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
581
+ Slider.Provider,
141
582
  {
142
583
  ...{
143
- // A toolbar across the top, then the area the device sits in.
144
- className: "flex flex-col w-full min-w-0 rounded border border-gray overflow-hidden"
584
+ value: {
585
+ current: current == null ? void 0 : current.id,
586
+ last,
587
+ nodes,
588
+ register,
589
+ select
590
+ }
145
591
  },
146
- children: [
147
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
148
- "div",
149
- {
150
- ...{
151
- // The states on the left, the zoom and the sizes on the right.
152
- className: "flex flex-wrap items-center justify-between gap-2 px-3 py-2 bg-white border-b border-gray"
153
- },
154
- children: [
155
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
156
- "div",
157
- {
158
- ...{
159
- // Narrow with no states, the empty slot takes no line.
160
- className: narrow ? hasStates ? "w-full" : "hidden" : "w-52 max-w-full"
161
- },
162
- children: hasStates && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
- import_input_combobox.default,
592
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
593
+ "div",
594
+ {
595
+ ...{
596
+ // Never shrunk in the page's column, so the page scrolls.
597
+ className: "grid grid-cols-1 gap-6 items-start shrink-0 xl:grid-cols-2",
598
+ ref: layout
599
+ },
600
+ children: [
601
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
602
+ Pane,
603
+ {
604
+ ...{
605
+ // First in the page's order, so Tab reaches its step picker before the
606
+ // cards; drawn on the right, in view as the page scrolls ( useFill ).
607
+ "data-preview-panel": true,
608
+ className: "xl:sticky xl:top-0 xl:order-last min-w-0 xl:min-h-[480px] xl:rounded",
609
+ // The one step picker, each step's own states nested under it ( Darren,
610
+ // 2026-11-15 ). No steps yet ( a chain with none ): no chips, and the
611
+ // panel says there is nothing to preview.
612
+ left: slides.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
613
+ States,
164
614
  {
165
615
  ...{
166
- onChange: states.onChange,
167
- options: states.options,
168
- size: "small",
169
- value: states.value
616
+ align: "start",
617
+ onChange: (path) => {
618
+ var _a2, _b2;
619
+ const [id, state] = [].concat(path);
620
+ select(id, (_a2 = layout.current) == null ? void 0 : _a2.querySelector('[data-slide="' + id + '"]'));
621
+ if (state !== void 0) (_b2 = states[id]) == null ? void 0 : _b2.onChange(state);
622
+ },
623
+ options: slides.map((slide) => {
624
+ var _a2;
625
+ return {
626
+ key: slide.title,
627
+ options: (_a2 = states[slide.id]) == null ? void 0 : _a2.options,
628
+ value: slide.id
629
+ };
630
+ }),
631
+ value: [current == null ? void 0 : current.id, (_a = states[current == null ? void 0 : current.id]) == null ? void 0 : _a.value]
170
632
  }
171
633
  }
172
- )
173
- }
174
- ),
175
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
176
- "div",
177
- {
178
- ...{
179
- className: "flex items-center gap-2 " + (narrow ? "w-full" : "ml-auto")
180
- },
181
- children: [
182
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
- "div",
184
- {
185
- ...{
186
- className: narrow ? "flex-1 min-w-0" : "w-24"
187
- },
188
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
189
- import_input_combobox.default,
190
- {
191
- ...{
192
- onChange: (value) => {
193
- setEase(true);
194
- setZoom(value);
195
- },
196
- options: ZOOMS,
197
- size: "small",
198
- value: zoom
199
- }
200
- }
201
- )
634
+ ),
635
+ peek,
636
+ right: slides.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
637
+ View,
638
+ {
639
+ ...{
640
+ onZoom: setZoom,
641
+ zoom,
642
+ zooms
202
643
  }
203
- ),
204
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
205
- "div",
206
- {
207
- ...{
208
- // The sizes, small icon buttons spaced as the dashboard's button
209
- // groups are, the chosen one filled dark.
210
- "aria-label": "Screen size",
211
- className: "flex gap-2",
212
- role: "group"
213
- },
214
- children: Object.entries(DEVICES).map(([key, { icon, label }]) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
215
- import_button.default,
216
- {
217
- ...{
218
- "aria-label": label,
219
- "aria-pressed": device === key,
220
- icon,
221
- inline: true,
222
- // A new size starts fitted.
223
- onClick: () => {
224
- setEase(false);
225
- setDevice(key);
226
- setZoom("fit");
227
- },
228
- size: "small",
229
- variant: device === key ? "primary" : "secondary"
230
- }
231
- },
232
- key
233
- ))
644
+ }
645
+ ),
646
+ style: {
647
+ backgroundColor: plain ? void 0 : ((_c = (_b = style == null ? void 0 : style.background) == null ? void 0 : _b.color) == null ? void 0 : _c.rgb) || ((_e = (_d = style == null ? void 0 : style.background) == null ? void 0 : _d.color) == null ? void 0 : _e.hex),
648
+ color: plain ? void 0 : ((_g = (_f = style == null ? void 0 : style.text) == null ? void 0 : _f.color) == null ? void 0 : _g.rgb) || ((_i = (_h = style == null ? void 0 : style.text) == null ? void 0 : _h.color) == null ? void 0 : _i.hex)
649
+ }
650
+ },
651
+ children: [
652
+ (blank || !slides.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
653
+ "div",
654
+ {
655
+ ...{
656
+ className: stepBox + " " + (peek.open ? "pt-28" : "pt-16")
657
+ },
658
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NoPreview, {})
659
+ }
660
+ ),
661
+ slides.map((slide) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
662
+ "div",
663
+ {
664
+ ...{
665
+ className: !blank && slide.id === (current == null ? void 0 : current.id) ? stepBox + " " + (peek.open ? "pt-28" : "pt-16") : "hidden",
666
+ ref: keep(slide.id)
234
667
  }
235
- )
236
- ]
237
- }
238
- )
239
- ]
240
- }
241
- ),
242
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
243
- "div",
244
- {
245
- ...{
246
- className: "relative w-full overflow-hidden bg-gray-light touch-none select-none" + (larger ? dragging ? " cursor-grabbing" : " cursor-grab" : ""),
247
- // Dragging moves the device only when it is larger than the area. The
248
- // pointer is captured, so a drag that leaves the area still follows it
249
- // and still ends on release.
250
- onLostPointerCapture: () => {
251
- drag.current = null;
252
- setDragging(false);
253
- },
254
- onPointerDown: (event) => {
255
- if (!larger || event.button !== 0) return;
256
- const from = { x: clamp(offset.x, reach.x), y: clamp(offset.y, reach.y) };
257
- setEase(false);
258
- setOffset(from);
259
- drag.current = { left: event.clientX - from.x, top: event.clientY - from.y };
260
- event.currentTarget.setPointerCapture(event.pointerId);
261
- setDragging(true);
262
- },
263
- onPointerMove: (event) => drag.current && setOffset({
264
- x: clamp(event.clientX - drag.current.left, reach.x),
265
- y: clamp(event.clientY - drag.current.top, reach.y)
266
- }),
267
- ref: area,
268
- style: {
269
- height: HEIGHT
668
+ },
669
+ slide.id
670
+ ))
671
+ ]
270
672
  }
271
- },
272
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
673
+ ),
674
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
273
675
  "div",
274
676
  {
275
677
  ...{
276
- // The device, measured for fitting, placed by one transform from the top
277
- // left. pointer-events-none: a picture of the page, so nothing in it
278
- // can be clicked.
279
- className: "absolute top-0 left-0 w-max origin-top-left pointer-events-none",
280
- "data-preview-stage": true,
281
- ref: frame,
282
- style: {
283
- opacity: ready ? 1 : 0,
284
- transform: "translate(" + x + "px, " + y + "px) scale(" + scale + ")",
285
- // The fade in, once laid out; a zoom from the dropdown eases. Hidden at once.
286
- transition: ready ? ["opacity 150ms ease", ease && "transform 150ms ease"].filter(Boolean).join(", ") : "none"
287
- }
678
+ // The cards run with the page.
679
+ className: "min-w-0"
288
680
  },
289
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
290
- import_device.default,
291
- {
292
- ...{
293
- type: device
294
- },
295
- children
296
- }
297
- )
681
+ children: [
682
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
683
+ PeekButton,
684
+ {
685
+ ...{
686
+ peek
687
+ }
688
+ }
689
+ ),
690
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
691
+ "div",
692
+ {
693
+ ...{
694
+ ref: cards
695
+ },
696
+ children
697
+ }
698
+ )
699
+ ]
298
700
  }
299
701
  )
300
- }
301
- )
302
- ]
702
+ ]
703
+ }
704
+ )
303
705
  }
304
706
  );
305
707
  };
306
- const STYLES = 'style, link[rel="stylesheet"]';
307
- const mirrorStyles = (doc) => {
308
- const copy = (node) => doc.head.appendChild(node.cloneNode(true));
309
- document.querySelectorAll(STYLES).forEach(copy);
310
- const base = doc.createElement("style");
311
- base.textContent = "html, body { height : 100%; margin : 0; }";
312
- doc.head.appendChild(base);
313
- const observer = new MutationObserver((records) => records.forEach((record) => record.addedNodes.forEach((node) => {
314
- var _a;
315
- return ((_a = node.matches) == null ? void 0 : _a.call(node, STYLES)) && copy(node);
316
- })));
317
- observer.observe(document.head, { childList: true });
318
- return () => observer.disconnect();
319
- };
320
708
  const Preview = ({
321
709
  children,
322
- loading = false,
323
- states,
324
- style
710
+ id,
711
+ states
712
+ }) => {
713
+ const slider = (0, import_react.useContext)(Slider);
714
+ const register = slider == null ? void 0 : slider.register;
715
+ (0, import_react.useEffect)(() => {
716
+ register == null ? void 0 : register(id, states);
717
+ }, [id, register, states == null ? void 0 : states.onChange, states == null ? void 0 : states.options, states == null ? void 0 : states.value]);
718
+ if (!slider) return null;
719
+ return slider.nodes[id] && (0, import_react_dom.createPortal)(
720
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children }) }),
721
+ slider.nodes[id]
722
+ );
723
+ };
724
+ const Mail = ({
725
+ html,
726
+ title
325
727
  }) => {
326
- var _a, _b, _c, _d;
327
728
  const frame = (0, import_react.useRef)(null);
328
- const [body, setBody] = (0, import_react.useState)(null);
329
- const stop = (0, import_react.useRef)(null);
330
- (0, import_react.useEffect)(() => () => {
331
- var _a2;
332
- return (_a2 = stop.current) == null ? void 0 : _a2.call(stop);
333
- }, []);
729
+ const [height, setHeight] = (0, import_react.useState)(400);
730
+ const [shown, setShown] = (0, import_react.useState)(false);
334
731
  (0, import_react.useEffect)(() => {
335
- var _a2, _b2, _c2, _d2;
336
- if (!body) return;
337
- body.style.backgroundColor = ((_b2 = (_a2 = style == null ? void 0 : style.background) == null ? void 0 : _a2.color) == null ? void 0 : _b2.rgb) || "#FFFFFF";
338
- body.style.color = ((_d2 = (_c2 = style == null ? void 0 : style.text) == null ? void 0 : _c2.color) == null ? void 0 : _d2.rgb) || "";
339
- }, [body, (_b = (_a = style == null ? void 0 : style.background) == null ? void 0 : _a.color) == null ? void 0 : _b.rgb, (_d = (_c = style == null ? void 0 : style.text) == null ? void 0 : _c.color) == null ? void 0 : _d.rgb]);
732
+ if (frame.current) frame.current.inert = true;
733
+ }, []);
340
734
  const onLoad = () => {
341
- var _a2;
342
- const doc = frame.current.contentDocument;
343
- (_a2 = stop.current) == null ? void 0 : _a2.call(stop);
344
- stop.current = mirrorStyles(doc);
345
- setBody(doc.body);
735
+ var _a, _b, _c;
736
+ const doc = (_a = frame.current) == null ? void 0 : _a.contentDocument;
737
+ if (!html || !(doc == null ? void 0 : doc.body)) return;
738
+ const fit = () => doc.documentElement.offsetHeight && setHeight(doc.documentElement.offsetHeight);
739
+ doc.documentElement.style.overflow = "hidden";
740
+ doc.addEventListener("load", fit, true);
741
+ (_b = doc.defaultView) == null ? void 0 : _b.addEventListener("resize", fit);
742
+ fit();
743
+ const images = [...doc.images].filter((image) => !image.complete).map((image) => new Promise((resolve) => {
744
+ image.addEventListener("load", resolve, { once: true });
745
+ image.addEventListener("error", resolve, { once: true });
746
+ }));
747
+ Promise.race([
748
+ Promise.all([(_c = doc.fonts) == null ? void 0 : _c.ready, ...images]),
749
+ new Promise((resolve) => setTimeout(resolve, 1e3))
750
+ ]).then(() => {
751
+ fit();
752
+ requestAnimationFrame(() => setShown(true));
753
+ });
346
754
  };
347
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
348
- PreviewFrame,
755
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
756
+ "iframe",
349
757
  {
350
758
  ...{
351
- states
352
- },
353
- children: [
354
- loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
355
- import_loader.default,
356
- {
357
- ...{
358
- className: "bg-purple-light"
359
- }
360
- }
361
- ),
362
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
363
- "iframe",
364
- {
365
- ...{
366
- className: "block w-full h-full border-0",
367
- onLoad,
368
- ref: frame,
369
- srcDoc: '<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>',
370
- title: "Preview"
371
- }
372
- }
373
- ),
374
- body && !loading && (0, import_react_dom.createPortal)(children, body)
375
- ]
759
+ // A picture: its button and links do nothing.
760
+ className: "block w-full border-0 bg-white pointer-events-none transition-opacity duration-200 motion-reduce:transition-none " + (shown ? "opacity-100" : "opacity-0"),
761
+ onLoad,
762
+ ref: frame,
763
+ srcDoc: html || "",
764
+ style: {
765
+ height
766
+ },
767
+ title
768
+ }
376
769
  }
377
770
  );
378
771
  };
379
772
  const PreviewPage = ({
380
- states,
773
+ fill = true,
774
+ html,
775
+ left,
381
776
  update,
382
- url
777
+ url,
778
+ zooms = ZOOMS
383
779
  }) => {
780
+ const area = (0, import_react.useRef)(null);
384
781
  const frame = (0, import_react.useRef)(null);
782
+ const screen = (0, import_react.useRef)(null);
385
783
  const [loading, setLoading] = (0, import_react.useState)(true);
784
+ const [space, setSpace] = (0, import_react.useState)({
785
+ height: 0,
786
+ width: 0
787
+ });
788
+ const [tall, setTall] = (0, import_react.useState)(0);
789
+ const [size, setSize] = (0, import_react.useState)("phone");
790
+ const [zoom, setZoom] = (0, import_react.useState)(zooms[0].value);
791
+ const peek = usePeek();
792
+ const [previous, setPrevious] = (0, import_react.useState)(url);
793
+ if (previous !== url) {
794
+ setPrevious(url);
795
+ setLoading(true);
796
+ }
797
+ const { height, width } = url ? SIZES.find((item) => item.key === size) : {
798
+ height: tall,
799
+ width: MAIL
800
+ };
801
+ const scale = zoom === "fit" ? fitScale(space, { height, width }) : zoom;
386
802
  const origin = url ? new URL(url).origin : null;
387
803
  const message = JSON.stringify({ update });
388
804
  const post = () => {
@@ -391,7 +807,7 @@ const PreviewPage = ({
391
807
  };
392
808
  (0, import_react.useEffect)(
393
809
  () => {
394
- post();
810
+ if (!loading) post();
395
811
  const onReady = (event) => {
396
812
  var _a, _b;
397
813
  if (event.source === ((_a = frame.current) == null ? void 0 : _a.contentWindow) && ((_b = event.data) == null ? void 0 : _b.ready)) post();
@@ -402,45 +818,143 @@ const PreviewPage = ({
402
818
  // eslint-disable-next-line react-hooks/exhaustive-deps
403
819
  [message, origin]
404
820
  );
405
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
406
- PreviewFrame,
407
- {
408
- ...{
409
- states
410
- },
411
- children: [
412
- loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
413
- import_loader.default,
414
- {
415
- ...{
416
- className: "bg-purple-light"
821
+ (0, import_react.useLayoutEffect)(() => {
822
+ const measure = () => setSpace({
823
+ height: area.current.clientHeight,
824
+ width: area.current.clientWidth
825
+ });
826
+ const observer = new ResizeObserver(measure);
827
+ measure();
828
+ observer.observe(area.current);
829
+ return () => observer.disconnect();
830
+ }, []);
831
+ (0, import_react.useLayoutEffect)(() => {
832
+ if (url) return void 0;
833
+ const measure = () => setTall(screen.current.offsetHeight);
834
+ const observer = new ResizeObserver(measure);
835
+ measure();
836
+ observer.observe(screen.current);
837
+ return () => observer.disconnect();
838
+ }, [url]);
839
+ useFill(peek.pane, peek.open || !fill);
840
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
841
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
842
+ PeekButton,
843
+ {
844
+ ...{
845
+ peek
846
+ }
847
+ }
848
+ ),
849
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
850
+ Pane,
851
+ {
852
+ ...{
853
+ // Beside the form it runs to the page's foot ( useFill ).
854
+ className: "xl:relative " + (peek.open ? "" : "rounded " + (fill ? "xl:min-h-[480px]" : "xl:h-[520px]")),
855
+ left,
856
+ peek,
857
+ right: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
858
+ View,
859
+ {
860
+ ...{
861
+ ...url && {
862
+ onSize: setSize
863
+ },
864
+ onZoom: setZoom,
865
+ size,
866
+ zoom,
867
+ zooms
868
+ }
417
869
  }
418
- }
419
- ),
420
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
421
- "iframe",
870
+ )
871
+ },
872
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
873
+ "div",
422
874
  {
423
875
  ...{
424
- className: "absolute inset-0 w-full h-full border-0",
425
- onLoad: () => {
426
- setLoading(false);
427
- post();
428
- },
429
- ref: frame,
430
- src: url,
431
- title: "Page preview"
432
- }
876
+ className: "absolute inset-x-0 bottom-0 " + (peek.open ? "top-28" : "top-14") + " " + (zoom === "fit" ? "overflow-hidden" : "overflow-auto"),
877
+ ref: area
878
+ },
879
+ children: [
880
+ url && loading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
881
+ import_loader.default,
882
+ {
883
+ ...{
884
+ className: "bg-gray"
885
+ }
886
+ }
887
+ ),
888
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
889
+ "div",
890
+ {
891
+ ...{
892
+ className: "origin-top-left",
893
+ ref: screen,
894
+ style: {
895
+ ...url && {
896
+ height
897
+ },
898
+ marginLeft: Math.max(GUTTER, (space.width - width * scale) / 2),
899
+ marginTop: Math.max(GUTTER, (space.height - height * scale) / 2),
900
+ // A transform takes no room of its own: these give the scroll the scaled screen's extent.
901
+ marginBottom: height * scale - height + GUTTER,
902
+ marginRight: width * scale - width + GUTTER,
903
+ transform: "scale(" + scale + ")",
904
+ width
905
+ }
906
+ },
907
+ children: url ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
908
+ "iframe",
909
+ {
910
+ ...{
911
+ className: "block w-full h-full border-0 rounded-lg bg-white",
912
+ onLoad: () => {
913
+ setLoading(false);
914
+ post();
915
+ },
916
+ ref: frame,
917
+ src: url,
918
+ // A picture: Tab never walks into the page.
919
+ tabIndex: -1,
920
+ title: "Page preview"
921
+ }
922
+ }
923
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
924
+ Mail,
925
+ {
926
+ ...{
927
+ html,
928
+ title: "Email preview"
929
+ }
930
+ }
931
+ )
932
+ }
933
+ )
934
+ ]
433
935
  }
434
936
  )
435
- ]
436
- }
437
- );
937
+ }
938
+ )
939
+ ] });
438
940
  };
439
941
  var preview_default = Preview;
440
942
  // Annotate the CommonJS export names for ESM import in node:
441
943
  0 && (module.exports = {
944
+ CHIP,
945
+ Mail,
946
+ NoPreview,
442
947
  PreviewPage,
443
- clamp,
948
+ SIZES,
949
+ Slider,
950
+ SliderLayout,
951
+ States,
952
+ ZOOMS,
953
+ fillHeight,
444
954
  fitScale,
445
- scroller
955
+ fitZoom,
956
+ pressScrolls,
957
+ scrollTarget,
958
+ useCard,
959
+ useFill
446
960
  });