@kentcdodds/tmp-remix-utils
Version:
This package contains simple utility functions to use with [Remix.run](https://remix.run).
51 lines (50 loc) • 1.43 kB
JavaScript
/* eslint-disable jsx-a11y/autocomplete-valid */
import * as React from "react";
const HoneypotContext = React.createContext({});
export function HoneypotInputs({ label = "Please leave this field blank" }) {
let context = React.useContext(HoneypotContext);
let {
nameFieldName = "name__confirm",
validFromFieldName = "from__confirm",
encryptedValidFrom,
} = context;
return React.createElement(
"div",
{
id: `${nameFieldName}_wrap`,
style: { display: "none" },
"aria-hidden": "true",
},
React.createElement("label", { htmlFor: nameFieldName }, label),
React.createElement("input", {
id: nameFieldName,
name: nameFieldName,
type: "text",
defaultValue: "",
autoComplete: "nope",
tabIndex: -1,
}),
validFromFieldName && encryptedValidFrom
? React.createElement(
React.Fragment,
null,
React.createElement("label", { htmlFor: validFromFieldName }, label),
React.createElement("input", {
name: validFromFieldName,
type: "text",
value: encryptedValidFrom,
readOnly: true,
autoComplete: "off",
tabIndex: -1,
})
)
: null
);
}
export function HoneypotProvider({ children, ...context }) {
return React.createElement(
HoneypotContext.Provider,
{ value: context },
children
);
}