@drawbridge/components 0.1.35 → 0.1.37

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 (338) hide show
  1. package/components/styles.css +355 -68
  2. package/dist/advertisement.js +20 -15
  3. package/dist/advertisement.mjs +20 -15
  4. package/dist/bridge/advertisements.js +2 -4
  5. package/dist/bridge/advertisements.mjs +3 -5
  6. package/dist/bridge/fields.js +6 -89
  7. package/dist/bridge/fields.mjs +7 -89
  8. package/dist/bridge/form-subdomain-embed.js +1 -5
  9. package/dist/bridge/form-subdomain-embed.mjs +1 -5
  10. package/dist/bridge/form-subdomain-header.js +14 -21
  11. package/dist/bridge/form-subdomain-header.mjs +14 -20
  12. package/dist/bridge/form-subdomain-issue.js +8 -17
  13. package/dist/bridge/form-subdomain-issue.mjs +8 -17
  14. package/dist/bridge/form-subdomain-missions.js +52 -58
  15. package/dist/bridge/form-subdomain-missions.mjs +54 -60
  16. package/dist/bridge/form-subdomain.js +94 -223
  17. package/dist/bridge/form-subdomain.mjs +96 -222
  18. package/dist/bridge/lib/entry.js +6 -61
  19. package/dist/bridge/lib/entry.mjs +5 -51
  20. package/dist/bridge/lib/order.js +0 -23
  21. package/dist/bridge/lib/order.mjs +0 -20
  22. package/dist/bridge/template-layout.js +2 -5
  23. package/dist/bridge/template-layout.mjs +3 -6
  24. package/dist/bridge/template-modal.js +15 -82
  25. package/dist/bridge/template-modal.mjs +16 -83
  26. package/dist/bridge/template-preview.js +208 -0
  27. package/dist/bridge/template-preview.mjs +173 -0
  28. package/dist/bridge/template-subdomain-gallery.js +75 -126
  29. package/dist/bridge/template-subdomain-gallery.mjs +75 -122
  30. package/dist/bridge/template-subdomain.js +14 -16
  31. package/dist/bridge/template-subdomain.mjs +15 -17
  32. package/dist/dashboard/avatar.js +0 -5
  33. package/dist/dashboard/avatar.mjs +0 -5
  34. package/dist/dashboard/card-affiliate.js +2 -3
  35. package/dist/dashboard/card-affiliate.mjs +2 -3
  36. package/dist/dashboard/card-campaign-switch.js +9 -34
  37. package/dist/dashboard/card-campaign-switch.mjs +8 -32
  38. package/dist/dashboard/card-connection.js +91 -51
  39. package/dist/dashboard/card-connection.mjs +89 -50
  40. package/dist/dashboard/card-order.js +14 -6
  41. package/dist/dashboard/card-order.mjs +14 -6
  42. package/dist/dashboard/card-section.js +26 -69
  43. package/dist/dashboard/card-section.mjs +26 -65
  44. package/dist/dashboard/card-tile.js +35 -3
  45. package/dist/dashboard/card-tile.mjs +34 -3
  46. package/dist/dashboard/device.js +95 -0
  47. package/dist/dashboard/device.mjs +72 -0
  48. package/dist/dashboard/drawer-subscription.js +14 -52
  49. package/dist/dashboard/drawer-subscription.mjs +14 -52
  50. package/dist/dashboard/drawer.js +3 -20
  51. package/dist/dashboard/drawer.mjs +4 -21
  52. package/dist/dashboard/dropdown.js +2 -6
  53. package/dist/dashboard/dropdown.mjs +2 -6
  54. package/dist/dashboard/form-admin-subscription-custom.js +8 -72
  55. package/dist/dashboard/form-admin-subscription-custom.mjs +8 -72
  56. package/dist/dashboard/form-ai.js +148 -0
  57. package/dist/dashboard/form-ai.mjs +148 -1
  58. package/dist/dashboard/form-filters-analytics.js +62 -85
  59. package/dist/dashboard/form-filters-analytics.mjs +61 -85
  60. package/dist/dashboard/form-organization-brand.js +13 -30
  61. package/dist/dashboard/form-organization-brand.mjs +13 -30
  62. package/dist/dashboard/form-organization-campaign-advertisement.js +112 -38
  63. package/dist/dashboard/form-organization-campaign-advertisement.mjs +112 -38
  64. package/dist/dashboard/form-organization-campaign-agreement.js +210 -414
  65. package/dist/dashboard/form-organization-campaign-agreement.mjs +212 -411
  66. package/dist/dashboard/form-organization-campaign-field-list.js +425 -0
  67. package/dist/dashboard/form-organization-campaign-field-list.mjs +396 -0
  68. package/dist/dashboard/form-organization-campaign-field-number.js +7 -48
  69. package/dist/dashboard/form-organization-campaign-field-number.mjs +7 -48
  70. package/dist/dashboard/form-organization-campaign-field-select.js +4 -15
  71. package/dist/dashboard/form-organization-campaign-field-select.mjs +4 -15
  72. package/dist/dashboard/form-organization-campaign-field-text.js +6 -46
  73. package/dist/dashboard/form-organization-campaign-field-text.mjs +6 -46
  74. package/dist/dashboard/form-organization-campaign-field-textarea.js +13 -22
  75. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +13 -22
  76. package/dist/dashboard/form-organization-campaign-integration-age.js +35 -2
  77. package/dist/dashboard/form-organization-campaign-integration-age.mjs +35 -2
  78. package/dist/dashboard/form-organization-campaign-integration-geocode.js +1 -4
  79. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +1 -4
  80. package/dist/dashboard/form-organization-campaign-page-embed.js +1 -1
  81. package/dist/dashboard/form-organization-campaign-page-embed.mjs +1 -1
  82. package/dist/dashboard/form-organization-campaign-page-preview.js +2 -1
  83. package/dist/dashboard/form-organization-campaign-page-preview.mjs +2 -1
  84. package/dist/dashboard/form-organization-campaign-page-qr.js +2 -2
  85. package/dist/dashboard/form-organization-campaign-page-qr.mjs +2 -2
  86. package/dist/dashboard/form-organization-campaign-page-share.js +5 -5
  87. package/dist/dashboard/form-organization-campaign-page-share.mjs +5 -5
  88. package/dist/dashboard/form-organization-campaign-page-slug.js +3 -2
  89. package/dist/dashboard/form-organization-campaign-page-slug.mjs +3 -2
  90. package/dist/dashboard/form-organization-campaign-page.js +265 -168
  91. package/dist/dashboard/form-organization-campaign-page.mjs +266 -170
  92. package/dist/dashboard/form-organization-campaign-section.js +107 -125
  93. package/dist/dashboard/form-organization-campaign-section.mjs +107 -121
  94. package/dist/dashboard/form-organization-campaign.js +9 -119
  95. package/dist/dashboard/form-organization-campaign.mjs +9 -118
  96. package/dist/dashboard/form-organization-file-frame.js +1 -7
  97. package/dist/dashboard/form-organization-file-frame.mjs +1 -7
  98. package/dist/dashboard/form-organization-workflow.js +545 -589
  99. package/dist/dashboard/form-organization-workflow.mjs +545 -590
  100. package/dist/dashboard/form-organization.js +0 -22
  101. package/dist/dashboard/form-organization.mjs +0 -22
  102. package/dist/dashboard/form-verify-prize.js +34 -114
  103. package/dist/dashboard/form-verify-prize.mjs +34 -111
  104. package/dist/dashboard/google.js +1 -8
  105. package/dist/dashboard/google.mjs +1 -8
  106. package/dist/dashboard/input-array.js +0 -2
  107. package/dist/dashboard/input-array.mjs +0 -2
  108. package/dist/dashboard/input-combobox.js +9 -0
  109. package/dist/dashboard/input-combobox.mjs +9 -0
  110. package/dist/dashboard/input-date.js +8 -3
  111. package/dist/dashboard/input-date.mjs +8 -3
  112. package/dist/dashboard/input-editor.js +6 -17
  113. package/dist/dashboard/input-editor.mjs +6 -17
  114. package/dist/dashboard/input-fields.js +437 -287
  115. package/dist/dashboard/input-fields.mjs +436 -287
  116. package/dist/dashboard/input-file.js +2 -70
  117. package/dist/dashboard/input-file.mjs +2 -70
  118. package/dist/dashboard/input-font.js +55 -64
  119. package/dist/dashboard/input-font.mjs +55 -64
  120. package/dist/dashboard/input-resource.js +1 -4
  121. package/dist/dashboard/input-resource.mjs +1 -4
  122. package/dist/dashboard/item-row.js +92 -0
  123. package/dist/dashboard/item-row.mjs +63 -0
  124. package/dist/dashboard/lib/features.js +1 -1
  125. package/dist/dashboard/lib/features.mjs +1 -1
  126. package/dist/dashboard/lib/item-list.js +15 -0
  127. package/dist/dashboard/lib/item-list.mjs +14 -0
  128. package/dist/dashboard/lib/rail.js +17 -16
  129. package/dist/dashboard/lib/rail.mjs +16 -15
  130. package/dist/dashboard/lib/sms.js +2 -8
  131. package/dist/dashboard/lib/sms.mjs +1 -6
  132. package/dist/dashboard/list-resource.js +0 -2
  133. package/dist/dashboard/list-resource.mjs +0 -2
  134. package/dist/dashboard/menu.js +5 -54
  135. package/dist/dashboard/menu.mjs +5 -53
  136. package/dist/dashboard/modal.js +4 -19
  137. package/dist/dashboard/modal.mjs +5 -20
  138. package/dist/dashboard/order-sections.js +0 -4
  139. package/dist/dashboard/order-sections.mjs +0 -4
  140. package/dist/dashboard/preview.js +324 -838
  141. package/dist/dashboard/preview.mjs +324 -826
  142. package/dist/dashboard/provider-ui.js +12 -20
  143. package/dist/dashboard/provider-ui.mjs +13 -21
  144. package/dist/dashboard/recharts.js +28 -53
  145. package/dist/dashboard/recharts.mjs +28 -53
  146. package/dist/dashboard/swatch.js +0 -35
  147. package/dist/dashboard/swatch.mjs +0 -31
  148. package/dist/dashboard/table-contacts.js +10 -6
  149. package/dist/dashboard/table-contacts.mjs +10 -6
  150. package/dist/dashboard/table.js +3 -10
  151. package/dist/dashboard/table.mjs +3 -9
  152. package/dist/dashboard/template-dashboard.js +21 -13
  153. package/dist/dashboard/template-dashboard.mjs +21 -12
  154. package/dist/dashboard/template-rail.js +126 -198
  155. package/dist/dashboard/template-rail.mjs +125 -196
  156. package/dist/dashboard/template-socket.js +12 -0
  157. package/dist/dashboard/template-socket.mjs +12 -0
  158. package/dist/dashboard/template-ui.js +11 -20
  159. package/dist/dashboard/template-ui.mjs +13 -22
  160. package/dist/input-checkbox.js +1 -7
  161. package/dist/input-checkbox.mjs +1 -7
  162. package/dist/input-name.js +3 -3
  163. package/dist/input-name.mjs +3 -3
  164. package/dist/input-select.js +1 -3
  165. package/dist/input-select.mjs +1 -3
  166. package/dist/provider-font.js +3 -4
  167. package/dist/provider-font.mjs +3 -4
  168. package/dist/shared/badge.js +0 -15
  169. package/dist/shared/badge.mjs +0 -11
  170. package/dist/shared/carousel.js +7 -11
  171. package/dist/shared/carousel.mjs +7 -11
  172. package/dist/shared/lib/campaign.js +9 -3
  173. package/dist/shared/lib/campaign.mjs +9 -3
  174. package/dist/shared/lib/helpers.js +0 -24
  175. package/dist/shared/lib/helpers.mjs +0 -22
  176. package/dist/shared/lib/video.js +0 -6
  177. package/dist/shared/lib/video.mjs +0 -5
  178. package/dist/shared/sortable.js +10 -27
  179. package/dist/shared/sortable.mjs +10 -27
  180. package/dist/shared/tabs.js +1 -1
  181. package/dist/shared/tabs.mjs +1 -1
  182. package/dist/video.js +9 -127
  183. package/dist/video.mjs +11 -125
  184. package/package.json +20 -176
  185. package/types/bridge/fields.d.ts +1 -6
  186. package/types/bridge/form-subdomain-missions.d.ts +0 -2
  187. package/types/bridge/form-subdomain.d.ts +3 -62
  188. package/types/bridge/lib/entry.d.ts +7 -44
  189. package/types/bridge/lib/order.d.ts +2 -13
  190. package/types/bridge/subdomain-content.d.ts +0 -1
  191. package/types/bridge/template-preview.d.ts +10 -0
  192. package/types/bridge/template-subdomain-gallery.d.ts +1 -13
  193. package/types/dashboard/card-campaign-switch.d.ts +1 -20
  194. package/types/dashboard/card-connection.d.ts +8 -0
  195. package/types/dashboard/card-order.d.ts +2 -2
  196. package/types/dashboard/card-section.d.ts +1 -9
  197. package/types/dashboard/card-tile.d.ts +9 -4
  198. package/types/dashboard/device.d.ts +12 -0
  199. package/types/dashboard/drawer.d.ts +0 -3
  200. package/types/dashboard/form-ai.d.ts +17 -0
  201. package/types/dashboard/form-filters-analytics.d.ts +14 -0
  202. package/types/dashboard/form-organization-brand.d.ts +0 -3
  203. package/types/dashboard/form-organization-campaign-agreement.d.ts +10 -53
  204. package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
  205. package/types/dashboard/form-organization-campaign-field-number.d.ts +1 -4
  206. package/types/dashboard/form-organization-campaign-field-select.d.ts +1 -6
  207. package/types/dashboard/form-organization-campaign-field-text.d.ts +1 -5
  208. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +1 -4
  209. package/types/dashboard/form-organization-campaign-integration-age.d.ts +1 -2
  210. package/types/dashboard/form-organization-campaign-integration-geocode.d.ts +0 -2
  211. package/types/dashboard/form-organization-campaign-page.d.ts +15 -9
  212. package/types/dashboard/form-organization-campaign-section.d.ts +8 -24
  213. package/types/dashboard/form-organization-campaign.d.ts +0 -3
  214. package/types/dashboard/form-organization-workflow.d.ts +4 -3
  215. package/types/dashboard/form-organization.d.ts +2 -2
  216. package/types/dashboard/form-verify-prize.d.ts +3 -30
  217. package/types/dashboard/input-combobox.d.ts +2 -0
  218. package/types/dashboard/input-date.d.ts +2 -0
  219. package/types/dashboard/input-editor.d.ts +0 -9
  220. package/types/dashboard/input-fields.d.ts +5 -8
  221. package/types/dashboard/input-file.d.ts +0 -4
  222. package/types/dashboard/input-resource.d.ts +0 -1
  223. package/types/dashboard/item-row.d.ts +25 -0
  224. package/types/dashboard/lib/item-list.d.ts +5 -10
  225. package/types/dashboard/lib/rail.d.ts +1 -0
  226. package/types/dashboard/lib/sms.d.ts +0 -7
  227. package/types/dashboard/modal.d.ts +1 -3
  228. package/types/dashboard/preview.d.ts +10 -65
  229. package/types/dashboard/recharts.d.ts +0 -3
  230. package/types/dashboard/swatch.d.ts +0 -4
  231. package/types/dashboard/template-dashboard.d.ts +2 -3
  232. package/types/input-select.d.ts +0 -2
  233. package/types/shared/button.d.ts +1 -1
  234. package/types/shared/lib/helpers.d.ts +1 -22
  235. package/types/shared/lib/video.d.ts +0 -3
  236. package/types/shared/sortable.d.ts +0 -6
  237. package/types/video.d.ts +2 -18
  238. package/dist/bridge/form-subdomain-agreement.js +0 -165
  239. package/dist/bridge/form-subdomain-agreement.mjs +0 -132
  240. package/dist/dashboard/campaign-form.js +0 -1798
  241. package/dist/dashboard/campaign-form.mjs +0 -1769
  242. package/dist/dashboard/card-campaign-agreement.js +0 -172
  243. package/dist/dashboard/card-campaign-agreement.mjs +0 -139
  244. package/dist/dashboard/card-shortcut.js +0 -181
  245. package/dist/dashboard/card-shortcut.mjs +0 -152
  246. package/dist/dashboard/document-blocks.js +0 -305
  247. package/dist/dashboard/document-blocks.mjs +0 -270
  248. package/dist/dashboard/form-organization-campaign-advertisements.js +0 -374
  249. package/dist/dashboard/form-organization-campaign-advertisements.mjs +0 -345
  250. package/dist/dashboard/form-organization-campaign-design.js +0 -258
  251. package/dist/dashboard/form-organization-campaign-design.mjs +0 -223
  252. package/dist/dashboard/form-organization-campaign-field-item.js +0 -585
  253. package/dist/dashboard/form-organization-campaign-field-item.mjs +0 -552
  254. package/dist/dashboard/form-organization-campaign-field-skill.js +0 -359
  255. package/dist/dashboard/form-organization-campaign-field-skill.mjs +0 -330
  256. package/dist/dashboard/form-organization-campaign-footer.js +0 -178
  257. package/dist/dashboard/form-organization-campaign-footer.mjs +0 -149
  258. package/dist/dashboard/form-reposition.js +0 -396
  259. package/dist/dashboard/form-reposition.mjs +0 -359
  260. package/dist/dashboard/form-support.js +0 -189
  261. package/dist/dashboard/form-support.mjs +0 -160
  262. package/dist/dashboard/form-tests.js +0 -683
  263. package/dist/dashboard/form-tests.mjs +0 -646
  264. package/dist/dashboard/lib/ab-tests.js +0 -130
  265. package/dist/dashboard/lib/ab-tests.mjs +0 -94
  266. package/dist/dashboard/lib/focus.js +0 -93
  267. package/dist/dashboard/lib/focus.mjs +0 -69
  268. package/dist/dashboard/lib/form-page.js +0 -203
  269. package/dist/dashboard/lib/form-page.mjs +0 -155
  270. package/dist/dashboard/template-design.js +0 -564
  271. package/dist/dashboard/template-design.mjs +0 -531
  272. package/dist/dashboard/template-test-page.js +0 -436
  273. package/dist/dashboard/template-test-page.mjs +0 -407
  274. package/dist/dashboard/template-tests.js +0 -141
  275. package/dist/dashboard/template-tests.mjs +0 -112
  276. package/dist/dashboard/template-variant.js +0 -185
  277. package/dist/dashboard/template-variant.mjs +0 -156
  278. package/dist/icons/arrow-down-long.js +0 -47
  279. package/dist/icons/arrow-down-long.mjs +0 -28
  280. package/dist/icons/arrows-pointing-out.js +0 -46
  281. package/dist/icons/arrows-pointing-out.mjs +0 -27
  282. package/dist/icons/beaker.js +0 -46
  283. package/dist/icons/beaker.mjs +0 -27
  284. package/dist/icons/identification.js +0 -46
  285. package/dist/icons/identification.mjs +0 -27
  286. package/dist/icons/lifebuoy.js +0 -46
  287. package/dist/icons/lifebuoy.mjs +0 -27
  288. package/dist/icons/rectangle-group.js +0 -46
  289. package/dist/icons/rectangle-group.mjs +0 -27
  290. package/dist/icons/rectangle-stack.js +0 -46
  291. package/dist/icons/rectangle-stack.mjs +0 -27
  292. package/dist/icons/shopping-bag.js +0 -46
  293. package/dist/icons/shopping-bag.mjs +0 -27
  294. package/dist/icons/swatch.js +0 -46
  295. package/dist/icons/swatch.mjs +0 -27
  296. package/dist/icons/window.js +0 -46
  297. package/dist/icons/window.mjs +0 -27
  298. package/dist/icons/zoom-in.js +0 -46
  299. package/dist/icons/zoom-in.mjs +0 -27
  300. package/dist/input-answer.js +0 -60
  301. package/dist/input-answer.mjs +0 -27
  302. package/dist/shared/document-pieces.js +0 -295
  303. package/dist/shared/document-pieces.mjs +0 -260
  304. package/types/bridge/form-subdomain-agreement.d.ts +0 -27
  305. package/types/dashboard/campaign-form.d.ts +0 -42
  306. package/types/dashboard/card-campaign-agreement.d.ts +0 -26
  307. package/types/dashboard/card-shortcut.d.ts +0 -38
  308. package/types/dashboard/document-blocks.d.ts +0 -14
  309. package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -15
  310. package/types/dashboard/form-organization-campaign-design.d.ts +0 -46
  311. package/types/dashboard/form-organization-campaign-field-item.d.ts +0 -36
  312. package/types/dashboard/form-organization-campaign-field-skill.d.ts +0 -36
  313. package/types/dashboard/form-organization-campaign-footer.d.ts +0 -23
  314. package/types/dashboard/form-reposition.d.ts +0 -29
  315. package/types/dashboard/form-support.d.ts +0 -14
  316. package/types/dashboard/form-tests.d.ts +0 -78
  317. package/types/dashboard/lib/ab-tests.d.ts +0 -50
  318. package/types/dashboard/lib/escape.d.ts +0 -4
  319. package/types/dashboard/lib/focus.d.ts +0 -16
  320. package/types/dashboard/lib/form-page.d.ts +0 -25
  321. package/types/dashboard/template-design.d.ts +0 -30
  322. package/types/dashboard/template-test-page.d.ts +0 -69
  323. package/types/dashboard/template-tests.d.ts +0 -30
  324. package/types/dashboard/template-variant.d.ts +0 -18
  325. package/types/icons/arrow-down-long.d.ts +0 -5
  326. package/types/icons/arrows-pointing-out.d.ts +0 -5
  327. package/types/icons/beaker.d.ts +0 -5
  328. package/types/icons/identification.d.ts +0 -5
  329. package/types/icons/lifebuoy.d.ts +0 -5
  330. package/types/icons/rectangle-group.d.ts +0 -5
  331. package/types/icons/rectangle-stack.d.ts +0 -5
  332. package/types/icons/shopping-bag.d.ts +0 -5
  333. package/types/icons/swatch.d.ts +0 -5
  334. package/types/icons/window.d.ts +0 -5
  335. package/types/icons/zoom-in.d.ts +0 -5
  336. package/types/input-answer.d.ts +0 -15
  337. package/types/shared/document-pieces.d.ts +0 -34
  338. package/types/shared/lib/motion.d.ts +0 -2
