@danderson00/react-forms-material 0.0.27 → 0.1.0

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 CHANGED
@@ -1,214 +1,135 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Text = exports.Submit = exports.Select = exports.RadioButton = exports.Radio = exports.Input = exports.Form = exports.ErrorMessage = exports.Checkbox = exports.Button = void 0;
7
- Object.defineProperty(exports, "useFormValues", {
8
- enumerable: true,
9
- get: function get() {
10
- return _reactForms.useFormValues;
11
- }
1
+ import { createElement } from 'react';
2
+ import { FormProvider, context, createRawConsumer, wrapInput, wrapSubmit, useFormValues } from '@danderson00/react-forms';
3
+ import { extractErrorMessage } from '@danderson00/react-forms/dist/ErrorMessage';
4
+ import MuiButton from '@mui/material/Button';
5
+ import MuiCheckbox from '@mui/material/Checkbox';
6
+ import MuiFormControl from '@mui/material/FormControl';
7
+ import MuiFormHelperText from '@mui/material/FormHelperText';
8
+ import MuiInput from '@mui/material/Input';
9
+ import MuiInputLabel from '@mui/material/InputLabel';
10
+ import MuiMenuItem from '@mui/material/MenuItem';
11
+ import MuiRadio from '@mui/material/Radio';
12
+ import MuiRadioGroup from '@mui/material/RadioGroup';
13
+ import MuiSelect from '@mui/material/Select';
14
+ import './styles';
15
+ export const ErrorMessage = ({
16
+ error
17
+ }) => createElement(MuiFormHelperText, {
18
+ children: extractErrorMessage(error),
19
+ error: true
12
20
  });
13
- exports.wrapField = void 0;
14
-
15
- var _react = require("react");
16
-
17
- var _reactForms = require("@danderson00/react-forms");
18
-
19
- var _ErrorMessage = require("@danderson00/react-forms/dist/ErrorMessage");
20
-
21
- var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
22
-
23
- var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
24
-
25
- var _FormControl = _interopRequireDefault(require("@material-ui/core/FormControl"));
26
-
27
- var _FormHelperText = _interopRequireDefault(require("@material-ui/core/FormHelperText"));
28
-
29
- var _Input = _interopRequireDefault(require("@material-ui/core/Input"));
30
-
31
- var _InputLabel = _interopRequireDefault(require("@material-ui/core/InputLabel"));
32
-
33
- var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
34
-
35
- var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));
36
-
37
- var _RadioGroup = _interopRequireDefault(require("@material-ui/core/RadioGroup"));
38
-
39
- var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
40
-
41
- require("./styles");
42
-
43
- var _excluded = ["className", "error", "hiddenLabel", "variant", "margin", "label", "helperText", "shrinkLabel", "valid"],
44
- _excluded2 = ["name", "values", "labels", "numeric", "required", "getFieldValue", "getFieldValues"],
45
- _excluded3 = ["values", "labels"];
46
-
47
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
48
-
49
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
50
-
51
- 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."); }
52
-
53
- 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); }
56
-
57
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
58
-
59
- 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; }
60
-
61
- 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; }
62
-
63
- 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; }
64
-
65
- 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; }
66
-
67
- 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; }
68
-
69
- 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; }
70
-
71
- var ErrorMessage = function ErrorMessage(_ref) {
72
- var error = _ref.error;
73
- return /*#__PURE__*/(0, _react.createElement)(_FormHelperText["default"], {
74
- children: (0, _ErrorMessage.extractErrorMessage)(error),
75
- error: true
76
- });
77
- };
78
-
79
- exports.ErrorMessage = ErrorMessage;
80
- var Form = (0, _reactForms.FormProvider)(_reactForms.context.Provider, {
21
+ export const Form = FormProvider(context.Provider, {
81
22
  margin: 'dense'
82
23
  }, ErrorMessage);
83
- exports.Form = Form;
84
- var Submit = (0, _reactForms.wrapSubmit)(_Button["default"]);
85
- exports.Submit = Submit;
86
- var Button = _Button["default"];
87
- exports.Button = Button;
88
-
89
- var wrapped = function wrapped(component, options, baseOptions) {
90
- return (0, _reactForms.wrapInput)(base(component, options, baseOptions), _objectSpread({
91
- passErrorProp: true
92
- }, options));
93
- };
24
+ export const Submit = wrapSubmit(MuiButton);
25
+ export const Button = MuiButton;
26
+ export { useFormValues };
94
27
 
95
- var base = function base(component) {
96
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
97
-
98
- var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
99
- alwaysShrinkLabel = _ref2.alwaysShrinkLabel,
100
- _ref2$shrinkLabel = _ref2.shrinkLabel,
101
- shrinkLabelOption = _ref2$shrinkLabel === void 0 ? true : _ref2$shrinkLabel,
102
- passError = _ref2.passError;
103
-
104
- return function (_ref3) {
105
- var className = _ref3.className,
106
- error = _ref3.error,
107
- hiddenLabel = _ref3.hiddenLabel,
108
- variant = _ref3.variant,
109
- margin = _ref3.margin,
110
- label = _ref3.label,
111
- helperText = _ref3.helperText,
112
- shrinkLabel = _ref3.shrinkLabel,
113
- valid = _ref3.valid,
114
- inputProps = _objectWithoutProperties(_ref3, _excluded);
28
+ const wrapped = (component, options, baseOptions) => wrapInput(base(component, options, baseOptions), {
29
+ passErrorProp: true,
30
+ ...options
31
+ });
115
32
 
116
- return /*#__PURE__*/(0, _react.createElement)(_FormControl["default"], {
117
- className: "react-forms-material-field".concat(options.type ? " react-forms-material-".concat(options.type) : '').concat(className ? " ".concat(className) : ''),
118
- error: error,
119
- fullWidth: inputProps.fullWidth,
120
- hiddenLabel: hiddenLabel,
121
- required: inputProps.required,
122
- variant: variant,
123
- margin: margin,
124
- children: [].concat(_toConsumableArray(label ? [/*#__PURE__*/(0, _react.createElement)(_InputLabel["default"], _objectSpread(_objectSpread({
125
- key: 'label',
126
- htmlFor: inputProps.id,
127
- children: label
128
- }, shrinkLabelOption === false && {
129
- shrink: false
130
- }), (alwaysShrinkLabel || shrinkLabel) && {
131
- className: 'MuiInputLabel-shrink'
132
- }))] : []), [/*#__PURE__*/(0, _react.createElement)(component, _objectSpread(_objectSpread({
133
- key: 'input',
134
- variant: variant
135
- }, passError && {
136
- error: error
137
- }), inputProps))], _toConsumableArray(helperText ? [/*#__PURE__*/(0, _react.createElement)(_FormHelperText["default"], {
138
- key: 'helperText',
139
- children: helperText
140
- })] : []))
141
- });
142
- };
143
- };
33
+ const base = (component, options = {}, {
34
+ alwaysShrinkLabel,
35
+ shrinkLabel: shrinkLabelOption = true,
36
+ passError
37
+ } = {}) => ({
38
+ className,
39
+ error,
40
+ hiddenLabel,
41
+ variant,
42
+ margin,
43
+ label,
44
+ helperText,
45
+ shrinkLabel,
46
+ valid,
47
+ ...inputProps
48
+ }) => createElement(MuiFormControl, {
49
+ className: `react-forms-material-field${options.type ? ` react-forms-material-${options.type}` : ''}${className ? ` ${className}` : ''}`,
50
+ error,
51
+ fullWidth: inputProps.fullWidth,
52
+ hiddenLabel,
53
+ required: inputProps.required,
54
+ variant,
55
+ margin,
56
+ children: [...(label ? [createElement(MuiInputLabel, {
57
+ key: 'label',
58
+ htmlFor: inputProps.id,
59
+ children: label,
60
+ ...(shrinkLabelOption === false && {
61
+ shrink: false
62
+ }),
63
+ ...((alwaysShrinkLabel || shrinkLabel) && {
64
+ className: 'MuiInputLabel-shrink'
65
+ })
66
+ })] : []), createElement(component, {
67
+ key: 'input',
68
+ variant,
69
+ ...(passError && {
70
+ error
71
+ }),
72
+ ...inputProps
73
+ }), ...(helperText ? [createElement(MuiFormHelperText, {
74
+ key: 'helperText',
75
+ children: helperText
76
+ })] : [])]
77
+ });
144
78
 
145
- var Input = (0, _reactForms.wrapInput)(_Input["default"]);
146
- exports.Input = Input;
147
- var Text = wrapped(_Input["default"]);
148
- exports.Text = Text;
149
- var Checkbox = wrapped(_Checkbox["default"], {
79
+ export const Input = wrapInput(MuiInput);
80
+ export const Text = wrapped(MuiInput);
81
+ export const Checkbox = wrapped(MuiCheckbox, {
150
82
  type: 'checkbox'
151
83
  }, {
152
84
  alwaysShrinkLabel: true
153
85
  });
154
- exports.Checkbox = Checkbox;
155
- var RadioButton = wrapped(_Radio["default"], {
86
+ export const RadioButton = wrapped(MuiRadio, {
156
87
  type: 'radio'
157
88
  }, {
158
89
  shrinkLabel: false
159
90
  });
160
- exports.RadioButton = RadioButton;
161
- var Radio = (0, _reactForms.createRawConsumer)(base(function (_ref4) {
162
- var name = _ref4.name,
163
- values = _ref4.values,
164
- labels = _ref4.labels,
165
- numeric = _ref4.numeric,
166
- required = _ref4.required,
167
- getFieldValue = _ref4.getFieldValue,
168
- getFieldValues = _ref4.getFieldValues,
169
- props = _objectWithoutProperties(_ref4, _excluded2);
170
-
171
- return /*#__PURE__*/(0, _react.createElement)(_RadioGroup["default"], _objectSpread(_objectSpread({}, props), {}, {
172
- children: [values.map(function (value, index) {
173
- return /*#__PURE__*/(0, _react.createElement)(RadioButton, _objectSpread({
174
- name: name,
175
- value: value,
176
- numeric: numeric,
177
- key: value,
178
- label: labels && labels[index] || value,
179
- margin: props.margin
180
- }, required && {
181
- required: required
182
- }));
183
- })]
184
- }));
185
- }, {
91
+ export const Radio = createRawConsumer(base(({
92
+ name,
93
+ values,
94
+ labels,
95
+ numeric,
96
+ required,
97
+ getFieldValue,
98
+ getFieldValues,
99
+ ...props
100
+ }) => createElement(MuiRadioGroup, { ...props,
101
+ children: [values.map((value, index) => createElement(RadioButton, {
102
+ name,
103
+ value,
104
+ numeric,
105
+ key: value,
106
+ label: labels && labels[index] || value,
107
+ margin: props.margin,
108
+ ...(required && {
109
+ required
110
+ })
111
+ }))]
112
+ }), {
186
113
  type: 'radiogroup'
187
114
  }, {
188
115
  alwaysShrinkLabel: true
189
116
  }));
190
- exports.Radio = Radio;
191
- var Select = wrapped(function (_ref5) {
192
- var values = _ref5.values,
193
- labels = _ref5.labels,
194
- props = _objectWithoutProperties(_ref5, _excluded3);
195
-
196
- return /*#__PURE__*/(0, _react.createElement)(_Select["default"], _objectSpread(_objectSpread({}, props), {}, {
197
- children: values.map(function (value, index) {
198
- return /*#__PURE__*/(0, _react.createElement)(_MenuItem["default"], _objectSpread({
199
- value: value,
200
- key: value,
201
- children: labels && labels[index] || value
202
- }, props.required && {
203
- required: props.required
204
- }));
117
+ export const Select = wrapped(({
118
+ values,
119
+ labels,
120
+ ...props
121
+ }) => createElement(MuiSelect, { ...props,
122
+ children: values.map((value, index) => createElement(MuiMenuItem, {
123
+ value,
124
+ key: value,
125
+ children: labels && labels[index] || value,
126
+ ...(props.required && {
127
+ required: props.required
205
128
  })
206
- }));
207
- }, {
129
+ }))
130
+ }), {
208
131
  type: 'select'
209
132
  }, {
210
133
  alwaysShrinkLabel: true
211
134
  });
212
- exports.Select = Select;
213
- var wrapField = wrapped;
214
- exports.wrapField = wrapField;
135
+ export const wrapField = wrapped;
package/dist/styles.js CHANGED
@@ -1,7 +1,48 @@
1
- "use strict";
1
+ import injectCss from '@danderson00/react-forms/dist/injectCss';
2
+ injectCss('react-forms-material-styles', `
3
+ .react-forms-material-radiogroup.MuiFormControl-root {
4
+ overflow: hidden;
5
+ }
2
6
 
3
- var _injectCss = _interopRequireDefault(require("@danderson00/react-forms/dist/injectCss"));
7
+ .react-forms-material-radio.MuiFormControl-root {
8
+ flex-direction: row-reverse;
9
+ justify-content: flex-end;
10
+ }
11
+
12
+ .react-forms-material-radio .MuiInputLabel-formControl {
13
+ position: static;
14
+ }
4
15
 
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
+ .react-forms-material-radio .MuiRadio-root {
17
+ transform: translate(0, 9px) scale(1);
18
+ }
19
+
20
+ .react-forms-material-checkbox .MuiCheckbox-root {
21
+ transform: translate(0, 9px) scale(1);
22
+ }
23
+
24
+ /* allow forms to be embedded in dialogs - essentially replicate a few styles */
25
+ .MuiDialog-container form {
26
+ display: flex;
27
+ }
28
+
29
+ .MuiDialog-container form .MuiDialogContent-root {
30
+ display: flex;
31
+ align-items: flex-start;
32
+ flex-direction: column;
33
+ }
6
34
 
7
- (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");
35
+ .MuiDialog-container form .MuiDialogActions-root {
36
+ align-self: flex-end;
37
+ }
38
+
39
+ .react-forms input::-webkit-outer-spin-button,
40
+ .react-forms input::-webkit-inner-spin-button {
41
+ -webkit-appearance: none;
42
+ margin: 0;
43
+ }
44
+
45
+ .react-forms input[type=number] {
46
+ -moz-appearance: textfield;
47
+ }
48
+ `);
package/package.json CHANGED
@@ -1,32 +1,23 @@
1
1
  {
2
2
  "name": "@danderson00/react-forms-material",
3
- "version": "0.0.27",
3
+ "version": "0.1.0",
4
4
  "description": "Beautiful, ultra simple, stateless, validated forms for use in React function components",
5
- "main": "dist/index.js",
6
5
  "module": "src/index.js",
7
6
  "scripts": {
8
- "test": "jest",
9
- "build": "babel src --out-dir dist",
10
- "prepare": "babel src --source-maps false --out-dir dist"
7
+ "test": "jest"
11
8
  },
12
9
  "dependencies": {
13
- "@danderson00/react-forms": "0.0.27",
14
- "@material-ui/core": "^4.11.3"
15
10
  },
16
11
  "peerDependencies": {
17
- "react": "^17.0.1"
12
+ "react": "^18.2.0"
18
13
  },
19
14
  "devDependencies": {
20
- "@babel/cli": "^7.4.4",
21
- "@babel/core": "^7.4.4",
22
- "@babel/preset-env": "^7.4.4",
23
- "@babel/preset-react": "^7.0.0",
24
- "babel-jest": "26.6.0",
25
- "enzyme": "^3.9.0",
26
- "enzyme-adapter-react-16": "^1.9.1",
27
- "jest": "26.6.0",
28
- "react": "^17.0.1",
29
- "react-dom": "^17.0.1"
15
+ "@danderson00/react-forms": "0.0.27",
16
+ "@emotion/react": "^11.9.3",
17
+ "@emotion/styled": "^11.9.3",
18
+ "@mui/material": "^5.8.7",
19
+ "react": "^18.2.0",
20
+ "react-dom": "^18.2.0"
30
21
  },
31
22
  "jest": {
32
23
  "moduleNameMapper": {
@@ -36,12 +27,6 @@
36
27
  "<rootDir>test/setup/beforeAll.js"
37
28
  ]
38
29
  },
39
- "babel": {
40
- "presets": [
41
- "@babel/preset-env",
42
- "@babel/preset-react"
43
- ]
44
- },
45
30
  "keywords": [
46
31
  "react",
47
32
  "stateless",
@@ -60,4 +45,4 @@
60
45
  "type": "git",
61
46
  "url": "git+https://gitlab.com/danderson00/react-forms.git"
62
47
  }
63
- }
48
+ }
package/src/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { createElement } from 'react'
2
2
  import { FormProvider, context, createRawConsumer, wrapInput, wrapSubmit, useFormValues } from '@danderson00/react-forms'
3
3
  import { extractErrorMessage } from '@danderson00/react-forms/dist/ErrorMessage'
4
- import MuiButton from '@material-ui/core/Button'
5
- import MuiCheckbox from '@material-ui/core/Checkbox'
6
- import MuiFormControl from '@material-ui/core/FormControl'
7
- import MuiFormHelperText from '@material-ui/core/FormHelperText'
8
- import MuiInput from '@material-ui/core/Input'
9
- import MuiInputLabel from '@material-ui/core/InputLabel'
10
- import MuiMenuItem from '@material-ui/core/MenuItem'
11
- import MuiRadio from '@material-ui/core/Radio'
12
- import MuiRadioGroup from '@material-ui/core/RadioGroup'
13
- import MuiSelect from '@material-ui/core/Select'
4
+ import MuiButton from '@mui/material/Button'
5
+ import MuiCheckbox from '@mui/material/Checkbox'
6
+ import MuiFormControl from '@mui/material/FormControl'
7
+ import MuiFormHelperText from '@mui/material/FormHelperText'
8
+ import MuiInput from '@mui/material/Input'
9
+ import MuiInputLabel from '@mui/material/InputLabel'
10
+ import MuiMenuItem from '@mui/material/MenuItem'
11
+ import MuiRadio from '@mui/material/Radio'
12
+ import MuiRadioGroup from '@mui/material/RadioGroup'
13
+ import MuiSelect from '@mui/material/Select'
14
14
  import './styles'
15
15
 
16
16
  export const ErrorMessage = ({ error }) => createElement(MuiFormHelperText, { children: extractErrorMessage(error), error: true })
@@ -25,38 +25,40 @@ 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 }) => (
29
- createElement(MuiFormControl, {
30
- className: `react-forms-material-field${options.type ? ` react-forms-material-${options.type}` : ''}${className ? ` ${className}` : ''}`,
31
- error,
32
- fullWidth: inputProps.fullWidth,
33
- hiddenLabel,
34
- required: inputProps.required,
35
- variant,
36
- margin,
37
- children: [
38
- ...(label ? [createElement(MuiInputLabel, {
39
- key: 'label',
40
- htmlFor: inputProps.id,
41
- children: label,
42
- ...(shrinkLabelOption === false && { shrink: false }),
43
- ...((alwaysShrinkLabel || shrinkLabel) && { className: 'MuiInputLabel-shrink' }),
44
- })] : []),
28
+ ({ className, error, hiddenLabel, variant, margin, label, helperText, shrinkLabel, valid, ...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
- createElement(component, {
47
- key: 'input',
48
- variant,
49
- ...(passError && { error }),
50
- ...inputProps
51
- }),
47
+ createElement(component, {
48
+ key: 'input',
49
+ variant,
50
+ ...(passError && { error }),
51
+ ...inputProps
52
+ }),
52
53
 
53
- ...(helperText ? [createElement(MuiFormHelperText, {
54
- key: 'helperText',
55
- children: helperText
56
- })] : [])
57
- ]
58
- })
59
- )
54
+ ...(helperText ? [createElement(MuiFormHelperText, {
55
+ key: 'helperText',
56
+ children: helperText
57
+ })] : [])
58
+ ]
59
+ })
60
+ )
61
+ }
60
62
  )
61
63
 
62
64
  export const Input = wrapInput(MuiInput)
package/src/styles.js CHANGED
@@ -5,24 +5,39 @@ injectCss('react-forms-material-styles', `
5
5
  overflow: hidden;
6
6
  }
7
7
 
8
+ .react-forms-material-radio,
9
+ .react-forms-material-checkbox {
10
+ display: flex !important;
11
+ flex-direction: row-reverse !important;
12
+ align-items: center;
13
+ }
14
+
8
15
  .react-forms-material-radio.MuiFormControl-root {
9
16
  flex-direction: row-reverse;
10
17
  justify-content: flex-end;
11
18
  }
12
19
 
13
- .react-forms-material-radio .MuiInputLabel-formControl {
20
+ .react-forms-material-radio .MuiInputLabel-formControl,
21
+ .react-forms-material-radiogroup .MuiInputLabel-formControl,
22
+ .react-forms-material-checkbox .MuiInputLabel-formControl {
14
23
  position: static;
24
+ transform: none;
25
+ line-height: 1;
26
+ transform: translateY(2px) scale(1);
15
27
  }
16
-
17
- .react-forms-material-radio .MuiRadio-root {
18
- transform: translate(0, 9px) scale(1);
19
- }
20
28
 
21
- .react-forms-material-checkbox .MuiCheckbox-root {
22
- transform: translate(0, 9px) scale(1);
29
+
30
+ .react-forms input::-webkit-outer-spin-button,
31
+ .react-forms input::-webkit-inner-spin-button {
32
+ -webkit-appearance: none;
33
+ margin: 0;
34
+ }
35
+
36
+ .react-forms input[type=number] {
37
+ -moz-appearance: textfield;
23
38
  }
24
39
 
25
- /* allow forms to be embedded in dialogs - essentially replicate a few styles */
40
+ ${''/* allow forms to be embedded in dialogs - essentially replicate a few styles */}
26
41
  .MuiDialog-container form {
27
42
  display: flex;
28
43
  }
@@ -36,16 +51,6 @@ injectCss('react-forms-material-styles', `
36
51
  .MuiDialog-container form .MuiDialogActions-root {
37
52
  align-self: flex-end;
38
53
  }
39
-
40
- .react-forms input::-webkit-outer-spin-button,
41
- .react-forms input::-webkit-inner-spin-button {
42
- -webkit-appearance: none;
43
- margin: 0;
44
- }
45
-
46
- .react-forms input[type=number] {
47
- -moz-appearance: textfield;
48
- }
49
54
  `)
50
55
 
51
56