@ai-matrx/records-ui 0.116.57 → 0.116.58

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.
package/dist/index.js CHANGED
@@ -32051,6 +32051,24 @@ function FormRunner(props) {
32051
32051
  }
32052
32052
  return /* @__PURE__ */ jsx105(ConnectedFormRunner, { ...props });
32053
32053
  }
32054
+ var SEND_CEILING_MS = 6e4;
32055
+ async function sendWithin(send, values, ceilingMs) {
32056
+ const notLanded = (why) => ({
32057
+ ok: false,
32058
+ message: `This answer did not land: ${why} Your answers are still here; pressing send again is safe.`
32059
+ });
32060
+ let timer;
32061
+ const ceiling = new Promise((resolve) => {
32062
+ timer = setTimeout(() => resolve(notLanded("it took too long to get an answer.")), ceilingMs);
32063
+ });
32064
+ try {
32065
+ return await Promise.race([send(values), ceiling]);
32066
+ } catch {
32067
+ return notLanded("the send failed before it was answered.");
32068
+ } finally {
32069
+ if (timer) clearTimeout(timer);
32070
+ }
32071
+ }
32054
32072
  function ConnectedFormRunner(props) {
32055
32073
  const client = useOptionalRecordsClient9();
32056
32074
  const fields = useFields24(props.form.subject);
@@ -32278,7 +32296,7 @@ function FormStage({
32278
32296
  live.map((q) => [q.key, answers[q.key] ?? null])
32279
32297
  );
32280
32298
  if (honeypotKey) values[honeypotKey] = decoy.current;
32281
- const outcome = await onSubmit(values);
32299
+ const outcome = await sendWithin(onSubmit, values, SEND_CEILING_MS);
32282
32300
  setWriting(false);
32283
32301
  if (!outcome.ok) {
32284
32302
  const inWords = (text) => questions.reduce(