@@ -28,23 +28,11 @@ 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,
34
31
  PreviewPage: () => PreviewPage,
35
- SIZES: () => SIZES,
36
- Slider: () => Slider,
37
- SliderLayout: () => SliderLayout,
38
- States: () => States,
39
- ZOOMS: () => ZOOMS,
32
+ clamp: () => clamp,
40
33
  default: () => preview_default,
41
- fillHeight: () => fillHeight,
42
34
  fitScale: () => fitScale,
43
- fitZoom: () => fitZoom,
44
- pressScrolls: () => pressScrolls,
45
- scrollTarget: () => scrollTarget,
46
- useCard: () => useCard,
47
- useFill: () => useFill
35
+ scroller: () => scroller
48
36
  });
49
37
  module.exports = __toCommonJS(preview_exports);
50
38
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -52,753 +40,349 @@ var import_react = require("react");
52
40
  var import_react_dom = require("react-dom");
53
41
  var import_button = __toESM(require("../shared/button"));
54
42
  var import_loader = __toESM(require("../shared/loader"));
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"));
43
+ var import_input_combobox = __toESM(require("./input-combobox"));
44
+ var import_device = __toESM(require("./device"));
61
45
  var import_desktop = __toESM(require("../icons/desktop"));
62
46
  var import_phone = __toESM(require("../icons/phone"));
