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