@digigov/form 0.11.0 → 0.11.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @digigov/form
2
2
 
3
- This log was last generated on Tue, 02 May 2023 09:16:06 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 11 May 2023 10:48:56 GMT and should not be manually modified.
4
+
5
+ ## 0.11.1
6
+ Thu, 11 May 2023 10:48:56 GMT
7
+
8
+ ### Patches
9
+
10
+ - Fix input error validations for OtpInput and DateInput
4
11
 
5
12
  ## 0.11.0
6
13
  Tue, 02 May 2023 09:16:06 GMT
@@ -80,7 +80,8 @@ var FormBase = /*#__PURE__*/_react["default"].forwardRef(function FormBase(_ref,
80
80
  clearErrors: form.clearErrors,
81
81
  getValues: form.getValues,
82
82
  unregister: form.unregister,
83
- componentRegistry: componentRegistry
83
+ componentRegistry: componentRegistry,
84
+ setError: form.setError
84
85
  };
85
86
  return /*#__PURE__*/_react["default"].createElement(_FormContext.FormContext.Provider, {
86
87
  value: ctx
@@ -56,7 +56,8 @@ export var FormBase = /*#__PURE__*/React.forwardRef(function FormBase(_ref, ref)
56
56
  clearErrors: form.clearErrors,
57
57
  getValues: form.getValues,
58
58
  unregister: form.unregister,
59
- componentRegistry: componentRegistry
59
+ componentRegistry: componentRegistry,
60
+ setError: form.setError
60
61
  };
61
62
  return /*#__PURE__*/React.createElement(FormContext.Provider, {
62
63
  value: ctx
@@ -123,9 +123,10 @@ export var DateInput = function DateInput(_ref2) {
123
123
  value: date.day,
124
124
  width: 2,
125
125
  name: "".concat(name, "-day"),
126
- maxlength: "2",
126
+ maxLength: "2",
127
127
  disabled: props.disabled,
128
- "aria-required": props['aria-required']
128
+ "aria-required": props['aria-required'],
129
+ error: !date.day ? props.error : false
129
130
  }), /*#__PURE__*/React.createElement(DatePart, {
130
131
  label: t('form.label.month'),
131
132
  onChange: date.setMonth,
@@ -135,18 +136,20 @@ export var DateInput = function DateInput(_ref2) {
135
136
  value: date.month,
136
137
  width: 2,
137
138
  name: "".concat(props.name, "-month"),
138
- maxlength: "2",
139
+ maxLength: "2",
139
140
  disabled: props.disabled,
140
- "aria-required": props['aria-required']
141
+ "aria-required": props['aria-required'],
142
+ error: !date.month ? props.error : false
141
143
  }), /*#__PURE__*/React.createElement(DatePart, {
142
144
  label: t('form.label.year'),
143
145
  onChange: date.setYear,
144
146
  value: date.year,
145
147
  width: 4,
146
148
  name: "".concat(props.name, "-year"),
147
- maxlength: "4",
149
+ maxLength: "4",
148
150
  disabled: props.disabled,
149
- "aria-required": props['aria-required']
151
+ "aria-required": props['aria-required'],
152
+ error: !date.year ? props.error : false
150
153
  }));
151
154
  };
152
155
  export default DateInput;
@@ -160,7 +160,8 @@ export var OtpInput = function OtpInput(_ref2) {
160
160
  return otp.inputOnKeyDown(e, idx);
161
161
  },
162
162
  onFocus: otp.inputOnFocus,
163
- onPaste: otp.handleOnPaste
163
+ onPaste: otp.handleOnPaste,
164
+ error: !digit ? props.error : false
164
165
  });
165
166
  }));
166
167
  };
@@ -56,7 +56,8 @@ export var FormBase = /*#__PURE__*/React.forwardRef(function FormBase(_ref, ref)
56
56
  clearErrors: form.clearErrors,
57
57
  getValues: form.getValues,
58
58
  unregister: form.unregister,
59
- componentRegistry: componentRegistry
59
+ componentRegistry: componentRegistry,
60
+ setError: form.setError
60
61
  };
