@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,288 +1,8 @@
1
- 'use client';
2
1
  'use strict';
3
2
 
4
- var chunkEDFZ6EMM_js = require('./chunk-EDFZ6EMM.js');
5
- var React2 = require('react');
6
3
  var jsxRuntime = require('react/jsx-runtime');
7
4
 
8
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
-
10
- var React2__default = /*#__PURE__*/_interopDefault(React2);
11
-
12
- var DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
13
- var MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
14
- function pad(n) {
15
- return n < 10 ? `0${n}` : `${n}`;
16
- }
17
- function toDateStr(y, m, d) {
18
- return `${y}-${pad(m + 1)}-${pad(d)}`;
19
- }
20
- function parseDate(str) {
21
- if (!str) return null;
22
- const [y, m, d] = str.split("-").map(Number);
23
- if (!y || !m || !d) return null;
24
- return { year: y, month: m - 1, day: d };
25
- }
26
- function getDaysInMonth(year, month) {
27
- return new Date(year, month + 1, 0).getDate();
28
- }
29
- function getFirstDayOfMonth(year, month) {
30
- return new Date(year, month, 1).getDay();
31
- }
32
- function formatDisplay(dateStr) {
33
- const parsed = parseDate(dateStr);
34
- if (!parsed) return "";
35
- return `${MONTHS[parsed.month]} ${parsed.day}, ${parsed.year}`;
36
- }
37
- function DatePicker({
38
- value,
39
- onChange,
40
- id,
41
- name,
42
- required,
43
- minDate,
44
- placeholder = "Select a date",
45
- className = "",
46
- style
47
- }) {
48
- const today = /* @__PURE__ */ new Date();
49
- const todayStr = toDateStr(today.getFullYear(), today.getMonth(), today.getDate());
50
- const effectiveMin = minDate || "";
51
- const parsed = parseDate(value);
52
- const [viewYear, setViewYear] = React2.useState(parsed?.year || today.getFullYear());
53
- const [viewMonth, setViewMonth] = React2.useState(parsed?.month ?? today.getMonth());
54
- const [open, setOpen] = React2.useState(false);
55
- const [closing, setClosing] = React2.useState(false);
56
- const closeTimer = React2.useRef(null);
57
- const containerRef = React2.useRef(null);
58
- const closeAnimated = React2.useCallback(() => {
59
- if (closeTimer.current !== null) return;
60
- setClosing(true);
61
- closeTimer.current = window.setTimeout(() => {
62
- closeTimer.current = null;
63
- setClosing(false);
64
- setOpen(false);
65
- }, 180);
66
- }, []);
67
- React2.useEffect(
68
- () => () => {
69
- if (closeTimer.current !== null) window.clearTimeout(closeTimer.current);
70
- },
71
- []
72
- );
73
- React2.useEffect(() => {
74
- if (!open) return;
75
- const handler = (e) => {
76
- if (containerRef.current && !containerRef.current.contains(e.target)) {
77
- closeAnimated();
78
- }
79
- };
80
- document.addEventListener("mousedown", handler);
81
- return () => document.removeEventListener("mousedown", handler);
82
- }, [open, closeAnimated]);
83
- React2.useEffect(() => {
84
- if (!open) return;
85
- const handler = (e) => {
86
- if (e.key === "Escape") closeAnimated();
87
- };
88
- window.addEventListener("keydown", handler);
89
- return () => window.removeEventListener("keydown", handler);
90
- }, [open, closeAnimated]);
91
- const prevMonth = React2.useCallback(() => {
92
- if (viewMonth === 0) {
93
- setViewMonth(11);
94
- setViewYear((y) => y - 1);
95
- } else setViewMonth((m) => m - 1);
96
- }, [viewMonth]);
97
- const nextMonth = React2.useCallback(() => {
98
- if (viewMonth === 11) {
99
- setViewMonth(0);
100
- setViewYear((y) => y + 1);
101
- } else setViewMonth((m) => m + 1);
102
- }, [viewMonth]);
103
- const selectDay = React2.useCallback((day) => {
104
- const dateStr = toDateStr(viewYear, viewMonth, day);
105
- onChange(dateStr);
106
- closeAnimated();
107
- }, [viewYear, viewMonth, onChange, closeAnimated]);
108
- const isDisabled = React2.useCallback((day) => {
109
- const dateStr = toDateStr(viewYear, viewMonth, day);
110
- return dateStr < effectiveMin;
111
- }, [viewYear, viewMonth, effectiveMin]);
112
- const isSelected = React2.useCallback((day) => {
113
- if (!value) return false;
114
- return toDateStr(viewYear, viewMonth, day) === value;
115
- }, [viewYear, viewMonth, value]);
116
- const isToday = React2.useCallback((day) => {
117
- return toDateStr(viewYear, viewMonth, day) === todayStr;
118
- }, [viewYear, viewMonth, todayStr]);
119
- const daysInMonth = getDaysInMonth(viewYear, viewMonth);
120
- const firstDay = getFirstDayOfMonth(viewYear, viewMonth);
121
- const weeks = [];
122
- let week = Array(firstDay).fill(null);
123
- for (let d = 1; d <= daysInMonth; d++) {
124
- week.push(d);
125
- if (week.length === 7) {
126
- weeks.push(week);
127
- week = [];
128
- }
129
- }
130
- if (week.length > 0) {
131
- while (week.length < 7) week.push(null);
132
- weeks.push(week);
133
- }
134
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: `sk-datepicker ${className}`, style: { position: "relative", ...style }, children: [
135
- /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: value || "" }),
136
- /* @__PURE__ */ jsxRuntime.jsxs(
137
- "button",
138
- {
139
- type: "button",
140
- id,
141
- onClick: () => open ? closeAnimated() : setOpen(true),
142
- "aria-required": required,
143
- "aria-expanded": open,
144
- style: {
145
- display: "flex",
146
- alignItems: "center",
147
- justifyContent: "space-between",
148
- width: "100%",
149
- padding: "var(--sk-input-padding, 10px 12px)",
150
- backgroundColor: "var(--sk-input-bg, #fff)",
151
- border: `1px solid ${open ? "var(--sk-input-border-focus, #2563eb)" : "var(--sk-input-border, #d1d5db)"}`,
152
- borderRadius: "var(--sk-input-radius, 0.375rem)",
153
- fontSize: "var(--sk-font-size, 14px)",
154
- color: value ? "var(--sk-form-success-text, #111)" : "var(--sk-text-tertiary, #9ca3af)",
155
- cursor: "pointer",
156
- outline: "none",
157
- textAlign: "left"
158
- },
159
- children: [
160
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: value ? "sk-datepicker__value--stamp" : void 0, children: value ? formatDisplay(value) : placeholder }, value || "empty"),
161
- /* @__PURE__ */ jsxRuntime.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: [
162
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2", ry: "2" }),
163
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "2", x2: "16", y2: "6" }),
164
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "8", y1: "2", x2: "8", y2: "6" }),
165
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "3", y1: "10", x2: "21", y2: "10" })
166
- ] })
167
- ]
168
- }
169
- ),
170
- open && /* @__PURE__ */ jsxRuntime.jsxs(
171
- "div",
172
- {
173
- className: "sk-datepicker__pop",
174
- "data-sk-closing": closing ? "true" : void 0,
175
- style: {
176
- position: "absolute",
177
- top: "100%",
178
- left: 0,
179
- right: 0,
180
- marginTop: "4px",
181
- backgroundColor: "var(--sk-input-bg, #fff)",
182
- border: "1px solid var(--sk-input-border, #d1d5db)",
183
- borderRadius: "var(--sk-input-radius, 0.375rem)",
184
- boxShadow: "0 10px 25px rgba(0,0,0,0.3)",
185
- zIndex: 50,
186
- padding: "12px",
187
- minWidth: "280px"
188
- },
189
- children: [
190
- /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: "12px" }, children: [
191
- /* @__PURE__ */ jsxRuntime.jsx(
192
- "button",
193
- {
194
- type: "button",
195
- onClick: prevMonth,
196
- style: { background: "none", border: "none", cursor: "pointer", padding: "4px 8px", color: "var(--sk-label-color, #6b7280)", fontSize: "18px", lineHeight: 1 },
197
- "aria-label": "Previous month",
198
- children: "\u2039"
199
- }
200
- ),
201
- /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { fontWeight: 600, fontSize: "14px", color: "var(--sk-form-success-text, #111)" }, children: [
202
- MONTHS[viewMonth],
203
- " ",
204
- viewYear
205
- ] }),
206
- /* @__PURE__ */ jsxRuntime.jsx(
207
- "button",
208
- {
209
- type: "button",
210
- onClick: nextMonth,
211
- style: { background: "none", border: "none", cursor: "pointer", padding: "4px 8px", color: "var(--sk-label-color, #6b7280)", fontSize: "18px", lineHeight: 1 },
212
- "aria-label": "Next month",
213
- children: "\u203A"
214
- }
215
- )
216
- ] }),
217
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: "2px", marginBottom: "4px" }, children: DAYS.map((d) => /* @__PURE__ */ jsxRuntime.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)) }),
218
- weeks.map((week2, wi) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: "2px" }, children: week2.map((day, di) => {
219
- if (day === null) {
220
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "6px" } }, di);
221
- }
222
- const disabled = isDisabled(day);
223
- const selected = isSelected(day);
224
- const todayMark = isToday(day);
225
- return /* @__PURE__ */ jsxRuntime.jsx(
226
- "button",
227
- {
228
- type: "button",
229
- disabled,
230
- onClick: () => selectDay(day),
231
- style: {
232
- padding: "6px",
233
- textAlign: "center",
234
- fontSize: "13px",
235
- fontWeight: selected ? 700 : todayMark ? 600 : 400,
236
- borderRadius: "6px",
237
- border: todayMark && !selected ? "1px solid var(--sk-primary, #2563eb)" : "1px solid transparent",
238
- background: selected ? "var(--sk-primary, #2563eb)" : "transparent",
239
- color: disabled ? "var(--sk-text-tertiary, #9ca3af)" : selected ? "#fff" : "var(--sk-form-success-text, #111)",
240
- cursor: disabled ? "not-allowed" : "pointer",
241
- opacity: disabled ? 0.4 : 1,
242
- transition: "background 0.15s, color 0.15s"
243
- },
244
- onMouseEnter: (e) => {
245
- if (!disabled && !selected) {
246
- e.target.style.background = "var(--sk-input-border, #e5e7eb)";
247
- }
248
- },
249
- onMouseLeave: (e) => {
250
- if (!disabled && !selected) {
251
- e.target.style.background = "transparent";
252
- }
253
- },
254
- "aria-label": `${MONTHS[viewMonth]} ${day}, ${viewYear}`,
255
- "aria-selected": selected,
256
- children: day
257
- },
258
- di
259
- );
260
- }) }, wi)),
261
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginTop: "8px", textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(
262
- "button",
263
- {
264
- type: "button",
265
- onClick: () => {
266
- onChange(todayStr);
267
- setOpen(false);
268
- },
269
- style: {
270
- background: "none",
271
- border: "none",
272
- cursor: "pointer",
273
- fontSize: "12px",
274
- fontWeight: 600,
275
- color: "var(--sk-primary, #2563eb)",
276
- padding: "4px 8px"
277
- },
278
- children: "Today"
279
- }
280
- ) })
281
- ]
282
- }
283
- )
284
- ] });
285
- }
5
+ // src/forms/delight.tsx
286
6
  var STYLE_ID = "sk-delight-css";
