@financial-times/o3-form 0.11.0 → 0.12.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/cjs/CheckBox.d.ts +1 -1
- package/cjs/CheckBox.js +1 -5
- package/cjs/DateInput.d.ts +1 -1
- package/cjs/DateInput.js +2 -5
- package/cjs/DateInputPicker.d.ts +1 -1
- package/cjs/DateInputPicker.js +2 -5
- package/cjs/Error-summary.d.ts +1 -1
- package/cjs/FileInput.d.ts +1 -1
- package/cjs/FileInput.js +3 -6
- package/cjs/PasswordInput.d.ts +1 -1
- package/cjs/PasswordInput.js +2 -5
- package/cjs/RadioButton.d.ts +1 -1
- package/cjs/RadioButton.js +0 -5
- package/cjs/SelectInput.d.ts +1 -1
- package/cjs/SelectInput.js +2 -5
- package/cjs/TextInput.d.ts +1 -1
- package/cjs/TextInput.js +2 -5
- package/cjs/fieldComponents/Feedback.d.ts +1 -1
- package/cjs/fieldComponents/FormField.d.ts +4 -4
- package/cjs/fieldComponents/FormField.js +10 -10
- package/cjs/{index-DupfYbgc.d.ts → index-DehCIKP7.d.ts} +7 -5
- package/cjs/index.d.ts +1 -1
- package/esm/CheckBox.d.ts +1 -1
- package/esm/CheckBox.js +1 -5
- package/esm/DateInput.d.ts +1 -1
- package/esm/DateInput.js +2 -5
- package/esm/DateInputPicker.d.ts +1 -1
- package/esm/DateInputPicker.js +2 -5
- package/esm/Error-summary.d.ts +1 -1
- package/esm/FileInput.d.ts +1 -1
- package/esm/FileInput.js +3 -6
- package/esm/PasswordInput.d.ts +1 -1
- package/esm/PasswordInput.js +2 -5
- package/esm/RadioButton.d.ts +1 -1
- package/esm/RadioButton.js +0 -5
- package/esm/SelectInput.d.ts +1 -1
- package/esm/SelectInput.js +2 -5
- package/esm/TextInput.d.ts +1 -1
- package/esm/TextInput.js +2 -5
- package/esm/fieldComponents/Feedback.d.mts +1 -1
- package/esm/fieldComponents/FormField.d.mts +4 -4
- package/esm/fieldComponents/FormField.js +10 -10
- package/esm/{index-DupfYbgc.d.ts → index-DehCIKP7.d.ts} +7 -5
- package/esm/index.d.ts +1 -1
- package/package.json +1 -2
package/cjs/CheckBox.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as CheckBoxProps, F as FormFieldsetProps } from './index-
|
|
2
|
+
import { C as CheckBoxProps, F as FormFieldsetProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const CheckBoxItem: (props: CheckBoxProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
declare const CheckBox: (props: CheckBoxProps) => react_jsx_runtime.JSX.Element;
|
package/cjs/CheckBox.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _jsxruntime = require('react/jsx-runtime');
|
|
2
2
|
var _react = require('react');
|
|
3
|
-
var _outils = require('@financial-times/o-utils');
|
|
4
3
|
var _FormField = require('./fieldComponents/FormField');
|
|
5
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-checkbox-input");
|
|
6
4
|
const CheckBoxItem = (props) => {
|
|
7
5
|
let { inputId, checkboxDescription, attributes, optional, error } = props;
|
|
8
|
-
if (!inputId) {
|
|
9
|
-
inputId = uniqueId("_");
|
|
10
|
-
}
|
|
11
6
|
const classNames = ["o3-form-input-checkbox__input", "o3-visually-hidden"];
|
|
12
7
|
if (error) {
|
|
13
8
|
classNames.push("o3-form-input-error");
|
|
@@ -34,6 +29,7 @@ const CheckBox = (props) => {
|
|
|
34
29
|
const newProps = {
|
|
35
30
|
...props,
|
|
36
31
|
labelId: props.inputId,
|
|
32
|
+
labelsElement: props.inputId,
|
|
37
33
|
descriptionId: props.inputId
|
|
38
34
|
};
|
|
39
35
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FormField.TitledFormField, { ...newProps, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
package/cjs/DateInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { D as DateInputProps } from './index-
|
|
2
|
+
import { D as DateInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const DateInput: ({ label, feedback, description, disabled, attributes, inputId, optional, }: DateInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/cjs/DateInput.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
var _outils = require('@financial-times/o-utils');
|
|
3
2
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
3
|
var _react = require('react');
|
|
5
4
|
var _DateInputMask = require('./DateInputMask');
|
|
6
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-date-input");
|
|
7
5
|
const DateInput = ({
|
|
8
6
|
label,
|
|
9
7
|
feedback,
|
|
@@ -14,7 +12,6 @@ const DateInput = ({
|
|
|
14
12
|
optional
|
|
15
13
|
}) => {
|
|
16
14
|
let inputRef = _react.useRef.call(void 0, null);
|
|
17
|
-
const id = inputId || uniqueId("_");
|
|
18
15
|
const inputClasses = [
|
|
19
16
|
"o3-form",
|
|
20
17
|
"o3-form-text-input"
|
|
@@ -33,13 +30,13 @@ const DateInput = ({
|
|
|
33
30
|
label,
|
|
34
31
|
feedback,
|
|
35
32
|
description,
|
|
36
|
-
|
|
33
|
+
labelsElement: inputId,
|
|
37
34
|
optional,
|
|
38
35
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
39
36
|
"input",
|
|
40
37
|
{
|
|
41
38
|
...attributes,
|
|
42
|
-
id,
|
|
39
|
+
id: inputId,
|
|
43
40
|
ref: inputRef,
|
|
44
41
|
disabled,
|
|
45
42
|
className: inputClasses.join(" "),
|
package/cjs/DateInputPicker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { D as DateInputProps } from './index-
|
|
2
|
+
import { D as DateInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const DateInputPicker: ({ label, feedback, description, disabled, attributes, inputId, optional, }: DateInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/cjs/DateInputPicker.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
var _outils = require('@financial-times/o-utils');
|
|
3
2
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-date-input");
|
|
5
3
|
const DateInputPicker = ({
|
|
6
4
|
label,
|
|
7
5
|
feedback,
|
|
@@ -11,7 +9,6 @@ const DateInputPicker = ({
|
|
|
11
9
|
inputId,
|
|
12
10
|
optional
|
|
13
11
|
}) => {
|
|
14
|
-
const id = inputId || uniqueId("_");
|
|
15
12
|
const inputClasses = [
|
|
16
13
|
"o3-form",
|
|
17
14
|
"o3-form-text-input"
|
|
@@ -25,13 +22,13 @@ const DateInputPicker = ({
|
|
|
25
22
|
label,
|
|
26
23
|
feedback,
|
|
27
24
|
description,
|
|
28
|
-
|
|
25
|
+
labelsElement: inputId,
|
|
29
26
|
optional,
|
|
30
27
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
31
28
|
"input",
|
|
32
29
|
{
|
|
33
30
|
...attributes,
|
|
34
|
-
id,
|
|
31
|
+
id: inputId,
|
|
35
32
|
disabled,
|
|
36
33
|
className: inputClasses.join(" "),
|
|
37
34
|
required: !optional,
|
package/cjs/Error-summary.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { E as ErrorSummaryProps } from './index-
|
|
2
|
+
import { E as ErrorSummaryProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const ErrorSummary: ({ errors, errorMessage, }: ErrorSummaryProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/cjs/FileInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as FileInputProps } from './index-
|
|
2
|
+
import { a as FileInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const FileInput: ({ label, feedback, description, disabled, attributes, inputId, optional, isUploading }: FileInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/cjs/FileInput.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
var _outils = require('@financial-times/o-utils');
|
|
3
2
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
3
|
var _react = require('react');
|
|
5
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-file-input");
|
|
6
4
|
const FileInput = ({
|
|
7
5
|
label,
|
|
8
6
|
feedback,
|
|
@@ -13,7 +11,6 @@ const FileInput = ({
|
|
|
13
11
|
optional,
|
|
14
12
|
isUploading
|
|
15
13
|
}) => {
|
|
16
|
-
const id = inputId || uniqueId("_");
|
|
17
14
|
const [file, setFile] = _react.useState.call(void 0, null);
|
|
18
15
|
const onUpload = (event) => {
|
|
19
16
|
setFile(_nullishCoalesce(_optionalChain([event, 'access', _ => _.target, 'access', _2 => _2.files, 'optionalAccess', _3 => _3[0]]), () => ( null)));
|
|
@@ -31,11 +28,11 @@ const FileInput = ({
|
|
|
31
28
|
label,
|
|
32
29
|
feedback,
|
|
33
30
|
description,
|
|
34
|
-
|
|
31
|
+
labelsElement: inputId,
|
|
35
32
|
optional,
|
|
36
33
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
37
34
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: inputClasses.join(" "), children: [
|
|
38
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { htmlFor:
|
|
35
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { htmlFor: inputId, className: "o3-form-file-input__label", children: [
|
|
39
36
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
40
37
|
"span",
|
|
41
38
|
{
|
|
@@ -56,7 +53,7 @@ const FileInput = ({
|
|
|
56
53
|
"input",
|
|
57
54
|
{
|
|
58
55
|
...attributes,
|
|
59
|
-
id,
|
|
56
|
+
id: inputId,
|
|
60
57
|
className: "o3-form-file-input__input-field",
|
|
61
58
|
disabled,
|
|
62
59
|
required: !optional,
|
package/cjs/PasswordInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { P as PasswordInputProps } from './index-
|
|
2
|
+
import { P as PasswordInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const PasswordInput: ({ label, feedback, description, disabled, attributes, inputId, optional, forgotPasswordLink, }: PasswordInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/cjs/PasswordInput.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
var _outils = require('@financial-times/o-utils');
|
|
3
2
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
3
|
var _PasswordInputToggle = require('./PasswordInputToggle');
|
|
5
4
|
var _react = require('react');
|
|
6
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-password-input");
|
|
7
5
|
const PasswordInput = ({
|
|
8
6
|
label,
|
|
9
7
|
feedback,
|
|
@@ -14,7 +12,6 @@ const PasswordInput = ({
|
|
|
14
12
|
optional,
|
|
15
13
|
forgotPasswordLink
|
|
16
14
|
}) => {
|
|
17
|
-
const id = inputId || uniqueId("_");
|
|
18
15
|
let inputRef = _react.useRef.call(void 0, null);
|
|
19
16
|
let buttonRef = _react.useRef.call(void 0, null);
|
|
20
17
|
let toggleRef = _react.useRef.call(void 0, null);
|
|
@@ -44,14 +41,14 @@ const PasswordInput = ({
|
|
|
44
41
|
label,
|
|
45
42
|
feedback,
|
|
46
43
|
description,
|
|
47
|
-
|
|
44
|
+
labelsElement: inputId,
|
|
48
45
|
optional,
|
|
49
46
|
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-password-input__container", children: [
|
|
50
47
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
51
48
|
"input",
|
|
52
49
|
{
|
|
53
50
|
...attributes,
|
|
54
|
-
id,
|
|
51
|
+
id: inputId,
|
|
55
52
|
ref: inputRef,
|
|
56
53
|
disabled,
|
|
57
54
|
"data-testid": "o3-password-input",
|
package/cjs/RadioButton.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { R as RadioButtonProps, F as FormFieldsetProps } from './index-
|
|
2
|
+
import { R as RadioButtonProps, F as FormFieldsetProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const RadioButtonItem: (props: RadioButtonProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
declare const RadioButtonGroup: (props: FormFieldsetProps) => react_jsx_runtime.JSX.Element;
|
package/cjs/RadioButton.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _jsxruntime = require('react/jsx-runtime');
|
|
2
2
|
var _react = require('react');
|
|
3
|
-
var _outils = require('@financial-times/o-utils');
|
|
4
3
|
var _FormField = require('./fieldComponents/FormField');
|
|
5
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-radio-button-input");
|
|
6
4
|
const RadioButtonItem = (props) => {
|
|
7
5
|
let { inputId, attributes, optional, error } = props;
|
|
8
|
-
if (!inputId) {
|
|
9
|
-
inputId = uniqueId("_");
|
|
10
|
-
}
|
|
11
6
|
const classNames = ["o3-form-input-radio-button", "o3-visually-hidden"];
|
|
12
7
|
if (error) {
|
|
13
8
|
classNames.push("o3-form-input-error");
|
package/cjs/SelectInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { S as SelectInputProps } from './index-
|
|
2
|
+
import { S as SelectInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const SelectInput: ({ label, feedback, description, disabled, attributes, inputId, optional, children, length, }: SelectInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/cjs/SelectInput.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
var _outils = require('@financial-times/o-utils');
|
|
3
2
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-select-input");
|
|
5
3
|
const SelectInput = ({
|
|
6
4
|
label,
|
|
7
5
|
feedback,
|
|
@@ -13,7 +11,6 @@ const SelectInput = ({
|
|
|
13
11
|
children,
|
|
14
12
|
length
|
|
15
13
|
}) => {
|
|
16
|
-
const id = inputId || uniqueId("_");
|
|
17
14
|
const inputClasses = ["o3-form", "o3-form-select-input"];
|
|
18
15
|
if (feedback && feedback.type === "error") {
|
|
19
16
|
inputClasses.push("o3-form-select-input--error");
|
|
@@ -24,7 +21,7 @@ const SelectInput = ({
|
|
|
24
21
|
label,
|
|
25
22
|
feedback,
|
|
26
23
|
description,
|
|
27
|
-
|
|
24
|
+
labelsElement: inputId,
|
|
28
25
|
optional,
|
|
29
26
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
30
27
|
"div",
|
|
@@ -34,7 +31,7 @@ const SelectInput = ({
|
|
|
34
31
|
"select",
|
|
35
32
|
{
|
|
36
33
|
...attributes,
|
|
37
|
-
id,
|
|
34
|
+
id: inputId,
|
|
38
35
|
disabled,
|
|
39
36
|
className: inputClasses.join(" "),
|
|
40
37
|
required: !optional,
|
package/cjs/TextInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { T as TextInputProps } from './index-
|
|
2
|
+
import { T as TextInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const TextInput: ({ label, feedback, description, disabled, length, attributes, inputId, optional, }: TextInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/cjs/TextInput.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
var _outils = require('@financial-times/o-utils');
|
|
3
2
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-text-input");
|
|
5
3
|
const TextInput = ({
|
|
6
4
|
label,
|
|
7
5
|
feedback,
|
|
@@ -12,7 +10,6 @@ const TextInput = ({
|
|
|
12
10
|
inputId,
|
|
13
11
|
optional
|
|
14
12
|
}) => {
|
|
15
|
-
const id = inputId || uniqueId("_");
|
|
16
13
|
const inputClasses = ["o3-form", "o3-form-text-input"];
|
|
17
14
|
if (feedback && feedback.type === "error") {
|
|
18
15
|
inputClasses.push("o3-form-text-input--error");
|
|
@@ -26,13 +23,13 @@ const TextInput = ({
|
|
|
26
23
|
label,
|
|
27
24
|
feedback,
|
|
28
25
|
description,
|
|
29
|
-
|
|
26
|
+
labelsElement: inputId,
|
|
30
27
|
optional,
|
|
31
28
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
32
29
|
"input",
|
|
33
30
|
{
|
|
34
31
|
...attributes,
|
|
35
|
-
id,
|
|
32
|
+
id: inputId,
|
|
36
33
|
disabled,
|
|
37
34
|
className: inputClasses.join(" "),
|
|
38
35
|
required: !optional,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { b as FeedbackProps } from '../index-
|
|
2
|
+
import { b as FeedbackProps } from '../index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const Feedback: ({ message, type }: FeedbackProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { c as FormFieldProps, F as FormFieldsetProps } from '../index-
|
|
2
|
+
import { c as FormFieldProps, F as FormFieldsetProps } from '../index-DehCIKP7.js';
|
|
3
3
|
|
|
4
|
-
declare const LabeledFormField: ({
|
|
5
|
-
declare const TitledFormField: ({ label, description, feedback, children, optional, }: FormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
6
|
-
declare const FormFieldset: ({ label, description, feedback, children, optional, }: FormFieldsetProps) => react_jsx_runtime.JSX.Element;
|
|
4
|
+
declare const LabeledFormField: ({ label, labelsElement, description, feedback, children, optional, }: FormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
5
|
+
declare const TitledFormField: ({ label, labelsElement, description, feedback, children, optional, }: FormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
6
|
+
declare const FormFieldset: ({ label, description, feedback, children, optional, inputId }: FormFieldsetProps) => react_jsx_runtime.JSX.Element;
|
|
7
7
|
|
|
8
8
|
export { FormFieldset, LabeledFormField, TitledFormField };
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
var _outils = require('@financial-times/o-utils');
|
|
3
2
|
var _Feedback = require('./Feedback');
|
|
4
|
-
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form");
|
|
5
3
|
const LabeledFormField = ({
|
|
6
|
-
inputId,
|
|
7
4
|
label,
|
|
5
|
+
labelsElement,
|
|
8
6
|
description,
|
|
9
7
|
feedback,
|
|
10
8
|
children,
|
|
11
9
|
optional
|
|
12
10
|
}) => {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
11
|
+
const descriptionId = description ? `description_${labelsElement}` : void 0;
|
|
12
|
+
const labelId = `label_${labelsElement}`;
|
|
15
13
|
const labelClasses = ["o3-form-field__label"];
|
|
16
14
|
if (optional) {
|
|
17
15
|
labelClasses.push("o3-form-field--optional");
|
|
18
16
|
}
|
|
19
17
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-form-field", children: [
|
|
20
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { className: labelClasses.join(" "), htmlFor:
|
|
18
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { className: labelClasses.join(" "), id: labelId, htmlFor: labelsElement, children: label }),
|
|
21
19
|
description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "o3-form-input__description", id: descriptionId, children: description }),
|
|
22
20
|
children,
|
|
23
21
|
feedback && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Feedback.Feedback, { ...feedback })
|
|
@@ -25,13 +23,14 @@ const LabeledFormField = ({
|
|
|
25
23
|
};
|
|
26
24
|
const TitledFormField = ({
|
|
27
25
|
label,
|
|
26
|
+
labelsElement,
|
|
28
27
|
description,
|
|
29
28
|
feedback,
|
|
30
29
|
children,
|
|
31
30
|
optional
|
|
32
31
|
}) => {
|
|
33
|
-
const descriptionId = description ?
|
|
34
|
-
const labelId =
|
|
32
|
+
const descriptionId = description ? `description_${labelsElement}` : void 0;
|
|
33
|
+
const labelId = `label_${labelsElement}`;
|
|
35
34
|
const labelClasses = ["o3-form-field__title"];
|
|
36
35
|
if (optional) {
|
|
37
36
|
labelClasses.push("o3-form-field--optional");
|
|
@@ -48,9 +47,10 @@ const FormFieldset = ({
|
|
|
48
47
|
description,
|
|
49
48
|
feedback,
|
|
50
49
|
children,
|
|
51
|
-
optional
|
|
50
|
+
optional,
|
|
51
|
+
inputId
|
|
52
52
|
}) => {
|
|
53
|
-
const descriptionId =
|
|
53
|
+
const descriptionId = `checkbox_${inputId}`;
|
|
54
54
|
const labelClasses = ["o3-form-field__legend"];
|
|
55
55
|
if (optional) {
|
|
56
56
|
labelClasses.push("o3-form-field--optional");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type BaseInputProps = {
|
|
2
|
-
inputId
|
|
3
|
-
label
|
|
2
|
+
inputId: string;
|
|
3
|
+
label: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
optional?: boolean;
|
|
6
6
|
error?: boolean;
|
|
@@ -25,8 +25,8 @@ interface SelectInputProps {
|
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
feedback?: FeedbackProps;
|
|
27
27
|
children?: React.JSX.Element[];
|
|
28
|
-
inputId
|
|
29
|
-
label
|
|
28
|
+
inputId: string;
|
|
29
|
+
label: string;
|
|
30
30
|
length?: 1 | 3;
|
|
31
31
|
description?: string;
|
|
32
32
|
optional?: boolean;
|
|
@@ -49,13 +49,15 @@ interface RadioButtonProps extends BaseInputProps {
|
|
|
49
49
|
radioButtonLabel: string;
|
|
50
50
|
}
|
|
51
51
|
interface FormFieldsetProps {
|
|
52
|
+
inputId: string;
|
|
52
53
|
label: string;
|
|
53
54
|
description?: string;
|
|
54
55
|
children: React.JSX.Element | React.JSX.Element[];
|
|
55
56
|
feedback?: FeedbackProps;
|
|
56
57
|
optional?: boolean;
|
|
57
58
|
}
|
|
58
|
-
interface FormFieldProps extends BaseInputProps {
|
|
59
|
+
interface FormFieldProps extends Omit<BaseInputProps, 'inputId'> {
|
|
60
|
+
labelsElement: string;
|
|
59
61
|
feedback?: FeedbackProps;
|
|
60
62
|
children: React.JSX.Element & JSX.IntrinsicElements['input'];
|
|
61
63
|
}
|
package/cjs/index.d.ts
CHANGED
package/esm/CheckBox.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { C as CheckBoxProps, F as FormFieldsetProps } from './index-
|
|
2
|
+
import { C as CheckBoxProps, F as FormFieldsetProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const CheckBoxItem: (props: CheckBoxProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
declare const CheckBox: (props: CheckBoxProps) => react_jsx_runtime.JSX.Element;
|
package/esm/CheckBox.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createElement } from "react";
|
|
3
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
4
3
|
import { TitledFormField, FormFieldset } from "./fieldComponents/FormField";
|
|
5
|
-
const uniqueId = uidBuilder("o3-form-checkbox-input");
|
|
6
4
|
const CheckBoxItem = (props) => {
|
|
7
5
|
let { inputId, checkboxDescription, attributes, optional, error } = props;
|
|
8
|
-
if (!inputId) {
|
|
9
|
-
inputId = uniqueId("_");
|
|
10
|
-
}
|
|
11
6
|
const classNames = ["o3-form-input-checkbox__input", "o3-visually-hidden"];
|
|
12
7
|
if (error) {
|
|
13
8
|
classNames.push("o3-form-input-error");
|
|
@@ -34,6 +29,7 @@ const CheckBox = (props) => {
|
|
|
34
29
|
const newProps = {
|
|
35
30
|
...props,
|
|
36
31
|
labelId: props.inputId,
|
|
32
|
+
labelsElement: props.inputId,
|
|
37
33
|
descriptionId: props.inputId
|
|
38
34
|
};
|
|
39
35
|
return /* @__PURE__ */ jsx(TitledFormField, { ...newProps, children: /* @__PURE__ */ jsx(
|
package/esm/DateInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { D as DateInputProps } from './index-
|
|
2
|
+
import { D as DateInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const DateInput: ({ label, feedback, description, disabled, attributes, inputId, optional, }: DateInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/esm/DateInput.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
3
2
|
import { LabeledFormField } from "./fieldComponents/FormField";
|
|
4
3
|
import { useEffect, useRef } from "react";
|
|
5
4
|
import { DateInputMask } from "./DateInputMask";
|
|
6
|
-
const uniqueId = uidBuilder("o3-form-date-input");
|
|
7
5
|
const DateInput = ({
|
|
8
6
|
label,
|
|
9
7
|
feedback,
|
|
@@ -14,7 +12,6 @@ const DateInput = ({
|
|
|
14
12
|
optional
|
|
15
13
|
}) => {
|
|
16
14
|
let inputRef = useRef(null);
|
|
17
|
-
const id = inputId || uniqueId("_");
|
|
18
15
|
const inputClasses = [
|
|
19
16
|
"o3-form",
|
|
20
17
|
"o3-form-text-input"
|
|
@@ -33,13 +30,13 @@ const DateInput = ({
|
|
|
33
30
|
label,
|
|
34
31
|
feedback,
|
|
35
32
|
description,
|
|
36
|
-
|
|
33
|
+
labelsElement: inputId,
|
|
37
34
|
optional,
|
|
38
35
|
children: /* @__PURE__ */ jsx(
|
|
39
36
|
"input",
|
|
40
37
|
{
|
|
41
38
|
...attributes,
|
|
42
|
-
id,
|
|
39
|
+
id: inputId,
|
|
43
40
|
ref: inputRef,
|
|
44
41
|
disabled,
|
|
45
42
|
className: inputClasses.join(" "),
|
package/esm/DateInputPicker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { D as DateInputProps } from './index-
|
|
2
|
+
import { D as DateInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const DateInputPicker: ({ label, feedback, description, disabled, attributes, inputId, optional, }: DateInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/esm/DateInputPicker.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
3
2
|
import { LabeledFormField } from "./fieldComponents/FormField";
|
|
4
|
-
const uniqueId = uidBuilder("o3-form-date-input");
|
|
5
3
|
const DateInputPicker = ({
|
|
6
4
|
label,
|
|
7
5
|
feedback,
|
|
@@ -11,7 +9,6 @@ const DateInputPicker = ({
|
|
|
11
9
|
inputId,
|
|
12
10
|
optional
|
|
13
11
|
}) => {
|
|
14
|
-
const id = inputId || uniqueId("_");
|
|
15
12
|
const inputClasses = [
|
|
16
13
|
"o3-form",
|
|
17
14
|
"o3-form-text-input"
|
|
@@ -25,13 +22,13 @@ const DateInputPicker = ({
|
|
|
25
22
|
label,
|
|
26
23
|
feedback,
|
|
27
24
|
description,
|
|
28
|
-
|
|
25
|
+
labelsElement: inputId,
|
|
29
26
|
optional,
|
|
30
27
|
children: /* @__PURE__ */ jsx(
|
|
31
28
|
"input",
|
|
32
29
|
{
|
|
33
30
|
...attributes,
|
|
34
|
-
id,
|
|
31
|
+
id: inputId,
|
|
35
32
|
disabled,
|
|
36
33
|
className: inputClasses.join(" "),
|
|
37
34
|
required: !optional,
|
package/esm/Error-summary.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { E as ErrorSummaryProps } from './index-
|
|
2
|
+
import { E as ErrorSummaryProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const ErrorSummary: ({ errors, errorMessage, }: ErrorSummaryProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/esm/FileInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as FileInputProps } from './index-
|
|
2
|
+
import { a as FileInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const FileInput: ({ label, feedback, description, disabled, attributes, inputId, optional, isUploading }: FileInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/esm/FileInput.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
3
2
|
import { LabeledFormField } from "./fieldComponents/FormField";
|
|
4
3
|
import { useState } from "react";
|
|
5
|
-
const uniqueId = uidBuilder("o3-form-file-input");
|
|
6
4
|
const FileInput = ({
|
|
7
5
|
label,
|
|
8
6
|
feedback,
|
|
@@ -13,7 +11,6 @@ const FileInput = ({
|
|
|
13
11
|
optional,
|
|
14
12
|
isUploading
|
|
15
13
|
}) => {
|
|
16
|
-
const id = inputId || uniqueId("_");
|
|
17
14
|
const [file, setFile] = useState(null);
|
|
18
15
|
const onUpload = (event) => {
|
|
19
16
|
setFile(event.target.files?.[0] ?? null);
|
|
@@ -31,11 +28,11 @@ const FileInput = ({
|
|
|
31
28
|
label,
|
|
32
29
|
feedback,
|
|
33
30
|
description,
|
|
34
|
-
|
|
31
|
+
labelsElement: inputId,
|
|
35
32
|
optional,
|
|
36
33
|
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
34
|
/* @__PURE__ */ jsxs("div", { className: inputClasses.join(" "), children: [
|
|
38
|
-
/* @__PURE__ */ jsxs("label", { htmlFor:
|
|
35
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: "o3-form-file-input__label", children: [
|
|
39
36
|
/* @__PURE__ */ jsx(
|
|
40
37
|
"span",
|
|
41
38
|
{
|
|
@@ -56,7 +53,7 @@ const FileInput = ({
|
|
|
56
53
|
"input",
|
|
57
54
|
{
|
|
58
55
|
...attributes,
|
|
59
|
-
id,
|
|
56
|
+
id: inputId,
|
|
60
57
|
className: "o3-form-file-input__input-field",
|
|
61
58
|
disabled,
|
|
62
59
|
required: !optional,
|
package/esm/PasswordInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { P as PasswordInputProps } from './index-
|
|
2
|
+
import { P as PasswordInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const PasswordInput: ({ label, feedback, description, disabled, attributes, inputId, optional, forgotPasswordLink, }: PasswordInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/esm/PasswordInput.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
3
2
|
import { LabeledFormField } from "./fieldComponents/FormField";
|
|
4
3
|
import { PasswordInputToggle as PasswordInputToggleController } from "./PasswordInputToggle";
|
|
5
4
|
import { useEffect, useRef } from "react";
|
|
6
|
-
const uniqueId = uidBuilder("o3-form-password-input");
|
|
7
5
|
const PasswordInput = ({
|
|
8
6
|
label,
|
|
9
7
|
feedback,
|
|
@@ -14,7 +12,6 @@ const PasswordInput = ({
|
|
|
14
12
|
optional,
|
|
15
13
|
forgotPasswordLink
|
|
16
14
|
}) => {
|
|
17
|
-
const id = inputId || uniqueId("_");
|
|
18
15
|
let inputRef = useRef(null);
|
|
19
16
|
let buttonRef = useRef(null);
|
|
20
17
|
let toggleRef = useRef(null);
|
|
@@ -44,14 +41,14 @@ const PasswordInput = ({
|
|
|
44
41
|
label,
|
|
45
42
|
feedback,
|
|
46
43
|
description,
|
|
47
|
-
|
|
44
|
+
labelsElement: inputId,
|
|
48
45
|
optional,
|
|
49
46
|
children: /* @__PURE__ */ jsxs("div", { className: "o3-password-input__container", children: [
|
|
50
47
|
/* @__PURE__ */ jsx(
|
|
51
48
|
"input",
|
|
52
49
|
{
|
|
53
50
|
...attributes,
|
|
54
|
-
id,
|
|
51
|
+
id: inputId,
|
|
55
52
|
ref: inputRef,
|
|
56
53
|
disabled,
|
|
57
54
|
"data-testid": "o3-password-input",
|
package/esm/RadioButton.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { R as RadioButtonProps, F as FormFieldsetProps } from './index-
|
|
2
|
+
import { R as RadioButtonProps, F as FormFieldsetProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const RadioButtonItem: (props: RadioButtonProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
declare const RadioButtonGroup: (props: FormFieldsetProps) => react_jsx_runtime.JSX.Element;
|
package/esm/RadioButton.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createElement } from "react";
|
|
3
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
4
3
|
import { FormFieldset } from "./fieldComponents/FormField";
|
|
5
|
-
const uniqueId = uidBuilder("o3-form-radio-button-input");
|
|
6
4
|
const RadioButtonItem = (props) => {
|
|
7
5
|
let { inputId, attributes, optional, error } = props;
|
|
8
|
-
if (!inputId) {
|
|
9
|
-
inputId = uniqueId("_");
|
|
10
|
-
}
|
|
11
6
|
const classNames = ["o3-form-input-radio-button", "o3-visually-hidden"];
|
|
12
7
|
if (error) {
|
|
13
8
|
classNames.push("o3-form-input-error");
|
package/esm/SelectInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { S as SelectInputProps } from './index-
|
|
2
|
+
import { S as SelectInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const SelectInput: ({ label, feedback, description, disabled, attributes, inputId, optional, children, length, }: SelectInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/esm/SelectInput.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
3
2
|
import { LabeledFormField } from "./fieldComponents/FormField";
|
|
4
|
-
const uniqueId = uidBuilder("o3-form-select-input");
|
|
5
3
|
const SelectInput = ({
|
|
6
4
|
label,
|
|
7
5
|
feedback,
|
|
@@ -13,7 +11,6 @@ const SelectInput = ({
|
|
|
13
11
|
children,
|
|
14
12
|
length
|
|
15
13
|
}) => {
|
|
16
|
-
const id = inputId || uniqueId("_");
|
|
17
14
|
const inputClasses = ["o3-form", "o3-form-select-input"];
|
|
18
15
|
if (feedback && feedback.type === "error") {
|
|
19
16
|
inputClasses.push("o3-form-select-input--error");
|
|
@@ -24,7 +21,7 @@ const SelectInput = ({
|
|
|
24
21
|
label,
|
|
25
22
|
feedback,
|
|
26
23
|
description,
|
|
27
|
-
|
|
24
|
+
labelsElement: inputId,
|
|
28
25
|
optional,
|
|
29
26
|
children: /* @__PURE__ */ jsx(
|
|
30
27
|
"div",
|
|
@@ -34,7 +31,7 @@ const SelectInput = ({
|
|
|
34
31
|
"select",
|
|
35
32
|
{
|
|
36
33
|
...attributes,
|
|
37
|
-
id,
|
|
34
|
+
id: inputId,
|
|
38
35
|
disabled,
|
|
39
36
|
className: inputClasses.join(" "),
|
|
40
37
|
required: !optional,
|
package/esm/TextInput.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { T as TextInputProps } from './index-
|
|
2
|
+
import { T as TextInputProps } from './index-DehCIKP7.js';
|
|
3
3
|
|
|
4
4
|
declare const TextInput: ({ label, feedback, description, disabled, length, attributes, inputId, optional, }: TextInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
package/esm/TextInput.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
3
2
|
import { LabeledFormField } from "./fieldComponents/FormField";
|
|
4
|
-
const uniqueId = uidBuilder("o3-form-text-input");
|
|
5
3
|
const TextInput = ({
|
|
6
4
|
label,
|
|
7
5
|
feedback,
|
|
@@ -12,7 +10,6 @@ const TextInput = ({
|
|
|
12
10
|
inputId,
|
|
13
11
|
optional
|
|
14
12
|
}) => {
|
|
15
|
-
const id = inputId || uniqueId("_");
|
|
16
13
|
const inputClasses = ["o3-form", "o3-form-text-input"];
|
|
17
14
|
if (feedback && feedback.type === "error") {
|
|
18
15
|
inputClasses.push("o3-form-text-input--error");
|
|
@@ -26,13 +23,13 @@ const TextInput = ({
|
|
|
26
23
|
label,
|
|
27
24
|
feedback,
|
|
28
25
|
description,
|
|
29
|
-
|
|
26
|
+
labelsElement: inputId,
|
|
30
27
|
optional,
|
|
31
28
|
children: /* @__PURE__ */ jsx(
|
|
32
29
|
"input",
|
|
33
30
|
{
|
|
34
31
|
...attributes,
|
|
35
|
-
id,
|
|
32
|
+
id: inputId,
|
|
36
33
|
disabled,
|
|
37
34
|
className: inputClasses.join(" "),
|
|
38
35
|
required: !optional,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { b as FeedbackProps } from '../index-
|
|
2
|
+
import { b as FeedbackProps } from '../index-DehCIKP7.mjs';
|
|
3
3
|
|
|
4
4
|
declare const Feedback: ({ message, type }: FeedbackProps) => react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { c as FormFieldProps, F as FormFieldsetProps } from '../index-
|
|
2
|
+
import { c as FormFieldProps, F as FormFieldsetProps } from '../index-DehCIKP7.mjs';
|
|
3
3
|
|
|
4
|
-
declare const LabeledFormField: ({
|
|
5
|
-
declare const TitledFormField: ({ label, description, feedback, children, optional, }: FormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
6
|
-
declare const FormFieldset: ({ label, description, feedback, children, optional, }: FormFieldsetProps) => react_jsx_runtime.JSX.Element;
|
|
4
|
+
declare const LabeledFormField: ({ label, labelsElement, description, feedback, children, optional, }: FormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
5
|
+
declare const TitledFormField: ({ label, labelsElement, description, feedback, children, optional, }: FormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
6
|
+
declare const FormFieldset: ({ label, description, feedback, children, optional, inputId }: FormFieldsetProps) => react_jsx_runtime.JSX.Element;
|
|
7
7
|
|
|
8
8
|
export { FormFieldset, LabeledFormField, TitledFormField };
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { uidBuilder } from "@financial-times/o-utils";
|
|
3
2
|
import { Feedback } from "./Feedback";
|
|
4
|
-
const uniqueId = uidBuilder("o3-form");
|
|
5
3
|
const LabeledFormField = ({
|
|
6
|
-
inputId,
|
|
7
4
|
label,
|
|
5
|
+
labelsElement,
|
|
8
6
|
description,
|
|
9
7
|
feedback,
|
|
10
8
|
children,
|
|
11
9
|
optional
|
|
12
10
|
}) => {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
11
|
+
const descriptionId = description ? `description_${labelsElement}` : void 0;
|
|
12
|
+
const labelId = `label_${labelsElement}`;
|
|
15
13
|
const labelClasses = ["o3-form-field__label"];
|
|
16
14
|
if (optional) {
|
|
17
15
|
labelClasses.push("o3-form-field--optional");
|
|
18
16
|
}
|
|
19
17
|
return /* @__PURE__ */ jsxs("div", { className: "o3-form-field", children: [
|
|
20
|
-
/* @__PURE__ */ jsx("label", { className: labelClasses.join(" "), htmlFor:
|
|
18
|
+
/* @__PURE__ */ jsx("label", { className: labelClasses.join(" "), id: labelId, htmlFor: labelsElement, children: label }),
|
|
21
19
|
description && /* @__PURE__ */ jsx("span", { className: "o3-form-input__description", id: descriptionId, children: description }),
|
|
22
20
|
children,
|
|
23
21
|
feedback && /* @__PURE__ */ jsx(Feedback, { ...feedback })
|
|
@@ -25,13 +23,14 @@ const LabeledFormField = ({
|
|
|
25
23
|
};
|
|
26
24
|
const TitledFormField = ({
|
|
27
25
|
label,
|
|
26
|
+
labelsElement,
|
|
28
27
|
description,
|
|
29
28
|
feedback,
|
|
30
29
|
children,
|
|
31
30
|
optional
|
|
32
31
|
}) => {
|
|
33
|
-
const descriptionId = description ?
|
|
34
|
-
const labelId =
|
|
32
|
+
const descriptionId = description ? `description_${labelsElement}` : void 0;
|
|
33
|
+
const labelId = `label_${labelsElement}`;
|
|
35
34
|
const labelClasses = ["o3-form-field__title"];
|
|
36
35
|
if (optional) {
|
|
37
36
|
labelClasses.push("o3-form-field--optional");
|
|
@@ -48,9 +47,10 @@ const FormFieldset = ({
|
|
|
48
47
|
description,
|
|
49
48
|
feedback,
|
|
50
49
|
children,
|
|
51
|
-
optional
|
|
50
|
+
optional,
|
|
51
|
+
inputId
|
|
52
52
|
}) => {
|
|
53
|
-
const descriptionId =
|
|
53
|
+
const descriptionId = `checkbox_${inputId}`;
|
|
54
54
|
const labelClasses = ["o3-form-field__legend"];
|
|
55
55
|
if (optional) {
|
|
56
56
|
labelClasses.push("o3-form-field--optional");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type BaseInputProps = {
|
|
2
|
-
inputId
|
|
3
|
-
label
|
|
2
|
+
inputId: string;
|
|
3
|
+
label: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
optional?: boolean;
|
|
6
6
|
error?: boolean;
|
|
@@ -25,8 +25,8 @@ interface SelectInputProps {
|
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
feedback?: FeedbackProps;
|
|
27
27
|
children?: React.JSX.Element[];
|
|
28
|
-
inputId
|
|
29
|
-
label
|
|
28
|
+
inputId: string;
|
|
29
|
+
label: string;
|
|
30
30
|
length?: 1 | 3;
|
|
31
31
|
description?: string;
|
|
32
32
|
optional?: boolean;
|
|
@@ -49,13 +49,15 @@ interface RadioButtonProps extends BaseInputProps {
|
|
|
49
49
|
radioButtonLabel: string;
|
|
50
50
|
}
|
|
51
51
|
interface FormFieldsetProps {
|
|
52
|
+
inputId: string;
|
|
52
53
|
label: string;
|
|
53
54
|
description?: string;
|
|
54
55
|
children: React.JSX.Element | React.JSX.Element[];
|
|
55
56
|
feedback?: FeedbackProps;
|
|
56
57
|
optional?: boolean;
|
|
57
58
|
}
|
|
58
|
-
interface FormFieldProps extends BaseInputProps {
|
|
59
|
+
interface FormFieldProps extends Omit<BaseInputProps, 'inputId'> {
|
|
60
|
+
labelsElement: string;
|
|
59
61
|
feedback?: FeedbackProps;
|
|
60
62
|
children: React.JSX.Element & JSX.IntrinsicElements['input'];
|
|
61
63
|
}
|
package/esm/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/o3-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Provides a viewport-aware tooltip for annotating or or highlighting other aspects of a product's UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"form",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"check:type": "tsc --noEmit"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@financial-times/o-utils": "^2.2.1",
|
|
39
38
|
"@financial-times/o3-foundation": "^3.0.0"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|