@sharadox/form-web-library 0.7.0 → 0.7.1-bot-field-rerender.22

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.
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useEffect, useRef } from "react";
3
+ import { useEffect, useState } from "react";
4
4
  /** Out of sight but still in the form, so robots that fill every field give themselves away. */
5
5
  const HIDDEN = { position: "absolute", left: "-9999px", width: 1, height: 1, overflow: "hidden" };
6
6
  /**
@@ -12,10 +12,10 @@ const HIDDEN = { position: "absolute", left: "-9999px", width: 1, height: 1, ove
12
12
  * <form action={send}><BotFields />…</form>
13
13
  */
14
14
  export function BotFields({ honeypotField = "website", startedAtField = "started-at", honeypotLabel = "Website", }) {
15
- const startedAt = useRef(null);
16
- useEffect(() => {
17
- startedAt.current.value = String(Date.now());
18
- }, []);
19
- return (_jsxs(_Fragment, { children: [_jsx("input", { ref: startedAt, type: "hidden", name: startedAtField, defaultValue: "0" }), _jsx("div", { style: HIDDEN, "aria-hidden": true, children: _jsxs("label", { children: [honeypotLabel, _jsx("input", { name: honeypotField, tabIndex: -1, autoComplete: "off" })] }) })] }));
15
+ // Held in state, not written into the field: React puts a hidden field back to its default whenever the form renders
16
+ // again, which would silently turn the fill-time check off.
17
+ const [startedAt, setStartedAt] = useState(0);
18
+ useEffect(() => setStartedAt(Date.now()), []);
19
+ return (_jsxs(_Fragment, { children: [_jsx("input", { type: "hidden", name: startedAtField, value: startedAt, readOnly: true }), _jsx("div", { style: HIDDEN, "aria-hidden": true, children: _jsxs("label", { children: [honeypotLabel, _jsx("input", { name: honeypotField, tabIndex: -1, autoComplete: "off" })] }) })] }));
20
20
  }
21
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/bot-field/index.tsx"],"names":[],"mappings":"AAAA,YAA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;;GAOG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,aAAa,GAAG,SAAS,EACzB,cAAc,GAAG,YAAY,EAC7B,aAAa,GAAG,SAAS,GACL;IACpB,qHAAqH;IACrH,4DAA4D;IAC5D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,OAAO,CACL,8BACE,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,SAAG,EACxE,cAAK,KAAK,EAAE,MAAM,iCAChB,4BACG,aAAa,EACd,gBAAO,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,YAAY,EAAC,KAAK,GAAG,IACzD,GACJ,IACL,CACJ,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/form-web-library",
3
- "version": "0.7.0",
3
+ "version": "0.7.1-bot-field-rerender.22",
4
4
  "description": "Forms: a phone field with every country's flag and calling code, and on the server field reading, honeypot and fill-time bot checks, rate limiting and a contact form action that emails messages with the visitor as reply-to.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENCA.md",