@financial-times/o3-form 0.8.0 → 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 +413 -269
- package/cjs/CheckBox.d.ts +1 -1
- package/cjs/DateInput.d.ts +6 -0
- package/cjs/DateInput.js +57 -0
- package/cjs/DateInputMask.d.ts +17 -0
- package/cjs/DateInputMask.js +53 -0
- package/cjs/DateInputPicker.d.ts +6 -0
- package/cjs/DateInputPicker.js +48 -0
- package/cjs/Error-summary.d.ts +1 -1
- package/cjs/PasswordInput.d.ts +1 -1
- package/cjs/RadioButton.d.ts +1 -1
- package/cjs/SelectInput.d.ts +1 -1
- package/cjs/TextInput.d.ts +1 -1
- package/cjs/fieldComponents/Feedback.d.ts +1 -1
- package/cjs/fieldComponents/FormField.d.ts +1 -1
- package/cjs/{index-1UM0FDHf.d.ts → index-CtGGU7zN.d.ts} +6 -1
- package/cjs/index.d.ts +3 -1
- package/cjs/index.js +2 -0
- package/css/main.css +19 -2
- package/esm/CheckBox.d.ts +1 -1
- package/esm/DateInput.d.ts +6 -0
- package/esm/DateInput.js +57 -0
- package/esm/DateInputMask.d.ts +17 -0
- package/esm/DateInputMask.js +53 -0
- package/esm/DateInputPicker.d.ts +6 -0
- package/esm/DateInputPicker.js +48 -0
- package/esm/Error-summary.d.ts +1 -1
- package/esm/PasswordInput.d.ts +1 -1
- package/esm/RadioButton.d.ts +1 -1
- package/esm/SelectInput.d.ts +1 -1
- package/esm/TextInput.d.ts +1 -1
- package/esm/fieldComponents/Feedback.d.mts +1 -1
- package/esm/fieldComponents/FormField.d.mts +1 -1
- package/esm/{index-1UM0FDHf.d.ts → index-CtGGU7zN.d.ts} +6 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.js +2 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -4,14 +4,15 @@ Provides components to construct forms.
|
|
|
4
4
|
|
|
5
5
|
- [Overview](#overview)
|
|
6
6
|
- [Components](#components)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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`
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
Form,
|
|
109
|
+
TitledFormField,
|
|
110
|
+
LabeledFormField,
|
|
111
|
+
CheckBoxItem,
|
|
101
112
|
} from '@financial-times/o3-form/cjs'; // or esm
|
|
102
113
|
|
|
103
114
|
<Form>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
183
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
208
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
241
|
-
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
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
|
-
|
|
319
|
-
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
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[] | |
|
|
@@ -460,38 +482,39 @@ A dropdown select input for choosing one option from a list.
|
|
|
460
482
|
**HTML**
|
|
461
483
|
|
|
462
484
|
```html
|
|
485
|
+
|
|
463
486
|
<div class="o3-form-field">
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
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
|
+
>
|
|
474
497
|
Printed on the front side of your payment card.
|
|
475
498
|
</span>
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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>
|
|
495
518
|
</div>
|
|
496
519
|
```
|
|
497
520
|
|
|
@@ -501,14 +524,14 @@ A dropdown select input for choosing one option from a list.
|
|
|
501
524
|
import {SelectInput} from '@financial-times/o3-form';
|
|
502
525
|
|
|
503
526
|
<SelectInput
|
|
504
|
-
|
|
505
|
-
|
|
527
|
+
label="Card type"
|
|
528
|
+
description="Printed on the front side of your payment card."
|
|
506
529
|
>
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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>
|
|
512
535
|
</SelectInput>
|
|
513
536
|
```
|
|
514
537
|
|
|
@@ -517,32 +540,33 @@ import {SelectInput} from '@financial-times/o3-form';
|
|
|
517
540
|
Select input supports width control for shorter inputs:
|
|
518
541
|
|
|
519
542
|
```html
|
|
543
|
+
|
|
520
544
|
<div class="o3-form-field">
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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>
|
|
546
570
|
</div>
|
|
547
571
|
```
|
|
548
572
|
|
|
@@ -552,18 +576,138 @@ Select input supports width control for shorter inputs:
|
|
|
552
576
|
import {SelectInput} from '@financial-times/o3-form';
|
|
553
577
|
|
|
554
578
|
<SelectInput
|
|
555
|
-
|
|
556
|
-
|
|
579
|
+
label="Title"
|
|
580
|
+
length="3"
|
|
557
581
|
>
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
582
|
+
<option value="Mr">Mr</option>
|
|
583
|
+
<option value="Mrs">Mrs</option>
|
|
584
|
+
<option value="Mx>">Mx</option>
|
|
561
585
|
</SelectInput>
|
|
562
586
|
```
|
|
563
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
|
+
|
|
564
705
|
## Contact
|
|
565
706
|
|
|
566
|
-
If you have any questions or comments about this component, or need help using it, please
|
|
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).
|
|
567
711
|
|
|
568
712
|
---
|
|
569
713
|
|