@financial-times/o3-form 0.3.2 → 0.4.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 +3 -3
- package/cjs/Error-summary.d.ts +6 -0
- package/cjs/Error-summary.js +30 -0
- package/cjs/PasswordInput.d.ts +9 -0
- package/cjs/PasswordInput.js +55 -0
- package/cjs/RadioButton.d.ts +7 -0
- package/cjs/RadioButton.js +52 -0
- package/cjs/TextInput.d.ts +1 -1
- package/cjs/TextInput.js +3 -3
- 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 +69 -0
- package/cjs/{index-BZth9mTZ.d.ts → index-CHdbHHZ0.d.ts} +15 -2
- package/cjs/index.d.ts +9 -14
- package/cjs/index.js +4 -0
- package/css/main.css +201 -50
- package/css/whitelabel.css +15 -5
- package/esm/CheckBox.d.ts +1 -1
- package/esm/CheckBox.js +3 -3
- package/esm/Error-summary.d.ts +6 -0
- package/esm/Error-summary.js +30 -0
- package/esm/PasswordInput.d.ts +9 -0
- package/esm/PasswordInput.js +55 -0
- package/esm/RadioButton.d.ts +7 -0
- package/esm/RadioButton.js +52 -0
- package/esm/TextInput.d.ts +1 -1
- package/esm/TextInput.js +3 -3
- 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 +69 -0
- package/esm/{index-BZth9mTZ.d.ts → index-CHdbHHZ0.d.ts} +15 -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-CHdbHHZ0.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
|
@@ -3,11 +3,11 @@ var _react = require('react');
|
|
|
3
3
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
4
|
const CheckBoxItem = (props) => {
|
|
5
5
|
let { inputId, attributes, optional, error } = props;
|
|
6
|
-
const classNames = ["o3-form-
|
|
6
|
+
const classNames = ["o3-form-input-checkbox__input", "o3-visually-hidden"];
|
|
7
7
|
if (error) {
|
|
8
8
|
classNames.push("o3-form-input-error");
|
|
9
9
|
}
|
|
10
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-form-
|
|
10
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-form-input-checkbox", children: [
|
|
11
11
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
12
12
|
"input",
|
|
13
13
|
{
|
|
@@ -19,7 +19,7 @@ const CheckBoxItem = (props) => {
|
|
|
19
19
|
"aria-required": !optional
|
|
20
20
|
}
|
|
21
21
|
),
|
|
22
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: inputId, className: "o3-form-
|
|
22
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: inputId, className: "o3-form-input-checkbox__label", children: props.checkboxLabel })
|
|
23
23
|
] });
|
|
24
24
|
};
|
|
25
25
|
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,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { a as FormFieldProps } from './index-CHdbHHZ0.js';
|
|
3
|
+
|
|
4
|
+
interface PasswordInputProps extends FormFieldProps {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const PasswordInput: ({ label, feedback, description, disabled, attributes, inputId, optional, }: PasswordInputProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { PasswordInput };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
+
var _FormField = require('./fieldComponents/FormField');
|
|
3
|
+
var _CheckBox = require('./CheckBox');
|
|
4
|
+
const PasswordInput = ({
|
|
5
|
+
label,
|
|
6
|
+
feedback,
|
|
7
|
+
description,
|
|
8
|
+
disabled,
|
|
9
|
+
attributes,
|
|
10
|
+
inputId,
|
|
11
|
+
optional
|
|
12
|
+
}) => {
|
|
13
|
+
const inputClasses = ["o3-form", "o3-form-text-input"];
|
|
14
|
+
if (feedback && feedback.type === "error") {
|
|
15
|
+
inputClasses.push("o3-form-text-input--error");
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
18
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
19
|
+
_FormField.LabeledFormField,
|
|
20
|
+
{
|
|
21
|
+
label,
|
|
22
|
+
feedback,
|
|
23
|
+
description,
|
|
24
|
+
inputId,
|
|
25
|
+
optional,
|
|
26
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
27
|
+
"input",
|
|
28
|
+
{
|
|
29
|
+
...attributes,
|
|
30
|
+
id: inputId,
|
|
31
|
+
disabled,
|
|
32
|
+
className: inputClasses.join(" "),
|
|
33
|
+
required: !optional,
|
|
34
|
+
"aria-required": !optional,
|
|
35
|
+
type: "password"
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "o3-password-input__controls", children: [
|
|
41
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
42
|
+
_CheckBox.CheckBoxItem,
|
|
43
|
+
{
|
|
44
|
+
attributes: { disabled },
|
|
45
|
+
inputId: "showPassword",
|
|
46
|
+
checkboxLabel: "Show Password"
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
!disabled && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: "", children: "Forgot password?" })
|
|
50
|
+
] })
|
|
51
|
+
] });
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
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-CHdbHHZ0.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,52 @@
|
|
|
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 _FormField = require('./fieldComponents/FormField');
|
|
4
|
+
const RadioButtonItem = (props) => {
|
|
5
|
+
let { inputId, attributes, optional, error } = props;
|
|
6
|
+
const classNames = [
|
|
7
|
+
"o3-form-input-radio-button",
|
|
8
|
+
"o3-visually-hidden"
|
|
9
|
+
];
|
|
10
|
+
if (error) {
|
|
11
|
+
classNames.push("o3-form-input-error");
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
14
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
15
|
+
"input",
|
|
16
|
+
{
|
|
17
|
+
...attributes,
|
|
18
|
+
type: "radio",
|
|
19
|
+
id: inputId,
|
|
20
|
+
className: classNames.join(" "),
|
|
21
|
+
required: !optional,
|
|
22
|
+
"aria-required": !optional
|
|
23
|
+
}
|
|
24
|
+
),
|
|
25
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: inputId, className: "o3-form-input-radio-button__label", children: props.radioButtonLabel })
|
|
26
|
+
] });
|
|
27
|
+
};
|
|
28
|
+
const RadioButtonGroup = (props) => {
|
|
29
|
+
const { children, ...restProps } = props;
|
|
30
|
+
const radioGroupName = Math.random().toString(36).substring(7);
|
|
31
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FormField.FormFieldset, { ...restProps, children: children.map((child) => {
|
|
32
|
+
const hasError = _optionalChain([props, 'access', _ => _.feedback, 'optionalAccess', _2 => _2.errorElementIds, 'optionalAccess', _3 => _3.includes, 'call', _4 => _4(
|
|
33
|
+
child.props.inputId
|
|
34
|
+
)]);
|
|
35
|
+
return /* @__PURE__ */ _react.createElement.call(void 0,
|
|
36
|
+
RadioButtonItem,
|
|
37
|
+
{
|
|
38
|
+
...child.props,
|
|
39
|
+
error: hasError,
|
|
40
|
+
key: child.props.inputId,
|
|
41
|
+
attributes: {
|
|
42
|
+
...child.props.attributes,
|
|
43
|
+
name: radioGroupName
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}) });
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
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-CHdbHHZ0.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,5 +1,4 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _jsxruntime = require('react/jsx-runtime');
|
|
2
|
-
require('../../main.css');
|
|
3
2
|
var _FormField = require('./fieldComponents/FormField');
|
|
4
3
|
const TextInput = ({
|
|
5
4
|
label,
|
|
@@ -25,6 +24,7 @@ const TextInput = ({
|
|
|
25
24
|
feedback,
|
|
26
25
|
description,
|
|
27
26
|
inputId,
|
|
27
|
+
optional,
|
|
28
28
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
29
29
|
"input",
|
|
30
30
|
{
|
|
@@ -32,8 +32,8 @@ const TextInput = ({
|
|
|
32
32
|
id: inputId,
|
|
33
33
|
disabled,
|
|
34
34
|
className: inputClasses.join(" "),
|
|
35
|
-
required: optional,
|
|
36
|
-
"aria-required": optional,
|
|
35
|
+
required: !optional,
|
|
36
|
+
"aria-required": !optional,
|
|
37
37
|
maxLength: length,
|
|
38
38
|
type: "text"
|
|
39
39
|
}
|
|
@@ -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 { a as FormFieldProps, F as FormFieldsetProps } from '../index-CHdbHHZ0.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,69 @@
|
|
|
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.jsx.call(void 0, "legend", { className: labelClasses.join(" "), children: label }),
|
|
60
|
+
description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "o3-form-input__description", id: descriptionId, children: description }),
|
|
61
|
+
children,
|
|
62
|
+
feedback && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Feedback.Feedback, { ...feedback })
|
|
63
|
+
] });
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.FormFieldset = FormFieldset; exports.LabeledFormField = LabeledFormField; exports.TitledFormField = TitledFormField;
|
|
@@ -6,7 +6,7 @@ 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;
|
|
@@ -16,11 +16,16 @@ interface CheckBoxProps extends BaseInputProps {
|
|
|
16
16
|
checkboxLabel: string;
|
|
17
17
|
feedback?: FeedbackProps;
|
|
18
18
|
}
|
|
19
|
+
interface RadioButtonProps extends BaseInputProps {
|
|
20
|
+
inputId: string;
|
|
21
|
+
radioButtonLabel: string;
|
|
22
|
+
}
|
|
19
23
|
interface FormFieldsetProps {
|
|
20
24
|
label: string;
|
|
21
25
|
description?: string;
|
|
22
26
|
children: JSX.Element | JSX.Element[];
|
|
23
27
|
feedback?: FeedbackProps;
|
|
28
|
+
optional?: boolean;
|
|
24
29
|
}
|
|
25
30
|
interface FormFieldProps extends BaseInputProps {
|
|
26
31
|
feedback?: FeedbackProps;
|
|
@@ -31,5 +36,13 @@ type FeedbackProps = {
|
|
|
31
36
|
message: string;
|
|
32
37
|
type: 'error';
|
|
33
38
|
};
|
|
39
|
+
type ErrorSummaryProps = {
|
|
40
|
+
errorMessage?: string;
|
|
41
|
+
errors: {
|
|
42
|
+
id: string;
|
|
43
|
+
fieldName: string;
|
|
44
|
+
message: string;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
34
47
|
|
|
35
|
-
export type { CheckBoxProps as C,
|
|
48
|
+
export type { CheckBoxProps as C, ErrorSummaryProps as E, FormFieldsetProps as F, RadioButtonProps as R, TextInputProps as T, FormFieldProps as a, FeedbackProps 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-CHdbHHZ0.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/main.css
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/* src/css/components/form.css */
|
|
2
2
|
.o3-form {
|
|
3
3
|
font-family: var(--o3-font-family-metric);
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
justify-content: start;
|
|
7
|
+
gap: var(--o3-spacing-s);
|
|
4
8
|
}
|
|
5
9
|
|
|
6
10
|
/* src/css/components/form-field.css */
|
|
@@ -21,7 +25,7 @@
|
|
|
21
25
|
font-weight: var(--o3-font-weight-medium);
|
|
22
26
|
color: var(--o3-color-use-case-body-text);
|
|
23
27
|
}
|
|
24
|
-
.o3-form-field :is(.o3-form-field__label, .o3-form-field__title, .o3-form-field__legend)
|
|
28
|
+
.o3-form-field :is(.o3-form-field__label, .o3-form-field__title, .o3-form-field__legend).o3-form-field--optional::after {
|
|
25
29
|
content: "(optional)";
|
|
26
30
|
margin-left: var(--o3-spacing-3xs);
|
|
27
31
|
color: var(--o3-color-use-case-muted-text);
|
|
@@ -50,7 +54,7 @@
|
|
|
50
54
|
align-items: center;
|
|
51
55
|
font-size: var(--o3-font-size-metric2-negative-1);
|
|
52
56
|
line-height: var(--o3-font-lineheight-metric2-negative-1);
|
|
53
|
-
color: var(--o3-color-
|
|
57
|
+
color: var(--o3-color-use-case-error-text);
|
|
54
58
|
}
|
|
55
59
|
.o3-form-feedback__error-message {
|
|
56
60
|
display: flex;
|
|
@@ -73,13 +77,17 @@
|
|
|
73
77
|
|
|
74
78
|
/* src/css/components/text-input.css */
|
|
75
79
|
.o3-form-text-input {
|
|
76
|
-
border: var(--_o3-form-
|
|
80
|
+
border: var(--_o3-form-input-border);
|
|
77
81
|
padding: var(--o3-spacing-3xs) var(--o3-spacing-2xs);
|
|
78
|
-
background-color: var(--
|
|
79
|
-
|
|
82
|
+
background-color: var(--o3-form-color-use-case-background);
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
border-radius: var(--_o3-form-input-border-radius);
|
|
80
85
|
--o3-grid-columns-to-span-count: 4;
|
|
81
86
|
max-width: var(--_o3-form-text-input-max-width, var(--o3-grid-columns-to-span-width));
|
|
82
87
|
}
|
|
88
|
+
.o3-form-text-input[class*=--short] {
|
|
89
|
+
box-sizing: initial;
|
|
90
|
+
}
|
|
83
91
|
.o3-form-text-input--short-2 {
|
|
84
92
|
--_o3-form-text-input-max-width: 1.5em;
|
|
85
93
|
}
|
|
@@ -93,33 +101,39 @@
|
|
|
93
101
|
--_o3-form-text-input-max-width: 4.5em;
|
|
94
102
|
}
|
|
95
103
|
.o3-form-text-input--error {
|
|
96
|
-
border: var(--_o3-form-
|
|
97
|
-
background-color: var(--
|
|
104
|
+
border: var(--_o3-form-input-border-error);
|
|
105
|
+
background-color: var(--o3-form-color-use-case-background-error);
|
|
106
|
+
}
|
|
107
|
+
input[class*=o3-form-text-input][type=password]:disabled,
|
|
108
|
+
input[class*=o3-form-text-input][type=text]:disabled {
|
|
109
|
+
color: var(--o3-color-use-case-muted-text);
|
|
110
|
+
background-color: var(--o3-form-color-use-case-background-disabled);
|
|
111
|
+
border-color: var(--o3-form-color-use-case-border-disabled);
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
/* src/css/components/checkbox.css */
|
|
101
|
-
.o3-form-
|
|
115
|
+
.o3-form-input-checkbox__input + label::before {
|
|
102
116
|
content: "";
|
|
103
117
|
display: inline-block;
|
|
104
118
|
width: var(--o3-spacing-s);
|
|
105
119
|
height: var(--o3-spacing-s);
|
|
106
120
|
margin-right: var(--o3-spacing-3xs);
|
|
107
|
-
border:
|
|
108
|
-
border-radius: var(--
|
|
121
|
+
border: var(--_o3-form-input-border);
|
|
122
|
+
border-radius: var(--_o3-form-input-border-radius);
|
|
109
123
|
box-sizing: border-box;
|
|
110
124
|
}
|
|
111
|
-
.o3-form-
|
|
112
|
-
border-color: var(--o3-color-
|
|
125
|
+
.o3-form-input-checkbox__input:hover + label::before {
|
|
126
|
+
border-color: var(--o3-form-color-use-case-selected-hover);
|
|
113
127
|
}
|
|
114
|
-
.o3-form-
|
|
115
|
-
border-color: var(--o3-color-
|
|
128
|
+
.o3-form-input-checkbox__input:active + label::before {
|
|
129
|
+
border-color: var(--o3-form-color-use-case-selected-active);
|
|
116
130
|
}
|
|
117
|
-
.o3-form-
|
|
131
|
+
.o3-form-input-checkbox__input:checked + label::after {
|
|
118
132
|
position: absolute;
|
|
119
133
|
content: "";
|
|
120
134
|
width: var(--o3-spacing-s);
|
|
121
135
|
height: var(--o3-spacing-s);
|
|
122
|
-
background-color: var(--o3-color-
|
|
136
|
+
background-color: var(--o3-form-color-use-case-background);
|
|
123
137
|
-webkit-mask-image: var(--o3-icons-ft-icon-tick);
|
|
124
138
|
mask-image: var(--o3-icons-ft-icon-tick);
|
|
125
139
|
-webkit-mask-repeat: no-repeat;
|
|
@@ -127,45 +141,49 @@
|
|
|
127
141
|
-webkit-mask-size: contain;
|
|
128
142
|
mask-size: contain;
|
|
129
143
|
}
|
|
130
|
-
.o3-form-
|
|
131
|
-
background-color: var(--o3-color-
|
|
144
|
+
.o3-form-input-checkbox__input:checked + label::before {
|
|
145
|
+
background-color: var(--o3-form-color-use-case-selected-active);
|
|
146
|
+
border-color: var(--o3-form-color-use-case-selected-active);
|
|
132
147
|
}
|
|
133
|
-
.o3-form-
|
|
134
|
-
background-color: var(--o3-color-
|
|
148
|
+
.o3-form-input-checkbox__input:checked:hover + label::before {
|
|
149
|
+
background-color: var(--o3-form-color-use-case-selected-hover);
|
|
150
|
+
border-color: var(--o3-form-color-use-case-selected-hover);
|
|
135
151
|
}
|
|
136
|
-
.o3-form-
|
|
137
|
-
background-color: var(--o3-color-
|
|
152
|
+
.o3-form-input-checkbox__input:checked:active + label::before {
|
|
153
|
+
background-color: var(--o3-form-color-use-case-selected-active);
|
|
154
|
+
border-color: var(--o3-form-color-use-case-selected-active);
|
|
138
155
|
}
|
|
139
|
-
.o3-form-
|
|
140
|
-
border-color: var(--o3-color-
|
|
156
|
+
.o3-form-input-checkbox__input:disabled + label::before {
|
|
157
|
+
border-color: var(--o3-form-color-use-case-border-disabled);
|
|
141
158
|
}
|
|
142
|
-
.o3-form-
|
|
143
|
-
color: var(--o3-color-
|
|
159
|
+
.o3-form-input-checkbox__input:disabled + label {
|
|
160
|
+
color: var(--o3-form-color-use-case-border-disabled);
|
|
144
161
|
}
|
|
145
|
-
.o3-form-
|
|
146
|
-
background-color: var(--o3-color-
|
|
162
|
+
.o3-form-input-checkbox__input:checked:disabled + label::before {
|
|
163
|
+
background-color: var(--o3-form-color-use-case-selected-disabled);
|
|
164
|
+
border-color: var(--o3-form-color-use-case-selected-disabled);
|
|
147
165
|
}
|
|
148
|
-
.o3-form-
|
|
166
|
+
.o3-form-input-checkbox__input.o3-form-input-error + label::before {
|
|
149
167
|
border-color: var(--o3-color-use-case-error);
|
|
150
168
|
background-color: var(--o3-color-use-case-error-background);
|
|
151
169
|
}
|
|
152
|
-
.o3-form-
|
|
170
|
+
.o3-form-input-checkbox__input.o3-form-input-error:checked + label::before {
|
|
153
171
|
border-color: var(--o3-color-use-case-error);
|
|
154
172
|
background-color: var(--o3-color-use-case-error-background);
|
|
155
173
|
}
|
|
156
|
-
.o3-form-
|
|
174
|
+
.o3-form-input-checkbox__input.o3-form-input-error:checked + label::after {
|
|
157
175
|
background-color: var(--o3-color-use-case-error);
|
|
158
176
|
}
|
|
159
|
-
.o3-form-
|
|
160
|
-
border-color: var(--o3-color-
|
|
161
|
-
background-color: var(--o3-color-
|
|
177
|
+
.o3-form-input-checkbox__input:indeterminate + label::before {
|
|
178
|
+
border-color: var(--o3-form-color-use-case-selected-active);
|
|
179
|
+
background-color: var(--o3-form-color-use-case-selected-active);
|
|
162
180
|
}
|
|
163
|
-
.o3-form-
|
|
181
|
+
.o3-form-input-checkbox__input:indeterminate + label::after {
|
|
164
182
|
position: absolute;
|
|
165
183
|
content: "";
|
|
166
184
|
width: var(--o3-spacing-s);
|
|
167
185
|
height: var(--o3-spacing-s);
|
|
168
|
-
background-color: var(--o3-color-
|
|
186
|
+
background-color: var(--o3-form-color-use-case-background);
|
|
169
187
|
-webkit-mask-image: var(--o3-icons-ft-icon-minus);
|
|
170
188
|
mask-image: var(--o3-icons-ft-icon-minus);
|
|
171
189
|
-webkit-mask-repeat: no-repeat;
|
|
@@ -173,33 +191,166 @@
|
|
|
173
191
|
-webkit-mask-size: contain;
|
|
174
192
|
mask-size: contain;
|
|
175
193
|
}
|
|
176
|
-
.o3-form-
|
|
177
|
-
border-color: var(--o3-color-
|
|
178
|
-
background-color: var(--o3-color-
|
|
194
|
+
.o3-form-input-checkbox__input:indeterminate:hover + label::before {
|
|
195
|
+
border-color: var(--o3-form-color-use-case-selected-hover);
|
|
196
|
+
background-color: var(--o3-form-color-use-case-selected-hover);
|
|
179
197
|
}
|
|
180
|
-
.o3-form-
|
|
181
|
-
.o3-form-
|
|
182
|
-
border-color: var(--o3-color-
|
|
183
|
-
background-color: var(--o3-color-
|
|
198
|
+
.o3-form-input-checkbox__input:indeterminate:active + label::before,
|
|
199
|
+
.o3-form-input-checkbox__input:indeterminate:disabled + label::before {
|
|
200
|
+
border-color: var(--o3-form-color-use-case-selected-hover);
|
|
201
|
+
background-color: var(--o3-form-color-use-case-selected-hover);
|
|
184
202
|
}
|
|
185
|
-
.o3-form-
|
|
203
|
+
.o3-form-input-checkbox__input.o3-form-input-error:indeterminate + label::before {
|
|
186
204
|
border-color: var(--o3-color-use-case-error);
|
|
187
205
|
background-color: var(--o3-color-use-case-error-background);
|
|
188
206
|
}
|
|
189
|
-
.o3-form-
|
|
207
|
+
.o3-form-input-checkbox__input.o3-form-input-error:indeterminate + label::after {
|
|
190
208
|
background-color: var(--o3-color-use-case-error);
|
|
191
209
|
}
|
|
192
|
-
.o3-form-
|
|
210
|
+
.o3-form-input-checkbox__label {
|
|
193
211
|
display: flex;
|
|
194
212
|
align-items: center;
|
|
195
|
-
font-size: var(--o3-
|
|
196
|
-
line-height: var(--o3-
|
|
197
|
-
font-weight: var(--o3-font-weight
|
|
213
|
+
font-size: var(--o3-typography-use-case-body-small-font-size);
|
|
214
|
+
line-height: var(--o3-typography-use-case-body-small-line-height);
|
|
215
|
+
font-weight: var(--o3-typography-use-case-body-small-font-weight);
|
|
198
216
|
color: var(--o3-color-use-case-body-text);
|
|
199
217
|
}
|
|
200
|
-
.o3-form-
|
|
218
|
+
.o3-form-input-checkbox__label:focus-visible {
|
|
201
219
|
padding: var(--o3-spacing-5xs);
|
|
202
220
|
margin: calc(-1 * var(--o3-spacing-5xs)) 0 calc(-1 * var(--o3-spacing-5xs)) calc(-1 * var(--o3-spacing-5xs));
|
|
203
221
|
}
|
|
204
222
|
|
|
223
|
+
/* src/css/components/radio-button.css */
|
|
224
|
+
.o3-form-input-radio-button + label::before {
|
|
225
|
+
content: "";
|
|
226
|
+
display: inline-block;
|
|
227
|
+
width: var(--o3-spacing-s);
|
|
228
|
+
height: var(--o3-spacing-s);
|
|
229
|
+
margin-right: var(--o3-spacing-3xs);
|
|
230
|
+
border: var(--_o3-form-input-border);
|
|
231
|
+
border-radius: 50%;
|
|
232
|
+
box-sizing: border-box;
|
|
233
|
+
}
|
|
234
|
+
.o3-form-input-radio-button:hover + label::before {
|
|
235
|
+
border-color: var(--o3-form-color-use-case-border-hover);
|
|
236
|
+
}
|
|
237
|
+
.o3-form-input-radio-button:active + label::before {
|
|
238
|
+
border-color: var(--o3-form-color-use-case-border-active);
|
|
239
|
+
}
|
|
240
|
+
.o3-form-input-radio-button:checked + label::before {
|
|
241
|
+
border-color: var(--o3-form-color-use-case-selected);
|
|
242
|
+
}
|
|
243
|
+
.o3-form-input-radio-button:checked + label::after {
|
|
244
|
+
position: absolute;
|
|
245
|
+
content: "";
|
|
246
|
+
width: var(--o3-spacing-3xs);
|
|
247
|
+
height: var(--o3-spacing-3xs);
|
|
248
|
+
background-color: var(--o3-form-color-use-case-selected);
|
|
249
|
+
margin: 6px;
|
|
250
|
+
border-radius: 50%;
|
|
251
|
+
}
|
|
252
|
+
.o3-form-input-radio-button:checked:hover + label::before {
|
|
253
|
+
border-color: var(--o3-form-color-use-case-selected-hover);
|
|
254
|
+
}
|
|
255
|
+
.o3-form-input-radio-button:checked:hover + label::after {
|
|
256
|
+
background-color: var(--o3-form-color-use-case-selected-hover);
|
|
257
|
+
}
|
|
258
|
+
.o3-form-input-radio-button:checked:active + label::before {
|
|
259
|
+
border-color: var(--o3-form-color-use-case-selected-active);
|
|
260
|
+
}
|
|
261
|
+
.o3-form-input-radio-button:checked:active + label::after {
|
|
262
|
+
background-color: var(--o3-form-color-use-case-selected-active);
|
|
263
|
+
}
|
|
264
|
+
.o3-form-input-radio-button:disabled + label::before {
|
|
265
|
+
border-color: var(--o3-form-color-use-case-border-disabled);
|
|
266
|
+
}
|
|
267
|
+
.o3-form-input-radio-button:disabled:checked + label::after {
|
|
268
|
+
background-color: var(--o3-form-color-use-case-border-disabled);
|
|
269
|
+
}
|
|
270
|
+
.o3-form-input-radio-button:disabled + label {
|
|
271
|
+
color: var(--o3-form-color-use-case-border-disabled);
|
|
272
|
+
}
|
|
273
|
+
.o3-form-input-radio-button.o3-form-input-error + label::before {
|
|
274
|
+
border-color: var(--o3-color-use-case-error);
|
|
275
|
+
background-color: var(--o3-form-color-use-case-background-error);
|
|
276
|
+
}
|
|
277
|
+
.o3-form-input-radio-button.o3-form-input-error:checked + label::before {
|
|
278
|
+
border-color: var(--o3-color-use-case-error);
|
|
279
|
+
background-color: var(--o3-form-color-use-case-background-error);
|
|
280
|
+
}
|
|
281
|
+
.o3-form-input-radio-button.o3-form-input-error:checked + label::after {
|
|
282
|
+
background-color: var(--o3-color-use-case-error);
|
|
283
|
+
}
|
|
284
|
+
.o3-form-input-radio-button__label {
|
|
285
|
+
display: flex;
|
|
286
|
+
align-items: center;
|
|
287
|
+
font-size: var(--o3-typography-use-case-body-small-font-size);
|
|
288
|
+
line-height: var(--o3-typography-use-case-body-small-line-height);
|
|
289
|
+
font-weight: var(--o3-typography-use-case-body-small-font-weight);
|
|
290
|
+
font-family: var(--o3-typography-use-case-body-small-font-family);
|
|
291
|
+
color: var(--o3-color-use-case-body-text);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/* src/css/components/error-summary.css */
|
|
295
|
+
.o3-form__error-summary {
|
|
296
|
+
display: flex;
|
|
297
|
+
padding: var(--o3-spacing-xs);
|
|
298
|
+
background-color: var(--_o3-form-error-summary-background-color);
|
|
299
|
+
border-radius: var(--_o3-form-input-border-radius);
|
|
300
|
+
}
|
|
301
|
+
.o3-form__error-summary .o3-form__error-summary-icon::before {
|
|
302
|
+
content: "";
|
|
303
|
+
display: inline-block;
|
|
304
|
+
background-color: var(--o3-color-use-case-error);
|
|
305
|
+
width: var(--o3-typography-use-case-body-small-font-size);
|
|
306
|
+
height: var(--o3-typography-use-case-body-small-font-size);
|
|
307
|
+
-webkit-mask-image: var(--o3-icons-ft-icon-error);
|
|
308
|
+
mask-image: var(--o3-icons-ft-icon-error);
|
|
309
|
+
-webkit-mask-repeat: no-repeat;
|
|
310
|
+
mask-repeat: no-repeat;
|
|
311
|
+
-webkit-mask-size: contain;
|
|
312
|
+
mask-size: contain;
|
|
313
|
+
}
|
|
314
|
+
.o3-form__error-summary .o3-form__error-summary__heading {
|
|
315
|
+
margin-left: var(--o3-spacing-4xs);
|
|
316
|
+
}
|
|
317
|
+
.o3-form__error-summary .o3-form__error-summary__heading > span {
|
|
318
|
+
font-weight: var(--o3-font-weight-medium);
|
|
319
|
+
color: var(--o3-color-use-case-error-text);
|
|
320
|
+
display: inline-block;
|
|
321
|
+
margin-bottom: var(--o3-spacing-4xs);
|
|
322
|
+
}
|
|
323
|
+
.o3-form__error-summary .o3-forms__error-summary__list {
|
|
324
|
+
list-style-type: none;
|
|
325
|
+
padding-left: 0;
|
|
326
|
+
margin-top: 0;
|
|
327
|
+
margin-bottom: 0;
|
|
328
|
+
}
|
|
329
|
+
.o3-form__error-summary .o3-forms__error-summary__list li {
|
|
330
|
+
margin-bottom: var(--o3-spacing-4xs);
|
|
331
|
+
}
|
|
332
|
+
.o3-form__error-summary .o3-forms__error-summary__list li:last-child {
|
|
333
|
+
margin-bottom: 0;
|
|
334
|
+
}
|
|
335
|
+
.o3-form__error-summary .o3-forms__error-summary__list li a {
|
|
336
|
+
color: var(--o3-color-use-case-body-text);
|
|
337
|
+
text-decoration-color: var(--o3-color-use-case-body-text);
|
|
338
|
+
}
|
|
339
|
+
@media screen and (max-width: 489px) {
|
|
340
|
+
.o3-form__error-summary {
|
|
341
|
+
padding: var(--o3-spacing-3xs);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/* src/css/components/password-input.css */
|
|
346
|
+
.o3-password-input__controls {
|
|
347
|
+
display: flex;
|
|
348
|
+
justify-content: space-between;
|
|
349
|
+
--o3-grid-columns-to-span-count: 4;
|
|
350
|
+
max-width: var(--o3-grid-columns-to-span-width, 100%);
|
|
351
|
+
margin-top: var(--o3-spacing-3xs);
|
|
352
|
+
font-size: var(--o3-font-size-metric2-negative-1);
|
|
353
|
+
line-height: var(--o3-font-lineheight-metric2-negative-1);
|
|
354
|
+
}
|
|
355
|
+
|
|
205
356
|
/* main.css */
|
package/css/whitelabel.css
CHANGED
|
@@ -3,11 +3,21 @@
|
|
|
3
3
|
|
|
4
4
|
/* src/css/tokens/whitelabel/o3-form/_variables.css */
|
|
5
5
|
[data-o3-brand=whitelabel] .o3-form {
|
|
6
|
-
--
|
|
7
|
-
--_o3-form-
|
|
8
|
-
--_o3-form-
|
|
9
|
-
--
|
|
10
|
-
--
|
|
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-30);
|
|
10
|
+
--o3-form-color-use-case-selected-active: var(--o3-color-palette-black-40);
|
|
11
|
+
--o3-form-color-use-case-selected-hover: var(--o3-color-palette-black-30);
|
|
12
|
+
--o3-form-color-use-case-selected: var(--o3-color-palette-black-50);
|
|
13
|
+
--o3-form-color-use-case-border-disabled: var(--o3-color-palette-black-30);
|
|
14
|
+
--o3-form-color-use-case-border-active: var(--o3-color-palette-black-40);
|
|
15
|
+
--o3-form-color-use-case-border-hover: var(--o3-color-palette-black-20);
|
|
16
|
+
--o3-form-color-use-case-border: var(--o3-color-palette-black-30);
|
|
17
|
+
--o3-form-color-use-case-background-disabled: var(--o3-color-palette-black-5);
|
|
18
|
+
--o3-form-color-use-case-background: var(--o3-color-palette-white);
|
|
19
|
+
--_o3-form-input-border: 2px solid var(--o3-color-palette-black-30);
|
|
20
|
+
--_o3-form-input-border-error: 2px solid var(--o3-color-use-case-error);
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
/* src/css/brands/whitelabel.css */
|
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,
|
|
2
|
+
import { C as CheckBoxProps, F as FormFieldsetProps } from './index-CHdbHHZ0.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
|
@@ -3,11 +3,11 @@ import { createElement } from "react";
|
|
|
3
3
|
import { TitledFormField, FormFieldset } from "./fieldComponents/FormField";
|
|
4
4
|
const CheckBoxItem = (props) => {
|
|
5
5
|
let { inputId, attributes, optional, error } = props;
|
|
6
|
-
const classNames = ["o3-form-
|
|
6
|
+
const classNames = ["o3-form-input-checkbox__input", "o3-visually-hidden"];
|
|
7
7
|
if (error) {
|
|
8
8
|
classNames.push("o3-form-input-error");
|
|
9
9
|
}
|
|
10
|
-
return /* @__PURE__ */ jsxs("div", { className: "o3-form-
|
|
10
|
+
return /* @__PURE__ */ jsxs("div", { className: "o3-form-input-checkbox", children: [
|
|
11
11
|
/* @__PURE__ */ jsx(
|
|
12
12
|
"input",
|
|
13
13
|
{
|
|
@@ -19,7 +19,7 @@ const CheckBoxItem = (props) => {
|
|
|
19
19
|
"aria-required": !optional
|
|
20
20
|
}
|
|
21
21
|
),
|
|
22
|
-
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "o3-form-
|
|
22
|
+
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "o3-form-input-checkbox__label", children: props.checkboxLabel })
|
|
23
23
|
] });
|
|
24
24
|
};
|
|
25
25
|
const CheckBox = (props) => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
const ErrorSummary = ({
|
|
3
|
+
errors,
|
|
4
|
+
errorMessage = "Please correct these errors and try again."
|
|
5
|
+
}) => {
|
|
6
|
+
return /* @__PURE__ */ jsxs("div", { className: "o3-form__error-summary", children: [
|
|
7
|
+
/* @__PURE__ */ jsx("span", { className: "o3-form__error-summary-icon" }),
|
|
8
|
+
/* @__PURE__ */ jsxs(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: "o3-form__error-summary__heading",
|
|
12
|
+
role: "alert",
|
|
13
|
+
"aria-labelledby": "error-summary-title",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsx("span", { id: "error-summary-title", className: "o3-typography-heading5", children: errorMessage }),
|
|
16
|
+
/* @__PURE__ */ jsx("ul", { className: "o3-forms__error-summary__list o3-typography-body-small", children: errors.map(({ id, fieldName, message }) => /* @__PURE__ */ jsxs("li", { children: [
|
|
17
|
+
/* @__PURE__ */ jsx("a", { className: "o3-typography-link", href: `#${id}`, children: fieldName }),
|
|
18
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
19
|
+
": ",
|
|
20
|
+
message
|
|
21
|
+
] })
|
|
22
|
+
] }, id)) })
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
] });
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
ErrorSummary
|
|
30
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { a as FormFieldProps } from './index-CHdbHHZ0.js';
|
|
3
|
+
|
|
4
|
+
interface PasswordInputProps extends FormFieldProps {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const PasswordInput: ({ label, feedback, description, disabled, attributes, inputId, optional, }: PasswordInputProps) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { PasswordInput };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { LabeledFormField } from "./fieldComponents/FormField";
|
|
3
|
+
import { CheckBoxItem } from "./CheckBox";
|
|
4
|
+
const PasswordInput = ({
|
|
5
|
+
label,
|
|
6
|
+
feedback,
|
|
7
|
+
description,
|
|
8
|
+
disabled,
|
|
9
|
+
attributes,
|
|
10
|
+
inputId,
|
|
11
|
+
optional
|
|
12
|
+
}) => {
|
|
13
|
+
const inputClasses = ["o3-form", "o3-form-text-input"];
|
|
14
|
+
if (feedback && feedback.type === "error") {
|
|
15
|
+
inputClasses.push("o3-form-text-input--error");
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
LabeledFormField,
|
|
20
|
+
{
|
|
21
|
+
label,
|
|
22
|
+
feedback,
|
|
23
|
+
description,
|
|
24
|
+
inputId,
|
|
25
|
+
optional,
|
|
26
|
+
children: /* @__PURE__ */ jsx(
|
|
27
|
+
"input",
|
|
28
|
+
{
|
|
29
|
+
...attributes,
|
|
30
|
+
id: inputId,
|
|
31
|
+
disabled,
|
|
32
|
+
className: inputClasses.join(" "),
|
|
33
|
+
required: !optional,
|
|
34
|
+
"aria-required": !optional,
|
|
35
|
+
type: "password"
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ jsxs("div", { className: "o3-password-input__controls", children: [
|
|
41
|
+
/* @__PURE__ */ jsx(
|
|
42
|
+
CheckBoxItem,
|
|
43
|
+
{
|
|
44
|
+
attributes: { disabled },
|
|
45
|
+
inputId: "showPassword",
|
|
46
|
+
checkboxLabel: "Show Password"
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
!disabled && /* @__PURE__ */ jsx("a", { href: "", children: "Forgot password?" })
|
|
50
|
+
] })
|
|
51
|
+
] });
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
PasswordInput
|
|
55
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { R as RadioButtonProps, F as FormFieldsetProps } from './index-CHdbHHZ0.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,52 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { FormFieldset } from "./fieldComponents/FormField";
|
|
4
|
+
const RadioButtonItem = (props) => {
|
|
5
|
+
let { inputId, attributes, optional, error } = props;
|
|
6
|
+
const classNames = [
|
|
7
|
+
"o3-form-input-radio-button",
|
|
8
|
+
"o3-visually-hidden"
|
|
9
|
+
];
|
|
10
|
+
if (error) {
|
|
11
|
+
classNames.push("o3-form-input-error");
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
14
|
+
/* @__PURE__ */ jsx(
|
|
15
|
+
"input",
|
|
16
|
+
{
|
|
17
|
+
...attributes,
|
|
18
|
+
type: "radio",
|
|
19
|
+
id: inputId,
|
|
20
|
+
className: classNames.join(" "),
|
|
21
|
+
required: !optional,
|
|
22
|
+
"aria-required": !optional
|
|
23
|
+
}
|
|
24
|
+
),
|
|
25
|
+
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "o3-form-input-radio-button__label", children: props.radioButtonLabel })
|
|
26
|
+
] });
|
|
27
|
+
};
|
|
28
|
+
const RadioButtonGroup = (props) => {
|
|
29
|
+
const { children, ...restProps } = props;
|
|
30
|
+
const radioGroupName = Math.random().toString(36).substring(7);
|
|
31
|
+
return /* @__PURE__ */ jsx(FormFieldset, { ...restProps, children: children.map((child) => {
|
|
32
|
+
const hasError = props.feedback?.errorElementIds?.includes(
|
|
33
|
+
child.props.inputId
|
|
34
|
+
);
|
|
35
|
+
return /* @__PURE__ */ createElement(
|
|
36
|
+
RadioButtonItem,
|
|
37
|
+
{
|
|
38
|
+
...child.props,
|
|
39
|
+
error: hasError,
|
|
40
|
+
key: child.props.inputId,
|
|
41
|
+
attributes: {
|
|
42
|
+
...child.props.attributes,
|
|
43
|
+
name: radioGroupName
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}) });
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
RadioButtonGroup,
|
|
51
|
+
RadioButtonItem
|
|
52
|
+
};
|
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-CHdbHHZ0.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,5 +1,4 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import "../../main.css";
|
|
3
2
|
import { LabeledFormField } from "./fieldComponents/FormField";
|
|
4
3
|
const TextInput = ({
|
|
5
4
|
label,
|
|
@@ -25,6 +24,7 @@ const TextInput = ({
|
|
|
25
24
|
feedback,
|
|
26
25
|
description,
|
|
27
26
|
inputId,
|
|
27
|
+
optional,
|
|
28
28
|
children: /* @__PURE__ */ jsx(
|
|
29
29
|
"input",
|
|
30
30
|
{
|
|
@@ -32,8 +32,8 @@ const TextInput = ({
|
|
|
32
32
|
id: inputId,
|
|
33
33
|
disabled,
|
|
34
34
|
className: inputClasses.join(" "),
|
|
35
|
-
required: optional,
|
|
36
|
-
"aria-required": optional,
|
|
35
|
+
required: !optional,
|
|
36
|
+
"aria-required": !optional,
|
|
37
37
|
maxLength: length,
|
|
38
38
|
type: "text"
|
|
39
39
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
const Feedback = ({ message, type }) => {
|
|
3
|
+
return /* @__PURE__ */ jsx("div", { className: `o3-form-feedback o3-form-feedback__${type}`, children: /* @__PURE__ */ jsx("span", { className: `o3-form-feedback__${type}-message`, children: message }) });
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
Feedback
|
|
7
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { a as FormFieldProps, F as FormFieldsetProps } from '../index-CHdbHHZ0.mjs';
|
|
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,69 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { uidBuilder } from "@financial-times/o-utils";
|
|
3
|
+
import { Feedback } from "./Feedback";
|
|
4
|
+
const uniqueId = uidBuilder("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__ */ jsxs("div", { className: "o3-form-field", children: [
|
|
20
|
+
/* @__PURE__ */ jsx("label", { className: labelClasses.join(" "), htmlFor: id, children: label }),
|
|
21
|
+
description && /* @__PURE__ */ jsx("span", { className: "o3-form-input__description", id: descriptionId, children: description }),
|
|
22
|
+
children,
|
|
23
|
+
feedback && /* @__PURE__ */ jsx(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__ */ jsxs("div", { className: "o3-form-field", children: [
|
|
40
|
+
/* @__PURE__ */ jsx("span", { className: labelClasses.join(" "), id: labelId, children: label }),
|
|
41
|
+
description && /* @__PURE__ */ jsx("span", { className: "o3-form-input__description", id: descriptionId, children: description }),
|
|
42
|
+
children,
|
|
43
|
+
feedback && /* @__PURE__ */ jsx(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__ */ jsxs("fieldset", { className: "o3-form-field", "aria-describedby": `${descriptionId}`, children: [
|
|
59
|
+
/* @__PURE__ */ jsx("legend", { className: labelClasses.join(" "), children: label }),
|
|
60
|
+
description && /* @__PURE__ */ jsx("span", { className: "o3-form-input__description", id: descriptionId, children: description }),
|
|
61
|
+
children,
|
|
62
|
+
feedback && /* @__PURE__ */ jsx(Feedback, { ...feedback })
|
|
63
|
+
] });
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
FormFieldset,
|
|
67
|
+
LabeledFormField,
|
|
68
|
+
TitledFormField
|
|
69
|
+
};
|
|
@@ -6,7 +6,7 @@ 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;
|
|
@@ -16,11 +16,16 @@ interface CheckBoxProps extends BaseInputProps {
|
|
|
16
16
|
checkboxLabel: string;
|
|
17
17
|
feedback?: FeedbackProps;
|
|
18
18
|
}
|
|
19
|
+
interface RadioButtonProps extends BaseInputProps {
|
|
20
|
+
inputId: string;
|
|
21
|
+
radioButtonLabel: string;
|
|
22
|
+
}
|
|
19
23
|
interface FormFieldsetProps {
|
|
20
24
|
label: string;
|
|
21
25
|
description?: string;
|
|
22
26
|
children: JSX.Element | JSX.Element[];
|
|
23
27
|
feedback?: FeedbackProps;
|
|
28
|
+
optional?: boolean;
|
|
24
29
|
}
|
|
25
30
|
interface FormFieldProps extends BaseInputProps {
|
|
26
31
|
feedback?: FeedbackProps;
|
|
@@ -31,5 +36,13 @@ type FeedbackProps = {
|
|
|
31
36
|
message: string;
|
|
32
37
|
type: 'error';
|
|
33
38
|
};
|
|
39
|
+
type ErrorSummaryProps = {
|
|
40
|
+
errorMessage?: string;
|
|
41
|
+
errors: {
|
|
42
|
+
id: string;
|
|
43
|
+
fieldName: string;
|
|
44
|
+
message: string;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
34
47
|
|
|
35
|
-
export type { CheckBoxProps as C,
|
|
48
|
+
export type { CheckBoxProps as C, ErrorSummaryProps as E, FormFieldsetProps as F, RadioButtonProps as R, TextInputProps as T, FormFieldProps as a, FeedbackProps as b };
|
package/esm/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-CHdbHHZ0.js';
|
package/esm/index.js
CHANGED
|
@@ -2,3 +2,7 @@ export * from "./fieldComponents/Feedback";
|
|
|
2
2
|
export * from "./fieldComponents/FormField";
|
|
3
3
|
export * from "./fieldComponents/Form";
|
|
4
4
|
export * from "./CheckBox";
|
|
5
|
+
export * from "./RadioButton";
|
|
6
|
+
export * from "./Error-summary";
|
|
7
|
+
export * from "./PasswordInput";
|
|
8
|
+
export * from "./TextInput";
|