@sonordev/site-kit 4.0.1 → 4.0.2

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 (250) hide show
  1. package/agent-manifest.json +6 -1
  2. package/dist/AnalyticsProvider-5SX4ZRGN.js +31 -0
  3. package/dist/{AnalyticsProvider-UE34SYF2.js.map → AnalyticsProvider-5SX4ZRGN.js.map} +1 -1
  4. package/dist/AnalyticsProvider-6DIRTRRA.mjs +10 -0
  5. package/dist/{AnalyticsProvider-NSXC6IOO.mjs.map → AnalyticsProvider-6DIRTRRA.mjs.map} +1 -1
  6. package/dist/ChatWidget-3SUC7HZA.js +20 -0
  7. package/dist/{ChatWidget-OW37OU3Z.js.map → ChatWidget-3SUC7HZA.js.map} +1 -1
  8. package/dist/ChatWidget-JTTERPI5.mjs +11 -0
  9. package/dist/{ChatWidget-ASWCGCJJ.mjs.map → ChatWidget-JTTERPI5.mjs.map} +1 -1
  10. package/dist/DatePicker-4WNKNNCV.mjs +4 -0
  11. package/dist/DatePicker-4WNKNNCV.mjs.map +1 -0
  12. package/dist/DatePicker-VPZR7RU3.js +13 -0
  13. package/dist/DatePicker-VPZR7RU3.js.map +1 -0
  14. package/dist/EngageWidget-3MDY2W5G.mjs +9 -0
  15. package/dist/{EngageWidget-67UZ3P5P.mjs.map → EngageWidget-3MDY2W5G.mjs.map} +1 -1
  16. package/dist/EngageWidget-YVAIP2NW.js +18 -0
  17. package/dist/{EngageWidget-MXOCMVBQ.js.map → EngageWidget-YVAIP2NW.js.map} +1 -1
  18. package/dist/FileField-PD52URLX.js +91 -0
  19. package/dist/FileField-PD52URLX.js.map +1 -0
  20. package/dist/FileField-XMBF3XCG.mjs +85 -0
  21. package/dist/FileField-XMBF3XCG.mjs.map +1 -0
  22. package/dist/{FormSpotlight-6MXGX6TU.mjs → FormSpotlight-72TYHDPV.mjs} +7 -6
  23. package/dist/FormSpotlight-72TYHDPV.mjs.map +1 -0
  24. package/dist/{FormSpotlight-LOR57ENP.js → FormSpotlight-AL6KGMGG.js} +20 -19
  25. package/dist/FormSpotlight-AL6KGMGG.js.map +1 -0
  26. package/dist/{FormStage-ZLZD5EW4.mjs → FormStage-GNBPJ7WX.mjs} +6 -6
  27. package/dist/FormStage-GNBPJ7WX.mjs.map +1 -0
  28. package/dist/{FormStage-H35FBWTX.js → FormStage-NLO52ER2.js} +16 -16
  29. package/dist/FormStage-NLO52ER2.js.map +1 -0
  30. package/dist/ManagedForm-2SYVMJY6.mjs +14 -0
  31. package/dist/ManagedForm-2SYVMJY6.mjs.map +1 -0
  32. package/dist/ManagedForm-XWN3TVQQ.js +23 -0
  33. package/dist/ManagedForm-XWN3TVQQ.js.map +1 -0
  34. package/dist/{SignalCore-HEXXYFSX.mjs → SignalCore-4NOVH33M.mjs} +5 -5
  35. package/dist/{SignalCore-HEXXYFSX.mjs.map → SignalCore-4NOVH33M.mjs.map} +1 -1
  36. package/dist/{SignalCore-EUMJIPDK.js → SignalCore-PD75O7GB.js} +11 -11
  37. package/dist/{SignalCore-EUMJIPDK.js.map → SignalCore-PD75O7GB.js.map} +1 -1
  38. package/dist/SitemapSync-KKUF43DS.js +17 -0
  39. package/dist/{SitemapSync-HKUEDDG6.js.map → SitemapSync-KKUF43DS.js.map} +1 -1
  40. package/dist/SitemapSync-UH6VZ55T.mjs +8 -0
  41. package/dist/{SitemapSync-T4QDPMFG.mjs.map → SitemapSync-UH6VZ55T.mjs.map} +1 -1
  42. package/dist/analytics/index.js +9 -9
  43. package/dist/analytics/index.mjs +4 -4
  44. package/dist/{chunk-ZGQUIL7L.js → chunk-2ACKOMAL.js} +105 -514
  45. package/dist/chunk-2ACKOMAL.js.map +1 -0
  46. package/dist/{chunk-L5Q2ZJJM.js → chunk-2MIOQYF5.js} +6 -6
  47. package/dist/{chunk-L5Q2ZJJM.js.map → chunk-2MIOQYF5.js.map} +1 -1
  48. package/dist/{chunk-XCCW4Y3B.mjs → chunk-53RHVKTD.mjs} +5 -5
  49. package/dist/{chunk-XCCW4Y3B.mjs.map → chunk-53RHVKTD.mjs.map} +1 -1
  50. package/dist/{chunk-VL2WAC22.js → chunk-5QVXHD6V.js} +14 -14
  51. package/dist/{chunk-VL2WAC22.js.map → chunk-5QVXHD6V.js.map} +1 -1
  52. package/dist/{chunk-QABZPSHD.js → chunk-62Z4D3QR.js} +5 -5
  53. package/dist/{chunk-QABZPSHD.js.map → chunk-62Z4D3QR.js.map} +1 -1
  54. package/dist/{chunk-PVE6G5XQ.mjs → chunk-6PNWJXAE.mjs} +3 -3
  55. package/dist/{chunk-PVE6G5XQ.mjs.map → chunk-6PNWJXAE.mjs.map} +1 -1
  56. package/dist/{chunk-DG34TZ6T.mjs → chunk-6ZFXASW6.mjs} +4 -4
  57. package/dist/{chunk-DG34TZ6T.mjs.map → chunk-6ZFXASW6.mjs.map} +1 -1
  58. package/dist/{chunk-YNIZKOEW.js → chunk-A624YYDG.js} +2 -2
  59. package/dist/{chunk-YNIZKOEW.js.map → chunk-A624YYDG.js.map} +1 -1
  60. package/dist/chunk-AJNT5GCU.mjs +183 -0
  61. package/dist/chunk-AJNT5GCU.mjs.map +1 -0
  62. package/dist/chunk-AQA4PFMJ.mjs +44 -0
  63. package/dist/chunk-AQA4PFMJ.mjs.map +1 -0
  64. package/dist/{chunk-62QRWS2I.mjs → chunk-B7J7SU5A.mjs} +8 -8
  65. package/dist/{chunk-62QRWS2I.mjs.map → chunk-B7J7SU5A.mjs.map} +1 -1
  66. package/dist/chunk-DVYYGHSG.js +285 -0
  67. package/dist/chunk-DVYYGHSG.js.map +1 -0
  68. package/dist/{chunk-5GPFPMDQ.mjs → chunk-FGN27J35.mjs} +4 -4
  69. package/dist/{chunk-5GPFPMDQ.mjs.map → chunk-FGN27J35.mjs.map} +1 -1
  70. package/dist/{chunk-Z74IVGJB.mjs → chunk-FZ643CZK.mjs} +4 -4
  71. package/dist/{chunk-Z74IVGJB.mjs.map → chunk-FZ643CZK.mjs.map} +1 -1
  72. package/dist/{chunk-2LKWN26R.mjs → chunk-GCS4XZHC.mjs} +3 -3
  73. package/dist/{chunk-2LKWN26R.mjs.map → chunk-GCS4XZHC.mjs.map} +1 -1
  74. package/dist/{chunk-6535RSF5.mjs → chunk-HOB2A6JM.mjs} +3 -3
  75. package/dist/{chunk-6535RSF5.mjs.map → chunk-HOB2A6JM.mjs.map} +1 -1
  76. package/dist/{chunk-CTZHLX2B.mjs → chunk-JFVEKSZT.mjs} +5 -182
  77. package/dist/chunk-JFVEKSZT.mjs.map +1 -0
  78. package/dist/{chunk-JGTIVQIN.mjs → chunk-KNYK2VLX.mjs} +3 -3
  79. package/dist/{chunk-JGTIVQIN.mjs.map → chunk-KNYK2VLX.mjs.map} +1 -1
  80. package/dist/{chunk-LYDTOFXJ.mjs → chunk-LB7LHVWI.mjs} +107 -503
  81. package/dist/chunk-LB7LHVWI.mjs.map +1 -0
  82. package/dist/{chunk-RZW4XVG5.js → chunk-LP6MC2RH.js} +14 -14
  83. package/dist/{chunk-RZW4XVG5.js.map → chunk-LP6MC2RH.js.map} +1 -1
  84. package/dist/chunk-LVCUT2OX.js +148 -0
  85. package/dist/chunk-LVCUT2OX.js.map +1 -0
  86. package/dist/chunk-LYAU5PRS.js +8 -0
  87. package/dist/{chunk-34WY5XN2.js.map → chunk-LYAU5PRS.js.map} +1 -1
  88. package/dist/{chunk-WHGVQJG4.js → chunk-MPACJDDG.js} +8 -8
  89. package/dist/{chunk-WHGVQJG4.js.map → chunk-MPACJDDG.js.map} +1 -1
  90. package/dist/{chunk-NDB7EIOI.js → chunk-MRRTAJWQ.js} +3 -3
  91. package/dist/{chunk-NDB7EIOI.js.map → chunk-MRRTAJWQ.js.map} +1 -1
  92. package/dist/chunk-MU3D5IO7.mjs +283 -0
  93. package/dist/chunk-MU3D5IO7.mjs.map +1 -0
  94. package/dist/chunk-MZY3MEUO.mjs +138 -0
  95. package/dist/chunk-MZY3MEUO.mjs.map +1 -0
  96. package/dist/chunk-NCWVR4BU.mjs +508 -0
  97. package/dist/chunk-NCWVR4BU.mjs.map +1 -0
  98. package/dist/{chunk-52K556WM.js → chunk-NJN467OM.js} +14 -14
  99. package/dist/{chunk-52K556WM.js.map → chunk-NJN467OM.js.map} +1 -1
  100. package/dist/{chunk-MJY7LYOV.mjs → chunk-NWJX6NHR.mjs} +4 -4
  101. package/dist/{chunk-MJY7LYOV.mjs.map → chunk-NWJX6NHR.mjs.map} +1 -1
  102. package/dist/chunk-NWPNFCNY.js +511 -0
  103. package/dist/chunk-NWPNFCNY.js.map +1 -0
  104. package/dist/{chunk-NU5DJUVI.js → chunk-OP5FYTWJ.js} +12 -192
  105. package/dist/chunk-OP5FYTWJ.js.map +1 -0
  106. package/dist/{chunk-YGWWLTH5.js → chunk-PGND73EV.js} +4 -4
  107. package/dist/{chunk-YGWWLTH5.js.map → chunk-PGND73EV.js.map} +1 -1
  108. package/dist/chunk-QO5NS62X.js +46 -0
  109. package/dist/chunk-QO5NS62X.js.map +1 -0
  110. package/dist/chunk-QTN3F7D7.mjs +6 -0
  111. package/dist/{chunk-6GFEJH4F.mjs.map → chunk-QTN3F7D7.mjs.map} +1 -1
  112. package/dist/chunk-R4PCXP3F.mjs +60 -0
  113. package/dist/chunk-R4PCXP3F.mjs.map +1 -0
  114. package/dist/{chunk-Q7HLRTZA.js → chunk-RAX3HS4T.js} +15 -15
  115. package/dist/{chunk-Q7HLRTZA.js.map → chunk-RAX3HS4T.js.map} +1 -1
  116. package/dist/{chunk-I424AZPT.js → chunk-T2YAEBEY.js} +4 -4
  117. package/dist/{chunk-I424AZPT.js.map → chunk-T2YAEBEY.js.map} +1 -1
  118. package/dist/{chunk-6SHBMFYM.mjs → chunk-T5DXYGWK.mjs} +3 -3
  119. package/dist/{chunk-6SHBMFYM.mjs.map → chunk-T5DXYGWK.mjs.map} +1 -1
  120. package/dist/{chunk-KHJYA64F.mjs → chunk-U2CJZ6O5.mjs} +2 -2
  121. package/dist/{chunk-KHJYA64F.mjs.map → chunk-U2CJZ6O5.mjs.map} +1 -1
  122. package/dist/{chunk-XAMUTD4I.mjs → chunk-UBNVD567.mjs} +3 -3
  123. package/dist/{chunk-XAMUTD4I.mjs.map → chunk-UBNVD567.mjs.map} +1 -1
  124. package/dist/chunk-UQPUFRXF.mjs +104 -0
  125. package/dist/chunk-UQPUFRXF.mjs.map +1 -0
  126. package/dist/chunk-VLY3SFNH.js +64 -0
  127. package/dist/chunk-VLY3SFNH.js.map +1 -0
  128. package/dist/{chunk-DPTNQVMK.mjs → chunk-VUIQLKJB.mjs} +3 -3
  129. package/dist/{chunk-DPTNQVMK.mjs.map → chunk-VUIQLKJB.mjs.map} +1 -1
  130. package/dist/chunk-WHVUSVHA.js +110 -0
  131. package/dist/chunk-WHVUSVHA.js.map +1 -0
  132. package/dist/{chunk-QXIVUWQZ.js → chunk-WNNY2BCV.js} +8 -8
  133. package/dist/{chunk-QXIVUWQZ.js.map → chunk-WNNY2BCV.js.map} +1 -1
  134. package/dist/{chunk-EDFZ6EMM.js → chunk-WXKEYKE6.js} +15 -15
  135. package/dist/{chunk-EDFZ6EMM.js.map → chunk-WXKEYKE6.js.map} +1 -1
  136. package/dist/{chunk-4JEJTQYC.mjs → chunk-XNPITFJ5.mjs} +3 -3
  137. package/dist/{chunk-4JEJTQYC.mjs.map → chunk-XNPITFJ5.mjs.map} +1 -1
  138. package/dist/{chunk-OIBQYBEL.mjs → chunk-XRC3JZAK.mjs} +3 -3
  139. package/dist/{chunk-OIBQYBEL.mjs.map → chunk-XRC3JZAK.mjs.map} +1 -1
  140. package/dist/{chunk-CBUK2XB3.js → chunk-Y26LKDE4.js} +9 -9
  141. package/dist/{chunk-CBUK2XB3.js.map → chunk-Y26LKDE4.js.map} +1 -1
  142. package/dist/{chunk-LDRE2ELU.js → chunk-ZK5VSIRO.js} +12 -12
  143. package/dist/{chunk-LDRE2ELU.js.map → chunk-ZK5VSIRO.js.map} +1 -1
  144. package/dist/{chunk-62RQTXHX.js → chunk-ZPG4GTU7.js} +5 -5
  145. package/dist/{chunk-62RQTXHX.js.map → chunk-ZPG4GTU7.js.map} +1 -1
  146. package/dist/chunk-ZRGCKWIT.js +188 -0
  147. package/dist/chunk-ZRGCKWIT.js.map +1 -0
  148. package/dist/cli/index.js +3 -3
  149. package/dist/cli/index.mjs +1 -1
  150. package/dist/client/index.js +5 -5
  151. package/dist/client/index.mjs +4 -4
  152. package/dist/commerce/index.js +56 -56
  153. package/dist/commerce/index.mjs +5 -5
  154. package/dist/engage/index.js +10 -9
  155. package/dist/engage/index.js.map +1 -1
  156. package/dist/engage/index.mjs +7 -6
  157. package/dist/engage/index.mjs.map +1 -1
  158. package/dist/fleet/index.js +9 -9
  159. package/dist/fleet/index.mjs +5 -5
  160. package/dist/forms/FileField.d.ts +31 -0
  161. package/dist/forms/FileField.d.ts.map +1 -0
  162. package/dist/forms/FormClient.d.ts +10 -1
  163. package/dist/forms/FormClient.d.ts.map +1 -1
  164. package/dist/forms/FormEnhancer.d.ts +72 -0
  165. package/dist/forms/FormEnhancer.d.ts.map +1 -0
  166. package/dist/forms/FormField.d.ts +26 -3
  167. package/dist/forms/FormField.d.ts.map +1 -1
  168. package/dist/forms/FormSpotlight.d.ts.map +1 -1
  169. package/dist/forms/FormStage.d.ts.map +1 -1
  170. package/dist/forms/HoneypotField.d.ts +8 -2
  171. package/dist/forms/HoneypotField.d.ts.map +1 -1
  172. package/dist/forms/ManagedForm.d.ts +1 -1
  173. package/dist/forms/ManagedForm.d.ts.map +1 -1
  174. package/dist/forms/ServerForm.d.ts +73 -0
  175. package/dist/forms/ServerForm.d.ts.map +1 -0
  176. package/dist/forms/StaticForm.d.ts +50 -0
  177. package/dist/forms/StaticForm.d.ts.map +1 -0
  178. package/dist/forms/field-controls.d.ts +7 -0
  179. package/dist/forms/field-controls.d.ts.map +1 -0
  180. package/dist/forms/index.d.ts +7 -0
  181. package/dist/forms/index.d.ts.map +1 -1
  182. package/dist/forms/index.js +33 -557
  183. package/dist/forms/index.js.map +1 -1
  184. package/dist/forms/index.mjs +14 -550
  185. package/dist/forms/index.mjs.map +1 -1
  186. package/dist/forms/normalize-config.d.ts +18 -0
  187. package/dist/forms/normalize-config.d.ts.map +1 -0
  188. package/dist/forms/server.d.ts +5 -0
  189. package/dist/forms/server.d.ts.map +1 -1
  190. package/dist/forms/server.js +47 -0
  191. package/dist/forms/server.js.map +1 -1
  192. package/dist/forms/server.mjs +44 -1
  193. package/dist/forms/server.mjs.map +1 -1
  194. package/dist/forms/static-form.test.d.ts +2 -0
  195. package/dist/forms/static-form.test.d.ts.map +1 -0
  196. package/dist/forms/static.d.ts +17 -0
  197. package/dist/forms/static.d.ts.map +1 -0
  198. package/dist/forms/static.js +20 -0
  199. package/dist/forms/static.js.map +1 -0
  200. package/dist/forms/static.mjs +11 -0
  201. package/dist/forms/static.mjs.map +1 -0
  202. package/dist/forms/types.d.ts +7 -0
  203. package/dist/forms/types.d.ts.map +1 -1
  204. package/dist/forms/useForm.d.ts.map +1 -1
  205. package/dist/images/index.js +11 -11
  206. package/dist/images/index.mjs +4 -4
  207. package/dist/index.js +109 -109
  208. package/dist/index.mjs +9 -9
  209. package/dist/layout/client.js +9 -9
  210. package/dist/layout/client.mjs +8 -8
  211. package/dist/layout/index.js +11 -11
  212. package/dist/layout/index.mjs +9 -9
  213. package/dist/maps/index.js +5 -5
  214. package/dist/maps/index.mjs +3 -3
  215. package/dist/search/index.js +4 -4
  216. package/dist/search/index.mjs +3 -3
  217. package/dist/seo/client.js +5 -5
  218. package/dist/seo/client.mjs +4 -4
  219. package/dist/seo/index.js +14 -14
  220. package/dist/seo/index.mjs +6 -6
  221. package/dist/seo/server.js +5 -5
  222. package/dist/seo/server.mjs +1 -1
  223. package/dist/server/index.js +3 -3
  224. package/dist/server/index.mjs +2 -2
  225. package/dist/shared/build-entries.d.ts +6 -0
  226. package/dist/shared/build-entries.d.ts.map +1 -1
  227. package/dist/shared/version.d.ts +1 -1
  228. package/dist/signal/index.js +11 -11
  229. package/dist/signal/index.mjs +2 -2
  230. package/dist/sync/index.js +16 -16
  231. package/dist/sync/index.mjs +4 -4
  232. package/package.json +9 -4
  233. package/dist/AnalyticsProvider-NSXC6IOO.mjs +0 -10
  234. package/dist/AnalyticsProvider-UE34SYF2.js +0 -31
  235. package/dist/ChatWidget-ASWCGCJJ.mjs +0 -10
  236. package/dist/ChatWidget-OW37OU3Z.js +0 -19
  237. package/dist/EngageWidget-67UZ3P5P.mjs +0 -9
  238. package/dist/EngageWidget-MXOCMVBQ.js +0 -18
  239. package/dist/FormSpotlight-6MXGX6TU.mjs.map +0 -1
  240. package/dist/FormSpotlight-LOR57ENP.js.map +0 -1
  241. package/dist/FormStage-H35FBWTX.js.map +0 -1
  242. package/dist/FormStage-ZLZD5EW4.mjs.map +0 -1
  243. package/dist/SitemapSync-HKUEDDG6.js +0 -17
  244. package/dist/SitemapSync-T4QDPMFG.mjs +0 -8
  245. package/dist/chunk-34WY5XN2.js +0 -8
  246. package/dist/chunk-6GFEJH4F.mjs +0 -6
  247. package/dist/chunk-CTZHLX2B.mjs.map +0 -1
  248. package/dist/chunk-LYDTOFXJ.mjs.map +0 -1
  249. package/dist/chunk-NU5DJUVI.js.map +0 -1
  250. package/dist/chunk-ZGQUIL7L.js.map +0 -1