63
- var import_zoom_in = __toESM(require("../icons/zoom-in"));
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;
64
54
  const GUTTER = 24;
65
- const OFFSET = 20;
55
+ const NARROW = 486;
66
56
  const ZOOMS = [
67
57
  { key: "Fit", value: "fit" },
68
58
  { key: "25%", value: 0.25 },
69
59
  { key: "50%", value: 0.5 },
70
60
  { key: "100%", value: 1 },
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 }
61
+ { key: "150%", value: 1.5 },
62
+ { key: "200%", value: 2 }
76
63
  ];
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
- ]
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;
424
73
  }
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
- };
74
+ ;
75
+ return null;
530
76
  };
531
- const SliderLayout = ({
532
- blank,
77
+ const PreviewFrame = ({
533
78
  children,
534
- last,
535
- plain,
536
- slides = [],
537
- style,
538
- zooms = ZOOMS
79
+ states
539
80
  }) => {
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
- });
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)
563
96
  };
564
- useFill(peek.pane, peek.open);
565
- useFit(blank ? null : shown, zoom);
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]);
566
120
  (0, import_react.useEffect)(() => {
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
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();
574
130
  };
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,
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",
582
141
  {
583
142
  ...{
584
- value: {
585
- current: current == null ? void 0 : current.id,
586
- last,
587
- nodes,
588
- register,
589
- select
590
- }
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"
591
145
  },
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,
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,
614
164
  {
615
165
  ...{
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]
166
+ onChange: states.onChange,
167
+ options: states.options,
168
+ size: "small",
169
+ value: states.value
632
170
  }
633
171
  }
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
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
+ )
643
202
  }
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)
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
+ ))
667
234
  }
