@danderson00/react-forms-material 0.0.44 → 0.0.46
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 +11 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.js +1 -1
- package/dist/styles.js.map +1 -1
- package/package.json +4 -5
- package/src/index.js +43 -40
- package/src/styles.js +1 -1
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ Object.defineProperty(exports, "wrapInput", {
|
|
|
32
32
|
});
|
|
33
33
|
var _react = require("react");
|
|
34
34
|
var _reactForms = require("@danderson00/react-forms");
|
|
35
|
-
var _ErrorMessage = require("@danderson00/react-forms/
|
|
35
|
+
var _ErrorMessage = require("@danderson00/react-forms/src/ErrorMessage");
|
|
36
36
|
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
37
37
|
var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
|
|
38
38
|
var _FormControl = _interopRequireDefault(require("@material-ui/core/FormControl"));
|
|
@@ -45,20 +45,23 @@ var _RadioGroup = _interopRequireDefault(require("@material-ui/core/RadioGroup")
|
|
|
45
45
|
var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
|
|
46
46
|
require("./styles");
|
|
47
47
|
var _excluded = ["className", "error", "hiddenLabel", "variant", "margin", "label", "helperText", "shrinkLabel", "valid", "pattern"],
|
|
48
|
-
_excluded2 = ["name", "values", "labels", "numeric", "required", "getFieldValue", "getFieldValues"],
|
|
48
|
+
_excluded2 = ["name", "values", "labels", "numeric", "required", "getFieldValue", "getFieldValues", "inputProps"],
|
|
49
49
|
_excluded3 = ["values", "labels"];
|
|
50
50
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
51
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
51
52
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
52
53
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
53
54
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
54
55
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
55
56
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
56
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
57
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
57
58
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
58
59
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
59
60
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
60
61
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
61
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
62
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
63
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
64
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
62
65
|
var ErrorMessage = function ErrorMessage(_ref) {
|
|
63
66
|
var error = _ref.error;
|
|
64
67
|
return /*#__PURE__*/(0, _react.createElement)(_FormHelperText["default"], {
|
|
@@ -155,10 +158,11 @@ var Radio = (0, _reactForms.createRawConsumer)(base(function (_ref4) {
|
|
|
155
158
|
required = _ref4.required,
|
|
156
159
|
getFieldValue = _ref4.getFieldValue,
|
|
157
160
|
getFieldValues = _ref4.getFieldValues,
|
|
161
|
+
inputProps = _ref4.inputProps,
|
|
158
162
|
props = _objectWithoutProperties(_ref4, _excluded2);
|
|
159
163
|
return /*#__PURE__*/(0, _react.createElement)(_RadioGroup["default"], _objectSpread(_objectSpread({}, props), {}, {
|
|
160
164
|
children: [values.map(function (value, index) {
|
|
161
|
-
return /*#__PURE__*/(0, _react.createElement)(RadioButton, _objectSpread({
|
|
165
|
+
return /*#__PURE__*/(0, _react.createElement)(RadioButton, _objectSpread(_objectSpread({
|
|
162
166
|
name: name,
|
|
163
167
|
value: value,
|
|
164
168
|
numeric: numeric,
|
|
@@ -167,6 +171,8 @@ var Radio = (0, _reactForms.createRawConsumer)(base(function (_ref4) {
|
|
|
167
171
|
margin: props.margin
|
|
168
172
|
}, required && {
|
|
169
173
|
required: required
|
|
174
|
+
}), {}, {
|
|
175
|
+
inputProps: inputProps
|
|
170
176
|
}));
|
|
171
177
|
})]
|
|
172
178
|
}));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ErrorMessage","error","createElement","MuiFormHelperText","children","extractErrorMessage","Form","FormProvider","context","Provider","margin","Submit","wrapSubmit","MuiButton","Button","wrapped","component","options","baseOptions","wrapInput","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","createRawConsumer","name","values","labels","numeric","getFieldValue","getFieldValues","props","MuiRadioGroup","map","value","index","Select","MuiSelect","MuiMenuItem","wrapField"],"sources":["../src/index.js"],"sourcesContent":["import { createElement } from 'react'\nimport { FormProvider, Group, context, createRawConsumer, wrapInput, wrapSubmit, useForm, 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 { useForm, 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAiB;EAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEV,IAAMA,YAAY,GAAG,SAAfA,YAAY;EAAA,IAAMC,KAAK,QAALA,KAAK;EAAA,oBAAO,IAAAC,oBAAa,EAACC,0BAAiB,EAAE;IAAEC,QAAQ,EAAE,IAAAC,iCAAmB,EAACJ,KAAK,CAAC;IAAEA,KAAK,EAAE;EAAK,CAAC,CAAC;AAAA;AAAA;AAC3H,IAAMK,IAAI,GAAG,IAAAC,wBAAY,EAACC,mBAAO,CAACC,QAAQ,EAAE;EAAEC,MAAM,EAAE;AAAQ,CAAC,EAAEV,YAAY,CAAC;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Q,IAAI;QAAEA,QAAQ,EAAEqB,KAAK,CAACrB;MAAS,CAAC,EAClD;IAAA;EACH,GACD;AAAA,GACF;EAAEF,IAAI,EAAE;AAAS,CAAC,EAClB;EAAEb,iBAAiB,EAAE;AAAM,CAAC,CAC7B;AAAA;AAEM,IAAM4C,SAAS,GAAGnD,OAAO;AAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","require","_reactForms","_ErrorMessage","_Button","_interopRequireDefault","_Checkbox","_FormControl","_FormHelperText","_Input","_InputLabel","_MenuItem","_Radio","_RadioGroup","_Select","_excluded","_excluded2","_excluded3","obj","__esModule","_typeof","Symbol","iterator","constructor","prototype","_toConsumableArray","arr","_arrayWithoutHoles","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","TypeError","o","minLen","_arrayLikeToArray","n","Object","toString","call","slice","name","Array","from","test","iter","isArray","len","length","i","arr2","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","key","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","ownKeys","object","enumerableOnly","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","Number","ErrorMessage","_ref","error","createElement","MuiFormHelperText","children","extractErrorMessage","exports","Form","FormProvider","context","Provider","margin","Submit","wrapSubmit","MuiButton","Button","wrapped","component","options","baseOptions","wrapInput","base","passErrorProp","_ref2","alwaysShrinkLabel","_ref2$shrinkLabel","shrinkLabel","shrinkLabelOption","passError","_ref3","className","hiddenLabel","variant","label","helperText","valid","pattern","inputProps","MuiFormControl","concat","type","fullWidth","required","MuiInputLabel","htmlFor","id","shrink","Input","MuiInput","Text","Checkbox","MuiCheckbox","RadioButton","MuiRadio","Radio","createRawConsumer","_ref4","values","labels","numeric","getFieldValue","getFieldValues","props","MuiRadioGroup","map","index","Select","_ref5","MuiSelect","MuiMenuItem","wrapField"],"sources":["../src/index.js"],"sourcesContent":["import { createElement } from 'react'\nimport { FormProvider, Group, context, createRawConsumer, wrapInput, wrapSubmit, useForm, useFormValues } from '@danderson00/react-forms'\nimport { extractErrorMessage } from '@danderson00/react-forms/src/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 { useForm, 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 return (\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)\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, inputProps, ...props }) => {\n return createElement(MuiRadioGroup, { ...props, children: [\n values.map((value, index) => {\n return 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 inputProps\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,YAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,eAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,MAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS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tB,IAAA/D,oBAAa,EAACmE,oBAAW,EAAA3F,aAAA;QACvBO,KAAK,EAALA,KAAK;QACLxB,GAAG,EAAEwB,KAAK;QACVmB,QAAQ,EAAGsD,MAAM,IAAIA,MAAM,CAACO,KAAK,CAAC,IAAKhF;MAAK,GACxC6E,KAAK,CAACpB,QAAQ,IAAI;QAAEA,QAAQ,EAAEoB,KAAK,CAACpB;MAAS,CAAC,CACnD,CAAC;IAAA,CACJ;EAAC,EACF,CAAC;AAAA,GACF;EAAEF,IAAI,EAAE;AAAS,CAAC,EAClB;EAAEhB,iBAAiB,EAAE;AAAM,CAC7B,CAAC;AAAAlB,OAAA,CAAA4D,MAAA,GAAAA,MAAA;AAEM,IAAMI,SAAS,GAAGtD,OAAO;AAAAV,OAAA,CAAAgE,SAAA,GAAAA,SAAA"}
|
package/dist/styles.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _injectCss = _interopRequireDefault(require("@danderson00/react-forms/
|
|
3
|
+
var _injectCss = _interopRequireDefault(require("@danderson00/react-forms/src/injectCss"));
|
|
4
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
5
5
|
(0, _injectCss["default"])('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");
|
|
6
6
|
//# sourceMappingURL=styles.js.map
|
package/dist/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","names":["injectCss"],"sources":["../src/styles.js"],"sourcesContent":["import injectCss from '@danderson00/react-forms/
|
|
1
|
+
{"version":3,"file":"styles.js","names":["_injectCss","_interopRequireDefault","require","obj","__esModule","injectCss"],"sources":["../src/styles.js"],"sourcesContent":["import injectCss from '@danderson00/react-forms/src/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"],"mappings":";;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE9D,IAAAE,qBAAS,EAAC,6BAA6B,smCA8CtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danderson00/react-forms-material",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "Beautiful, ultra simple, stateless, validated forms for use in React function components",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "src/index.js",
|
|
5
|
+
"main": "src/index.js",
|
|
7
6
|
"scripts": {
|
|
8
7
|
"test": "jest",
|
|
9
8
|
"build": "babel src --source-maps --out-dir dist",
|
|
10
9
|
"prepare": "babel src --source-maps --out-dir dist"
|
|
11
10
|
},
|
|
12
11
|
"dependencies": {
|
|
13
|
-
"@danderson00/react-forms": "0.0.
|
|
12
|
+
"@danderson00/react-forms": "0.0.46",
|
|
14
13
|
"@material-ui/core": "^4.11.3"
|
|
15
14
|
},
|
|
16
15
|
"peerDependencies": {
|
|
@@ -60,4 +59,4 @@
|
|
|
60
59
|
"type": "git",
|
|
61
60
|
"url": "git+https://gitlab.com/danderson00/react-forms.git"
|
|
62
61
|
}
|
|
63
|
-
}
|
|
62
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement } from 'react'
|
|
2
2
|
import { FormProvider, Group, context, createRawConsumer, wrapInput, wrapSubmit, useForm, useFormValues } from '@danderson00/react-forms'
|
|
3
|
-
import { extractErrorMessage } from '@danderson00/react-forms/
|
|
3
|
+
import { extractErrorMessage } from '@danderson00/react-forms/src/ErrorMessage'
|
|
4
4
|
import MuiButton from '@material-ui/core/Button'
|
|
5
5
|
import MuiCheckbox from '@material-ui/core/Checkbox'
|
|
6
6
|
import MuiFormControl from '@material-ui/core/FormControl'
|
|
@@ -25,39 +25,41 @@ 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, pattern, ...inputProps }) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
({ className, error, hiddenLabel, variant, margin, label, helperText, shrinkLabel, valid, pattern, ...inputProps }) => {
|
|
29
|
+
return (
|
|
30
|
+
createElement(MuiFormControl, {
|
|
31
|
+
className: `react-forms-material-field${options.type ? ` react-forms-material-${options.type}` : ''}${className ? ` ${className}` : ''}`,
|
|
32
|
+
error,
|
|
33
|
+
fullWidth: inputProps.fullWidth,
|
|
34
|
+
hiddenLabel,
|
|
35
|
+
required: inputProps.required,
|
|
36
|
+
variant,
|
|
37
|
+
margin,
|
|
38
|
+
children: [
|
|
39
|
+
...(label ? [createElement(MuiInputLabel, {
|
|
40
|
+
key: 'label',
|
|
41
|
+
htmlFor: inputProps.id,
|
|
42
|
+
children: label,
|
|
43
|
+
...(shrinkLabelOption === false && { shrink: false }),
|
|
44
|
+
...((alwaysShrinkLabel || shrinkLabel) && { className: 'MuiInputLabel-shrink' }),
|
|
45
|
+
})] : []),
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
createElement(component, {
|
|
48
|
+
key: 'input',
|
|
49
|
+
variant,
|
|
50
|
+
...(passError && { error }),
|
|
51
|
+
...inputProps,
|
|
52
|
+
inputProps: { ...(pattern && { pattern }), ...inputProps.inputProps }
|
|
53
|
+
}),
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
...(helperText ? [createElement(MuiFormHelperText, {
|
|
56
|
+
key: 'helperText',
|
|
57
|
+
children: helperText
|
|
58
|
+
})] : [])
|
|
59
|
+
]
|
|
60
|
+
})
|
|
61
|
+
)
|
|
62
|
+
}
|
|
61
63
|
)
|
|
62
64
|
|
|
63
65
|
export const Input = wrapInput(MuiInput)
|
|
@@ -66,21 +68,22 @@ export const Checkbox = wrapped(MuiCheckbox, { type: 'checkbox' }, { alwaysShrin
|
|
|
66
68
|
export const RadioButton = wrapped(MuiRadio, { type: 'radio' }, { shrinkLabel: false })
|
|
67
69
|
|
|
68
70
|
export const Radio = createRawConsumer(base(
|
|
69
|
-
({ name, values, labels, numeric, required, getFieldValue, getFieldValues, ...props }) =>
|
|
70
|
-
createElement(MuiRadioGroup, { ...props, children: [
|
|
71
|
-
values.map((value, index) =>
|
|
72
|
-
createElement(RadioButton, {
|
|
71
|
+
({ name, values, labels, numeric, required, getFieldValue, getFieldValues, inputProps, ...props }) => {
|
|
72
|
+
return createElement(MuiRadioGroup, { ...props, children: [
|
|
73
|
+
values.map((value, index) => {
|
|
74
|
+
return createElement(RadioButton, {
|
|
73
75
|
name,
|
|
74
76
|
value,
|
|
75
77
|
numeric,
|
|
76
78
|
key: value,
|
|
77
79
|
label: (labels && labels[index]) || value,
|
|
78
80
|
margin: props.margin,
|
|
79
|
-
...(required && { required })
|
|
81
|
+
...(required && { required }),
|
|
82
|
+
inputProps
|
|
80
83
|
})
|
|
81
|
-
)
|
|
82
|
-
] }
|
|
83
|
-
),
|
|
84
|
+
})
|
|
85
|
+
] }
|
|
86
|
+
)},
|
|
84
87
|
{ type: 'radiogroup' },
|
|
85
88
|
{ alwaysShrinkLabel: true }
|
|
86
89
|
))
|
package/src/styles.js
CHANGED