287
7
  var CSS = `
288
8
  /* Every frame must carry the centering translateY: the animation fills both
@@ -508,7 +228,10 @@ function normalizeOptions(options) {
508
228
  }
509
229
  return [];
510
230
  }
511
- function FormField({ field, value, error, onChange, classPrefix = "sk-form", showValid }) {
231
+ function FormField({ field, value, error, onChange, classPrefix = "sk-form", showValid, controls }) {
232
+ const interactive = typeof onChange === "function";
233
+ const emit = (v) => onChange?.(v);
234
+ const bind = (v) => interactive ? { value: v, onChange: (e) => emit(e.target.value) } : { defaultValue: v || void 0 };
512
235
  const inputId = `sk-${field.id || field.slug}`;
513
236
  const options = normalizeOptions(field.options);
514
237
  const baseInputStyle = {
@@ -548,7 +271,7 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
548
271
  return /* @__PURE__ */ jsxRuntime.jsx("p", { className: `${classPrefix}__paragraph`, style: { color: "var(--sk-text-tertiary, #6b7280)", margin: "8px 0" }, children: field.help_text || field.label });
549
272
  }
550
273
  if (field.field_type === "hidden") {
551
- return /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: field.slug, value: String(value || "") });
274
+ return interactive ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: field.slug, value: String(value || ""), readOnly: true }) : /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name: field.slug, defaultValue: String(value || "") });
552
275
  }
553
276
  const hideLabel = !!field.hide_label;
554
277
  const effectivePlaceholder = hideLabel ? field.label : field.placeholder;
@@ -565,10 +288,9 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
565
288
  className: `${classPrefix}__input`,
566
289
  type: field.field_type === "phone" || field.field_type === "tel" ? "tel" : field.field_type,
567
290
  name: field.slug,
568
- value: String(value || ""),
291
+ ...bind(String(value || "")),
569
292
  placeholder: effectivePlaceholder,
570
293
  required: field.is_required,
571
- onChange: (e) => onChange(e.target.value),
572
294
  style: baseInputStyle
573
295
  }
574
296
  ),
@@ -580,11 +302,10 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
580
302
  id: inputId,
581
303
  className: `${classPrefix}__textarea`,
582
304
  name: field.slug,
583
- value: String(value || ""),
305
+ ...bind(String(value || "")),
584
306
  placeholder: effectivePlaceholder,
585
307
  required: field.is_required,
586
308
  rows: 4,
587
- onChange: (e) => onChange(e.target.value),
588
309
  style: { ...baseInputStyle, resize: "vertical" }
589
310
  }
590
311
  ),
@@ -594,9 +315,8 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
594
315
  id: inputId,
595
316
  className: `${classPrefix}__select`,
596
317
  name: field.slug,
597
- value: String(value || ""),
318
+ ...bind(String(value || "")),
598
319
  required: field.is_required,
599
- onChange: (e) => onChange(e.target.value),
600
320
  style: baseInputStyle,
601
321
  children: [
602
322
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: effectivePlaceholder || "Select an option" }),
@@ -610,13 +330,12 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
610
330
  id: inputId,
611
331
  className: `${classPrefix}__select ${classPrefix}__select--multi`,
612
332
  name: field.slug,
613
- value: Array.isArray(value) ? value : [],
333
+ ...interactive ? {
334
+ value: Array.isArray(value) ? value : [],
335
+ onChange: (e) => emit(Array.from(e.target.selectedOptions, (opt) => opt.value))
336
+ } : { defaultValue: Array.isArray(value) ? value : [] },
614
337
  required: field.is_required,
615
338
  multiple: true,
616
- onChange: (e) => {
617
- const selected = Array.from(e.target.selectedOptions, (opt) => opt.value);
618
- onChange(selected);
619
- },
620
339
  style: { ...baseInputStyle, height: 120 },
621
340
  children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value))
622
341
  }
@@ -628,8 +347,8 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
628
347
  type: "radio",
629
348
  name: field.slug,
630
349
  value: option.value,
631
- checked: value === option.value,
632
- onChange: () => onChange(option.value)
350
+ ...interactive ? { checked: value === option.value, onChange: () => emit(option.value) } : { defaultChecked: value === option.value },
351
+ required: field.is_required
633
352
  }
634
353
  ),
635
354
  option.label
@@ -640,8 +359,8 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
640
359
  {
641
360
  type: "checkbox",
642
361
  name: field.slug,
643
- checked: !!value,
644
- onChange: (e) => onChange(e.target.checked)
362
+ ...interactive ? { checked: !!value, onChange: (e) => emit(e.target.checked) } : { defaultChecked: !!value },
363
+ required: field.is_required
645
364
  }
646
365
  ),
647
366
  field.help_text || field.label
@@ -654,31 +373,46 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
654
373
  "input",
655
374
  {
656
375
  type: "checkbox",
657
- checked: isChecked,
658
- onChange: () => {
659
- if (isChecked) {
660
- onChange(selectedValues.filter((v) => v !== option.value));
661
- } else {
662
- onChange([...selectedValues, option.value]);
663
- }
664
- }
376
+ name: field.slug,
377
+ value: option.value,
378
+ ...interactive ? {
379
+ checked: isChecked,
380
+ onChange: () => emit(
381
+ isChecked ? selectedValues.filter((v) => v !== option.value) : [...selectedValues, option.value]
382
+ )
383
+ } : { defaultChecked: isChecked }
665
384
  }
666
385
  ),
667
386
  option.label
668
387
  ] }, option.value);
669
388
  }) }),
670
- field.field_type === "date" && /* @__PURE__ */ jsxRuntime.jsx(
671
- DatePicker,
389
+ field.field_type === "date" && (interactive && controls?.Date ? /* @__PURE__ */ jsxRuntime.jsx(
390
+ controls.Date,
672
391
  {
673
392
  id: inputId,
674
393
  name: field.slug,
675
394
  value: String(value || ""),
676
- onChange,
395
+ onChange: emit,
677
396
  required: field.is_required,
678
397
  placeholder: field.placeholder || "Select a date",
679
398
  className: `${classPrefix}__input ${classPrefix}__input--date`
680
399
  }
681
- ),
400
+ ) : (
401
+ // Static: the browser's own date control. Same name and class, so
402
+ // the swap to DatePicker on enhancement is in place.
403
+ /* @__PURE__ */ jsxRuntime.jsx(
404
+ "input",
405
+ {
406
+ id: inputId,
407
+ className: `${classPrefix}__input ${classPrefix}__input--date`,
408
+ type: "date",
409
+ name: field.slug,
410
+ defaultValue: String(value || "") || void 0,
411
+ required: field.is_required,
412
+ style: baseInputStyle
413
+ }
414
+ )
415
+ )),
682
416
  field.field_type === "time" && /* @__PURE__ */ jsxRuntime.jsx(
683
417
  "input",
684
418
  {
@@ -686,9 +420,8 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
686
420
  className: `${classPrefix}__input ${classPrefix}__input--time`,
687
421
  type: "time",
688
422
  name: field.slug,
689
- value: String(value || ""),
423
+ ...bind(String(value || "")),
690
424
  required: field.is_required,
691
- onChange: (e) => onChange(e.target.value),
692
425
  style: baseInputStyle
693
426
  }
694
427
  ),
@@ -699,39 +432,74 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
699
432
  className: `${classPrefix}__input ${classPrefix}__input--datetime`,
700
433
  type: "datetime-local",
701
434
  name: field.slug,
702
- value: String(value || ""),
435
+ ...bind(String(value || "")),
703
436
  required: field.is_required,
704
- onChange: (e) => onChange(e.target.value),
705
437
  style: baseInputStyle
706
438
  }
707
439
  ),
708
- field.field_type === "file" && /* @__PURE__ */ jsxRuntime.jsx(
709
- FileUploadField,
440
+ field.field_type === "file" && (interactive && controls?.File ? /* @__PURE__ */ jsxRuntime.jsx(
441
+ controls.File,
710
442
  {
711
443
  field,
712
444
  inputId,
713
445
  classPrefix,
714
446
  baseInputStyle,
715
- onChange
447
+ onChange: emit
716
448
  }
717
- ),
718
- field.field_type === "rating" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${classPrefix}__rating`, style: { display: "flex", gap: 4 }, children: [1, 2, 3, 4, 5].map((star) => /* @__PURE__ */ jsxRuntime.jsx(
719
- "button",
720
- {
721
- type: "button",
722
- onClick: () => onChange(star),
723
- className: `${classPrefix}__rating-star`,
724
- style: {
725
- background: "none",
726
- border: "none",
727
- fontSize: 24,
728
- cursor: "pointer",
729
- color: value >= star ? "var(--sk-rating-active, #fbbf24)" : "var(--sk-rating-inactive, #d1d5db)"
449
+ ) : (
450
+ // Static: a real file input so the field is visible and labelled,
451
+ // but the Sonor upload only happens once enhanced. Forms with a file
452
+ // field are excluded from native POST for exactly this reason
453
+ // (see nativeEligible in native-fallback.tsx).
454
+ /* @__PURE__ */ jsxRuntime.jsx(
455
+ "input",
456
+ {
457
+ id: inputId,
458
+ className: `${classPrefix}__input ${classPrefix}__input--file`,
459
+ type: "file",
460
+ name: field.slug,
461
+ required: field.is_required,
462
+ style: baseInputStyle
463
+ }
464
+ )
465
+ )),
466
+ field.field_type === "rating" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classPrefix}__rating`, style: { display: "flex", gap: 4 }, role: interactive ? void 0 : "radiogroup", "aria-label": interactive ? void 0 : field.label, children: [
467
+ !interactive && [1, 2, 3, 4, 5].map((star) => (
468
+ // Static: a real radio group. Submits natively, and is reachable
469
+ // by keyboard and screen readers without any script.
470
+ /* @__PURE__ */ jsxRuntime.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: [
471
+ /* @__PURE__ */ jsxRuntime.jsx(
472
+ "input",
473
+ {
474
+ type: "radio",
475
+ name: field.slug,
476
+ value: star,
477
+ defaultChecked: value === star,
478
+ required: field.is_required && star === 1,
479
+ style: { position: "absolute", width: 1, height: 1, opacity: 0 }
480
+ }
481
+ ),
482
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-label": `${star} star${star > 1 ? "s" : ""}`, children: "\u2605" })
483
+ ] }, `s${star}`)
484
+ )),
485
+ interactive && [1, 2, 3, 4, 5].map((star) => /* @__PURE__ */ jsxRuntime.jsx(
486
+ "button",
487
+ {
488
+ type: "button",
489
+ onClick: () => emit(star),
490
+ className: `${classPrefix}__rating-star`,
491
+ style: {
492
+ background: "none",
493
+ border: "none",
494
+ fontSize: 24,
495
+ cursor: "pointer",
496
+ color: value >= star ? "var(--sk-rating-active, #fbbf24)" : "var(--sk-rating-inactive, #d1d5db)"
497
+ },
498
+ children: "\u2605"
730
499
  },
731
- children: "\u2605"
732
- },
733
- star
734
- )) }),
500
+ star
501
+ ))
502
+ ] }),
735
503
  field.field_type === "slider" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${classPrefix}__slider`, children: [
736
504
  /* @__PURE__ */ jsxRuntime.jsx(
737
505
  "input",
@@ -739,10 +507,9 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
739
507
  id: inputId,
740
508
  type: "range",
741
509
  name: field.slug,
742
- value: Number(value || 50),
510
+ ...interactive ? { value: Number(value || 50), onChange: (e) => emit(Number(e.target.value)) } : { defaultValue: Number(value || 50) },
743
511
  min: field.validation?.min || 0,
744
512
  max: field.validation?.max || 100,
745
- onChange: (e) => onChange(Number(e.target.value)),
746
513
  style: { width: "100%" }
747
514
  }
748
515
  ),
@@ -752,185 +519,9 @@ function FormField({ field, value, error, onChange, classPrefix = "sk-form", sho
752
519
  field.help_text && !error && field.field_type !== "checkbox" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: `${classPrefix}__help`, style: helpStyle, children: field.help_text })
753
520
  ] });