668
- },
669
- slide.id
670
- ))
671
- ]
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
672
270
  }
673
- ),
674
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
271
+ },
272
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
675
273
  "div",
676
274
  {
677
275
  ...{
678
- // The cards run with the page.
679
- className: "min-w-0"
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
+ }
680
288
  },
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
- ]
289
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
290
+ import_device.default,
291
+ {
292
+ ...{
293
+ type: device
294
+ },
295
+ children
296
+ }
297
+ )
700
298
  }
701
299
  )
702
- ]
703
- }
704
- )
300
+ }
301
+ )
302
+ ]
705
303
  }
706
304
  );
707
305
  };
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
+ };
708
320
  const Preview = ({
709
321
  children,
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
322
+ loading = false,
323
+ states,
324
+ style
727
325
  }) => {
326
+ var _a, _b, _c, _d;
728
327
  const frame = (0, import_react.useRef)(null);
729
- const [height, setHeight] = (0, import_react.useState)(400);
730
- const [shown, setShown] = (0, import_react.useState)(false);
731
- (0, import_react.useEffect)(() => {
732
- if (frame.current) frame.current.inert = true;
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);
733
333
  }, []);
334
+ (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]);
734
340
  const onLoad = () => {
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
- });
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);
754
346
  };
755
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
756
- "iframe",
347
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
348
+ PreviewFrame,
757
349
  {
758
350
  ...{
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
- }
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
+ ]
769
376
  }