@@ -1,282 +1,6 @@
1
- 'use client';
2
- import { sonorFetch } from './chunk-5GPFPMDQ.mjs';
3
- import React2, { useState, useRef, useCallback, useEffect } from 'react';
4
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
5
2
 
6
- var DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
7
- var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
8
- function pad(n) {
9
- return n < 10 ? `0${n}` : `${n}`;
10
- }
11
- function toDateStr(y, m, d) {
12
- return `${y}-${pad(m + 1)}-${pad(d)}`;
13
- }
14
- function parseDate(str) {
15
- if (!str) return null;
16
- const [y, m, d] = str.split("-").map(Number);
17
- if (!y || !m || !d) return null;
18
- return { year: y, month: m - 1, day: d };
19
- }
20
- function getDaysInMonth(year, month) {
21
- return new Date(year, month + 1, 0).getDate();
22
- }
23
- function getFirstDayOfMonth(year, month) {
24
- return new Date(year, month, 1).getDay();
25
- }
26
- function formatDisplay(dateStr) {
27
- const parsed = parseDate(dateStr);
28
- if (!parsed) return "";
29
- return `${MONTHS[parsed.month]} ${parsed.day}, ${parsed.year}`;
30
- }
31
- function DatePicker({
32
- value,
33
- onChange,
34
- id,
35
- name,
36
- required,
37
- minDate,
38
- placeholder = "Select a date",
39
- className = "",
40
- style
41
- }) {
42
- const today = /* @__PURE__ */ new Date();
43
- const todayStr = toDateStr(today.getFullYear(), today.getMonth(), today.getDate());
44
- const effectiveMin = minDate || "";
45
- const parsed = parseDate(value);
46
- const [viewYear, setViewYear] = useState(parsed?.year || today.getFullYear());
47
- const [viewMonth, setViewMonth] = useState(parsed?.month ?? today.getMonth());
48
- const [open, setOpen] = useState(false);
49
- const [closing, setClosing] = useState(false);
50
- const closeTimer = useRef(null);
51
- const containerRef = useRef(null);
52
- const closeAnimated = useCallback(() => {
53
- if (closeTimer.current !== null) return;
54
- setClosing(true);
55
- closeTimer.current = window.setTimeout(() => {
56
- closeTimer.current = null;
57
- setClosing(false);
58
- setOpen(false);
59
- }, 180);
60
- }, []);
61
- useEffect(
62
- () => () => {
63
- if (closeTimer.current !== null) window.clearTimeout(closeTimer.current);
64
- },
65
- []
66
- );
67
- useEffect(() => {
68
- if (!open) return;
69
- const handler = (e) => {
70
- if (containerRef.current && !containerRef.current.contains(e.target)) {
71
- closeAnimated();
72
- }
73
- };
74
- document.addEventListener("mousedown", handler);
75
- return () => document.removeEventListener("mousedown", handler);
76
- }, [open, closeAnimated]);
77
- useEffect(() => {
78
- if (!open) return;
79
- const handler = (e) => {
80
- if (e.key === "Escape") closeAnimated();
81
- };
82
- window.addEventListener("keydown", handler);
83
- return () => window.removeEventListener("keydown", handler);
84
- }, [open, closeAnimated]);
85
- const prevMonth = useCallback(() => {
86
- if (viewMonth === 0) {
87
- setViewMonth(11);
88
- setViewYear((y) => y - 1);
89
- } else setViewMonth((m) => m - 1);
90
- }, [viewMonth]);
91
- const nextMonth = useCallback(() => {
92
- if (viewMonth === 11) {
93
- setViewMonth(0);
94
- setViewYear((y) => y + 1);
95
- } else setViewMonth((m) => m + 1);
96
- }, [viewMonth]);
97
- const selectDay = useCallback((day) => {
98
- const dateStr = toDateStr(viewYear, viewMonth, day);
99
- onChange(dateStr);
100
- closeAnimated();
101
- }, [viewYear, viewMonth, onChange, closeAnimated]);
102
- const isDisabled = useCallback((day) => {
103
- const dateStr = toDateStr(viewYear, viewMonth, day);
104
- return dateStr < effectiveMin;
105
- }, [viewYear, viewMonth, effectiveMin]);
106
- const isSelected = useCallback((day) => {
107
- if (!value) return false;
108
- return toDateStr(viewYear, viewMonth, day) === value;
109
- }, [viewYear, viewMonth, value]);
110
- const isToday = useCallback((day) => {
111
- return toDateStr(viewYear, viewMonth, day) === todayStr;
112
- }, [viewYear, viewMonth, todayStr]);
113
- const daysInMonth = getDaysInMonth(viewYear, viewMonth);
114
- const firstDay = getFirstDayOfMonth(viewYear, viewMonth);
115
- const weeks = [];
116
- let week = Array(firstDay).fill(null);
117
- for (let d = 1; d <= daysInMonth; d++) {
118
- week.push(d);
119
- if (week.length === 7) {
120
- weeks.push(week);
121
- week = [];
122
- }
123
- }
124
- if (week.length > 0) {
125
- while (week.length < 7) week.push(null);
126
- weeks.push(week);
127
- }
128
- return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `sk-datepicker ${className}`, style: { position: "relative", ...style }, children: [
129
- /* @__PURE__ */ jsx("input", { type: "hidden", name, value: value || "" }),
130
- /* @__PURE__ */ jsxs(
131
- "button",
132
- {
133
- type: "button",
134
- id,
135
- onClick: () => open ? closeAnimated() : setOpen(true),
136
- "aria-required": required,
137
- "aria-expanded": open,
138
- style: {
139
- display: "flex",
140
- alignItems: "center",
141
- justifyContent: "space-between",
142
- width: "100%",
143
- padding: "var(--sk-input-padding, 10px 12px)",
144
- backgroundColor: "var(--sk-input-bg, #fff)",
145
- border: `1px solid ${open ? "var(--sk-input-border-focus, #2563eb)" : "var(--sk-input-border, #d1d5db)"}`,
146
- borderRadius: "var(--sk-input-radius, 0.375rem)",
147
- fontSize: "var(--sk-font-size, 14px)",
148
- color: value ? "var(--sk-form-success-text, #111)" : "var(--sk-text-tertiary, #9ca3af)",
149
- cursor: "pointer",
150
- outline: "none",
151
- textAlign: "left"
152
- },
153
- children: [
154
- /* @__PURE__ */ jsx("span", { className: value ? "sk-datepicker__value--stamp" : void 0, children: value ? formatDisplay(value) : placeholder }, value || "empty"),
155
- /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { opacity: 0.5, flexShrink: 0 }, children: [
156
- /* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2", ry: "2" }),
157
- /* @__PURE__ */ jsx("line", { x1: "16", y1: "2", x2: "16", y2: "6" }),
158
- /* @__PURE__ */ jsx("line", { x1: "8", y1: "2", x2: "8", y2: "6" }),
159
- /* @__PURE__ */ jsx("line", { x1: "3", y1: "10", x2: "21", y2: "10" })
160
- ] })
161
- ]
162
- }
163
- ),
164
- open && /* @__PURE__ */ jsxs(
165
- "div",
166
- {
167
- className: "sk-datepicker__pop",
168
- "data-sk-closing": closing ? "true" : void 0,
169
- style: {
170
- position: "absolute",
171
- top: "100%",
172
- left: 0,
173
- right: 0,
174
- marginTop: "4px",
175
- backgroundColor: "var(--sk-input-bg, #fff)",
176
- border: "1px solid var(--sk-input-border, #d1d5db)",
177
- borderRadius: "var(--sk-input-radius, 0.375rem)",
178
- boxShadow: "0 10px 25px rgba(0,0,0,0.3)",
179
- zIndex: 50,
180
- padding: "12px",
181
- minWidth: "280px"
182
- },
183
- children: [
184
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: "12px" }, children: [
185
- /* @__PURE__ */ jsx(
186
- "button",
187
- {
188
- type: "button",
189
- onClick: prevMonth,
190
- style: { background: "none", border: "none", cursor: "pointer", padding: "4px 8px", color: "var(--sk-label-color, #6b7280)", fontSize: "18px", lineHeight: 1 },
191
- "aria-label": "Previous month",
192
- children: "\u2039"
193
- }
194
- ),
195
- /* @__PURE__ */ jsxs("span", { style: { fontWeight: 600, fontSize: "14px", color: "var(--sk-form-success-text, #111)" }, children: [
196
- MONTHS[viewMonth],
197
- " ",
198
- viewYear
199
- ] }),
200
- /* @__PURE__ */ jsx(
201
- "button",
202
- {
203
- type: "button",
204
- onClick: nextMonth,
205
- style: { background: "none", border: "none", cursor: "pointer", padding: "4px 8px", color: "var(--sk-label-color, #6b7280)", fontSize: "18px", lineHeight: 1 },
206
- "aria-label": "Next month",
207
- children: "\u203A"
208
- }
209
- )
210
- ] }),
211
- /* @__PURE__ */ jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: "2px", marginBottom: "4px" }, children: DAYS.map((d) => /* @__PURE__ */ jsx("div", { style: { textAlign: "center", fontSize: "11px", fontWeight: 600, color: "var(--sk-text-tertiary, #9ca3af)", padding: "4px 0", textTransform: "uppercase", letterSpacing: "0.05em" }, children: d }, d)) }),
212
- weeks.map((week2, wi) => /* @__PURE__ */ jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: "2px" }, children: week2.map((day, di) => {
213
- if (day === null) {
214
- return /* @__PURE__ */ jsx("div", { style: { padding: "6px" } }, di);
215
- }
216
- const disabled = isDisabled(day);
217
- const selected = isSelected(day);
218
- const todayMark = isToday(day);
219
- return /* @__PURE__ */ jsx(
220
- "button",
221
- {
222
- type: "button",
223
- disabled,
224
- onClick: () => selectDay(day),
225
- style: {
226
- padding: "6px",
227
- textAlign: "center",
228
- fontSize: "13px",
229
- fontWeight: selected ? 700 : todayMark ? 600 : 400,
230
- borderRadius: "6px",
231
- border: todayMark && !selected ? "1px solid var(--sk-primary, #2563eb)" : "1px solid transparent",
232
- background: selected ? "var(--sk-primary, #2563eb)" : "transparent",
233
- color: disabled ? "var(--sk-text-tertiary, #9ca3af)" : selected ? "#fff" : "var(--sk-form-success-text, #111)",
234
- cursor: disabled ? "not-allowed" : "pointer",
235
- opacity: disabled ? 0.4 : 1,
236
- transition: "background 0.15s, color 0.15s"
237
- },
238
- onMouseEnter: (e) => {
239
- if (!disabled && !selected) {
240
- e.target.style.background = "var(--sk-input-border, #e5e7eb)";
241
- }
242
- },
243
- onMouseLeave: (e) => {
244
- if (!disabled && !selected) {
245
- e.target.style.background = "transparent";
246
- }
247
- },
248
- "aria-label": `${MONTHS[viewMonth]} ${day}, ${viewYear}`,
249
- "aria-selected": selected,
250
- children: day
251
- },
252
- di
253
- );
254
- }) }, wi)),
255
- /* @__PURE__ */ jsx("div", { style: { marginTop: "8px", textAlign: "center" }, children: /* @__PURE__ */ jsx(
256
- "button",
257
- {
258
- type: "button",
259
- onClick: () => {
260
- onChange(todayStr);
261
- setOpen(false);
262
- },
263
- style: {
264
- background: "none",
265
- border: "none",
266
- cursor: "pointer",
267
- fontSize: "12px",
268
- fontWeight: 600,
269
- color: "var(--sk-primary, #2563eb)",
270
- padding: "4px 8px"
271
- },
272
- children: "Today"
273
- }
274
- ) })
275
- ]
276
- }
277
- )
278
- ] });
279
- }
3
+ // src/forms/delight.tsx
280
4
  var STYLE_ID = "sk-delight-css";
