New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

remix-forms

Package Overview
Dependencies
Maintainers
4
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remix-forms - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

251

dist/index.js

@@ -67,14 +67,38 @@ "use strict";

if (!React.isValidElement(child))
return fn(child);
return child;
const mapped = fn(child);
if (child.props.children && typeof child.props.children !== "function") {
return fn(
React.cloneElement(child, {
...child.props,
children: mapChildren(child.props.children, fn)
})
);
const mappedChildren = mapChildren(child.props.children, fn);
return mapped && React.cloneElement(mapped, { children: mappedChildren });
}
return fn(child);
return mapped;
});
}
function findElement(root, predicate) {
const initialState = null;
return reduceElements(
root,
initialState,
(previous, current) => {
if (previous)
return previous;
if (predicate(current)) {
return current;
}
return null;
}
);
}
function findParent(root, child) {
return findElement(root, (parentCandidate) => {
var _a, _b, _c;
const me = (_c = (_b = (_a = parentCandidate.props) == null ? void 0 : _a.children) == null ? void 0 : _b.find) == null ? void 0 : _c.call(
_b,
(ch) => {
return ch === child;
}
);
return !!me;
});
}
function reduceElements(children, initialState, reducer) {

@@ -85,7 +109,6 @@ let foldedValue = initialState;

return;
foldedValue = reducer(foldedValue, child);
if (child.props.children && typeof child.props.children !== "function") {
foldedValue = reduceElements(child.props.children, foldedValue, reducer);
return;
}
foldedValue = reducer(foldedValue, child);
});

@@ -209,2 +232,7 @@ return foldedValue;

};
function getInputType(type, radio) {
if (radio)
return "radio";
return types[type];
}
var makeSelectOption = ({ name, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {

@@ -333,3 +361,3 @@ value,

const style = hidden ? { display: "none" } : void 0;
const type = typeProp ?? types[fieldType];
const type = typeProp ?? getInputType(fieldType, radio);
const registerProps = register(String(name), {

@@ -359,3 +387,3 @@ setValueAs: (value2) => coerceValue(value2, shape)

if (childrenFn) {
const children = childrenFn({
const childrenDefinition = childrenFn({
Label,

@@ -389,93 +417,124 @@ SmartInput,

});
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
hidden,
style,
...props,
children: mapChildren(children, (child) => {
if (!React2.isValidElement(child))
return child;
if (child.type === Label) {
const children = mapChildren(childrenDefinition, (child) => {
if (child.type === Label) {
return React2.cloneElement(child, {
id: labelId,
htmlFor: String(name),
children: label,
...child.props
});
} else if (child.type === SmartInput) {
return React2.cloneElement(child, {
fieldType,
type,
options,
multiline,
radio,
placeholder,
registerProps,
autoFocus,
value,
a11yProps,
...child.props
});
} else if (child.type === Input) {
return React2.cloneElement(child, {
id: String(name),
type,
...registerProps,
...a11yProps,
placeholder,
autoFocus,
defaultValue: value,
...child.props
});
} else if (child.type === Multiline) {
return React2.cloneElement(child, {
id: String(name),
...registerProps,
...a11yProps,
placeholder,
autoFocus,
defaultValue: value,
...child.props
});
} else if (child.type === Select) {
return React2.cloneElement(child, {
id: String(name),
...registerProps,
...a11yProps,
autoFocus,
defaultValue: value,
children: makeOptionComponents(makeSelectOption, options),
...child.props
});
} else if (child.type === Checkbox) {
return React2.cloneElement(child, {
id: String(name),
type,
autoFocus,
...registerProps,
...a11yProps,
placeholder,
defaultChecked: Boolean(value),
...child.props
});
} else if (child.type === RadioGroup) {
return React2.cloneElement(child, {
...a11yProps,
...child.props
});
} else if (child.type === Radio) {
return React2.cloneElement(child, {
id: `${name}-${child.props.value}`,
type: "radio",
autoFocus,
...registerProps,
defaultChecked: value === child.props.value,
...child.props
});
} else if (child.type === Errors) {
if (!child.props.children && !(errors == null ? void 0 : errors.length))
return null;
if (child.props.children || !(errors == null ? void 0 : errors.length)) {
return React2.cloneElement(child, {
id: labelId,
htmlFor: String(name),
children: label,
id: errorsId,
role: "alert",
...child.props
});
} else if (child.type === SmartInput) {
return React2.cloneElement(child, {
fieldType,
type,
options,
multiline,
radio,
placeholder,
registerProps,
autoFocus,
value,
a11yProps,
...child.props
});
} else if (child.type === Input) {
return React2.cloneElement(child, {
id: String(name),
type,
...registerProps,
...a11yProps,
placeholder,
autoFocus,
defaultValue: value,
...child.props
});
} else if (child.type === Multiline) {
return React2.cloneElement(child, {
id: String(name),
...registerProps,
...a11yProps,
placeholder,
autoFocus,
defaultValue: value,
...child.props
});
} else if (child.type === Select) {
return React2.cloneElement(child, {
id: String(name),
...registerProps,
...a11yProps,
autoFocus,
defaultValue: value,
children: makeOptionComponents(makeSelectOption, options),
...child.props
});
} else if (child.type === Checkbox) {
return React2.cloneElement(child, {
id: String(name),
type,
autoFocus,
...registerProps,
...a11yProps,
placeholder,
defaultChecked: Boolean(value),
...child.props
});
} else if (child.type === Errors) {
if (!child.props.children && !(errors == null ? void 0 : errors.length))
return null;
if (child.props.children || !(errors == null ? void 0 : errors.length)) {
}
return React2.cloneElement(child, {
id: errorsId,
role: "alert",
children: errorsChildren,
...child.props
});
} else {
return child;
}
});
const fixRadioLabels = (children2) => mapChildren(children2, (child) => {
var _a;
if (child.type === Label) {
const parent = findParent(children2, child);
if (parent && parent.type === RadioWrapper) {
const radioChild = findElement(
(_a = parent.props) == null ? void 0 : _a.children,
(ch) => ch.type === Radio
);
if (radioChild) {
return React2.cloneElement(child, {
id: errorsId,
role: "alert",
...child.props
htmlFor: radioChild.props.id
});
}
return React2.cloneElement(child, {
id: errorsId,
role: "alert",
children: errorsChildren,
...child.props
});
} else {
return child;
}
})
}
return child;
});
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
hidden,
style,
...props,
children: fixRadioLabels(children)
});
}

@@ -726,4 +785,2 @@ const smartInput = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SmartInput, {

(child) => {
if (!React3.isValidElement(child))
return child;
if (child.type === Field) {

@@ -730,0 +787,0 @@ const { name } = child.props;

{
"name": "remix-forms",
"version": "1.2.1",
"version": "1.2.2",
"description": "The full-stack form library for Remix and React Router",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc