@financial-times/o3-form 0.7.3 → 0.9.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/README.md CHANGED
@@ -4,14 +4,15 @@ Provides components to construct forms.
4
4
 
5
5
  - [Overview](#overview)
6
6
  - [Components](#components)
7
- - [Form](#form)
8
- - [Form Field, Form Fieldset and Feedback](#form-field-form-fieldset-and-feedback)
9
- - [Text Input](#text-input)
10
- - [Short text input](#short-text-input)
11
- - [Password Input](#password-input)
12
- - [Checkbox](#checkbox)
13
- - [Checkbox Group](#checkbox-group)
14
- - [Select Input](#select-input)
7
+ - [Form](#form)
8
+ - [Form Field, Form Fieldset and Feedback](#form-field-form-fieldset-and-feedback)
9
+ - [Text Input](#text-input)
10
+ - [Short text input](#short-text-input)
11
+ - [Password Input](#password-input)
12
+ - [Checkbox](#checkbox)
13
+ - [Checkbox Group](#checkbox-group)
14
+ - [Select Input](#select-input)
15
+ - [Date Input](#date-input)
15
16
  - [Contact](#contact)
16
17
  - [Licence](#licence)
17
18
 
@@ -26,8 +27,9 @@ o3-form provides UI form elements with consistent labelling, descriptions, and e
26
27
  Form is the top-level component that wraps all form elements. It can be used as plain HTML:
27
28
 
28
29
  ```html
30
+
29
31
  <form class="o3-form">
30
- <!-- form elements go here -->
32
+ <!-- form elements go here -->
31
33
  </form>
32
34
  ```
33
35
 
@@ -37,88 +39,97 @@ Or users can also import JSX components:
37
39
  import {Form} from '@financial-times/o3-form/cjs'; // or esm
38
40
 
39
41
  <Form>
40
- <!-- form elements go here -->
42
+ <!-- form elements go here -->
41
43
  </Form>;
42
44
  ```
43
45
 
44
46
  | Prop | Description | required | Type | Default |
45
- | ---------- | -------------------------------- | -------- | ---- | ------- |
47
+ |------------|----------------------------------|----------|------|---------|
46
48
  | `children` | The form elements to be rendered | true | any | - |
47
49
 
48
50
  ### Form Field, Form Fieldset and Feedback
49
51
 
50
- Form Field components can be complex and contain multiple elements. Form Field and Form Fieldset are containers for form elements. Shared anatomy of Form Field and Form Fieldset looks like composition of the following elements:
52
+ Form Field components can be complex and contain multiple elements. Form Field and Form Fieldset are containers for form
53
+ elements. Shared anatomy of Form Field and Form Fieldset looks like composition of the following elements:
51
54
 
52
55
  ```html
56
+
53
57
  <form>
54
- <form-field-element>
55
- <title-label-element>
56
- Title/Label
57
- </title-label-element>
58
- <description-element>
59
- Description
60
- </description-element>
61
- <!-- form elements go here -->
62
- <feedback-element>
63
- Feedback
64
- </feedback-element>
65
- </form-field>
58
+ <form-field-element>
59
+ <title-label-element>
60
+ Title/Label
61
+ </title-label-element>
62
+ <description-element>
63
+ Description
64
+ </description-element>
65
+ <!-- form elements go here -->
66
+ <feedback-element>
67
+ Feedback
68
+ </feedback-element>
69
+ </form-field>
66
70
  </form>
67
71
  ```
68
72
 
69
- We are using Title and Label interchangeably. But we export two JSX components from `o3-form` package: `TitledFormField` and `LabeledFormField`. Both components are similar but `TitledFormField` is used with checkboxes, radio buttons and use-cases when `<label>` element needs to be part of form element or more flexibility is require. `LabeledFormField` is used with other text inputs.
73
+ We are using Title and Label interchangeably. But we export two JSX components from `o3-form` package: `TitledFormField`
74
+ and `LabeledFormField`. Both components are similar but `TitledFormField` is used with checkboxes, radio buttons and
75
+ use-cases when `<label>` element needs to be part of form element or more flexibility is require. `LabeledFormField` is
76
+ used with other text inputs.
70
77
 
71
78
  The main difference between them is HTML they output. `TitledFormField` outputs:
72
79
 
73
80
  ```html
81
+
74
82
  <div className="o3-form-field">
75
- <span className="o3-form-field__title" id="{labelId}"> Title </span>
76
- <!--- Description -->
77
- {children}
78
- <!--- Feedback --->
83
+ <span className="o3-form-field__title" id="{labelId}"> Title </span>
84
+ <!--- Description -->
85
+ {children}
86
+ <!--- Feedback --->
79
87
  </div>
80
88
  ```
81
89
 
82
90
  And `LabeledFormField` outputs:
83
91
 
84
92
  ```html
93
+
85
94
  <div className="o3-form-field">
86
- <label className="o3-form-field__label" htmlFor="{id}"> label </label>
87
- <!--- Description -->
88
- {children}
89
- <!--- Feedback --->
95
+ <label className="o3-form-field__label" htmlFor="{id}"> label </label>
96
+ <!--- Description -->
97
+ {children}
98
+ <!--- Feedback --->
90
99
  </div>
91
100
  ```
92
101
 
93
- `TitleFormField` expects children to contain both `<input>` and `<label>` elements, which helps us a lot with checkboxes and radio buttons. `LabeledFormField` expects children to contain only `<input>` element. Two components in JSX can be used as follows:
102
+ `TitleFormField` expects children to contain both `<input>` and `<label>` elements, which helps us a lot with checkboxes
103
+ and radio buttons. `LabeledFormField` expects children to contain only `<input>` element. Two components in JSX can be
104
+ used as follows:
94
105
 
95
106
  ```tsx
96
107
  import {
97
- Form,
98
- TitledFormField,
99
- LabeledFormField,
100
- CheckBoxItem,
108
+ Form,
109
+ TitledFormField,
110
+ LabeledFormField,
111
+ CheckBoxItem,
101
112
  } from '@financial-times/o3-form/cjs'; // or esm
102
113
 
103
114
  <Form>
104
- <TitledFormField label="Title for checkbox" description="Description">
105
- <input type="checkbox" id={inputId} />
106
- <label htmlFor={inputId}>Checkbox Label</label>
107
- </TitledFormField>
108
-
109
- <LabeledFormField
110
- label="Label for text input"
111
- description="Description"
112
- inputId={inputId}>
113
- <input type="text" id={inputId} />
114
- </LabeledFormField>
115
+ <TitledFormField label="Title for checkbox" description="Description">
116
+ <input type="checkbox" id={inputId} />
117
+ <label htmlFor={inputId}>Checkbox Label</label>
118
+ </TitledFormField>
119
+
120
+ <LabeledFormField
121
+ label="Label for text input"
122
+ description="Description"
123
+ inputId={inputId}>
124
+ <input type="text" id={inputId} />
125
+ </LabeledFormField>
115
126
  </Form>;
116
127
  ```
117
128
 
118
129
  Form Field and Form Fieldset components have same props:
119
130
 
120
131
  | Prop | Description | required | Type | Default |
121
- | ------------- | -------------------------------------------------------------------------------------------------- | -------- | ------ | ------- |
132
+ |---------------|----------------------------------------------------------------------------------------------------|----------|--------|---------|
122
133
  | `label` | The label for the form fieldset | true | string | - |
123
134
  | `inputId` | The id of the form input element | false | string | - |
124
135
  | `description` | A description of the form fieldset | false | string | - |
@@ -128,18 +139,19 @@ Form Field and Form Fieldset components have same props:
128
139
  Form Fieldset is used to group related form elements together such as checkboxes. They can be used as plain HTML:
129
140
 
130
141
  ```html
142
+
131
143
  <form class="o3-form">
132
- <div class="o3-form-field">
133
- <fieldset className="o3-form-field" aria-describedby="descriptionId">
134
- <legend className="o3-form-field__legend ">
135
- Field group label/title
136
- </legend>
137
- <span className="o3-form-input__description" id="descriptionId">
144
+ <div class="o3-form-field">
145
+ <fieldset className="o3-form-field" aria-describedby="descriptionId">
146
+ <legend className="o3-form-field__legend ">
147
+ Field group label/title
148
+ </legend>
149
+ <span className="o3-form-input__description" id="descriptionId">
138
150
  description of the field group
139
151
  </span>
140
- <!-- form elements go here -->
141
- </fieldset>
142
- </div>
152
+ <!-- form elements go here -->
153
+ </fieldset>
154
+ </div>
143
155
  </form>
144
156
  ```
145
157
 
@@ -149,14 +161,14 @@ Or users can also import JSX components:
149
161
  import {Form, FormFieldset} from '@financial-times/o3-form/cjs'; // or esm
150
162
 
151
163
  <Form>
152
- <FormFieldset label="Field group label/title" description="description of the field group">
153
- <!-- form elements go here -->
154
- </FormFieldset>
164
+ <FormFieldset label="Field group label/title" description="description of the field group">
165
+ <!-- form elements go here -->
166
+ </FormFieldset>
155
167
  </Form>;
156
168
  ```
157
169
 
158
170
  | Prop | Description | required | Type | Default |
159
- | ------------- | -------------------------------------------------------------------------------------------------- | -------- | ------ | ------- |
171
+ |---------------|----------------------------------------------------------------------------------------------------|----------|--------|---------|
160
172
  | `label` | The label for the form fieldset | true | string | - |
161
173
  | `description` | A description of the form fieldset | false | string | - |
162
174
  | `children` | The form elements to be rendered | true | any | - |
@@ -171,16 +183,17 @@ description: 'Your full name as printed on your driving license',
171
183
  **HTML**
172
184
 
173
185
  ```html
186
+
174
187
  <div data-o3-brand="whitelabel">
175
- <div class="o3-form-field">
176
- <label for="my-input-field">Full name</label>
177
- <span
178
- class="o3-form-input-description"
179
- >
188
+ <div class="o3-form-field">
189
+ <label for="my-input-field">Full name</label>
190
+ <span
191
+ class="o3-form-input-description"
192
+ >
180
193
  Your full name as printed on your driving license
181
194
  </span>
182
- <input id="my-input-field" class="o3-form o3-form-text-input" type="text" />
183
- </div>
195
+ <input id="my-input-field" class="o3-form o3-form-text-input" type="text" />
196
+ </div>
184
197
  </div>
185
198
  ```
186
199
 
@@ -190,9 +203,9 @@ description: 'Your full name as printed on your driving license',
190
203
  import {TextInput} from '@financial-times/o3-form/cjs'; // or esm
191
204
 
192
205
  <TextInput
193
- label="Full name"
194
- disabled="{false}"
195
- description="Your full name as printed on your driving license"
206
+ label="Full name"
207
+ disabled="{false}"
208
+ description="Your full name as printed on your driving license"
196
209
  />
197
210
  ```
198
211
 
@@ -203,17 +216,18 @@ The size and max length of the text input can be limited with the `length` prope
203
216
  **HTML**
204
217
 
205
218
  ```html
219
+
206
220
  <div class="o3-form-field">
207
- <label for="my-input-field">Security Code</label>
208
- <span class="o3-form-input-description">
221
+ <label for="my-input-field">Security Code</label>
222
+ <span class="o3-form-input-description">
209
223
  3 digit security code as printed on the back of your credit card.
210
224
  </span>
211
- <input
212
- id="my-input-field"
213
- class="o3-form o3-form-text-input o3-form-text-input--short-3"
214
- maxlength="3"
215
- type="text"
216
- />
225
+ <input
226
+ id="my-input-field"
227
+ class="o3-form o3-form-text-input o3-form-text-input--short-3"
228
+ maxlength="3"
229
+ type="text"
230
+ />
217
231
  </div>
218
232
  ```
219
233
 
@@ -223,9 +237,9 @@ The size and max length of the text input can be limited with the `length` prope
223
237
  import {TextInput} from '@financial-times/o3-form/cjs'; // or esm
224
238
 
225
239
  <TextInput
226
- label="Security code"
227
- description="3 digit security code as printed on the back of your credit card."
228
- length="{3}"
240
+ label="Security code"
241
+ description="3 digit security code as printed on the back of your credit card."
242
+ length="{3}"
229
243
  />;
230
244
  ```
231
245
 
@@ -236,17 +250,18 @@ If you prefer to limit the length without styling, use the `maxLength` attribute
236
250
  **HTML**
237
251
 
238
252
  ```html
253
+
239
254
  <div class="o3-form-field">
240
- <label for="my-input-field">Security Code</label>
241
- <span class="o3-form-input-description">
255
+ <label for="my-input-field">Security Code</label>
256
+ <span class="o3-form-input-description">
242
257
  3 digit security code as printed on the back of your credit card.
243
258
  </span>
244
- <input
245
- id="my-input-field"
246
- class="o3-form o3-form-text-input"
247
- maxlength="3"
248
- type="text"
249
- />
259
+ <input
260
+ id="my-input-field"
261
+ class="o3-form o3-form-text-input"
262
+ maxlength="3"
263
+ type="text"
264
+ />
250
265
  </div>
251
266
  ```
252
267
 
@@ -256,12 +271,12 @@ If you prefer to limit the length without styling, use the `maxLength` attribute
256
271
  import {TextInput} from '@financial-times/o3-form/cjs'; // or esm
257
272
 
258
273
  <TextInput
259
- label="Security code"
260
- description="3 digit security code as printed on the back of your credit card."
261
- feedback={args.feedback}
262
- attributes={{
263
- maxLength: 3,
264
- }}
274
+ label="Security code"
275
+ description="3 digit security code as printed on the back of your credit card."
276
+ feedback={args.feedback}
277
+ attributes={{
278
+ maxLength: 3,
279
+ }}
265
280
  />
266
281
  ```
267
282
 
@@ -270,42 +285,44 @@ import {TextInput} from '@financial-times/o3-form/cjs'; // or esm
270
285
  A password input for collecting password values. Features a show/hide password toggle and a forgot password link.
271
286
 
272
287
  **HTML**
288
+
273
289
  ```html
290
+
274
291
  <div class="o3-form-field">
275
- <label
276
- class="o3-form-field__label"
277
- for="o3-form-password-input-_5538262633951523"
278
- >
279
- Password
280
- </label>
281
- <span
282
- class="o3-form-input__description"
283
- id="o3-form-description_5812824517374977"
284
- >
292
+ <label
293
+ class="o3-form-field__label"
294
+ for="o3-form-password-input-_5538262633951523"
295
+ >
296
+ Password
297
+ </label>
298
+ <span
299
+ class="o3-form-input__description"
300
+ id="o3-form-description_5812824517374977"
301
+ >
285
302
  Your password must be at least 8 characters.
286
303
  </span>
287
- <div class="o3-password-input__container">
288
- <input
289
- id="o3-form-password-input-_5538262633951523"
290
- class="o3-form o3-form-text-input o3-form-text-input--password"
291
- required=""
292
- type="password"
293
- aria-required="true"
294
- />
295
- <button
296
- id="o3-form-password-toggle"
297
- class="o3-password-input__show-password-toggle o3-password-input__show-password-toggle--show"
298
- aria-label="Show password"
299
- title="Show password"
300
- aria-pressed="false"
301
- ></button>
302
- </div>
303
- <div class="o3-form-feedback o3-form-feedback__undefined">
304
- <span class="o3-form-feedback__undefined-message"></span>
305
- </div>
304
+ <div class="o3-password-input__container">
305
+ <input
306
+ id="o3-form-password-input-_5538262633951523"
307
+ class="o3-form o3-form-text-input o3-form-text-input--password"
308
+ required=""
309
+ type="password"
310
+ aria-required="true"
311
+ />
312
+ <button
313
+ id="o3-form-password-toggle"
314
+ class="o3-password-input__show-password-toggle o3-password-input__show-password-toggle--show"
315
+ aria-label="Show password"
316
+ title="Show password"
317
+ aria-pressed="false"
318
+ ></button>
319
+ </div>
320
+ <div class="o3-form-feedback o3-form-feedback__undefined">
321
+ <span class="o3-form-feedback__undefined-message"></span>
322
+ </div>
306
323
  </div>
307
324
  <div class="o3-password-input__controls">
308
- <a class="o3-typography-link" href="#">Forgot password?</a>
325
+ <a class="o3-typography-link" href="#">Forgot password?</a>
309
326
  </div>
310
327
  ```
311
328
 
@@ -314,10 +331,10 @@ Be sure to include Javascript to enable the password toggle feature.
314
331
  ```javascript
315
332
  import PasswordInput from '@financial-times/o3-form/cjs/PasswordInput';
316
333
 
317
- document.addEventListener('DOMContentLoaded', function () {
318
- const passwordInput = new PasswordInput(
319
- document.getElementById('o3-form-password-toggle')
320
- );
334
+ document.addEventListener('DOMContentLoaded', function() {
335
+ const passwordInput = new PasswordInput(
336
+ document.getElementById('o3-form-password-toggle')
337
+ );
321
338
  });
322
339
  ```
323
340
 
@@ -325,41 +342,45 @@ document.addEventListener('DOMContentLoaded', function () {
325
342
  import {PasswordInput} from '@financial-times/o3-form';
326
343
 
327
344
  <Form>
328
- <PasswordInput
329
- label="Password"
330
- description="Your password must be at least 8 characters."
331
- forgotPasswordLink="#" />
345
+ <PasswordInput
346
+ label="Password"
347
+ description="Your password must be at least 8 characters."
348
+ forgotPasswordLink="#" />
332
349
  </Form>
333
350
  ```
334
351
 
335
352
  ### Checkbox
336
353
 
337
- A customizable and accessible checkbox input for selecting one or more items from a list, or turning an item on or off. Checkbox can also have a state of `indeterminate` and `o3-form` provides styling, for `indeterminate` state but this state can only be set using javaScript. Read more about [indeterminate state](https://css-tricks.com/indeterminate-checkboxes/).
354
+ A customizable and accessible checkbox input for selecting one or more items from a list, or turning an item on or off.
355
+ Checkbox can also have a state of `indeterminate` and `o3-form` provides styling, for `indeterminate` state but this
356
+ state can only be set using javaScript. Read more
357
+ about [indeterminate state](https://css-tricks.com/indeterminate-checkboxes/).
338
358
 
339
359
  Checkboxes can be used as plain HTML:
340
360
 
341
361
  ```html
362
+
342
363
  <form class="o3-form">
343
- <div class="o3-form-field">
364
+ <div class="o3-form-field">
344
365
  <span class="o3-form-field__title" id="o3-form-label_Demo_ID">
345
366
  Check this box
346
367
  </span>
347
- <span class="o3-form-input__description" id="o3-form-description_DEMO_ID">
368
+ <span class="o3-form-input__description" id="o3-form-description_DEMO_ID">
348
369
  Please check the box to continue
349
370
  </span>
350
- <div class="o3-form-input__checkbox">
351
- <input
352
- type="checkbox"
353
- id="checkbox_1"
354
- class="o3-form-input__checkbox-input o3-visually-hidden"
355
- required=""
356
- aria-required="true"
357
- />
358
- <label for="checkbox_1" class="o3-form-input__checkbox-label">
359
- I agree to the terms and conditions
360
- </label>
361
- </div>
362
- </div>
371
+ <div class="o3-form-input__checkbox">
372
+ <input
373
+ type="checkbox"
374
+ id="checkbox_1"
375
+ class="o3-form-input__checkbox-input o3-visually-hidden"
376
+ required=""
377
+ aria-required="true"
378
+ />
379
+ <label for="checkbox_1" class="o3-form-input__checkbox-label">
380
+ I agree to the terms and conditions
381
+ </label>
382
+ </div>
383
+ </div>
363
384
  </form>
364
385
  ```
365
386
 
@@ -369,17 +390,17 @@ Or users can also import JSX components:
369
390
  import {CheckBox, TitledFormField} from '@financial-times/o3-form/cjs'; // or esm
370
391
 
371
392
  <TitledFormField>
372
- <CheckBox
373
- inputId="terms"
374
- checkboxLabel="I agree to the terms and conditions"
375
- optional={false}
376
- />
377
- ;
393
+ <CheckBox
394
+ inputId="terms"
395
+ checkboxLabel="I agree to the terms and conditions"
396
+ optional={false}
397
+ />
398
+ ;
378
399
  </TitledFormField>;
379
400
  ```
380
401
 
381
402
  | Prop | Description | required | Type | Default |
382
- | --------------- | --------------------------------------------------------------------------------------------- | -------- | ------- | ------- |
403
+ |-----------------|-----------------------------------------------------------------------------------------------|----------|---------|---------|
383
404
  | `inputId` | The id of the checkbox input | true | string | - |
384
405
  | `checkboxLabel` | The label for the checkbox | true | string | - |
385
406
  | `feedback` | The feedback object for the checkbox that contains `message` and `type` of message properties | false | string | - |
@@ -392,46 +413,47 @@ import {CheckBox, TitledFormField} from '@financial-times/o3-form/cjs'; // or es
392
413
  For multiple related checkboxes, use the CheckBoxGroup component:
393
414
 
394
415
  ```html
416
+
395
417
  <form class="o3-form">
396
- <fieldset
397
- class="o3-form-field"
398
- aria-describedby="o3-form-Interest-description"
399
- >
400
- <legend class="o3-form-field__legend">Select your interests</legend>
401
- <span class="o3-form-input__description" id="o3-form-Interest-description2">
418
+ <fieldset
419
+ class="o3-form-field"
420
+ aria-describedby="o3-form-Interest-description"
421
+ >
422
+ <legend class="o3-form-field__legend">Select your interests</legend>
423
+ <span class="o3-form-input__description" id="o3-form-Interest-description2">
402
424
  Choose all interests that apply
403
425
  </span>
404
- <div class="o3-form-input__checkbox">
405
- <input
406
- type="checkbox"
407
- id="interest-tech"
408
- class="o3-form-input__checkbox-input o3-visually-hidden"
409
- />
410
- <label for="interest-tech" class="o3-form-input__checkbox-label">
411
- Technology
412
- </label>
413
- </div>
414
- <div class="o3-form-input__checkbox">
415
- <input
416
- type="checkbox"
417
- id="interest-finance"
418
- class="o3-form-input__checkbox-input o3-visually-hidden"
419
- />
420
- <label for="interest-finance" class="o3-form-input__checkbox-label">
421
- Finance
422
- </label>
423
- </div>
424
- <div class="o3-form-input__checkbox">
425
- <input
426
- type="checkbox"
427
- id="interest-sports"
428
- class="o3-form-input__checkbox-input o3-visually-hidden"
429
- />
430
- <label for="interest-sports" class="o3-form-input__checkbox-label">
431
- Sports
432
- </label>
433
- </div>
434
- </fieldset>
426
+ <div class="o3-form-input__checkbox">
427
+ <input
428
+ type="checkbox"
429
+ id="interest-tech"
430
+ class="o3-form-input__checkbox-input o3-visually-hidden"
431
+ />
432
+ <label for="interest-tech" class="o3-form-input__checkbox-label">
433
+ Technology
434
+ </label>
435
+ </div>
436
+ <div class="o3-form-input__checkbox">
437
+ <input
438
+ type="checkbox"
439
+ id="interest-finance"
440
+ class="o3-form-input__checkbox-input o3-visually-hidden"
441
+ />
442
+ <label for="interest-finance" class="o3-form-input__checkbox-label">
443
+ Finance
444
+ </label>
445
+ </div>
446
+ <div class="o3-form-input__checkbox">
447
+ <input
448
+ type="checkbox"
449
+ id="interest-sports"
450
+ class="o3-form-input__checkbox-input o3-visually-hidden"
451
+ />
452
+ <label for="interest-sports" class="o3-form-input__checkbox-label">
453
+ Sports
454
+ </label>
455
+ </div>
456
+ </fieldset>
435
457
  </form>
436
458
  ```
437
459
 
@@ -439,16 +461,16 @@ For multiple related checkboxes, use the CheckBoxGroup component:
439
461
  import {CheckBoxGroup, CheckBoxItem} from '@financial-times/o3-form/cjs'; // or esm
440
462
 
441
463
  <CheckBoxGroup
442
- label="Select your interests"
443
- description="Choose all that apply">
444
- <CheckBoxItem inputId="interest-tech" checkboxLabel="Technology" />
445
- <CheckBoxItem inputId="interest-finance" checkboxLabel="Finance" />
446
- <CheckBoxItem inputId="interest-sports" checkboxLabel="Sports" />
464
+ label="Select your interests"
465
+ description="Choose all that apply">
466
+ <CheckBoxItem inputId="interest-tech" checkboxLabel="Technology" />
467
+ <CheckBoxItem inputId="interest-finance" checkboxLabel="Finance" />
468
+ <CheckBoxItem inputId="interest-sports" checkboxLabel="Sports" />
447
469
  </CheckBoxGroup>;
448
470
  ```
449
471
 
450
472
  | Attribute | Description | Type | Default |
451
- | ------------- | ---------------------------------------- | ---------- | ------- |
473
+ |---------------|------------------------------------------|------------|---------|
452
474
  | `label` | The label for the group of checkboxes | string | |
453
475
  | `description` | A description of the group of checkboxes | string | |
454
476
  | `children` | The checkboxes to be rendered | CheckBox[] | |
@@ -457,60 +479,235 @@ import {CheckBoxGroup, CheckBoxItem} from '@financial-times/o3-form/cjs'; // or
457
479
 
458
480
  A dropdown select input for choosing one option from a list.
459
481
 
482
+ **HTML**
483
+
460
484
  ```html
485
+
461
486
  <div class="o3-form-field">
462
- <label
463
- class="o3-form-field__label"
464
- for="o3-form-select-input-_3564083419195512"
465
- >
466
- Card type
467
- </label>
468
- <span
469
- class="o3-form-input__description"
470
- id="o3-form-description_14471165011746046"
471
- >
487
+ <label
488
+ class="o3-form-field__label"
489
+ for="o3-form-select-input-_3564083419195512"
490
+ >
491
+ Card type
492
+ </label>
493
+ <span
494
+ class="o3-form-input__description"
495
+ id="o3-form-description_14471165011746046"
496
+ >
472
497
  Printed on the front side of your payment card.
473
498
  </span>
474
- <div class="o3-form-select-input__container">
475
- <select
476
- id="o3-form-select-input-_3564083419195512"
477
- class="o3-form o3-form-select-input"
478
- required=""
479
- aria-required="true"
480
- maxlength="0"
481
- type="select"
482
- >
483
- <option value="American Express">American Express</option>
484
- <option value="Visa Debit">Visa Debit</option>
485
- <option value="Visa Credit">Visa Credit</option>
486
- <option value="Mastercard Debit">Mastercard Debit</option>
487
- <option value="Mastercard Credit">Mastercard Credit</option>
488
- </select>
489
- </div>
490
- <div class="o3-form-feedback o3-form-feedback__undefined">
491
- <span class="o3-form-feedback__undefined-message"></span>
492
- </div>
499
+ <div class="o3-form-select-input__container">
500
+ <select
501
+ id="o3-form-select-input-_3564083419195512"
502
+ class="o3-form o3-form-select-input"
503
+ required=""
504
+ aria-required="true"
505
+ maxlength="0"
506
+ type="select"
507
+ >
508
+ <option value="American Express">American Express</option>
509
+ <option value="Visa Debit">Visa Debit</option>
510
+ <option value="Visa Credit">Visa Credit</option>
511
+ <option value="Mastercard Debit">Mastercard Debit</option>
512
+ <option value="Mastercard Credit">Mastercard Credit</option>
513
+ </select>
514
+ </div>
515
+ <div class="o3-form-feedback o3-form-feedback__undefined">
516
+ <span class="o3-form-feedback__undefined-message"></span>
517
+ </div>
493
518
  </div>
494
519
  ```
495
520
 
521
+ **TSX**
522
+
496
523
  ```tsx
497
524
  import {SelectInput} from '@financial-times/o3-form';
498
525
 
499
526
  <SelectInput
500
- label="Card type"
501
- description="Printed on the front side of your payment card."
527
+ label="Card type"
528
+ description="Printed on the front side of your payment card."
502
529
  >
503
- <option value="American Express">American Express</option>
504
- <option value="Visa Debit">Visa Debit</option>
505
- <option value="Visa Credit">Visa Credit</option>
506
- <option value="Mastercard Debit">Mastercard Debit</option>
507
- <option value="Mastercard Credit">Mastercard Credit</option>
530
+ <option value="American Express">American Express</option>
531
+ <option value="Visa Debit">Visa Debit</option>
532
+ <option value="Visa Credit">Visa Credit</option>
533
+ <option value="Mastercard Debit">Mastercard Debit</option>
534
+ <option value="Mastercard Credit">Mastercard Credit</option>
508
535
  </SelectInput>
509
536
  ```
510
537
 
538
+ #### Short Text Input
539
+
540
+ Select input supports width control for shorter inputs:
541
+
542
+ ```html
543
+
544
+ <div class="o3-form-field">
545
+ <label
546
+ class="o3-form-field__label"
547
+ for="o3-form-select-input-_3564083419195512"
548
+ >
549
+ Title
550
+ </label>
551
+ <div class="o3-form-select-input__container o3-form-select-input--short-3">
552
+ <select
553
+ id="o3-form-select-input-_3564083419195512"
554
+ class="o3-form o3-form-select-input"
555
+ required=""
556
+ aria-required="true"
557
+ maxlength="0"
558
+ type="select"
559
+ >
560
+ <option value="American Express">American Express</option>
561
+ <option value="Visa Debit">Visa Debit</option>
562
+ <option value="Visa Credit">Visa Credit</option>
563
+ <option value="Mastercard Debit">Mastercard Debit</option>
564
+ <option value="Mastercard Credit">Mastercard Credit</option>
565
+ </select>
566
+ </div>
567
+ <div class="o3-form-feedback o3-form-feedback__undefined">
568
+ <span class="o3-form-feedback__undefined-message"></span>
569
+ </div>
570
+ </div>
571
+ ```
572
+
573
+ **TSX**
574
+
575
+ ```tsx
576
+ import {SelectInput} from '@financial-times/o3-form';
577
+
578
+ <SelectInput
579
+ label="Title"
580
+ length="3"
581
+ >
582
+ <option value="Mr">Mr</option>
583
+ <option value="Mrs">Mrs</option>
584
+ <option value="Mx>">Mx</option>
585
+ </SelectInput>
586
+ ```
587
+
588
+ ### Date Input
589
+
590
+ Used for collecting date values, Origami provides two options for date input.
591
+
592
+ #### Date Picker
593
+
594
+ Makes use of the browser's native date picker. We recommend using this if you need to support core experiences.
595
+
596
+ **TSX**
597
+
598
+ ```tsx
599
+ import {DateInputPicker} from '@financial-times/o3-form';
600
+
601
+ const MyForm = () => {
602
+ <Form>
603
+ <DateInputPicker
604
+ label="Date of birth"
605
+ description="The year you were born"
606
+ />
607
+ </Form>;
608
+ };
609
+ ```
610
+
611
+ **HTML**
612
+
613
+ ```HTML
614
+ <div class="o3-form">
615
+ <div class="o3-form-field">
616
+ <label
617
+ class="o3-form-field__label"
618
+ for="o3-form-date-input"
619
+ >
620
+ Date of Birth
621
+ </label>
622
+ <span
623
+ class="o3-form-input__description"
624
+ id="o3-form-description"
625
+ >
626
+ The date you were born
627
+ </span>
628
+ <input
629
+ id="o3-form-date-input"
630
+ class="o3-form o3-form-text-input"
631
+ required=""
632
+ type="date"
633
+ aria-required="true"
634
+ pattern="[0-9]{2}/[0-9]{2}/[0-9]{4}"
635
+ />
636
+ <div class="o3-form-feedback o3-form-feedback__undefined">
637
+ <span class="o3-form-feedback__undefined-message"></span>
638
+ </div>
639
+ </div>
640
+ </div>
641
+ ```
642
+
643
+ #### Date Text Input
644
+
645
+ An input allowing users to input a date via text input only. We recommend using [Date Picker](#date-picker) if you need to support core experiences.
646
+
647
+ ```tsx
648
+ import {DateInputPicker} from '@financial-times/o3-form';
649
+
650
+ const MyForm = () => {
651
+ <Form>
652
+ <DateInput
653
+ label="Date of birth"
654
+ description="The year you were born"
655
+ />
656
+ </Form>;
657
+ };
658
+ ```
659
+
660
+ ```html
661
+ <script>
662
+ import DateInput from '@financial-times/o3-form/cjs/DateInput';
663
+
664
+ document.addEventListener('DOMContentLoaded', function() {
665
+ const dateInput = new DateInput(
666
+ document.getElementById('o3-form-date-input)
667
+ );
668
+ });
669
+ </script>
670
+ <div
671
+ class="o3-form"
672
+ style="grid-column: content-start / content-end; font-family: var(--o3-font-family-metric);"
673
+ >
674
+ <div class="o3-form-field">
675
+ <label
676
+ class="o3-form-field__label"
677
+ for="o3-form-date-input"
678
+ >
679
+ Date of Birth
680
+ </label>
681
+ <span
682
+ class="o3-form-input__description"
683
+ id="o3-form-description"
684
+ >
685
+ The date you were born
686
+ </span>
687
+ <input
688
+ id="o3-form-date-input"
689
+ class="o3-form o3-form-text-input"
690
+ required=""
691
+ type="text"
692
+ aria-required="true"
693
+ pattern="[0-9]{2}/[0-9]{2}/[0-9]{4}"
694
+ />
695
+ <div class="o3-form-feedback o3-form-feedback__undefined">
696
+ <span class="o3-form-feedback__undefined-message"></span>
697
+ </div>
698
+ </div>
699
+ </div>
700
+ </div>
701
+ ```
702
+
703
+
704
+
511
705
  ## Contact
512
706
 
513
- If you have any questions or comments about this component, or need help using it, please either [raise an issue](https://github.com/Financial-Times/o3-editorial-typography/issues), visit [#origami-support](https://financialtimes.slack.com/messages/origami-support/) or email [Origami Support](mailto:origami-support@ft.com).
707
+ If you have any questions or comments about this component, or need help using it, please
708
+ either [raise an issue](https://github.com/Financial-Times/o3-editorial-typography/issues),
709
+ visit [#origami-support](https://financialtimes.slack.com/messages/origami-support/) or
710
+ email [Origami Support](mailto:origami-support@ft.com).
514
711
 
515
712
  ---
516
713