281
5
  var CSS = `
282
6
  /* Every frame must carry the centering translateY: the animation fills both
@@ -502,7 +226,10 @@ function normalizeOptions(options) {
502
226
  }
503
227
  return [];
504
228
  }
505
- function FormField({ field, value, error, onChange, classPrefix = "sk-form", showValid }) {
229
+ function FormField({ field, value, error, onChange, classPrefix = "sk-form", showValid, controls }) {
230
+ const interactive = typeof onChange === "function";
231
+ const emit = (v) => onChange?.(v);
232
+ const bind = (v) => interactive ? { value: v, onChange: (e) => emit(e.target.value) } : { defaultValue: v || void 0 };
506
233
  const inputId = `sk-${field.id || field.slug}`;
507
234
  const options = normalizeOptions(field.options);
508
235
  const baseInputStyle = {
@@ -542,7 +269,7 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
542
269
  return /* @__PURE__ */ jsx("p", { className: `${classPrefix}__paragraph`, style: { color: "var(--sk-text-tertiary, #6b7280)", margin: "8px 0" }, children: field.help_text || field.label });
543
270
  }
544
271
  if (field.field_type === "hidden") {
545
- return /* @__PURE__ */ jsx("input", { type: "hidden", name: field.slug, value: String(value || "") });
272
+ return interactive ? /* @__PURE__ */ jsx("input", { type: "hidden", name: field.slug, value: String(value || ""), readOnly: true }) : /* @__PURE__ */ jsx("input", { type: "hidden", name: field.slug, defaultValue: String(value || "") });
546
273
  }
547
274
  const hideLabel = !!field.hide_label;
548
275
  const effectivePlaceholder = hideLabel ? field.label : field.placeholder;
@@ -559,10 +286,9 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
559
286
  className: `${classPrefix}__input`,
560
287
  type: field.field_type === "phone" || field.field_type === "tel" ? "tel" : field.field_type,
561
288
  name: field.slug,
562
- value: String(value || ""),
289
+ ...bind(String(value || "")),
563
290
  placeholder: effectivePlaceholder,
564
291
  required: field.is_required,
565
- onChange: (e) => onChange(e.target.value),
566
292
  style: baseInputStyle
567
293
  }
568
294
  ),
@@ -574,11 +300,10 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
574
300
  id: inputId,
575
301
  className: `${classPrefix}__textarea`,
576
302
  name: field.slug,
577
- value: String(value || ""),
303
+ ...bind(String(value || "")),
578
304
  placeholder: effectivePlaceholder,
579
305
  required: field.is_required,
580
306
  rows: 4,
581
- onChange: (e) => onChange(e.target.value),
582
307
  style: { ...baseInputStyle, resize: "vertical" }
583
308
  }
584
309
  ),
@@ -588,9 +313,8 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
588
313
  id: inputId,
589
314
  className: `${classPrefix}__select`,
590
315
  name: field.slug,
591
- value: String(value || ""),
316
+ ...bind(String(value || "")),
592
317
  required: field.is_required,
593
- onChange: (e) => onChange(e.target.value),
594
318
  style: baseInputStyle,
595
319
  children: [
596
320
  /* @__PURE__ */ jsx("option", { value: "", children: effectivePlaceholder || "Select an option" }),
@@ -604,13 +328,12 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
604
328
  id: inputId,
605
329
  className: `${classPrefix}__select ${classPrefix}__select--multi`,
606
330
  name: field.slug,
607
- value: Array.isArray(value) ? value : [],
331
+ ...interactive ? {
332
+ value: Array.isArray(value) ? value : [],
333
+ onChange: (e) => emit(Array.from(e.target.selectedOptions, (opt) => opt.value))
334
+ } : { defaultValue: Array.isArray(value) ? value : [] },
608
335
  required: field.is_required,
609
336
  multiple: true,
610
- onChange: (e) => {
611
- const selected = Array.from(e.target.selectedOptions, (opt) => opt.value);
612
- onChange(selected);
613
- },
614
337
  style: { ...baseInputStyle, height: 120 },
615
338
  children: options.map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
616
339
  }
@@ -622,8 +345,8 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
622
345
  type: "radio",
623
346
  name: field.slug,
624
347
  value: option.value,
625
- checked: value === option.value,
626
- onChange: () => onChange(option.value)
348
+ ...interactive ? { checked: value === option.value, onChange: () => emit(option.value) } : { defaultChecked: value === option.value },
349
+ required: field.is_required
627
350
  }
628
351
  ),
629
352
  option.label
@@ -634,8 +357,8 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
634
357
  {
635
358
  type: "checkbox",
636
359
  name: field.slug,
637
- checked: !!value,
638
- onChange: (e) => onChange(e.target.checked)
360
+ ...interactive ? { checked: !!value, onChange: (e) => emit(e.target.checked) } : { defaultChecked: !!value },
361
+ required: field.is_required
639
362
  }
640
363
  ),
641
364
  field.help_text || field.label
@@ -648,31 +371,46 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
648
371
  "input",
649
372
  {
650
373
  type: "checkbox",
651
- checked: isChecked,
652
- onChange: () => {
653
- if (isChecked) {
654
- onChange(selectedValues.filter((v) => v !== option.value));
655
- } else {
656
- onChange([...selectedValues, option.value]);
657
- }
658
- }
374
+ name: field.slug,
375
+ value: option.value,
376
+ ...interactive ? {
377
+ checked: isChecked,
378
+ onChange: () => emit(
379
+ isChecked ? selectedValues.filter((v) => v !== option.value) : [...selectedValues, option.value]
380
+ )
381
+ } : { defaultChecked: isChecked }
659
382
  }
660
383
  ),
661
384
  option.label
662
385
  ] }, option.value);
663
386
  }) }),
664
- field.field_type === "date" && /* @__PURE__ */ jsx(
665
- DatePicker,
387
+ field.field_type === "date" && (interactive && controls?.Date ? /* @__PURE__ */ jsx(
388
+ controls.Date,
666
389
  {
667
390
  id: inputId,
668
391
  name: field.slug,
669
392
  value: String(value || ""),
670
- onChange,
393
+ onChange: emit,
671
394
  required: field.is_required,
672
395
  placeholder: field.placeholder || "Select a date",
673
396
  className: `${classPrefix}__input ${classPrefix}__input--date`
674
397
  }
675
- ),
398
+ ) : (
399
+ // Static: the browser's own date control. Same name and class, so
400
+ // the swap to DatePicker on enhancement is in place.
401
+ /* @__PURE__ */ jsx(
402
+ "input",
403
+ {
404
+ id: inputId,
405
+ className: `${classPrefix}__input ${classPrefix}__input--date`,
406
+ type: "date",
407
+ name: field.slug,
408
+ defaultValue: String(value || "") || void 0,
409
+ required: field.is_required,
410
+ style: baseInputStyle
411
+ }
412
+ )
413
+ )),
676
414
  field.field_type === "time" && /* @__PURE__ */ jsx(
677
415
  "input",
678
416
  {
@@ -680,9 +418,8 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
680
418
  className: `${classPrefix}__input ${classPrefix}__input--time`,
681
419
  type: "time",
682
420
  name: field.slug,
683
- value: String(value || ""),
421
+ ...bind(String(value || "")),
684
422
  required: field.is_required,
685
- onChange: (e) => onChange(e.target.value),
686
423
  style: baseInputStyle
687
424
  }
688
425
  ),
@@ -693,39 +430,74 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
693
430
  className: `${classPrefix}__input ${classPrefix}__input--datetime`,
694
431
  type: "datetime-local",
695
432
  name: field.slug,
696
- value: String(value || ""),
433
+ ...bind(String(value || "")),
697
434
  required: field.is_required,
698
- onChange: (e) => onChange(e.target.value),
699
435
  style: baseInputStyle
700
436
  }
701
437
  ),
702
- field.field_type === "file" && /* @__PURE__ */ jsx(
703
- FileUploadField,
438
+ field.field_type === "file" && (interactive && controls?.File ? /* @__PURE__ */ jsx(
439
+ controls.File,
704
440
  {
705
441
  field,
706
442
  inputId,
707
443
  classPrefix,
708
444
  baseInputStyle,
709
- onChange
445
+ onChange: emit
710
446
  }
711
- ),
712
- field.field_type === "rating" && /* @__PURE__ */ jsx("div", { className: `${classPrefix}__rating`, style: { display: "flex", gap: 4 }, children: [1, 2, 3, 4, 5].map((star) => /* @__PURE__ */ jsx(
713
- "button",
714
- {
715
- type: "button",
716
- onClick: () => onChange(star),
717
- className: `${classPrefix}__rating-star`,
718
- style: {
719
- background: "none",
720
- border: "none",
721
- fontSize: 24,
722
- cursor: "pointer",
723
- color: value >= star ? "var(--sk-rating-active, #fbbf24)" : "var(--sk-rating-inactive, #d1d5db)"
447
+ ) : (
448
+ // Static: a real file input so the field is visible and labelled,
449
+ // but the Sonor upload only happens once enhanced. Forms with a file
450
+ // field are excluded from native POST for exactly this reason
451
+ // (see nativeEligible in native-fallback.tsx).
452
+ /* @__PURE__ */ jsx(
453
+ "input",
454
+ {
455
+ id: inputId,
456
+ className: `${classPrefix}__input ${classPrefix}__input--file`,
457
+ type: "file",
458
+ name: field.slug,
459
+ required: field.is_required,
460
+ style: baseInputStyle
461
+ }
462
+ )
463
+ )),
464
+ field.field_type === "rating" && /* @__PURE__ */ jsxs("div", { className: `${classPrefix}__rating`, style: { display: "flex", gap: 4 }, role: interactive ? void 0 : "radiogroup", "aria-label": interactive ? void 0 : field.label, children: [
465
+ !interactive && [1, 2, 3, 4, 5].map((star) => (
466
+ // Static: a real radio group. Submits natively, and is reachable
467
+ // by keyboard and screen readers without any script.
468
+ /* @__PURE__ */ jsxs("label", { className: `${classPrefix}__rating-star`, style: { fontSize: 24, cursor: "pointer", color: value >= star ? "var(--sk-rating-active, #fbbf24)" : "var(--sk-rating-inactive, #d1d5db)" }, children: [
469
+ /* @__PURE__ */ jsx(
470
+ "input",
471
+ {
472
+ type: "radio",
473
+ name: field.slug,
474
+ value: star,
475
+ defaultChecked: value === star,
476
+ required: field.is_required && star === 1,
477
+ style: { position: "absolute", width: 1, height: 1, opacity: 0 }
478
+ }
479
+ ),
480
+ /* @__PURE__ */ jsx("span", { "aria-label": `${star} star${star > 1 ? "s" : ""}`, children: "\u2605" })
481
+ ] }, `s${star}`)
482
+ )),
483
+ interactive && [1, 2, 3, 4, 5].map((star) => /* @__PURE__ */ jsx(
484
+ "button",
485
+ {
486
+ type: "button",
487
+ onClick: () => emit(star),
488
+ className: `${classPrefix}__rating-star`,
489
+ style: {
490
+ background: "none",
491
+ border: "none",
492
+ fontSize: 24,
493
+ cursor: "pointer",
494
+ color: value >= star ? "var(--sk-rating-active, #fbbf24)" : "var(--sk-rating-inactive, #d1d5db)"
495
+ },
496
+ children: "\u2605"
724
497
  },
725
- children: "\u2605"
726
- },
727
- star
728
- )) }),
498
+ star
499
+ ))
500
+ ] }),
729
501
  field.field_type === "slider" && /* @__PURE__ */ jsxs("div", { className: `${classPrefix}__slider`, children: [
730
502
  /* @__PURE__ */ jsx(
731
503
  "input",
@@ -733,10 +505,9 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
733
505
  id: inputId,
734
506
  type: "range",
735
507
  name: field.slug,
736
- value: Number(value || 50),
508
+ ...interactive ? { value: Number(value || 50), onChange: (e) => emit(Number(e.target.value)) } : { defaultValue: Number(value || 50) },
737
509
  min: field.validation?.min || 0,
738
510
  max: field.validation?.max || 100,
739
- onChange: (e) => onChange(Number(e.target.value)),
740
511
  style: { width: "100%" }
741
512
  }
742
513
  ),
@@ -746,174 +517,7 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
746
517
  field.help_text && !error && field.field_type !== "checkbox" && /* @__PURE__ */ jsx("p", { className: `${classPrefix}__help`, style: helpStyle, children: field.help_text })
747
518
  ] });
748
519
  }
749
- function FileUploadField({
750
- field,
751
- inputId,
752
- classPrefix,
753
- baseInputStyle,
754
- onChange
755
- }) {
756
- const [status, setStatus] = React2.useState("idle");
757
- const [fileName, setFileName] = React2.useState("");
758
- const handleFile = async (e) => {
759
- const file = e.target.files?.[0];
760
- if (!file) return;
761
- setFileName(file.name);
762
- setStatus("uploading");
763
- onChange("");
764
- try {
765
- const url = await uploadFormFile(file);
766
- onChange(url);
767
- setStatus("idle");
768
- } catch (err) {
769
- console.error("[Forms] File upload failed:", err);
770
- onChange("");
771
- setStatus("error");
772
- }
773
- };
774
- return /* @__PURE__ */ jsxs(Fragment, { children: [
775
- /* @__PURE__ */ jsx(
776
- "input",
777
- {
778
- id: inputId,
779
- className: `${classPrefix}__input ${classPrefix}__input--file`,
780
- type: "file",
781
- name: field.slug,
782
- required: field.is_required,
783
- disabled: status === "uploading",
784
- onChange: handleFile,
785
- style: baseInputStyle
786
- }
787
- ),
788
- status === "uploading" && /* @__PURE__ */ jsxs("p", { style: { color: "var(--sk-text-tertiary, #6b7280)", fontSize: 14, marginTop: 4 }, children: [
789
- "Uploading ",
790
- fileName,
791
- "\u2026"
792
- ] }),
793
- status === "error" && /* @__PURE__ */ jsx("p", { role: "alert", style: { color: "var(--sk-error, #dc2626)", fontSize: 14, marginTop: 4 }, children: "Upload failed. Please choose the file again." })
794
- ] });
795
- }
796
- async function uploadFormFile(file) {
797
- const apiUrl = typeof window !== "undefined" ? window.__SITE_KIT_API_URL__ || "https://api.sonor.io" : "https://api.sonor.io";
798
- const apiKey = typeof window !== "undefined" ? window.__SITE_KIT_API_KEY__ : void 0;
799
- if (!apiKey) {
800
- throw new Error("API key is required to upload files.");
801
- }
802
- const body = new FormData();
803
- body.append("file", file);
804
- const response = await sonorFetch(
805
- `${apiUrl}/api/public/forms/upload`,
806
- {
807
- method: "POST",
808
- headers: { Authorization: `Bearer ${apiKey}` },
809
- body
810
- },
811
- { retries: 1, timeoutMs: 6e4 }
812
- );
813
- if (!response.ok) {
814
- throw new Error(`Upload failed (${response.status})`);
815
- }
816
- const data = await response.json().catch(() => null);
817
- if (!data?.url) {
818
- throw new Error("Upload did not return a URL.");
819
- }
820
- return data.url;
821
- }
822
-
823
- // src/forms/experience-plan.ts
824
- var NON_QUESTION_TYPES = ["heading", "section_header", "paragraph", "hidden"];
825
- function stageQuestions(config) {
826
- const input = (config.fields || []).filter(
827
- (f) => !NON_QUESTION_TYPES.includes(f.field_type)
828
- );
829
- if (!config.is_multi_step || !config.steps?.length) {
830
- return input.map((field) => ({ field }));
831
- }
832
- const ordered = [...config.steps].sort((a, b) => a.step_number - b.step_number);
833
- const out = [];
834
- const claimed = /* @__PURE__ */ new Set();
835
- for (const step of ordered) {
836
- for (const field of input) {
837
- if (field.step_id === step.id) {
838
- out.push({ field, step });
839
- claimed.add(field.id);
840
- }
841
- }
842
- }
843
- for (const field of input) {
844
- if (!claimed.has(field.id)) out.push({ field });
845
- }
846
- return out;
847
- }
848
- var WIDTH_FRACTION = {
849
- full: 1,
850
- half: 1 / 2,
851
- third: 1 / 3,
852
- quarter: 1 / 4
853
- };
854
- function stageViews(config) {
855
- const questions = stageQuestions(config);
856
- const views = [];
857
- let open = null;
858
- let openWidth = 0;
859
- const close = () => {
860
- if (open) views.push(open);
861
- open = null;
862
- openWidth = 0;
863
- };
864
- for (const q of questions) {
865
- const fraction = WIDTH_FRACTION[q.field.width] ?? 1;
866
- const chapterChanged = open && open.step?.id !== q.step?.id;
867
- if (fraction >= 1 || chapterChanged) close();
868
- if (!open) {
869
- open = { fields: [q.field], step: q.step };
870
- openWidth = fraction;
871
- if (fraction >= 1) close();
872
- continue;
873
- }
874
- if (openWidth + fraction > 1.0001) close();
875
- if (!open) {
876
- open = { fields: [q.field], step: q.step };
877
- openWidth = fraction;
878
- continue;
879
- }
880
- open.fields.push(q.field);
881
- openWidth += fraction;
882
- }
883
- close();
884
- return views;
885
- }
886
- function countStageViews(config) {
887
- return stageViews(config).length;
888
- }
889
- function countStageQuestions(config) {
890
- return stageQuestions(config).length;
891
- }
892
- function stageEstimate(questionCount) {
893
- const seconds = questionCount * 8;
894
- if (seconds < 50) return `about ${Math.max(15, Math.ceil(seconds / 5) * 5)} seconds`;
895
- if (seconds <= 90) return "about a minute";
896
- return `about ${Math.round(seconds / 60)} minutes`;
897
- }
898
- function stageFirstName(value) {
899
- if (typeof value !== "string") return null;
900
- const token = value.trim().split(/\s+/)[0];
901
- if (!token || token.length > 24) return null;
902
- return token;
903
- }
904
- function isEmptyValue(value) {
905
- if (value === void 0 || value === null || value === "") return true;
906
- if (Array.isArray(value)) return value.length === 0;
907
- return false;
908
- }
909
- function formatAnswer(value) {
910
- if (isEmptyValue(value)) return null;
911
- if (Array.isArray(value)) return value.map(String).join(", ");
912
- if (typeof value === "boolean") return value ? "Yes" : "No";
913
- return String(value);
914
- }
915
- var AUTO_ADVANCE_TYPES = ["radio", "select", "rating"];
916
520
 
917
- export { AUTO_ADVANCE_TYPES, DatePicker, DelightStyles, FormField, FormMomentum, countStageQuestions, countStageViews, formatAnswer, isEmptyValue, stageEstimate, stageFirstName, stageViews };
918
- //# sourceMappingURL=chunk-LYDTOFXJ.mjs.map
919
- //# sourceMappingURL=chunk-LYDTOFXJ.mjs.map
521
+ export { DelightStyles, FormField, FormMomentum };
522
+ //# sourceMappingURL=chunk-LB7LHVWI.mjs.map
523
+ //# sourceMappingURL=chunk-LB7LHVWI.mjs.map