remix-forms
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -56,4 +56,5 @@ import * as React$1 from 'react'; | ||
Checkbox: React$1.ForwardRefExoticComponent<React$1.PropsWithoutRef<JSX.IntrinsicElements['input']> & React$1.RefAttributes<HTMLInputElement>> | string; | ||
RadioGroup: ComponentOrTagName<'fieldset'>; | ||
RadioWrapper: ComponentOrTagName<'div'>; | ||
Radio: React$1.ForwardRefExoticComponent<React$1.PropsWithoutRef<JSX.IntrinsicElements['input']> & React$1.RefAttributes<HTMLInputElement>> | string; | ||
RadioWrapper: ComponentOrTagName<'fieldset'>; | ||
CheckboxWrapper: ComponentOrTagName<'div'>; | ||
@@ -91,3 +92,2 @@ Errors: ComponentOrTagName<'div'>; | ||
autoFocus?: boolean; | ||
selectChildren?: JSX.Element[]; | ||
options?: Option[]; | ||
@@ -94,0 +94,0 @@ multiline?: boolean; |
@@ -217,4 +217,5 @@ "use strict"; | ||
checkboxComponent: Checkbox = "input", | ||
labelComponent: Label = "label", | ||
radioComponent: Radio = "input", | ||
radioWrapperComponent: RadioWrapper = React2.Fragment | ||
radioWrapperComponent: RadioWrapper = "div" | ||
}) { | ||
@@ -226,3 +227,2 @@ return ({ | ||
autoFocus, | ||
selectChildren, | ||
options, | ||
@@ -238,3 +238,3 @@ multiline, | ||
return null; | ||
const makeRadioOption = (props2) => ({ name: name2, value: value2 }) => { | ||
const makeRadioOption = (props2, checkedValue) => ({ name: name2, value: value2 }) => { | ||
const propsWithUniqueId = mapObject( | ||
@@ -249,10 +249,11 @@ props2, | ||
value: value2, | ||
defaultChecked: value2 === checkedValue, | ||
...propsWithUniqueId | ||
}, String(propsWithUniqueId == null ? void 0 : propsWithUniqueId.id)), | ||
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { | ||
}), | ||
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { | ||
htmlFor: String(propsWithUniqueId == null ? void 0 : propsWithUniqueId.id), | ||
children: name2 | ||
}, `label-${propsWithUniqueId == null ? void 0 : propsWithUniqueId.id}`) | ||
}) | ||
] | ||
}); | ||
}, String(propsWithUniqueId == null ? void 0 : propsWithUniqueId.id)); | ||
}; | ||
@@ -272,9 +273,9 @@ const { name } = registerProps; | ||
...a11yProps | ||
}) : (selectChildren || options) && !radio ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, { | ||
}) : options && !radio ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, { | ||
defaultValue: value, | ||
...commonProps, | ||
...a11yProps, | ||
children: selectChildren ?? makeOptionComponents(makeSelectOption, options) | ||
children: makeOptionComponents(makeSelectOption, options) | ||
}) : options && radio ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { | ||
children: makeOptionComponents(makeRadioOption(commonProps), options) | ||
children: makeOptionComponents(makeRadioOption(commonProps, value), options) | ||
}) : multiline ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Multiline, { | ||
@@ -305,2 +306,3 @@ placeholder, | ||
radioGroupComponent: RadioGroup = "fieldset", | ||
radioWrapperComponent: RadioWrapper = "div", | ||
fieldErrorsComponent: Errors = "div", | ||
@@ -352,5 +354,7 @@ errorComponent: Error2 = "div" | ||
checkboxComponent: Checkbox, | ||
radioComponent: Radio | ||
radioComponent: Radio, | ||
radioWrapperComponent: RadioWrapper, | ||
labelComponent: Label | ||
}), | ||
[Input, Multiline, Select, Checkbox, Radio] | ||
[Input, Multiline, Select, Checkbox, Radio, RadioWrapper, Label] | ||
); | ||
@@ -366,3 +370,4 @@ if (childrenFn) { | ||
Radio, | ||
RadioWrapper: RadioGroup, | ||
RadioGroup, | ||
RadioWrapper, | ||
CheckboxWrapper, | ||
@@ -405,6 +410,2 @@ Errors, | ||
type, | ||
selectChildren: makeOptionComponents( | ||
makeSelectOption, | ||
options | ||
), | ||
options, | ||
@@ -487,3 +488,2 @@ multiline, | ||
type, | ||
selectChildren: makeOptionComponents(makeSelectOption, options), | ||
options, | ||
@@ -512,10 +512,12 @@ multiline, | ||
] | ||
}) : radio ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(RadioGroup, { | ||
...a11yProps, | ||
}) : radio ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { | ||
children: [ | ||
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", { | ||
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { | ||
id: labelId, | ||
children: label | ||
}), | ||
smartInput | ||
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RadioGroup, { | ||
...a11yProps, | ||
children: smartInput | ||
}) | ||
] | ||
@@ -661,2 +663,3 @@ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { | ||
radioGroupComponent, | ||
radioWrapperComponent, | ||
fieldErrorsComponent, | ||
@@ -675,2 +678,3 @@ errorComponent: Error2 | ||
radioGroupComponent, | ||
radioWrapperComponent, | ||
fieldErrorsComponent, | ||
@@ -677,0 +681,0 @@ Error2 |
{ | ||
"name": "remix-forms", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"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
66209
1937