@comicrelief/storybook 2.4.0 → 2.5.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comicrelief/storybook",
3
3
  "description": "React components to build the Comic Relief front-end experience",
4
- "version": "2.4.0",
4
+ "version": "2.5.0",
5
5
  "dependencies": {
6
6
  "@snyk/protect": "^1.1060.0",
7
7
  "@storybook/addon-info": "3",
@@ -30,6 +30,7 @@ export default {
30
30
  id: 'postConsent',
31
31
  text: 'Send me post',
32
32
  name: 'Post',
33
+ additionalFieldGroupInfo: '',
33
34
  options: [
34
35
  {
35
36
  label: 'Post',
@@ -116,7 +117,8 @@ export default {
116
117
  label: 'Phone number',
117
118
  placeholder: null,
118
119
  required: true,
119
- pattern: '^(((((\\+44)|(0044))\\s?\\d{4}|\\(?0\\d{4}\\)?)\\s?\\d{3}\\s?\\d{3})|((((\\+44)|(0044))\\s?\\d{3}|\\(?0\\d{3}\\)?)\\s?\\d{3}\\s?\\d{4})|((((\\+44)|(0044))\\s?\\d{2}|\\(?0\\d{2}\\)?)\\s?\\d{4}\\s?\\d{4}))(\\s?\\\\#(\\d{4}|\\d{3}))?$',
120
+ // For reference for the future usage, but also because I had to do some weird formatting with the escape characters, don't wanna lose it!
121
+ // pattern: '^(((((\\+44)|(0044))\\s?\\d{4}|\\(?0\\d{4}\\)?)\\s?\\d{3}\\s?\\d{3})|((((\\+44)|(0044))\\s?\\d{3}|\\(?0\\d{3}\\)?)\\s?\\d{3}\\s?\\d{4})|((((\\+44)|(0044))\\s?\\d{2}|\\(?0\\d{2}\\)?)\\s?\\d{4}\\s?\\d{4}))(\\s?\\\\#(\\d{4}|\\d{3}))?$',
120
122
  },
121
123
  ],
122
124
  },
@@ -142,7 +144,7 @@ export default {
142
144
  label: 'Mobile number',
143
145
  placeholder: null,
144
146
  required: true,
145
- pattern: '^(((((\\+44)|(0044))\\s?\\d{4}|\\(?0\\d{4}\\)?)\\s?\\d{3}\\s?\\d{3})|((((\\+44)|(0044))\\s?\\d{3}|\\(?0\\d{3}\\)?)\\s?\\d{3}\\s?\\d{4})|((((\\+44)|(0044))\\s?\\d{2}|\\(?0\\d{2}\\)?)\\s?\\d{4}\\s?\\d{4}))(\\s?\\\\#(\\d{4}|\\d{3}))?$',
147
+ // pattern: '^(((((\\+44)|(0044))\\s?\\d{4}|\\(?0\\d{4}\\)?)\\s?\\d{3}\\s?\\d{3})|((((\\+44)|(0044))\\s?\\d{3}|\\(?0\\d{3}\\)?)\\s?\\d{3}\\s?\\d{4})|((((\\+44)|(0044))\\s?\\d{2}|\\(?0\\d{2}\\)?)\\s?\\d{4}\\s?\\d{4}))(\\s?\\\\#(\\d{4}|\\d{3}))?$',
146
148
  },
147
149
  ],
148
150
  },
@@ -159,10 +159,14 @@ class MarketingConsentCheckbox extends Component {
159
159
  const bgStyle = 'form__field--background';
160
160
  const customMessage = typeof item.customMessage !== 'undefined' ? item.customMessage : null;
161
161
  const subFieldShowing = !(this.state.checkboxValidation[checkbox].isFieldsHidden);
162
+ const additionalFieldGroupInfo = typeof item.additionalFieldGroupInfo !== 'undefined' ? item.additionalFieldGroupInfo : null;
162
163
 
163
164
  return (
164
165
  <div key={item.id} className={`form__field--wrapper form__field-wrapper--checkbox form__field-wrapper--background form__field-wrapper--${item.name} ${(subFieldShowing ? 'showing' : '')}`}>
165
166
  <p className="form__fieldset--label" aria-label={`Can we contact you by ${item.name}?`}>{item.text}</p>
167
+
168
+ { additionalFieldGroupInfo && <p className="form__fieldset--additional-info">{additionalFieldGroupInfo}</p> }
169
+
166
170
  { customMessage && <p>{customMessage}</p> }
167
171
  <div id={`field-wrapper--${item.name}`} className="form__field--wrapper" >
168
172
  {
@@ -222,8 +226,8 @@ class MarketingConsentCheckbox extends Component {
222
226
  showErrorMessage={this.props.showErrorMessages}
223
227
  fieldValue={this.state.checkboxValidation[checkbox].fieldValidation[field.name]}
224
228
  value={() => this.fieldValue(checkbox, field.name)}
225
- // Only use our improved Yup-based validation for email
226
- yupValidation={field.type === 'email'}
229
+ // Only use our improved Yup-based validation for the problematic fields
230
+ yupValidation={field.type === 'email' || field.type === 'tel'}
227
231
  />
228
232
  </div>
229
233
  ))