@financial-times/o3-form 0.3.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/CheckBox.d.ts +1 -1
- package/cjs/CheckBox.js +8 -3
- package/cjs/Error-summary.d.ts +6 -0
- package/cjs/Error-summary.js +30 -0
- package/cjs/PasswordInput.d.ts +6 -0
- package/cjs/PasswordInput.js +59 -0
- package/cjs/RadioButton.d.ts +7 -0
- package/cjs/RadioButton.js +54 -0
- package/cjs/TextInput.d.ts +1 -1
- package/cjs/TextInput.js +8 -5
- package/cjs/fieldComponents/Feedback.d.ts +6 -0
- package/cjs/fieldComponents/Feedback.js +7 -0
- package/cjs/fieldComponents/Form.d.ts +7 -0
- package/cjs/fieldComponents/Form.js +7 -0
- package/cjs/fieldComponents/FormField.d.ts +8 -0
- package/cjs/fieldComponents/FormField.js +72 -0
- package/cjs/{index-BZth9mTZ.d.ts → index-D6jDTWIC.d.ts} +19 -2
- package/cjs/index.d.ts +9 -14
- package/cjs/index.js +4 -0
- package/css/core.css +23 -0
- package/css/internal.css +23 -0
- package/css/main.css +231 -55
- package/css/professional.css +23 -0
- package/css/sustainable-views.css +23 -0
- package/css/whitelabel.css +15 -5
- package/esm/CheckBox.d.ts +1 -1
- package/esm/CheckBox.js +8 -3
- package/esm/Error-summary.d.ts +6 -0
- package/esm/Error-summary.js +30 -0
- package/esm/PasswordInput.d.ts +6 -0
- package/esm/PasswordInput.js +59 -0
- package/esm/RadioButton.d.ts +7 -0
- package/esm/RadioButton.js +54 -0
- package/esm/TextInput.d.ts +1 -1
- package/esm/TextInput.js +8 -5
- package/esm/fieldComponents/Feedback.d.mts +6 -0
- package/esm/fieldComponents/Feedback.js +7 -0
- package/esm/fieldComponents/Form.d.mts +7 -0
- package/esm/fieldComponents/Form.js +7 -0
- package/esm/fieldComponents/FormField.d.mts +8 -0
- package/esm/fieldComponents/FormField.js +72 -0
- package/esm/{index-BZth9mTZ.d.ts → index-D6jDTWIC.d.ts} +19 -2
- package/esm/index.d.ts +9 -14
- package/esm/index.js +4 -0
- package/package.json +1 -1
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,
|
|
2
|
+
import { C as CheckBoxProps, F as FormFieldsetProps } from './index-D6jDTWIC.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,18 @@
|
|
|
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');
|
|
3
4
|
var _FormField = require('./fieldComponents/FormField');
|
|
5
|
+
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-checkbox-input");
|
|
4
6
|
const CheckBoxItem = (props) => {
|
|
5
7
|
let { inputId, attributes, optional, error } = props;
|
|
6
|
-
|
|
8
|
+
if (!inputId) {
|
|
9
|
+
inputId = uniqueId("_");
|
|
10
|
+
}
|
|
11
|
+
const classNames = ["o3-form-input-checkbox__input", "o3-visually-hidden"];
|
|
7
12
|
if (error) {
|
|
8
13
|
classNames.push("o3-form-input-error");
|
|
9
14
|
}
|
|
10
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-form-
|
|
15
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-form-input-checkbox", children: [
|
|
11
16
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
12
17
|
"input",
|
|
13
18
|
{
|
|
@@ -19,7 +24,7 @@ const CheckBoxItem = (props) => {
|
|
|
19
24
|
"aria-required": !optional
|
|
20
25
|
}
|
|
21
26
|
),
|
|
22
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: inputId, className: "o3-form-
|
|
27
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: inputId, className: "o3-form-input-checkbox__label", children: props.checkboxLabel })
|
|
23
28
|
] });
|
|
24
29
|
};
|
|
25
30
|
const CheckBox = (props) => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
+
const ErrorSummary = ({
|
|
3
|
+
errors,
|
|
4
|
+
errorMessage = "Please correct these errors and try again."
|
|
5
|
+
}) => {
|
|
6
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-form__error-summary", children: [
|
|
7
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "o3-form__error-summary-icon" }),
|
|
8
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: "o3-form__error-summary__heading",
|
|
12
|
+
role: "alert",
|
|
13
|
+
"aria-labelledby": "error-summary-title",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { id: "error-summary-title", className: "o3-typography-heading5", children: errorMessage }),
|
|
16
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "o3-forms__error-summary__list o3-typography-body-small", children: errors.map(({ id, fieldName, message }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { children: [
|
|
17
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { className: "o3-typography-link", href: `#${id}`, children: fieldName }),
|
|
18
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
|
|
19
|
+
": ",
|
|
20
|
+
message
|
|
21
|
+
] })
|
|
22
|
+
] }, id)) })
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
] });
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
exports.ErrorSummary = ErrorSummary;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { P as PasswordInputProps } from './index-D6jDTWIC.js';
|
|
3
|
+
|
|
4
|
+
declare const PasswordInput: ({ label, feedback, description, disabled, attributes, inputId, optional, }: PasswordInputProps) => react_jsx_runtime.JSX.Element;
|
|
5
|
+
|
|
6
|
+
export { PasswordInput };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
+
var _outils = require('@financial-times/o-utils');
|
|
3
|
+
var _FormField = require('./fieldComponents/FormField');
|
|
4
|
+
var _CheckBox = require('./CheckBox');
|
|
5
|
+
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-password-input");
|
|
6
|
+
const PasswordInput = ({
|
|
7
|
+
label,
|
|
8
|
+
feedback,
|
|
9
|
+
description,
|
|
10
|
+
disabled,
|
|
11
|
+
attributes,
|
|
12
|
+
inputId,
|
|
13
|
+
optional
|
|
14
|
+
}) => {
|
|
15
|
+
const id = inputId || uniqueId("_");
|
|
16
|
+
const showPasswordId = `${id}-showPassword`;
|
|
17
|
+
const inputClasses = ["o3-form", "o3-form-text-input"];
|
|
18
|
+
if (feedback && feedback.type === "error") {
|
|
19
|
+
inputClasses.push("o3-form-text-input--error");
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
22
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
23
|
+
_FormField.LabeledFormField,
|
|
24
|
+
{
|
|
25
|
+
label,
|
|
26
|
+
feedback,
|
|
27
|
+
description,
|
|
28
|
+
inputId: id,
|
|
29
|
+
optional,
|
|
30
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
31
|
+
"input",
|
|
32
|
+
{
|
|
33
|
+
...attributes,
|
|
34
|
+
id,
|
|
35
|
+
disabled,
|
|
36
|
+
className: inputClasses.join(" "),
|
|
37
|
+
required: !optional,
|
|
38
|
+
"aria-required": !optional,
|
|
39
|
+
type: "password"
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-password-input__controls", children: [
|
|
45
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
46
|
+
_CheckBox.CheckBoxItem,
|
|
47
|
+
{
|
|
48
|
+
attributes: { disabled },
|
|
49
|
+
inputId: showPasswordId,
|
|
50
|
+
checkboxLabel: "Show Password"
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
!disabled && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { className: "o3-typography-link", href: "", children: "Forgot password?" })
|
|
54
|
+
] })
|
|
55
|
+
] });
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
exports.PasswordInput = PasswordInput;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { R as RadioButtonProps, F as FormFieldsetProps } from './index-D6jDTWIC.js';
|
|
3
|
+
|
|
4
|
+
declare const RadioButtonItem: (props: RadioButtonProps) => react_jsx_runtime.JSX.Element;
|
|
5
|
+
declare const RadioButtonGroup: (props: FormFieldsetProps) => react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { RadioButtonGroup, RadioButtonItem };
|
|
@@ -0,0 +1,54 @@
|
|
|
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 _react = require('react');
|
|
3
|
+
var _outils = require('@financial-times/o-utils');
|
|
4
|
+
var _FormField = require('./fieldComponents/FormField');
|
|
5
|
+
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-radio-button-input");
|
|
6
|
+
const RadioButtonItem = (props) => {
|
|
7
|
+
let { inputId, attributes, optional, error } = props;
|
|
8
|
+
if (!inputId) {
|
|
9
|
+
inputId = uniqueId("_");
|
|
10
|
+
}
|
|
11
|
+
const classNames = ["o3-form-input-radio-button", "o3-visually-hidden"];
|
|
12
|
+
if (error) {
|
|
13
|
+
classNames.push("o3-form-input-error");
|
|
14
|
+
}
|
|
15
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
16
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
17
|
+
"input",
|
|
18
|
+
{
|
|
19
|
+
...attributes,
|
|
20
|
+
type: "radio",
|
|
21
|
+
id: inputId,
|
|
22
|
+
className: classNames.join(" "),
|
|
23
|
+
required: !optional,
|
|
24
|
+
"aria-required": !optional
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: inputId, className: "o3-form-input-radio-button__label", children: props.radioButtonLabel })
|
|
28
|
+
] });
|
|
29
|
+
};
|
|
30
|
+
const RadioButtonGroup = (props) => {
|
|
31
|
+
const { children, ...restProps } = props;
|
|
32
|
+
const radioGroupName = Math.random().toString(36).substring(7);
|
|
33
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FormField.FormFieldset, { ...restProps, children: children.map((child) => {
|
|
34
|
+
const hasError = _optionalChain([props, 'access', _ => _.feedback, 'optionalAccess', _2 => _2.errorElementIds, 'optionalAccess', _3 => _3.includes, 'call', _4 => _4(
|
|
35
|
+
child.props.inputId
|
|
36
|
+
)]);
|
|
37
|
+
return /* @__PURE__ */ _react.createElement.call(void 0,
|
|
38
|
+
RadioButtonItem,
|
|
39
|
+
{
|
|
40
|
+
...child.props,
|
|
41
|
+
error: hasError,
|
|
42
|
+
key: child.props.inputId,
|
|
43
|
+
attributes: {
|
|
44
|
+
...child.props.attributes,
|
|
45
|
+
name: radioGroupName
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}) });
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
exports.RadioButtonGroup = RadioButtonGroup; exports.RadioButtonItem = RadioButtonItem;
|
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-D6jDTWIC.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,6 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
require('
|
|
2
|
+
var _outils = require('@financial-times/o-utils');
|
|
3
3
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
|
+
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form-text-input");
|
|
4
5
|
const TextInput = ({
|
|
5
6
|
label,
|
|
6
7
|
feedback,
|
|
@@ -11,6 +12,7 @@ const TextInput = ({
|
|
|
11
12
|
inputId,
|
|
12
13
|
optional
|
|
13
14
|
}) => {
|
|
15
|
+
const id = inputId || uniqueId("_");
|
|
14
16
|
const inputClasses = ["o3-form", "o3-form-text-input"];
|
|
15
17
|
if (feedback && feedback.type === "error") {
|
|
16
18
|
inputClasses.push("o3-form-text-input--error");
|
|
@@ -24,16 +26,17 @@ const TextInput = ({
|
|
|
24
26
|
label,
|
|
25
27
|
feedback,
|
|
26
28
|
description,
|
|
27
|
-
inputId,
|
|
29
|
+
inputId: id,
|
|
30
|
+
optional,
|
|
28
31
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
29
32
|
"input",
|
|
30
33
|
{
|
|
31
34
|
...attributes,
|
|
32
|
-
id
|
|
35
|
+
id,
|
|
33
36
|
disabled,
|
|
34
37
|
className: inputClasses.join(" "),
|
|
35
|
-
required: optional,
|
|
36
|
-
"aria-required": optional,
|
|
38
|
+
required: !optional,
|
|
39
|
+
"aria-required": !optional,
|
|
37
40
|
maxLength: length,
|
|
38
41
|
type: "text"
|
|
39
42
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
+
const Feedback = ({ message, type }) => {
|
|
3
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: `o3-form-feedback o3-form-feedback__${type}`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `o3-form-feedback__${type}-message`, children: message }) });
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.Feedback = Feedback;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
+
const Form = ({ children }) => {
|
|
3
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { className: "o3-form", children });
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.Form = Form;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { b as FormFieldProps, F as FormFieldsetProps } from '../index-D6jDTWIC.js';
|
|
3
|
+
|
|
4
|
+
declare const LabeledFormField: ({ inputId, label, description, feedback, children, optional, }: FormFieldProps) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
7
|
+
|
|
8
|
+
export { FormFieldset, LabeledFormField, TitledFormField };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
+
var _outils = require('@financial-times/o-utils');
|
|
3
|
+
var _Feedback = require('./Feedback');
|
|
4
|
+
const uniqueId = _outils.uidBuilder.call(void 0, "o3-form");
|
|
5
|
+
const LabeledFormField = ({
|
|
6
|
+
inputId,
|
|
7
|
+
label,
|
|
8
|
+
description,
|
|
9
|
+
feedback,
|
|
10
|
+
children,
|
|
11
|
+
optional
|
|
12
|
+
}) => {
|
|
13
|
+
const id = inputId || uniqueId("input_");
|
|
14
|
+
const descriptionId = description ? uniqueId("description_") : void 0;
|
|
15
|
+
const labelClasses = ["o3-form-field__label"];
|
|
16
|
+
if (optional) {
|
|
17
|
+
labelClasses.push("o3-form-field--optional");
|
|
18
|
+
}
|
|
19
|
+
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: id, children: label }),
|
|
21
|
+
description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "o3-form-input__description", id: descriptionId, children: description }),
|
|
22
|
+
children,
|
|
23
|
+
feedback && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Feedback.Feedback, { ...feedback })
|
|
24
|
+
] });
|
|
25
|
+
};
|
|
26
|
+
const TitledFormField = ({
|
|
27
|
+
label,
|
|
28
|
+
description,
|
|
29
|
+
feedback,
|
|
30
|
+
children,
|
|
31
|
+
optional
|
|
32
|
+
}) => {
|
|
33
|
+
const descriptionId = description ? uniqueId("description_") : void 0;
|
|
34
|
+
const labelId = uniqueId("label_");
|
|
35
|
+
const labelClasses = ["o3-form-field__title"];
|
|
36
|
+
if (optional) {
|
|
37
|
+
labelClasses.push("o3-form-field--optional");
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-form-field", children: [
|
|
40
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: labelClasses.join(" "), id: labelId, children: label }),
|
|
41
|
+
description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "o3-form-input__description", id: descriptionId, children: description }),
|
|
42
|
+
children,
|
|
43
|
+
feedback && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Feedback.Feedback, { ...feedback })
|
|
44
|
+
] });
|
|
45
|
+
};
|
|
46
|
+
const FormFieldset = ({
|
|
47
|
+
label,
|
|
48
|
+
description,
|
|
49
|
+
feedback,
|
|
50
|
+
children,
|
|
51
|
+
optional
|
|
52
|
+
}) => {
|
|
53
|
+
const descriptionId = uniqueId("checkbox_");
|
|
54
|
+
const labelClasses = ["o3-form-field__legend"];
|
|
55
|
+
if (optional) {
|
|
56
|
+
labelClasses.push("o3-form-field--optional");
|
|
57
|
+
}
|
|
58
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "fieldset", { className: "o3-form-field", "aria-describedby": `${descriptionId}`, children: [
|
|
59
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "legend", { className: labelClasses.join(" "), children: [
|
|
60
|
+
label,
|
|
61
|
+
" ",
|
|
62
|
+
description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "o3-form-input__description", id: descriptionId, children: description })
|
|
63
|
+
] }),
|
|
64
|
+
children,
|
|
65
|
+
feedback && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Feedback.Feedback, { ...feedback })
|
|
66
|
+
] });
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
exports.FormFieldset = FormFieldset; exports.LabeledFormField = LabeledFormField; exports.TitledFormField = TitledFormField;
|
|
@@ -6,21 +6,30 @@ type BaseInputProps = {
|
|
|
6
6
|
error?: boolean;
|
|
7
7
|
attributes?: JSX.IntrinsicElements['input'];
|
|
8
8
|
};
|
|
9
|
-
interface TextInputProps extends
|
|
9
|
+
interface TextInputProps extends BaseInputProps {
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
length?: 2 | 3 | 4 | 5;
|
|
12
12
|
feedback?: FeedbackProps;
|
|
13
13
|
}
|
|
14
|
+
interface PasswordInputProps extends BaseInputProps {
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
feedback?: FeedbackProps;
|
|
17
|
+
}
|
|
14
18
|
interface CheckBoxProps extends BaseInputProps {
|
|
15
19
|
inputId: string;
|
|
16
20
|
checkboxLabel: string;
|
|
17
21
|
feedback?: FeedbackProps;
|
|
18
22
|
}
|
|
23
|
+
interface RadioButtonProps extends BaseInputProps {
|
|
24
|
+
inputId: string;
|
|
25
|
+
radioButtonLabel: string;
|
|
26
|
+
}
|
|
19
27
|
interface FormFieldsetProps {
|
|
20
28
|
label: string;
|
|
21
29
|
description?: string;
|
|
22
30
|
children: JSX.Element | JSX.Element[];
|
|
23
31
|
feedback?: FeedbackProps;
|
|
32
|
+
optional?: boolean;
|
|
24
33
|
}
|
|
25
34
|
interface FormFieldProps extends BaseInputProps {
|
|
26
35
|
feedback?: FeedbackProps;
|
|
@@ -31,5 +40,13 @@ type FeedbackProps = {
|
|
|
31
40
|
message: string;
|
|
32
41
|
type: 'error';
|
|
33
42
|
};
|
|
43
|
+
type ErrorSummaryProps = {
|
|
44
|
+
errorMessage?: string;
|
|
45
|
+
errors: {
|
|
46
|
+
id: string;
|
|
47
|
+
fieldName: string;
|
|
48
|
+
message: string;
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
34
51
|
|
|
35
|
-
export type { CheckBoxProps as C,
|
|
52
|
+
export type { CheckBoxProps as C, ErrorSummaryProps as E, FormFieldsetProps as F, PasswordInputProps as P, RadioButtonProps as R, TextInputProps as T, FeedbackProps as a, FormFieldProps as b };
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { Feedback } from './fieldComponents/Feedback.js';
|
|
2
|
+
export { FormFieldset, LabeledFormField, TitledFormField } from './fieldComponents/FormField.js';
|
|
3
|
+
export { Form } from './fieldComponents/Form.js';
|
|
3
4
|
export { CheckBox, CheckBoxGroup, CheckBoxItem } from './CheckBox.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare const Form: ({ children }: {
|
|
12
|
-
children: JSX.Element | JSX.Element[];
|
|
13
|
-
}) => react_jsx_runtime.JSX.Element;
|
|
14
|
-
|
|
15
|
-
export { Feedback, Form, FormFieldset, LabeledFormField, TitledFormField };
|
|
5
|
+
export { RadioButtonGroup, RadioButtonItem } from './RadioButton.js';
|
|
6
|
+
export { ErrorSummary } from './Error-summary.js';
|
|
7
|
+
export { PasswordInput } from './PasswordInput.js';
|
|
8
|
+
export { TextInput } from './TextInput.js';
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
|
+
import './index-D6jDTWIC.js';
|
package/cjs/index.js
CHANGED
|
@@ -2,3 +2,7 @@
|
|
|
2
2
|
var _FormField = require('./fieldComponents/FormField'); _createStarExport(_FormField);
|
|
3
3
|
var _Form = require('./fieldComponents/Form'); _createStarExport(_Form);
|
|
4
4
|
var _CheckBox = require('./CheckBox'); _createStarExport(_CheckBox);
|
|
5
|
+
var _RadioButton = require('./RadioButton'); _createStarExport(_RadioButton);
|
|
6
|
+
var _Errorsummary = require('./Error-summary'); _createStarExport(_Errorsummary);
|
|
7
|
+
var _PasswordInput = require('./PasswordInput'); _createStarExport(_PasswordInput);
|
|
8
|
+
var _TextInput = require('./TextInput'); _createStarExport(_TextInput);
|
package/css/core.css
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import "@financial-times/o3-foundation/css/core.css";
|
|
2
|
+
@import "./main.css";
|
|
3
|
+
|
|
4
|
+
/* src/css/tokens/core/o3-form/_variables.css */
|
|
5
|
+
[data-o3-brand=core] .o3-form {
|
|
6
|
+
--_o3-form-error-summary-background-color: rgba(204, 0, 0, 0.14);
|
|
7
|
+
--_o3-form-input-border-radius: 6px;
|
|
8
|
+
--_o3-form-color-use-case-background-error: rgba(204, 0, 0, 0.06);
|
|
9
|
+
--_o3-form-input-border: 2px solid var(--o3-color-palette-black-30);
|
|
10
|
+
--_o3-form-color-use-case-selected-disabled: var(--o3-color-use-case-button-disabled);
|
|
11
|
+
--_o3-form-color-use-case-border-disabled: var(--o3-color-palette-black-10);
|
|
12
|
+
--_o3-form-color-use-case-border: var(--o3-color-palette-black-50);
|
|
13
|
+
--_o3-form-color-use-case-background-disabled: var(--o3-color-palette-black-10);
|
|
14
|
+
--_o3-form-color-use-case-background: var(--o3-color-palette-white);
|
|
15
|
+
--_o3-form-input-border-error: 2px solid var(--o3-color-use-case-error);
|
|
16
|
+
--_o3-form-color-use-case-selected-active: var(--o3-color-use-case-button-pressed);
|
|
17
|
+
--_o3-form-color-use-case-selected-hover: var(--o3-color-use-case-button-hover);
|
|
18
|
+
--_o3-form-color-use-case-selected: var(--o3-color-use-case-button-default);
|
|
19
|
+
--_o3-form-color-use-case-border-active: var(--o3-color-use-case-button-pressed);
|
|
20
|
+
--_o3-form-color-use-case-border-hover: var(--o3-color-use-case-button-hover);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* src/css/brands/core.css */
|
package/css/internal.css
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import "@financial-times/o3-foundation/css/internal.css";
|
|
2
|
+
@import "./main.css";
|
|
3
|
+
|
|
4
|
+
/* src/css/tokens/internal/o3-form/_variables.css */
|
|
5
|
+
[data-o3-brand=internal] .o3-form {
|
|
6
|
+
--_o3-form-color-use-case-background-error: rgba(204, 0, 0, 0.06);
|
|
7
|
+
--_o3-form-error-summary-background-color: rgba(204, 0, 0, 0.14);
|
|
8
|
+
--_o3-form-input-border-radius: 6px;
|
|
9
|
+
--_o3-form-color-use-case-selected-disabled: var(--o3-color-palette-black-5);
|
|
10
|
+
--_o3-form-color-use-case-border-disabled: var(--o3-color-use-case-button-disabled);
|
|
11
|
+
--_o3-form-color-use-case-border: var(--o3-color-palette-black-50);
|
|
12
|
+
--_o3-form-color-use-case-background-disabled: var(--o3-color-palette-black-10);
|
|
13
|
+
--_o3-form-color-use-case-background: var(--o3-color-palette-white);
|
|
14
|
+
--_o3-form-input-border: 2px solid var(--o3-color-palette-black-30);
|
|
15
|
+
--_o3-form-color-use-case-selected-active: var(--o3-color-use-case-button-pressed);
|
|
16
|
+
--_o3-form-color-use-case-selected-hover: var(--o3-color-use-case-button-hover);
|
|
17
|
+
--_o3-form-color-use-case-selected: var(--o3-color-use-case-button-default);
|
|
18
|
+
--_o3-form-color-use-case-border-active: var(--o3-color-use-case-button-pressed);
|
|
19
|
+
--_o3-form-color-use-case-border-hover: var(--o3-color-use-case-button-hover);
|
|
20
|
+
--_o3-form-input-border-error: 2px solid var(--o3-color-use-case-error);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* src/css/brands/internal.css */
|