754
521
  }
755
- function FileUploadField({
756
- field,
757
- inputId,
758
- classPrefix,
759
- baseInputStyle,
760
- onChange
761
- }) {
762
- const [status, setStatus] = React2__default.default.useState("idle");
763
- const [fileName, setFileName] = React2__default.default.useState("");
764
- const handleFile = async (e) => {
765
- const file = e.target.files?.[0];
766
- if (!file) return;
767
- setFileName(file.name);
768
- setStatus("uploading");
769
- onChange("");
770
- try {
771
- const url = await uploadFormFile(file);
772
- onChange(url);
773
- setStatus("idle");
774
- } catch (err) {
775
- console.error("[Forms] File upload failed:", err);
776
- onChange("");
777
- setStatus("error");
778
- }
779
- };
780
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
781
- /* @__PURE__ */ jsxRuntime.jsx(
782
- "input",
783
- {
784
- id: inputId,
785
- className: `${classPrefix}__input ${classPrefix}__input--file`,
786
- type: "file",
787
- name: field.slug,
788
- required: field.is_required,
789
- disabled: status === "uploading",
790
- onChange: handleFile,
791
- style: baseInputStyle
792
- }
793
- ),
794
- status === "uploading" && /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { color: "var(--sk-text-tertiary, #6b7280)", fontSize: 14, marginTop: 4 }, children: [
795
- "Uploading ",
796
- fileName,
797
- "\u2026"
798
- ] }),
799
- status === "error" && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "alert", style: { color: "var(--sk-error, #dc2626)", fontSize: 14, marginTop: 4 }, children: "Upload failed. Please choose the file again." })
800
- ] });
801
- }
802
- async function uploadFormFile(file) {
803
- const apiUrl = typeof window !== "undefined" ? window.__SITE_KIT_API_URL__ || "https://api.sonor.io" : "https://api.sonor.io";
804
- const apiKey = typeof window !== "undefined" ? window.__SITE_KIT_API_KEY__ : void 0;
805
- if (!apiKey) {
806
- throw new Error("API key is required to upload files.");
807
- }
808
- const body = new FormData();
809
- body.append("file", file);
810
- const response = await chunkEDFZ6EMM_js.sonorFetch(
811
- `${apiUrl}/api/public/forms/upload`,
812
- {
813
- method: "POST",
814
- headers: { Authorization: `Bearer ${apiKey}` },
815
- body
816
- },
817
- { retries: 1, timeoutMs: 6e4 }
818
- );
819
- if (!response.ok) {
820
- throw new Error(`Upload failed (${response.status})`);
821
- }
822
- const data = await response.json().catch(() => null);
823
- if (!data?.url) {
824
- throw new Error("Upload did not return a URL.");
825
- }
826
- return data.url;
827
- }
828
-
829
- // src/forms/experience-plan.ts
830
- var NON_QUESTION_TYPES = ["heading", "section_header", "paragraph", "hidden"];
831
- function stageQuestions(config) {
832
- const input = (config.fields || []).filter(
833
- (f) => !NON_QUESTION_TYPES.includes(f.field_type)
834
- );
835
- if (!config.is_multi_step || !config.steps?.length) {
836
- return input.map((field) => ({ field }));
837
- }
838
- const ordered = [...config.steps].sort((a, b) => a.step_number - b.step_number);
839
- const out = [];
840
- const claimed = /* @__PURE__ */ new Set();
841
- for (const step of ordered) {
842
- for (const field of input) {
843
- if (field.step_id === step.id) {
844
- out.push({ field, step });
845
- claimed.add(field.id);
846
- }
847
- }
848
- }
849
- for (const field of input) {
850
- if (!claimed.has(field.id)) out.push({ field });
851
- }
852
- return out;
853
- }
854
- var WIDTH_FRACTION = {
855
- full: 1,
856
- half: 1 / 2,
857
- third: 1 / 3,
858
- quarter: 1 / 4
859
- };
860
- function stageViews(config) {
861
- const questions = stageQuestions(config);
862
- const views = [];
863
- let open = null;
864
- let openWidth = 0;
865
- const close = () => {
866
- if (open) views.push(open);
867
- open = null;
868
- openWidth = 0;
869
- };
870
- for (const q of questions) {
871
- const fraction = WIDTH_FRACTION[q.field.width] ?? 1;
872
- const chapterChanged = open && open.step?.id !== q.step?.id;
873
- if (fraction >= 1 || chapterChanged) close();
874
- if (!open) {
875
- open = { fields: [q.field], step: q.step };
876
- openWidth = fraction;
877
- if (fraction >= 1) close();
878
- continue;
879
- }
880
- if (openWidth + fraction > 1.0001) close();
881
- if (!open) {
882
- open = { fields: [q.field], step: q.step };
883
- openWidth = fraction;
884
- continue;
885
- }
886
- open.fields.push(q.field);
887
- openWidth += fraction;
888
- }
889
- close();
890
- return views;
891
- }
892
- function countStageViews(config) {
893
- return stageViews(config).length;
894
- }
895
- function countStageQuestions(config) {
896
- return stageQuestions(config).length;
897
- }
898
- function stageEstimate(questionCount) {
899
- const seconds = questionCount * 8;
900
- if (seconds < 50) return `about ${Math.max(15, Math.ceil(seconds / 5) * 5)} seconds`;
901
- if (seconds <= 90) return "about a minute";
902
- return `about ${Math.round(seconds / 60)} minutes`;
903
- }
904
- function stageFirstName(value) {
905
- if (typeof value !== "string") return null;
906
- const token = value.trim().split(/\s+/)[0];
907
- if (!token || token.length > 24) return null;
908
- return token;
909
- }
910
- function isEmptyValue(value) {
911
- if (value === void 0 || value === null || value === "") return true;
912
- if (Array.isArray(value)) return value.length === 0;
913
- return false;
914
- }
915
- function formatAnswer(value) {
916
- if (isEmptyValue(value)) return null;
917
- if (Array.isArray(value)) return value.map(String).join(", ");
918
- if (typeof value === "boolean") return value ? "Yes" : "No";
919
- return String(value);
920
- }
921
- var AUTO_ADVANCE_TYPES = ["radio", "select", "rating"];
922
522
 
923
- exports.AUTO_ADVANCE_TYPES = AUTO_ADVANCE_TYPES;
924
- exports.DatePicker = DatePicker;
925
523
  exports.DelightStyles = DelightStyles;
926
524
  exports.FormField = FormField;
927
525
  exports.FormMomentum = FormMomentum;
928
- exports.countStageQuestions = countStageQuestions;
929
- exports.countStageViews = countStageViews;
930
- exports.formatAnswer = formatAnswer;
931
- exports.isEmptyValue = isEmptyValue;
932
- exports.stageEstimate = stageEstimate;
933
- exports.stageFirstName = stageFirstName;
934
- exports.stageViews = stageViews;
935
- //# sourceMappingURL=chunk-ZGQUIL7L.js.map
936
- //# sourceMappingURL=chunk-ZGQUIL7L.js.map
526
+ //# sourceMappingURL=chunk-2ACKOMAL.js.map
527
+ //# sourceMappingURL=chunk-2ACKOMAL.js.map