@danderson00/react-forms-material 0.0.34 → 0.0.37
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 +8 -3
- package/dist/index.js.map +1 -1
- package/dist/styles.js.map +1 -1
- package/package.json +2 -2
- package/src/index.js +3 -2
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
|
|
|
53
53
|
|
|
54
54
|
require("./styles");
|
|
55
55
|
|
|
56
|
-
var _excluded = ["className", "error", "hiddenLabel", "variant", "margin", "label", "helperText", "shrinkLabel", "valid"],
|
|
56
|
+
var _excluded = ["className", "error", "hiddenLabel", "variant", "margin", "label", "helperText", "shrinkLabel", "valid", "pattern"],
|
|
57
57
|
_excluded2 = ["name", "values", "labels", "numeric", "required", "getFieldValue", "getFieldValues"],
|
|
58
58
|
_excluded3 = ["values", "labels"];
|
|
59
59
|
|
|
@@ -124,6 +124,7 @@ var base = function base(component) {
|
|
|
124
124
|
helperText = _ref3.helperText,
|
|
125
125
|
shrinkLabel = _ref3.shrinkLabel,
|
|
126
126
|
valid = _ref3.valid,
|
|
127
|
+
pattern = _ref3.pattern,
|
|
127
128
|
inputProps = _objectWithoutProperties(_ref3, _excluded);
|
|
128
129
|
|
|
129
130
|
return /*#__PURE__*/(0, _react.createElement)(_FormControl["default"], {
|
|
@@ -142,12 +143,16 @@ var base = function base(component) {
|
|
|
142
143
|
shrink: false
|
|
143
144
|
}), (alwaysShrinkLabel || shrinkLabel) && {
|
|
144
145
|
className: 'MuiInputLabel-shrink'
|
|
145
|
-
}))] : []), [/*#__PURE__*/(0, _react.createElement)(component, _objectSpread(_objectSpread({
|
|
146
|
+
}))] : []), [/*#__PURE__*/(0, _react.createElement)(component, _objectSpread(_objectSpread(_objectSpread({
|
|
146
147
|
key: 'input',
|
|
147
148
|
variant: variant
|
|
148
149
|
}, passError && {
|
|
149
150
|
error: error
|
|
150
|
-
}), inputProps)
|
|
151
|
+
}), inputProps), {}, {
|
|
152
|
+
inputProps: _objectSpread(_objectSpread({}, pattern && {
|
|
153
|
+
pattern: pattern
|
|
154
|
+
}), inputProps.inputProps)
|
|
155
|
+
}))], _toConsumableArray(helperText ? [/*#__PURE__*/(0, _react.createElement)(_FormHelperText["default"], {
|
|
151
156
|
key: 'helperText',
|
|
152
157
|
children: helperText
|
|
153
158
|
})] : []))
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["ErrorMessage","error","MuiFormHelperText","children","Form","context","Provider","margin","Submit","MuiButton","Button","wrapped","component","options","baseOptions","base","passErrorProp","alwaysShrinkLabel","shrinkLabel","shrinkLabelOption","passError","className","hiddenLabel","variant","label","helperText","valid","pattern","inputProps","MuiFormControl","type","fullWidth","required","MuiInputLabel","key","htmlFor","id","shrink","Input","MuiInput","Text","Checkbox","MuiCheckbox","RadioButton","MuiRadio","Radio","name","values","labels","numeric","getFieldValue","getFieldValues","props","MuiRadioGroup","map","value","index","Select","MuiSelect","MuiMenuItem","wrapField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,YAAY,GAAG,SAAfA,YAAe;AAAA,MAAGC,KAAH,QAAGA,KAAH;AAAA,sBAAe,0BAAcC,0BAAd,EAAiC;AAAEC,IAAAA,QAAQ,EAAE,uCAAoBF,KAApB,CAAZ;AAAwCA,IAAAA,KAAK,EAAE;AAA/C,GAAjC,CAAf;AAAA,CAArB;;;AACA,IAAMG,IAAI,GAAG,8BAAaC,oBAAQC,QAArB,EAA+B;AAAEC,EAAAA,MAAM,EAAE;AAAV,CAA/B,EAAoDP,YAApD,CAAb;;AACA,IAAMQ,MAAM,GAAG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,KAAtB;;AAAA,sBAC5B,0BAAcM,kBAAd,kCAA8BN,KAA9B;AAAqCjD,IAAAA,QAAQ,EAC3C4C,MAAM,CAACO,GAAP,CAAW,UAACC,KAAD,EAAQC,KAAR;AAAA,0BACT,0BAAcG,oBAAd;AACEJ,QAAAA,KAAK,EAALA,KADF;AAEErB,QAAAA,GAAG,EAAEqB,KAFP;AAGEpD,QAAAA,QAAQ,EAAG6C,MAAM,IAAIA,MAAM,CAACQ,KAAD,CAAjB,IAA6BD;AAHzC,SAIMH,KAAK,CAACpB,QAAN,IAAkB;AAAEA,QAAAA,QAAQ,EAAEoB,KAAK,CAACpB;AAAlB,OAJxB,EADS;AAAA,KAAX;AADF,KAD4B;AAAA,CAAD,EAW3B;AAAEF,EAAAA,IAAI,EAAE;AAAR,CAX2B,EAY3B;AAAEb,EAAAA,iBAAiB,EAAE;AAArB,CAZ2B,CAAtB;;AAeA,IAAM2C,SAAS,GAAGjD,OAAlB","sourcesContent":["import { createElement } from 'react'\nimport { FormProvider, Group, context, createRawConsumer, wrapInput, wrapSubmit, useFormValues } from '@danderson00/react-forms'\nimport { extractErrorMessage } from '@danderson00/react-forms/dist/ErrorMessage'\nimport MuiButton from '@material-ui/core/Button'\nimport MuiCheckbox from '@material-ui/core/Checkbox'\nimport MuiFormControl from '@material-ui/core/FormControl'\nimport MuiFormHelperText from '@material-ui/core/FormHelperText'\nimport MuiInput from '@material-ui/core/Input'\nimport MuiInputLabel from '@material-ui/core/InputLabel'\nimport MuiMenuItem from '@material-ui/core/MenuItem'\nimport MuiRadio from '@material-ui/core/Radio'\nimport MuiRadioGroup from '@material-ui/core/RadioGroup'\nimport MuiSelect from '@material-ui/core/Select'\nimport './styles'\n\nexport const ErrorMessage = ({ error }) => createElement(MuiFormHelperText, { children: extractErrorMessage(error), error: true })\nexport const Form = FormProvider(context.Provider, { margin: 'dense' }, ErrorMessage)\nexport const Submit = wrapSubmit(MuiButton)\nexport const Button = MuiButton\nexport { useFormValues, Group, wrapInput }\n\nconst wrapped = (component, options, baseOptions) => wrapInput(\n base(component, options, baseOptions),\n { passErrorProp: true, ...options }\n)\n\nconst base = (component, options = {}, { alwaysShrinkLabel, shrinkLabel: shrinkLabelOption = true, passError } = {}) => (\n ({ className, error, hiddenLabel, variant, margin, label, helperText, shrinkLabel, valid, pattern, ...inputProps }) => (\n createElement(MuiFormControl, {\n className: `react-forms-material-field${options.type ? ` react-forms-material-${options.type}` : ''}${className ? ` ${className}` : ''}`,\n error,\n fullWidth: inputProps.fullWidth,\n hiddenLabel,\n required: inputProps.required,\n variant,\n margin,\n children: [\n ...(label ? [createElement(MuiInputLabel, {\n key: 'label',\n htmlFor: inputProps.id,\n children: label,\n ...(shrinkLabelOption === false && { shrink: false }),\n ...((alwaysShrinkLabel || shrinkLabel) && { className: 'MuiInputLabel-shrink' }),\n })] : []),\n\n createElement(component, {\n key: 'input',\n variant,\n ...(passError && { error }),\n ...inputProps,\n inputProps: { ...(pattern && { pattern }), ...inputProps.inputProps }\n }),\n\n ...(helperText ? [createElement(MuiFormHelperText, {\n key: 'helperText',\n children: helperText\n })] : [])\n ]\n })\n )\n)\n\nexport const Input = wrapInput(MuiInput)\nexport const Text = wrapped(MuiInput)\nexport const Checkbox = wrapped(MuiCheckbox, { type: 'checkbox' }, { alwaysShrinkLabel: true })\nexport const RadioButton = wrapped(MuiRadio, { type: 'radio' }, { shrinkLabel: false })\n\nexport const Radio = createRawConsumer(base(\n ({ name, values, labels, numeric, required, getFieldValue, getFieldValues, ...props }) => (\n createElement(MuiRadioGroup, { ...props, children: [\n values.map((value, index) =>\n createElement(RadioButton, {\n name,\n value,\n numeric,\n key: value,\n label: (labels && labels[index]) || value,\n margin: props.margin,\n ...(required && { required })\n })\n )\n ] })\n ),\n { type: 'radiogroup' },\n { alwaysShrinkLabel: true }\n))\n\nexport const Select = wrapped(({ values, labels, ...props }) =>\n createElement(MuiSelect, { ...props, children:\n values.map((value, index) =>\n createElement(MuiMenuItem, {\n value,\n key: value,\n children: (labels && labels[index]) || value,\n ...(props.required && { required: props.required })\n })\n )\n }),\n { type: 'select' },\n { alwaysShrinkLabel: true }\n)\n\nexport const wrapField = wrapped"],"file":"index.js"}
|
package/dist/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/styles.js"],"names":[],"mappings":";;AAAA;;;;AAEA,2BAAU,6BAAV","sourcesContent":["import injectCss from '@danderson00/react-forms/dist/injectCss'\n\ninjectCss('react-forms-material-styles', `\n .react-forms-material-radiogroup.MuiFormControl-root {\n overflow: hidden;\n }\n\n .react-forms-material-radio.MuiFormControl-root {\n flex-direction: row-reverse;\n justify-content: flex-end;\n }\n \n .react-forms-material-radio .MuiInputLabel-formControl {\n position: static;\n }\n\n .react-forms-material-radio .MuiRadio-root {\n transform: translate(0, 9px) scale(1);\n } \n \n .react-forms-material-checkbox .MuiCheckbox-root {\n transform: translate(0, 9px) scale(1);\n }\n \n /* allow forms to be embedded in dialogs - essentially replicate a few styles */\n .MuiDialog-container form {\n display: flex;\n }\n \n .MuiDialog-container form .MuiDialogContent-root {\n display: flex;\n align-items: flex-start;\n flex-direction: column;\n }\n\n .MuiDialog-container form .MuiDialogActions-root {\n align-self: flex-end;\n }\n \n .react-forms input::-webkit-outer-spin-button,\n .react-forms input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n .react-forms input[type=number] {\n -moz-appearance: textfield;\n }\n`)\n\n\n"],"file":"styles.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danderson00/react-forms-material",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "Beautiful, ultra simple, stateless, validated forms for use in React function components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"prepare": "babel src --source-maps --out-dir dist"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@danderson00/react-forms": "0.0.
|
|
13
|
+
"@danderson00/react-forms": "0.0.37",
|
|
14
14
|
"@material-ui/core": "^4.11.3"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
package/src/index.js
CHANGED
|
@@ -25,7 +25,7 @@ const wrapped = (component, options, baseOptions) => wrapInput(
|
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
const base = (component, options = {}, { alwaysShrinkLabel, shrinkLabel: shrinkLabelOption = true, passError } = {}) => (
|
|
28
|
-
({ className, error, hiddenLabel, variant, margin, label, helperText, shrinkLabel, valid, ...inputProps }) => (
|
|
28
|
+
({ className, error, hiddenLabel, variant, margin, label, helperText, shrinkLabel, valid, pattern, ...inputProps }) => (
|
|
29
29
|
createElement(MuiFormControl, {
|
|
30
30
|
className: `react-forms-material-field${options.type ? ` react-forms-material-${options.type}` : ''}${className ? ` ${className}` : ''}`,
|
|
31
31
|
error,
|
|
@@ -47,7 +47,8 @@ const base = (component, options = {}, { alwaysShrinkLabel, shrinkLabel: shrinkL
|
|
|
47
47
|
key: 'input',
|
|
48
48
|
variant,
|
|
49
49
|
...(passError && { error }),
|
|
50
|
-
...inputProps
|
|
50
|
+
...inputProps,
|
|
51
|
+
inputProps: { ...(pattern && { pattern }), ...inputProps.inputProps }
|
|
51
52
|
}),
|
|
52
53
|
|
|
53
54
|
...(helperText ? [createElement(MuiFormHelperText, {
|