@danderson00/react-forms-material 0.0.48 → 0.0.50

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/README.md CHANGED
@@ -1,145 +1,145 @@
1
- # @danderson00/react-forms-material
2
-
3
- Beautiful, ultra simple, stateless, validated forms for use in React function components.
4
-
5
- A demo is available at [https://danderson00digital.github.io/react-forms-material/](https://danderson00digital.github.io/react-forms-material/).
6
-
7
- ## Installation
8
-
9
- ```shell
10
- yarn add @danderson00/react-forms-material
11
- ```
12
-
13
- ## Usage
14
-
15
- ```jsx
16
- import React from 'react'
17
- import { Form, Text, Select, Radio, Checkbox, Submit } from '@danderson00/react-forms-material'
18
-
19
- export default ({ onSubmit, initialValues }) => (
20
- <Form onSubmit={onSubmit} values={initialValues}>
21
- <Text name="name" label="Name" required minLength="5" maxLength="50" />
22
- <Text name="description" label="Description" multiline maxLength="100" />
23
- <Select name="type" label="Type" values={['', 'Widget', 'Component']} required />
24
- <Radio name="rating" label="Rating" values={[1, 2, 3]} row />
25
- <Checkbox name="urgent" label="Urgent" />
26
-
27
- <Submit>Submit</Submit>
28
- </Form>
29
- )
30
- ```
31
-
32
- ## Core Components
33
-
34
- ### `Form`
35
-
36
- All input components must be contained within a `Form` component.
37
-
38
- #### Props
39
-
40
- Name|Type|Description
41
- ---|---|---
42
- values|object|Object containing initial values for form elements
43
- onSubmit|function(values)|A callback to be executed when the corresponding `Submit` component is clicked
44
-
45
- All other props are passed on to the underlying `form` element.
46
-
47
- ### `Submit`
48
-
49
- Renders a Material UI [`Button` component](https://material-ui.com/api/button/) that triggers the closest `Form`
50
- component's `onSubmit` callback.
51
-
52
- #### Props
53
-
54
- All props are passed on to the underlying `Button` component.
55
-
56
- ### `Button`
57
-
58
- A pass through of the Material UI [`Button` component](https://material-ui.com/api/button/) for convenience.
59
-
60
- ## Field Components
61
-
62
- Field components are constructed by wrapping a Material UI [`InputLabel` component](https://material-ui.com/api/input-label/),
63
- a form component and [`FormHelperText` component](https://material-ui.com/api/form-helper-text/) within a
64
- [`FormControl` component](https://material-ui.com/api/form-control/), similar to a
65
- [`TextField` component](https://material-ui.com/api/text-field/).
66
-
67
- All field components can be passed the following props:
68
-
69
- Name|Type|Description
70
- ---|---|---
71
- name|string|Specifies the name of the property to populate with the field value (required)
72
- label|string|Text on the field's label
73
- value|any|Initial value for the field. The DOM API will generally cast this to a string
74
- helperText|string|Specifies the helper text for the field
75
-
76
- The following props are passed to the parent [`FormControl` component](https://material-ui.com/api/form-control/):
77
-
78
- Name|Type|Description
79
- ---|---|---
80
- className|string|Class name to apply to the component
81
- fullWidth|boolean|Specifies that the field should occupy the full width of its parent
82
- variant|string|Corresponds to the `variant` [prop](https://material-ui.com/api/form-control/#props) of a `FormControl`. One of `standard`, `outlined` or `filled`
83
- margin|string|Corresponds to the `margin` [prop](https://material-ui.com/api/form-control/#props) of a `FormControl`. One of `none`, `dense` or `normal`. Most fields, except `Text` default to `normal`
84
-
85
- All other props are passed to the input component, as described below.
86
-
87
- ### `Text`
88
-
89
- Renders a field component with a Material UI [`Input` component](https://material-ui.com/api/input/) as the input
90
- component.
91
-
92
- ### `Select`
93
-
94
- Renders a field component with a Material UI [`Select` component](https://material-ui.com/api/select/) as the input
95
- component. Options are specified using the props below and are rendered as
96
- [`MenuItem` components](https://material-ui.com/api/menu-item/).
97
-
98
- #### Props
99
-
100
- Name|Type|Description
101
- ---|---|---
102
- values|array(any)|Specifies the values to use for each option. The DOM API casts these to strings
103
- labels|array(string)|Specifies the labels to use for each corresponding option in the `values` array. If not specified, entries from the `values` array are used.
104
-
105
- ### `Radio`
106
-
107
- Renders a field component with a Material UI [`RadioGroup` component](https://material-ui.com/api/radio-group/) as the
108
- input component. Options are specified using the props below and are rendered as `RadioButton` components, described
109
- in the next section.
110
-
111
- #### Props
112
-
113
- Name|Type|Description
114
- ---|---|---
115
- values|array(any)|Specifies the values to use for each option. The DOM API casts these to strings
116
- labels|array(string)|Specifies the labels to use for each corresponding option in the `values` array. If not specified, entries from the `values` array are used
117
-
118
- ### `RadioButton`
119
-
120
- Renders a field component with a Material UI [`Radio` component](https://material-ui.com/api/radio/) as the input
121
- component.
122
-
123
- ### `Checkbox`
124
-
125
- Renders a field component with a Material UI [`Checkbox` component](https://material-ui.com/api/checkbox/) as the
126
- input component.
127
-
128
- ## License
129
-
130
- **The MIT License (MIT)**
131
-
132
- Copyright © 2022 Dale Anderson
133
-
134
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
135
- documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
136
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
137
- persons to whom the Software is furnished to do so, subject to the following conditions:
138
-
139
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
140
- Software.
141
-
142
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
143
- WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
144
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
145
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # @danderson00/react-forms-material
2
+
3
+ Beautiful, ultra simple, stateless, validated forms for use in React function components.
4
+
5
+ A demo is available at [https://danderson00digital.github.io/react-forms-material/](https://danderson00digital.github.io/react-forms-material/).
6
+
7
+ ## Installation
8
+
9
+ ```shell
10
+ yarn add @danderson00/react-forms-material
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```jsx
16
+ import React from 'react'
17
+ import { Form, Text, Select, Radio, Checkbox, Submit } from '@danderson00/react-forms-material'
18
+
19
+ export default ({ onSubmit, initialValues }) => (
20
+ <Form onSubmit={onSubmit} values={initialValues}>
21
+ <Text name="name" label="Name" required minLength="5" maxLength="50" />
22
+ <Text name="description" label="Description" multiline maxLength="100" />
23
+ <Select name="type" label="Type" values={['', 'Widget', 'Component']} required />
24
+ <Radio name="rating" label="Rating" values={[1, 2, 3]} row />
25
+ <Checkbox name="urgent" label="Urgent" />
26
+
27
+ <Submit>Submit</Submit>
28
+ </Form>
29
+ )
30
+ ```
31
+
32
+ ## Core Components
33
+
34
+ ### `Form`
35
+
36
+ All input components must be contained within a `Form` component.
37
+
38
+ #### Props
39
+
40
+ Name|Type|Description
41
+ ---|---|---
42
+ values|object|Object containing initial values for form elements
43
+ onSubmit|function(values)|A callback to be executed when the corresponding `Submit` component is clicked
44
+
45
+ All other props are passed on to the underlying `form` element.
46
+
47
+ ### `Submit`
48
+
49
+ Renders a Material UI [`Button` component](https://material-ui.com/api/button/) that triggers the closest `Form`
50
+ component's `onSubmit` callback.
51
+
52
+ #### Props
53
+
54
+ All props are passed on to the underlying `Button` component.
55
+
56
+ ### `Button`
57
+
58
+ A pass through of the Material UI [`Button` component](https://material-ui.com/api/button/) for convenience.
59
+
60
+ ## Field Components
61
+
62
+ Field components are constructed by wrapping a Material UI [`InputLabel` component](https://material-ui.com/api/input-label/),
63
+ a form component and [`FormHelperText` component](https://material-ui.com/api/form-helper-text/) within a
64
+ [`FormControl` component](https://material-ui.com/api/form-control/), similar to a
65
+ [`TextField` component](https://material-ui.com/api/text-field/).
66
+
67
+ All field components can be passed the following props:
68
+
69
+ Name|Type|Description
70
+ ---|---|---
71
+ name|string|Specifies the name of the property to populate with the field value (required)
72
+ label|string|Text on the field's label
73
+ value|any|Initial value for the field. The DOM API will generally cast this to a string
74
+ helperText|string|Specifies the helper text for the field
75
+
76
+ The following props are passed to the parent [`FormControl` component](https://material-ui.com/api/form-control/):
77
+
78
+ Name|Type|Description
79
+ ---|---|---
80
+ className|string|Class name to apply to the component
81
+ fullWidth|boolean|Specifies that the field should occupy the full width of its parent
82
+ variant|string|Corresponds to the `variant` [prop](https://material-ui.com/api/form-control/#props) of a `FormControl`. One of `standard`, `outlined` or `filled`
83
+ margin|string|Corresponds to the `margin` [prop](https://material-ui.com/api/form-control/#props) of a `FormControl`. One of `none`, `dense` or `normal`. Most fields, except `Text` default to `normal`
84
+
85
+ All other props are passed to the input component, as described below.
86
+
87
+ ### `Text`
88
+
89
+ Renders a field component with a Material UI [`Input` component](https://material-ui.com/api/input/) as the input
90
+ component.
91
+
92
+ ### `Select`
93
+
94
+ Renders a field component with a Material UI [`Select` component](https://material-ui.com/api/select/) as the input
95
+ component. Options are specified using the props below and are rendered as
96
+ [`MenuItem` components](https://material-ui.com/api/menu-item/).
97
+
98
+ #### Props
99
+
100
+ Name|Type|Description
101
+ ---|---|---
102
+ values|array(any)|Specifies the values to use for each option. The DOM API casts these to strings
103
+ labels|array(string)|Specifies the labels to use for each corresponding option in the `values` array. If not specified, entries from the `values` array are used.
104
+
105
+ ### `Radio`
106
+
107
+ Renders a field component with a Material UI [`RadioGroup` component](https://material-ui.com/api/radio-group/) as the
108
+ input component. Options are specified using the props below and are rendered as `RadioButton` components, described
109
+ in the next section.
110
+
111
+ #### Props
112
+
113
+ Name|Type|Description
114
+ ---|---|---
115
+ values|array(any)|Specifies the values to use for each option. The DOM API casts these to strings
116
+ labels|array(string)|Specifies the labels to use for each corresponding option in the `values` array. If not specified, entries from the `values` array are used
117
+
118
+ ### `RadioButton`
119
+
120
+ Renders a field component with a Material UI [`Radio` component](https://material-ui.com/api/radio/) as the input
121
+ component.
122
+
123
+ ### `Checkbox`
124
+
125
+ Renders a field component with a Material UI [`Checkbox` component](https://material-ui.com/api/checkbox/) as the
126
+ input component.
127
+
128
+ ## License
129
+
130
+ **The MIT License (MIT)**
131
+
132
+ Copyright © 2022 Dale Anderson
133
+
134
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
135
+ documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
136
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
137
+ persons to whom the Software is furnished to do so, subject to the following conditions:
138
+
139
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
140
+ Software.
141
+
142
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
143
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
144
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
145
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/TODO.md CHANGED
@@ -1,2 +1,2 @@
1
- - Import specific components from @material-ui rather than everything from the main module (drastically reduce bundle size)
1
+ - Import specific components from @material-ui rather than everything from the main module (drastically reduce bundle size)
2
2
  - Change dependency on @material-ui to peerDependency of version "*" to prevent conflicts with user dependencies
package/dist/index.js CHANGED
@@ -30,6 +30,12 @@ Object.defineProperty(exports, "wrapInput", {
30
30
  return _reactForms.wrapInput;
31
31
  }
32
32
  });
33
+ Object.defineProperty(exports, "wrapSubmit", {
34
+ enumerable: true,
35
+ get: function get() {
36
+ return _reactForms.wrapSubmit;
37
+ }
38
+ });
33
39
  var _react = require("react");
34
40
  var _reactForms = require("@danderson00/react-forms");
35
41
  var _ErrorMessage = require("@danderson00/react-forms/src/ErrorMessage");
@@ -47,37 +53,33 @@ require("./styles");
47
53
  var _excluded = ["className", "error", "hiddenLabel", "variant", "margin", "label", "helperText", "shrinkLabel", "valid", "pattern"],
48
54
  _excluded2 = ["name", "values", "labels", "numeric", "required", "getFieldValue", "getFieldValues", "inputProps"],
49
55
  _excluded3 = ["values", "labels"];
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); }
52
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
56
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
57
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
58
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
53
59
  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."); }
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); }
55
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
56
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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; }
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; }
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; }
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; }
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; }
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); }
65
- var ErrorMessage = function ErrorMessage(_ref) {
60
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
61
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
62
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
63
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
64
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
65
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
66
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
67
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
68
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
69
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
70
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
71
+ var ErrorMessage = exports.ErrorMessage = function ErrorMessage(_ref) {
66
72
  var error = _ref.error;
67
73
  return /*#__PURE__*/(0, _react.createElement)(_FormHelperText["default"], {
68
74
  children: (0, _ErrorMessage.extractErrorMessage)(error),
69
75
  error: true
70
76
  });
71
77
  };
72
- exports.ErrorMessage = ErrorMessage;
73
- var Form = (0, _reactForms.FormProvider)(_reactForms.context.Provider, {
78
+ var Form = exports.Form = (0, _reactForms.FormProvider)(_reactForms.context.Provider, {
74
79
  margin: 'dense'
75
80
  }, ErrorMessage);
76
- exports.Form = Form;
77
- var Submit = (0, _reactForms.wrapSubmit)(_Button["default"]);
78
- exports.Submit = Submit;
79
- var Button = _Button["default"];
80
- exports.Button = Button;
81
+ var Submit = exports.Submit = (0, _reactForms.wrapSubmit)(_Button["default"]);
82
+ var Button = exports.Button = _Button["default"];
81
83
  var wrapped = function wrapped(component, options, baseOptions) {
82
84
  return (0, _reactForms.wrapInput)(base(component, options, baseOptions), _objectSpread({
83
85
  passErrorProp: true
@@ -134,23 +136,19 @@ var base = function base(component) {
134
136
  });
135
137
  };
136
138
  };
137
- var Input = (0, _reactForms.wrapInput)(_Input["default"]);
138
- exports.Input = Input;
139
- var Text = wrapped(_Input["default"]);
140
- exports.Text = Text;
141
- var Checkbox = wrapped(_Checkbox["default"], {
139
+ var Input = exports.Input = (0, _reactForms.wrapInput)(_Input["default"]);
140
+ var Text = exports.Text = wrapped(_Input["default"]);
141
+ var Checkbox = exports.Checkbox = wrapped(_Checkbox["default"], {
142
142
  type: 'checkbox'
143
143
  }, {
144
144
  alwaysShrinkLabel: true
145
145
  });
146
- exports.Checkbox = Checkbox;
147
- var RadioButton = wrapped(_Radio["default"], {
146
+ var RadioButton = exports.RadioButton = wrapped(_Radio["default"], {
148
147
  type: 'radio'
149
148
  }, {
150
149
  shrinkLabel: false
151
150
  });
152
- exports.RadioButton = RadioButton;
153
- var Radio = (0, _reactForms.createRawConsumer)(base(function (_ref4) {
151
+ var Radio = exports.Radio = (0, _reactForms.createRawConsumer)(base(function (_ref4) {
154
152
  var name = _ref4.name,
155
153
  values = _ref4.values,
156
154
  labels = _ref4.labels,
@@ -181,8 +179,7 @@ var Radio = (0, _reactForms.createRawConsumer)(base(function (_ref4) {
181
179
  }, {
182
180
  alwaysShrinkLabel: true
183
181
  }));
184
- exports.Radio = Radio;
185
- var Select = wrapped(function (_ref5) {
182
+ var Select = exports.Select = wrapped(function (_ref5) {
186
183
  var values = _ref5.values,
187
184
  labels = _ref5.labels,
188
185
  props = _objectWithoutProperties(_ref5, _excluded3);
@@ -202,7 +199,5 @@ var Select = wrapped(function (_ref5) {
202
199
  }, {
203
200
  alwaysShrinkLabel: true
204
201
  });
205
- exports.Select = Select;
206
- var wrapField = wrapped;
207
- exports.wrapField = wrapField;
202
+ var wrapField = exports.wrapField = wrapped;
208
203
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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'\r\nimport { FormProvider, Group, context, createRawConsumer, wrapInput, wrapSubmit, useForm, useFormValues } from '@danderson00/react-forms'\r\nimport { extractErrorMessage } from '@danderson00/react-forms/src/ErrorMessage'\r\nimport MuiButton from '@material-ui/core/Button'\r\nimport MuiCheckbox from '@material-ui/core/Checkbox'\r\nimport MuiFormControl from '@material-ui/core/FormControl'\r\nimport MuiFormHelperText from '@material-ui/core/FormHelperText'\r\nimport MuiInput from '@material-ui/core/Input'\r\nimport MuiInputLabel from '@material-ui/core/InputLabel'\r\nimport MuiMenuItem from '@material-ui/core/MenuItem'\r\nimport MuiRadio from '@material-ui/core/Radio'\r\nimport MuiRadioGroup from '@material-ui/core/RadioGroup'\r\nimport MuiSelect from '@material-ui/core/Select'\r\nimport './styles'\r\n\r\nexport const ErrorMessage = ({ error }) => createElement(MuiFormHelperText, { children: extractErrorMessage(error), error: true })\r\nexport const Form = FormProvider(context.Provider, { margin: 'dense' }, ErrorMessage)\r\nexport const Submit = wrapSubmit(MuiButton)\r\nexport const Button = MuiButton\r\nexport { useForm, useFormValues, Group, wrapInput }\r\n\r\nconst wrapped = (component, options, baseOptions) => wrapInput(\r\n base(component, options, baseOptions),\r\n { passErrorProp: true, ...options }\r\n)\r\n\r\nconst base = (component, options = {}, { alwaysShrinkLabel, shrinkLabel: shrinkLabelOption = true, passError } = {}) => (\r\n ({ className, error, hiddenLabel, variant, margin, label, helperText, shrinkLabel, valid, pattern, ...inputProps }) => {\r\n return (\r\n createElement(MuiFormControl, {\r\n className: `react-forms-material-field${options.type ? ` react-forms-material-${options.type}` : ''}${className ? ` ${className}` : ''}`,\r\n error,\r\n fullWidth: inputProps.fullWidth,\r\n hiddenLabel,\r\n required: inputProps.required,\r\n variant,\r\n margin,\r\n children: [\r\n ...(label ? [createElement(MuiInputLabel, {\r\n key: 'label',\r\n htmlFor: inputProps.id,\r\n children: label,\r\n ...(shrinkLabelOption === false && { shrink: false }),\r\n ...((alwaysShrinkLabel || shrinkLabel) && { className: 'MuiInputLabel-shrink' }),\r\n })] : []),\r\n\r\n createElement(component, {\r\n key: 'input',\r\n variant,\r\n ...(passError && { error }),\r\n ...inputProps,\r\n inputProps: { ...(pattern && { pattern }), ...inputProps.inputProps }\r\n }),\r\n\r\n ...(helperText ? [createElement(MuiFormHelperText, {\r\n key: 'helperText',\r\n children: helperText\r\n })] : [])\r\n ]\r\n })\r\n )\r\n }\r\n)\r\n\r\nexport const Input = wrapInput(MuiInput)\r\nexport const Text = wrapped(MuiInput)\r\nexport const Checkbox = wrapped(MuiCheckbox, { type: 'checkbox' }, { alwaysShrinkLabel: true })\r\nexport const RadioButton = wrapped(MuiRadio, { type: 'radio' }, { shrinkLabel: false })\r\n\r\nexport const Radio = createRawConsumer(base(\r\n ({ name, values, labels, numeric, required, getFieldValue, getFieldValues, inputProps, ...props }) => {\r\n return createElement(MuiRadioGroup, { ...props, children: [\r\n values.map((value, index) => {\r\n return createElement(RadioButton, {\r\n name,\r\n value,\r\n numeric,\r\n key: value,\r\n label: (labels && labels[index]) || value,\r\n margin: props.margin,\r\n ...(required && { required }),\r\n inputProps\r\n })\r\n })\r\n ] }\r\n )},\r\n { type: 'radiogroup' },\r\n { alwaysShrinkLabel: true }\r\n))\r\n\r\nexport const Select = wrapped(({ values, labels, ...props }) =>\r\n createElement(MuiSelect, { ...props, children:\r\n values.map((value, index) =>\r\n createElement(MuiMenuItem, {\r\n value,\r\n key: value,\r\n children: (labels && labels[index]) || value,\r\n ...(props.required && { required: props.required })\r\n })\r\n )\r\n }),\r\n { type: 'select' },\r\n { alwaysShrinkLabel: true }\r\n)\r\n\r\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,WAAA,GAAAL,sBAAA,CAAAJ,OAAA;AACA,IAAAU,SAAA,GAAAN,sBAAA,CAAAJ,OAAA;AACA,IAAAW,MAAA,GAAAP,sBAAA,CAAAJ,OAAA;AACA,IAAAY,WAAA,GAAAR,sBAAA,CAAAJ,OAAA;AACA,IAAAa,OAAA,GAAAT,sBAAA,CAAAJ,OAAA;AACAA,OAAA;AAAiB,IAAAc,SAAA;EAAAC,UAAA;EAAAC,UAAA;AAA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C,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"}
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","e","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_toConsumableArray","r","_arrayWithoutHoles","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","TypeError","a","_arrayLikeToArray","t","toString","call","slice","name","Array","from","test","isArray","length","n","_objectWithoutProperties","i","_objectWithoutPropertiesLoose","Object","getOwnPropertySymbols","indexOf","propertyIsEnumerable","hasOwnProperty","ownKeys","keys","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","_toPrimitive","toPrimitive","String","Number","ErrorMessage","exports","_ref","error","createElement","MuiFormHelperText","children","extractErrorMessage","Form","FormProvider","context","Provider","margin","Submit","wrapSubmit","MuiButton","Button","wrapped","component","options","baseOptions","wrapInput","base","passErrorProp","undefined","_ref2","alwaysShrinkLabel","_ref2$shrinkLabel","shrinkLabel","shrinkLabelOption","passError","_ref3","className","hiddenLabel","variant","label","helperText","valid","pattern","inputProps","MuiFormControl","concat","type","fullWidth","required","MuiInputLabel","key","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, wrapSubmit }\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\n"],"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,WAAA,GAAAL,sBAAA,CAAAJ,OAAA;AACA,IAAAU,SAAA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AAC,EAClB;EAAEhB,iBAAiB,EAAE;AAAM,CAC7B,CAAC;AAEM,IAAM+C,SAAS,GAAAxE,OAAA,CAAAwE,SAAA,GAAGxD,OAAO","ignoreList":[]}
package/dist/styles.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _injectCss = _interopRequireDefault(require("@danderson00/react-forms/src/injectCss"));
4
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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
@@ -1 +1 @@
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'\r\n\r\ninjectCss('react-forms-material-styles', `\r\n .react-forms-material-radiogroup.MuiFormControl-root {\r\n overflow: hidden;\r\n }\r\n\r\n .react-forms-material-radio.MuiFormControl-root {\r\n flex-direction: row-reverse;\r\n justify-content: flex-end;\r\n }\r\n \r\n .react-forms-material-radio .MuiInputLabel-formControl {\r\n position: static;\r\n }\r\n\r\n .react-forms-material-radio .MuiRadio-root {\r\n transform: translate(0, 9px) scale(1);\r\n } \r\n \r\n .react-forms-material-checkbox .MuiCheckbox-root {\r\n transform: translate(0, 9px) scale(1);\r\n }\r\n \r\n /* allow forms to be embedded in dialogs - essentially replicate a few styles */\r\n .MuiDialog-container form {\r\n display: flex;\r\n }\r\n \r\n .MuiDialog-container form .MuiDialogContent-root {\r\n display: flex;\r\n align-items: flex-start;\r\n flex-direction: column;\r\n }\r\n\r\n .MuiDialog-container form .MuiDialogActions-root {\r\n align-self: flex-end;\r\n }\r\n \r\n .react-forms input::-webkit-outer-spin-button,\r\n .react-forms input::-webkit-inner-spin-button {\r\n -webkit-appearance: none;\r\n margin: 0;\r\n }\r\n\r\n .react-forms input[type=number] {\r\n -moz-appearance: textfield;\r\n }\r\n`)\r\n\r\n\r\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"}
1
+ {"version":3,"file":"styles.js","names":["_injectCss","_interopRequireDefault","require","e","__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,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAE9D,IAAAE,qBAAS,EAAC,6BAA6B,smCA8CtC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,62 +1,62 @@
1
- {
2
- "name": "@danderson00/react-forms-material",
3
- "version": "0.0.48",
4
- "description": "Beautiful, ultra simple, stateless, validated forms for use in React function components",
5
- "main": "src/index.js",
6
- "scripts": {
7
- "test": "jest",
8
- "build": "babel src --source-maps --out-dir dist",
9
- "prepare": "babel src --source-maps --out-dir dist"
10
- },
11
- "dependencies": {
12
- "@danderson00/react-forms": "0.0.48",
13
- "@material-ui/core": "^4.11.3"
14
- },
15
- "peerDependencies": {
16
- "react": "*"
17
- },
18
- "devDependencies": {
19
- "@babel/cli": "^7.4.4",
20
- "@babel/core": "^7.4.4",
21
- "@babel/preset-env": "^7.4.4",
22
- "@babel/preset-react": "^7.0.0",
23
- "babel-jest": "26.6.3",
24
- "enzyme": "^3.9.0",
25
- "enzyme-adapter-react-16": "^1.9.1",
26
- "jest": "26.6.3",
27
- "react": "^18.2.0",
28
- "react-dom": "^18.2.0"
29
- },
30
- "jest": {
31
- "moduleNameMapper": {
32
- "\\.css$": "<rootDir>/test/setup/styleMock.js"
33
- },
34
- "setupFilesAfterEnv": [
35
- "<rootDir>test/setup/beforeAll.js"
36
- ]
37
- },
38
- "babel": {
39
- "presets": [
40
- "@babel/preset-env",
41
- "@babel/preset-react"
42
- ]
43
- },
44
- "keywords": [
45
- "react",
46
- "stateless",
47
- "form",
48
- "function",
49
- "component",
50
- "material",
51
- "ui"
52
- ],
53
- "author": "danderson00",
54
- "license": "MIT",
55
- "publishConfig": {
56
- "access": "public"
57
- },
58
- "repository": {
59
- "type": "git",
60
- "url": "git+https://gitlab.com/danderson00/react-forms.git"
61
- }
62
- }
1
+ {
2
+ "name": "@danderson00/react-forms-material",
3
+ "version": "0.0.50",
4
+ "description": "Beautiful, ultra simple, stateless, validated forms for use in React function components",
5
+ "main": "src/index.js",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "build": "babel src --source-maps --out-dir dist",
9
+ "prepare": "babel src --source-maps --out-dir dist"
10
+ },
11
+ "dependencies": {
12
+ "@danderson00/react-forms": "0.0.50",
13
+ "@material-ui/core": "^4.11.3"
14
+ },
15
+ "peerDependencies": {
16
+ "react": "*"
17
+ },
18
+ "devDependencies": {
19
+ "@babel/cli": "^7.4.4",
20
+ "@babel/core": "^7.4.4",
21
+ "@babel/preset-env": "^7.4.4",
22
+ "@babel/preset-react": "^7.0.0",
23
+ "babel-jest": "26.6.3",
24
+ "enzyme": "^3.9.0",
25
+ "enzyme-adapter-react-16": "^1.9.1",
26
+ "jest": "26.6.3",
27
+ "react": "^18.2.0",
28
+ "react-dom": "^18.2.0"
29
+ },
30
+ "jest": {
31
+ "moduleNameMapper": {
32
+ "\\.css$": "<rootDir>/test/setup/styleMock.js"
33
+ },
34
+ "setupFilesAfterEnv": [
35
+ "<rootDir>test/setup/beforeAll.js"
36
+ ]
37
+ },
38
+ "babel": {
39
+ "presets": [
40
+ "@babel/preset-env",
41
+ "@babel/preset-react"
42
+ ]
43
+ },
44
+ "keywords": [
45
+ "react",
46
+ "stateless",
47
+ "form",
48
+ "function",
49
+ "component",
50
+ "material",
51
+ "ui"
52
+ ],
53
+ "author": "danderson00",
54
+ "license": "MIT",
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "git+https://gitlab.com/danderson00/react-forms.git"
61
+ }
62
+ }
package/src/index.js CHANGED
@@ -1,106 +1,106 @@
1
- import { createElement } from 'react'
2
- import { FormProvider, Group, context, createRawConsumer, wrapInput, wrapSubmit, useForm, useFormValues } from '@danderson00/react-forms'
3
- import { extractErrorMessage } from '@danderson00/react-forms/src/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'
14
- import './styles'
15
-
16
- export const ErrorMessage = ({ error }) => createElement(MuiFormHelperText, { children: extractErrorMessage(error), error: true })
17
- export const Form = FormProvider(context.Provider, { margin: 'dense' }, ErrorMessage)
18
- export const Submit = wrapSubmit(MuiButton)
19
- export const Button = MuiButton
20
- export { useForm, useFormValues, Group, wrapInput }
21
-
22
- const wrapped = (component, options, baseOptions) => wrapInput(
23
- base(component, options, baseOptions),
24
- { passErrorProp: true, ...options }
25
- )
26
-
27
- const base = (component, options = {}, { alwaysShrinkLabel, shrinkLabel: shrinkLabelOption = true, passError } = {}) => (
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
- })] : []),
46
-
47
- createElement(component, {
48
- key: 'input',
49
- variant,
50
- ...(passError && { error }),
51
- ...inputProps,
52
- inputProps: { ...(pattern && { pattern }), ...inputProps.inputProps }
53
- }),
54
-
55
- ...(helperText ? [createElement(MuiFormHelperText, {
56
- key: 'helperText',
57
- children: helperText
58
- })] : [])
59
- ]
60
- })
61
- )
62
- }
63
- )
64
-
65
- export const Input = wrapInput(MuiInput)
66
- export const Text = wrapped(MuiInput)
67
- export const Checkbox = wrapped(MuiCheckbox, { type: 'checkbox' }, { alwaysShrinkLabel: true })
68
- export const RadioButton = wrapped(MuiRadio, { type: 'radio' }, { shrinkLabel: false })
69
-
70
- export const Radio = createRawConsumer(base(
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, {
75
- name,
76
- value,
77
- numeric,
78
- key: value,
79
- label: (labels && labels[index]) || value,
80
- margin: props.margin,
81
- ...(required && { required }),
82
- inputProps
83
- })
84
- })
85
- ] }
86
- )},
87
- { type: 'radiogroup' },
88
- { alwaysShrinkLabel: true }
89
- ))
90
-
91
- export const Select = wrapped(({ values, labels, ...props }) =>
92
- createElement(MuiSelect, { ...props, children:
93
- values.map((value, index) =>
94
- createElement(MuiMenuItem, {
95
- value,
96
- key: value,
97
- children: (labels && labels[index]) || value,
98
- ...(props.required && { required: props.required })
99
- })
100
- )
101
- }),
102
- { type: 'select' },
103
- { alwaysShrinkLabel: true }
104
- )
105
-
106
- export const wrapField = wrapped
1
+ import { createElement } from 'react'
2
+ import { FormProvider, Group, context, createRawConsumer, wrapInput, wrapSubmit, useForm, useFormValues } from '@danderson00/react-forms'
3
+ import { extractErrorMessage } from '@danderson00/react-forms/src/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'
14
+ import './styles'
15
+
16
+ export const ErrorMessage = ({ error }) => createElement(MuiFormHelperText, { children: extractErrorMessage(error), error: true })
17
+ export const Form = FormProvider(context.Provider, { margin: 'dense' }, ErrorMessage)
18
+ export const Submit = wrapSubmit(MuiButton)
19
+ export const Button = MuiButton
20
+ export { useForm, useFormValues, Group, wrapInput, wrapSubmit }
21
+
22
+ const wrapped = (component, options, baseOptions) => wrapInput(
23
+ base(component, options, baseOptions),
24
+ { passErrorProp: true, ...options }
25
+ )
26
+
27
+ const base = (component, options = {}, { alwaysShrinkLabel, shrinkLabel: shrinkLabelOption = true, passError } = {}) => (
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
+ })] : []),
46
+
47
+ createElement(component, {
48
+ key: 'input',
49
+ variant,
50
+ ...(passError && { error }),
51
+ ...inputProps,
52
+ inputProps: { ...(pattern && { pattern }), ...inputProps.inputProps }
53
+ }),
54
+
55
+ ...(helperText ? [createElement(MuiFormHelperText, {
56
+ key: 'helperText',
57
+ children: helperText
58
+ })] : [])
59
+ ]
60
+ })
61
+ )
62
+ }
63
+ )
64
+
65
+ export const Input = wrapInput(MuiInput)
66
+ export const Text = wrapped(MuiInput)
67
+ export const Checkbox = wrapped(MuiCheckbox, { type: 'checkbox' }, { alwaysShrinkLabel: true })
68
+ export const RadioButton = wrapped(MuiRadio, { type: 'radio' }, { shrinkLabel: false })
69
+
70
+ export const Radio = createRawConsumer(base(
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, {
75
+ name,
76
+ value,
77
+ numeric,
78
+ key: value,
79
+ label: (labels && labels[index]) || value,
80
+ margin: props.margin,
81
+ ...(required && { required }),
82
+ inputProps
83
+ })
84
+ })
85
+ ] }
86
+ )},
87
+ { type: 'radiogroup' },
88
+ { alwaysShrinkLabel: true }
89
+ ))
90
+
91
+ export const Select = wrapped(({ values, labels, ...props }) =>
92
+ createElement(MuiSelect, { ...props, children:
93
+ values.map((value, index) =>
94
+ createElement(MuiMenuItem, {
95
+ value,
96
+ key: value,
97
+ children: (labels && labels[index]) || value,
98
+ ...(props.required && { required: props.required })
99
+ })
100
+ )
101
+ }),
102
+ { type: 'select' },
103
+ { alwaysShrinkLabel: true }
104
+ )
105
+
106
+ export const wrapField = wrapped
package/src/styles.js CHANGED
@@ -1,51 +1,51 @@
1
- import injectCss from '@danderson00/react-forms/src/injectCss'
2
-
3
- injectCss('react-forms-material-styles', `
4
- .react-forms-material-radiogroup.MuiFormControl-root {
5
- overflow: hidden;
6
- }
7
-
8
- .react-forms-material-radio.MuiFormControl-root {
9
- flex-direction: row-reverse;
10
- justify-content: flex-end;
11
- }
12
-
13
- .react-forms-material-radio .MuiInputLabel-formControl {
14
- position: static;
15
- }
16
-
17
- .react-forms-material-radio .MuiRadio-root {
18
- transform: translate(0, 9px) scale(1);
19
- }
20
-
21
- .react-forms-material-checkbox .MuiCheckbox-root {
22
- transform: translate(0, 9px) scale(1);
23
- }
24
-
25
- /* allow forms to be embedded in dialogs - essentially replicate a few styles */
26
- .MuiDialog-container form {
27
- display: flex;
28
- }
29
-
30
- .MuiDialog-container form .MuiDialogContent-root {
31
- display: flex;
32
- align-items: flex-start;
33
- flex-direction: column;
34
- }
35
-
36
- .MuiDialog-container form .MuiDialogActions-root {
37
- align-self: flex-end;
38
- }
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
- `)
50
-
51
-
1
+ import injectCss from '@danderson00/react-forms/src/injectCss'
2
+
3
+ injectCss('react-forms-material-styles', `
4
+ .react-forms-material-radiogroup.MuiFormControl-root {
5
+ overflow: hidden;
6
+ }
7
+
8
+ .react-forms-material-radio.MuiFormControl-root {
9
+ flex-direction: row-reverse;
10
+ justify-content: flex-end;
11
+ }
12
+
13
+ .react-forms-material-radio .MuiInputLabel-formControl {
14
+ position: static;
15
+ }
16
+
17
+ .react-forms-material-radio .MuiRadio-root {
18
+ transform: translate(0, 9px) scale(1);
19
+ }
20
+
21
+ .react-forms-material-checkbox .MuiCheckbox-root {
22
+ transform: translate(0, 9px) scale(1);
23
+ }
24
+
25
+ /* allow forms to be embedded in dialogs - essentially replicate a few styles */
26
+ .MuiDialog-container form {
27
+ display: flex;
28
+ }
29
+
30
+ .MuiDialog-container form .MuiDialogContent-root {
31
+ display: flex;
32
+ align-items: flex-start;
33
+ flex-direction: column;
34
+ }
35
+
36
+ .MuiDialog-container form .MuiDialogActions-root {
37
+ align-self: flex-end;
38
+ }
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
+ `)
50
+
51
+