61
62
  return /*#__PURE__*/React.createElement(FormContext.Provider, {
62
63
  value: ctx
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Digigov v0.11.0
1
+ /** @license Digigov v0.11.1
2
2
  *
3
3
  * This source code is licensed under the BSD-2-Clause license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -123,9 +123,10 @@ export var DateInput = function DateInput(_ref2) {
123
123
  value: date.day,
124
124
  width: 2,
125
125
  name: "".concat(name, "-day"),
126
- maxlength: "2",
126
+ maxLength: "2",
127
127
  disabled: props.disabled,
128
- "aria-required": props['aria-required']
128
+ "aria-required": props['aria-required'],
129
+ error: !date.day ? props.error : false
129
130
  }), /*#__PURE__*/React.createElement(DatePart, {
130
131
  label: t('form.label.month'),
131
132
  onChange: date.setMonth,
@@ -135,18 +136,20 @@ export var DateInput = function DateInput(_ref2) {
135
136
  value: date.month,
136
137
  width: 2,
137
138
  name: "".concat(props.name, "-month"),
138
- maxlength: "2",
139
+ maxLength: "2",
139
140
  disabled: props.disabled,
140
- "aria-required": props['aria-required']
141
+ "aria-required": props['aria-required'],
142
+ error: !date.month ? props.error : false
141
143
  }), /*#__PURE__*/React.createElement(DatePart, {
142
144
  label: t('form.label.year'),
143
145
  onChange: date.setYear,
144
146
  value: date.year,
145
147
  width: 4,
146
148
  name: "".concat(props.name, "-year"),
147
- maxlength: "4",
149
+ maxLength: "4",
148
150
  disabled: props.disabled,
149
- "aria-required": props['aria-required']
151
+ "aria-required": props['aria-required'],
152
+ error: !date.year ? props.error : false
150
153
  }));
151
154
  };
152
155
  export default DateInput;
@@ -160,7 +160,8 @@ export var OtpInput = function OtpInput(_ref2) {
160
160
  return otp.inputOnKeyDown(e, idx);
161
161
  },
162
162
  onFocus: otp.inputOnFocus,
163
- onPaste: otp.handleOnPaste
163
+ onPaste: otp.handleOnPaste,
164
+ error: !digit ? props.error : false
164
165
  });
165
166
  }));
166
167
  };
@@ -146,9 +146,10 @@ var DateInput = function DateInput(_ref2) {
146
146
  value: date.day,
147
147
  width: 2,
148
148
  name: "".concat(name, "-day"),
149
- maxlength: "2",
149
+ maxLength: "2",
150
150
  disabled: props.disabled,
151
- "aria-required": props['aria-required']
151
+ "aria-required": props['aria-required'],
152
+ error: !date.day ? props.error : false
152
153
  }), /*#__PURE__*/_react["default"].createElement(DatePart, {
153
154
  label: t('form.label.month'),
154
155
  onChange: date.setMonth,
@@ -158,18 +159,20 @@ var DateInput = function DateInput(_ref2) {
158
159
  value: date.month,
159
160
  width: 2,
160
161
  name: "".concat(props.name, "-month"),
161
- maxlength: "2",
162
+ maxLength: "2",
162
163
  disabled: props.disabled,
163
- "aria-required": props['aria-required']
164
+ "aria-required": props['aria-required'],
165
+ error: !date.month ? props.error : false
164
166
  }), /*#__PURE__*/_react["default"].createElement(DatePart, {
165
167
  label: t('form.label.year'),
166
168
  onChange: date.setYear,
167
169
  value: date.year,
168
170
  width: 4,
169
171
  name: "".concat(props.name, "-year"),
170
- maxlength: "4",
172
+ maxLength: "4",
171
173
  disabled: props.disabled,
172
- "aria-required": props['aria-required']
174
+ "aria-required": props['aria-required'],
175
+ error: !date.year ? props.error : false
173
176
  }));