770
377
  );
771
378
  };
772
379
  const PreviewPage = ({
773
- fill = true,
774
- html,
775
- left,
380
+ states,
776
381
  update,
777
- url,
778
- zooms = ZOOMS
382
+ url
779
383
  }) => {
780
- const area = (0, import_react.useRef)(null);
781
384
  const frame = (0, import_react.useRef)(null);
782
- const screen = (0, import_react.useRef)(null);
783
385
  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;
802
386
  const origin = url ? new URL(url).origin : null;
803
387
  const message = JSON.stringify({ update });
804
388
  const post = () => {
@@ -807,7 +391,7 @@ const PreviewPage = ({
807
391
  };
808
392
  (0, import_react.useEffect)(
809
393
  () => {
810
- if (!loading) post();
394
+ post();
811
395
  const onReady = (event) => {
812
396
  var _a, _b;
813
397
  if (event.source === ((_a = frame.current) == null ? void 0 : _a.contentWindow) && ((_b = event.data) == null ? void 0 : _b.ready)) post();
@@ -818,143 +402,45 @@ const PreviewPage = ({
818
402
  // eslint-disable-next-line react-hooks/exhaustive-deps
819
403
  [message, origin]
820
404
  );
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
- }
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"
869
417
  }
870
- )
871
- },
872
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
873
- "div",
418
+ }
419
+ ),
420
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
421
+ "iframe",
874
422
  {
875
423
  ...{
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
- ]
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
+ }
935
433
  }
936
434
  )
937
- }
938
- )
939
- ] });
435
+ ]
436
+ }
437
+ );
940
438
  };
941
439
  var preview_default = Preview;
942
440
  // Annotate the CommonJS export names for ESM import in node:
943
441
  0 && (module.exports = {
944
- CHIP,
945
- Mail,
946
- NoPreview,
947
442
  PreviewPage,
948
- SIZES,
949
- Slider,
950
- SliderLayout,
951
- States,
952
- ZOOMS,
953
- fillHeight,
443
+ clamp,
954
444
  fitScale,
955
- fitZoom,
956
- pressScrolls,
957
- scrollTarget,
958
- useCard,
959
- useFill
445
+ scroller
960
446
  });