graphql-form-mui 0.0.16 → 0.0.19

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.
@@ -15,12 +15,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var material_1 = require("@mui/material");
18
+ var graphql_form_1 = require("graphql-form");
18
19
  var react_1 = __importDefault(require("react"));
19
20
  exports.default = (function (props) {
20
- var _a, _b;
21
+ var errs = (0, graphql_form_1.getErrorFromProps)(props);
21
22
  return (react_1.default.createElement(material_1.TextField, { value: props.formObject.value || '', placeholder: props.f.name.replace(/([A-Z])/g, ' $1').replace(/^./, function (str) {
22
23
  return str.toUpperCase();
23
- }), error: !!((_a = props.formObject.errors) === null || _a === void 0 ? void 0 : _a.length), helperText: (_b = props.formObject.errors) === null || _b === void 0 ? void 0 : _b.join(' and '), onChange: function (e) {
24
+ }), error: !!errs, helperText: errs, onChange: function (e) {
24
25
  props.onChange(__assign(__assign({}, props.formObject), { value: e.target.value }));
25
26
  } }));
26
27
  });
@@ -1 +1 @@
1
- {"version":3,"file":"UniversalField.js","sourceRoot":"","sources":["../../src/components/UniversalField.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAA0C;AAE1C,gDAA0B;AAC1B,mBAAe,UAAC,KAAsB;;IAAK,OAAA,CACvC,8BAAC,oBAAS,IACN,KAAK,EAAG,KAAK,CAAC,UAAU,CAAC,KAA4B,IAAI,EAAE,EAC3D,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG;YAC5E,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC,CAAC,EACF,KAAK,EAAE,CAAC,CAAC,CAAA,MAAA,KAAK,CAAC,UAAU,CAAC,MAAM,0CAAE,MAAM,CAAA,EACxC,UAAU,EAAE,MAAA,KAAK,CAAC,UAAU,CAAC,MAAM,0CAAE,IAAI,CAAC,OAAO,CAAC,EAClD,QAAQ,EAAE,UAAC,CAAC;YACR,KAAK,CAAC,QAAQ,uBACP,KAAK,CAAC,UAAU,KACnB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,IACvB,CAAC;QACP,CAAC,GACH,CACL,CAAA;CAAA,EAAC"}
1
+ {"version":3,"file":"UniversalField.js","sourceRoot":"","sources":["../../src/components/UniversalField.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAA0C;AAC1C,6CAAkE;AAClE,gDAA0B;AAC1B,mBAAe,UAAC,KAAsB;IAClC,IAAM,IAAI,GAAG,IAAA,gCAAiB,EAAC,KAAK,CAAC,CAAC;IACtC,OAAO,CACH,8BAAC,oBAAS,IACN,KAAK,EAAG,KAAK,CAAC,UAAU,CAAC,KAA4B,IAAI,EAAE,EAC3D,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG;YAC5E,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC,CAAC,EACF,KAAK,EAAE,CAAC,CAAC,IAAI,EACb,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,UAAC,CAAC;YACR,KAAK,CAAC,QAAQ,uBACP,KAAK,CAAC,UAAU,KACnB,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,IACvB,CAAC;QACP,CAAC,GACH,CACL,CAAC;AACN,CAAC,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-form-mui",
3
- "version": "0.0.16",
3
+ "version": "0.0.19",
4
4
  "description": "Easy form creation with GraphQL Editor and React",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,19 +1,22 @@
1
1
  import { TextField } from '@mui/material';
2
- import { PassedFormProps } from 'graphql-form';
2
+ import { getErrorFromProps, PassedFormProps } from 'graphql-form';
3
3
  import React from 'react';
4
- export default (props: PassedFormProps) => (
5
- <TextField
6
- value={(props.formObject.value as string | undefined) || ''}
7
- placeholder={props.f.name.replace(/([A-Z])/g, ' $1').replace(/^./, function (str) {
8
- return str.toUpperCase();
9
- })}
10
- error={!!props.formObject.errors?.length}
11
- helperText={props.formObject.errors?.join(' and ')}
12
- onChange={(e) => {
13
- props.onChange({
14
- ...props.formObject,
15
- value: e.target.value,
16
- });
17
- }}
18
- />
19
- );
4
+ export default (props: PassedFormProps) => {
5
+ const errs = getErrorFromProps(props);
6
+ return (
7
+ <TextField
8
+ value={(props.formObject.value as string | undefined) || ''}
9
+ placeholder={props.f.name.replace(/([A-Z])/g, ' $1').replace(/^./, function (str) {
10
+ return str.toUpperCase();
11
+ })}
12
+ error={!!errs}
13
+ helperText={errs}
14
+ onChange={(e) => {
15
+ props.onChange({
16
+ ...props.formObject,
17
+ value: e.target.value,
18
+ });
19
+ }}
20
+ />
21
+ );
22
+ };