174
177
  };
175
178
 
@@ -182,7 +182,8 @@ var OtpInput = function OtpInput(_ref2) {
182
182
  return otp.inputOnKeyDown(e, idx);
183
183
  },
184
184
  onFocus: otp.inputOnFocus,
185
- onPaste: otp.handleOnPaste
185
+ onPaste: otp.handleOnPaste,
186
+ error: !digit ? props.error : false
186
187
  });
187
188
  }));
188
189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digigov/form",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "@digigov form builder",
5
5
  "author": "GRNET Developers <devs@lists.grnet.gr>",
6
6
  "license": "BSD-2-Clause",
@@ -19,7 +19,7 @@
19
19
  "publint": "0.1.8"
20
20
  },
21
21
  "peerDependencies": {
22
- "@digigov/ui": "0.32.0",
22
+ "@digigov/ui": "0.32.1",
23
23
  "@digigov/react-core": "0.23.0",
24
24
  "@digigov/react-extensions": "0.21.2",
25
25
  "clsx": "1.1.1",
@@ -61,6 +61,7 @@ export const FormBase = React.forwardRef(function FormBase(
61
61
  getValues: form.getValues,
62
62
  unregister: form.unregister,
63
63
  componentRegistry,
64
+ setError: form.setError,
64
65
  };
65
66
  return (
66
67
  <FormContext.Provider value={ctx}>
@@ -99,9 +99,10 @@ export const DateInput = function DateInput({ name, type, ...props }) {
99
99
  value={date.day}
100
100
  width={2}
101
101
  name={`${name}-day`}
102
- maxlength="2"
102
+ maxLength="2"
103
103
  disabled={props.disabled}
104
104
  aria-required={props['aria-required']}
105
+ error={!date.day ? props.error : false}
105
106
  />
106
107
  <DatePart
107
108
  label={t('form.label.month')}
@@ -110,9 +111,10 @@ export const DateInput = function DateInput({ name, type, ...props }) {
110
111
  value={date.month}
111
112
  width={2}
112
113
  name={`${props.name}-month`}
113
- maxlength="2"
114
+ maxLength="2"
114
115
  disabled={props.disabled}
115
116
  aria-required={props['aria-required']}
117
+ error={!date.month ? props.error : false}
116
118
  />
117
119
  <DatePart
118
120
  label={t('form.label.year')}
@@ -120,9 +122,10 @@ export const DateInput = function DateInput({ name, type, ...props }) {
120
122
  value={date.year}
121
123
  width={4}
122
124
  name={`${props.name}-year`}
123
- maxlength="4"
125
+ maxLength="4"
124
126
  disabled={props.disabled}
125
127
  aria-required={props['aria-required']}
128
+ error={!date.year ? props.error : false}
126
129
  />
127
130
  </DateInputContainer>
128
131
  );
@@ -119,6 +119,7 @@ function useOtp(onChange, maxLength) {
119
119
  },
120
120
  []
121
121
  );
122
+
122
123
  return {
123
124
  otpValues,
124
125
  inputOnChange,
@@ -134,6 +135,7 @@ const SingleCharacterInputItemPart = ({ ...props }) => {
134
135
 
135
136
  export const OtpInput = function OtpInput({ name, maxLength = 6, ...props }) {
136
137
  const otp = useOtp(props.onChange, maxLength);
138
+
137
139
  return (
138
140
  <SingleCharacterInputContainer>
139
141
  {otp.otpValues.map((digit, idx) => (
@@ -152,6 +154,7 @@ export const OtpInput = function OtpInput({ name, maxLength = 6, ...props }) {
152
154
  onKeyDown={(e) => otp.inputOnKeyDown(e, idx)}
153
155
  onFocus={otp.inputOnFocus}
154
156
  onPaste={otp.handleOnPaste}
157
+ error={!digit ? props.error : false}
155
158
  />
156
159
  ))}
157
160
  </SingleCharacterInputContainer>