carbon-react 109.4.0 → 109.5.2
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/esm/__internal__/form-field/form-field.component.d.ts +59 -0
- package/esm/__internal__/form-field/form-field.component.js +202 -57
- package/esm/__internal__/form-field/form-field.style.d.ts +7 -0
- package/esm/__internal__/form-field/form-field.style.js +6 -12
- package/esm/__internal__/form-field/index.d.ts +2 -5
- package/esm/__internal__/label/label.component.d.ts +2 -4
- package/esm/__internal__/label/label.component.js +0 -3
- package/esm/components/button/button-types.style.js +4 -0
- package/esm/components/button-toggle-group/button-toggle-group.component.js +9 -10
- package/esm/components/button-toggle-group/button-toggle-group.d.ts +3 -1
- package/esm/components/icon-button/icon-button.component.d.ts +23 -0
- package/esm/components/icon-button/icon-button.component.js +168 -22
- package/esm/components/icon-button/icon-button.style.d.ts +4 -0
- package/esm/components/icon-button/index.d.ts +2 -2
- package/esm/components/loader/loader-square.style.d.ts +2 -0
- package/esm/components/loader/loader.config.d.ts +1 -0
- package/esm/components/pill/pill.component.d.ts +2 -2
- package/esm/components/pill/pill.component.js +7 -9
- package/esm/components/popover-container/popover-container.component.d.ts +4 -4
- package/esm/components/popover-container/popover-container.style.d.ts +3 -3
- package/esm/components/switch/switch.component.js +0 -3
- package/esm/components/switch/switch.d.ts +0 -2
- package/esm/components/tabs/tab/tab.d.ts +3 -3
- package/lib/__internal__/form-field/form-field.component.d.ts +59 -0
- package/lib/__internal__/form-field/form-field.component.js +201 -57
- package/lib/__internal__/form-field/form-field.style.d.ts +7 -0
- package/lib/__internal__/form-field/form-field.style.js +9 -13
- package/lib/__internal__/form-field/index.d.ts +2 -5
- package/lib/__internal__/label/label.component.d.ts +2 -4
- package/lib/__internal__/label/label.component.js +0 -3
- package/lib/components/button/button-types.style.js +5 -0
- package/lib/components/button-toggle-group/button-toggle-group.component.js +9 -10
- package/lib/components/button-toggle-group/button-toggle-group.d.ts +3 -1
- package/lib/components/icon-button/icon-button.component.d.ts +23 -0
- package/lib/components/icon-button/icon-button.component.js +168 -25
- package/lib/components/icon-button/icon-button.style.d.ts +4 -0
- package/lib/components/icon-button/index.d.ts +2 -2
- package/lib/components/loader/loader-square.style.d.ts +2 -0
- package/lib/components/loader/loader.config.d.ts +1 -0
- package/lib/components/pill/pill.component.d.ts +2 -2
- package/lib/components/pill/pill.component.js +7 -9
- package/lib/components/popover-container/popover-container.component.d.ts +4 -4
- package/lib/components/popover-container/popover-container.style.d.ts +3 -3
- package/lib/components/switch/switch.component.js +0 -3
- package/lib/components/switch/switch.d.ts +0 -2
- package/lib/components/tabs/tab/tab.d.ts +3 -3
- package/package.json +1 -1
- package/esm/__internal__/form-field/form-field.d.ts +0 -66
- package/esm/components/icon-button/icon-button.d.ts +0 -18
- package/lib/__internal__/form-field/form-field.d.ts +0 -66
- package/lib/components/icon-button/icon-button.d.ts +0 -18
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ValidationProps } from "__internal__/validations";
|
|
3
|
+
import { MarginProps } from "styled-system";
|
|
4
|
+
import { TagProps } from "../utils/helpers/tags/tags";
|
|
5
|
+
import { IconType } from "../../components/icon";
|
|
6
|
+
interface CommonFormFieldProps extends MarginProps, ValidationProps {
|
|
7
|
+
/** If true, the component will be disabled */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Help content to be displayed under an input */
|
|
10
|
+
fieldHelp?: React.ReactNode;
|
|
11
|
+
/** The unique id of the Help component tooltip, used for accessibility */
|
|
12
|
+
tooltipId?: string;
|
|
13
|
+
/** The unique id of the FieldHelp component */
|
|
14
|
+
fieldHelpId?: string;
|
|
15
|
+
/** Label content */
|
|
16
|
+
label?: React.ReactNode;
|
|
17
|
+
/** Text alignment of the label */
|
|
18
|
+
labelAlign?: "left" | "right";
|
|
19
|
+
/** A message that the Help component will display */
|
|
20
|
+
labelHelp?: React.ReactNode;
|
|
21
|
+
/** Help Icon type */
|
|
22
|
+
labelHelpIcon?: IconType;
|
|
23
|
+
/** The unique id of the label element */
|
|
24
|
+
labelId?: string;
|
|
25
|
+
/** When true label is inline */
|
|
26
|
+
labelInline?: boolean;
|
|
27
|
+
/** Spacing between label and a field for inline label, given number will be multiplied by base spacing unit (8) */
|
|
28
|
+
labelSpacing?: 1 | 2;
|
|
29
|
+
/** Label width */
|
|
30
|
+
labelWidth?: number;
|
|
31
|
+
/** If true the label switches position with the input */
|
|
32
|
+
reverse?: boolean;
|
|
33
|
+
/** Id of the validation icon */
|
|
34
|
+
validationIconId?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface FormFieldProps extends CommonFormFieldProps, TagProps {
|
|
37
|
+
/** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
|
|
38
|
+
adaptiveLabelBreakpoint?: number;
|
|
39
|
+
/** Content to be rendered inside the FormField */
|
|
40
|
+
children?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* If true, the FieldHelp will be displayed inline
|
|
43
|
+
* To be used with labelInline prop set to true
|
|
44
|
+
*/
|
|
45
|
+
fieldHelpInline?: boolean;
|
|
46
|
+
/** Id of the element a label should be bound to */
|
|
47
|
+
id: string;
|
|
48
|
+
/** [Legacy] Flag to configure component as optional in Form */
|
|
49
|
+
isOptional?: boolean;
|
|
50
|
+
/** Flag to configure component as mandatory */
|
|
51
|
+
isRequired?: boolean;
|
|
52
|
+
/** Whether to show the validation icon */
|
|
53
|
+
useValidationIcon?: boolean;
|
|
54
|
+
}
|
|
55
|
+
declare const FormField: {
|
|
56
|
+
({ children, disabled, fieldHelp: fieldHelpContent, fieldHelpInline, error, warning, info, tooltipId, fieldHelpId, label, labelId, labelAlign, labelHelp, labelHelpIcon, labelInline, labelSpacing, labelWidth, id, reverse, isOptional, useValidationIcon, adaptiveLabelBreakpoint, isRequired, validationIconId, ...rest }: FormFieldProps): JSX.Element;
|
|
57
|
+
displayName: string;
|
|
58
|
+
};
|
|
59
|
+
export default FormField;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
import React, { useContext, useEffect } from "react";
|
|
3
|
+
import React, { useContext, useEffect, useMemo } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import
|
|
5
|
+
import invariant from "invariant";
|
|
6
6
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
7
7
|
import FormFieldStyle, { FieldLineStyle } from "./form-field.style";
|
|
8
8
|
import Label from "../label";
|
|
@@ -10,7 +10,6 @@ import FieldHelp from "../field-help";
|
|
|
10
10
|
import tagComponent from "../utils/helpers/tags/tags";
|
|
11
11
|
import { TabContext } from "../../components/tabs/tab";
|
|
12
12
|
import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
|
|
13
|
-
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
14
13
|
|
|
15
14
|
const FormField = ({
|
|
16
15
|
children,
|
|
@@ -22,7 +21,6 @@ const FormField = ({
|
|
|
22
21
|
info,
|
|
23
22
|
tooltipId,
|
|
24
23
|
fieldHelpId,
|
|
25
|
-
helpTabIndex,
|
|
26
24
|
label,
|
|
27
25
|
labelId,
|
|
28
26
|
labelAlign,
|
|
@@ -40,7 +38,16 @@ const FormField = ({
|
|
|
40
38
|
validationIconId,
|
|
41
39
|
...rest
|
|
42
40
|
}) => {
|
|
43
|
-
const
|
|
41
|
+
const invalidValidationProp = useMemo(() => {
|
|
42
|
+
const validationProps = {
|
|
43
|
+
error: !!error,
|
|
44
|
+
warning: !!warning,
|
|
45
|
+
info: !!info
|
|
46
|
+
};
|
|
47
|
+
if (!disabled) return undefined;
|
|
48
|
+
return Object.keys(validationProps).find(propName => validationProps[propName]);
|
|
49
|
+
}, [error, warning, info, disabled]);
|
|
50
|
+
!(invalidValidationProp === undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Prop \`${invalidValidationProp}\` cannot be used in conjunction with \`disabled\`. ` + "Use `readOnly` if you require users to see validations with a non-interactive field") : invariant(false) : void 0;
|
|
44
51
|
const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
|
|
45
52
|
let inlineLabel = labelInline;
|
|
46
53
|
|
|
@@ -48,13 +55,16 @@ const FormField = ({
|
|
|
48
55
|
inlineLabel = largeScreen;
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
const {
|
|
59
|
+
setError,
|
|
60
|
+
setWarning,
|
|
61
|
+
setInfo
|
|
62
|
+
} = useContext(TabContext);
|
|
51
63
|
useEffect(() => {
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
}, [id, context, error, warning, info]);
|
|
64
|
+
if (setError) setError(id, !!error);
|
|
65
|
+
if (setWarning) setWarning(id, !!warning);
|
|
66
|
+
if (setInfo) setInfo(id, !!info);
|
|
67
|
+
}, [id, setError, setWarning, setInfo, error, warning, info]);
|
|
58
68
|
const marginProps = filterStyledSystemMarginProps(rest);
|
|
59
69
|
const fieldHelp = fieldHelpContent ? /*#__PURE__*/React.createElement(FieldHelp, {
|
|
60
70
|
labelInline: inlineLabel,
|
|
@@ -72,7 +82,6 @@ const FormField = ({
|
|
|
72
82
|
info: !rest.validationRedesignOptIn && info,
|
|
73
83
|
help: labelHelp,
|
|
74
84
|
tooltipId: tooltipId,
|
|
75
|
-
helpTabIndex: helpTabIndex,
|
|
76
85
|
htmlFor: id,
|
|
77
86
|
helpIcon: labelHelpIcon,
|
|
78
87
|
inline: inlineLabel,
|
|
@@ -86,52 +95,188 @@ const FormField = ({
|
|
|
86
95
|
}, label), fieldHelpInline && fieldHelp, !reverse && children), !fieldHelpInline && fieldHelp);
|
|
87
96
|
};
|
|
88
97
|
|
|
89
|
-
const errorPropType = (props, propName, componentName, ...rest) => {
|
|
90
|
-
if (props[propName] && props.disabled) {
|
|
91
|
-
return new Error(`Prop \`${propName}\` cannot be used in conjunction with \`disabled\`. ` + "Use `readOnly` if you require users to see validations with a non-interactive field");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return PropTypes.oneOfType([PropTypes.bool, PropTypes.string])(props, propName, componentName, ...rest);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
98
|
FormField.propTypes = {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
disabled: PropTypes.bool,
|
|
102
|
-
"data-component": PropTypes.string,
|
|
103
|
-
"data-role": PropTypes.string,
|
|
99
|
+
"adaptiveLabelBreakpoint": PropTypes.number,
|
|
100
|
+
"children": PropTypes.node,
|
|
101
|
+
"data-component": PropTypes.string.isRequired,
|
|
104
102
|
"data-element": PropTypes.string,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
error:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
label: PropTypes.node,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
labelInline: PropTypes.bool,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
103
|
+
"data-role": PropTypes.string,
|
|
104
|
+
"disabled": PropTypes.bool,
|
|
105
|
+
"error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
106
|
+
"fieldHelp": PropTypes.node,
|
|
107
|
+
"fieldHelpId": PropTypes.string,
|
|
108
|
+
"fieldHelpInline": PropTypes.bool,
|
|
109
|
+
"id": PropTypes.string.isRequired,
|
|
110
|
+
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
111
|
+
"isOptional": PropTypes.bool,
|
|
112
|
+
"isRequired": PropTypes.bool,
|
|
113
|
+
"label": PropTypes.node,
|
|
114
|
+
"labelAlign": PropTypes.oneOf(["left", "right"]),
|
|
115
|
+
"labelHelp": PropTypes.node,
|
|
116
|
+
"labelHelpIcon": PropTypes.oneOf(["add", "admin", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "arrow", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "go", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "piggy_bank", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "three_boxes", "tick_circle", "tick", "true_tick", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
117
|
+
"labelId": PropTypes.string,
|
|
118
|
+
"labelInline": PropTypes.bool,
|
|
119
|
+
"labelSpacing": PropTypes.oneOf([1, 2]),
|
|
120
|
+
"labelWidth": PropTypes.number,
|
|
121
|
+
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
122
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
123
|
+
"description": PropTypes.string,
|
|
124
|
+
"toString": PropTypes.func.isRequired,
|
|
125
|
+
"valueOf": PropTypes.func.isRequired
|
|
126
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
127
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
128
|
+
"description": PropTypes.string,
|
|
129
|
+
"toString": PropTypes.func.isRequired,
|
|
130
|
+
"valueOf": PropTypes.func.isRequired
|
|
131
|
+
}), PropTypes.string]),
|
|
132
|
+
"margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
133
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
134
|
+
"description": PropTypes.string,
|
|
135
|
+
"toString": PropTypes.func.isRequired,
|
|
136
|
+
"valueOf": PropTypes.func.isRequired
|
|
137
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
138
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
139
|
+
"description": PropTypes.string,
|
|
140
|
+
"toString": PropTypes.func.isRequired,
|
|
141
|
+
"valueOf": PropTypes.func.isRequired
|
|
142
|
+
}), PropTypes.string]),
|
|
143
|
+
"marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
144
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
145
|
+
"description": PropTypes.string,
|
|
146
|
+
"toString": PropTypes.func.isRequired,
|
|
147
|
+
"valueOf": PropTypes.func.isRequired
|
|
148
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
149
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
150
|
+
"description": PropTypes.string,
|
|
151
|
+
"toString": PropTypes.func.isRequired,
|
|
152
|
+
"valueOf": PropTypes.func.isRequired
|
|
153
|
+
}), PropTypes.string]),
|
|
154
|
+
"marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
155
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
156
|
+
"description": PropTypes.string,
|
|
157
|
+
"toString": PropTypes.func.isRequired,
|
|
158
|
+
"valueOf": PropTypes.func.isRequired
|
|
159
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
160
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
161
|
+
"description": PropTypes.string,
|
|
162
|
+
"toString": PropTypes.func.isRequired,
|
|
163
|
+
"valueOf": PropTypes.func.isRequired
|
|
164
|
+
}), PropTypes.string]),
|
|
165
|
+
"marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
166
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
167
|
+
"description": PropTypes.string,
|
|
168
|
+
"toString": PropTypes.func.isRequired,
|
|
169
|
+
"valueOf": PropTypes.func.isRequired
|
|
170
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
171
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
172
|
+
"description": PropTypes.string,
|
|
173
|
+
"toString": PropTypes.func.isRequired,
|
|
174
|
+
"valueOf": PropTypes.func.isRequired
|
|
175
|
+
}), PropTypes.string]),
|
|
176
|
+
"marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
177
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
178
|
+
"description": PropTypes.string,
|
|
179
|
+
"toString": PropTypes.func.isRequired,
|
|
180
|
+
"valueOf": PropTypes.func.isRequired
|
|
181
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
182
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
183
|
+
"description": PropTypes.string,
|
|
184
|
+
"toString": PropTypes.func.isRequired,
|
|
185
|
+
"valueOf": PropTypes.func.isRequired
|
|
186
|
+
}), PropTypes.string]),
|
|
187
|
+
"marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
188
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
189
|
+
"description": PropTypes.string,
|
|
190
|
+
"toString": PropTypes.func.isRequired,
|
|
191
|
+
"valueOf": PropTypes.func.isRequired
|
|
192
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
193
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
194
|
+
"description": PropTypes.string,
|
|
195
|
+
"toString": PropTypes.func.isRequired,
|
|
196
|
+
"valueOf": PropTypes.func.isRequired
|
|
197
|
+
}), PropTypes.string]),
|
|
198
|
+
"marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
199
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
200
|
+
"description": PropTypes.string,
|
|
201
|
+
"toString": PropTypes.func.isRequired,
|
|
202
|
+
"valueOf": PropTypes.func.isRequired
|
|
203
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
204
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
205
|
+
"description": PropTypes.string,
|
|
206
|
+
"toString": PropTypes.func.isRequired,
|
|
207
|
+
"valueOf": PropTypes.func.isRequired
|
|
208
|
+
}), PropTypes.string]),
|
|
209
|
+
"mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
210
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
211
|
+
"description": PropTypes.string,
|
|
212
|
+
"toString": PropTypes.func.isRequired,
|
|
213
|
+
"valueOf": PropTypes.func.isRequired
|
|
214
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
215
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
216
|
+
"description": PropTypes.string,
|
|
217
|
+
"toString": PropTypes.func.isRequired,
|
|
218
|
+
"valueOf": PropTypes.func.isRequired
|
|
219
|
+
}), PropTypes.string]),
|
|
220
|
+
"ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
221
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
222
|
+
"description": PropTypes.string,
|
|
223
|
+
"toString": PropTypes.func.isRequired,
|
|
224
|
+
"valueOf": PropTypes.func.isRequired
|
|
225
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
226
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
227
|
+
"description": PropTypes.string,
|
|
228
|
+
"toString": PropTypes.func.isRequired,
|
|
229
|
+
"valueOf": PropTypes.func.isRequired
|
|
230
|
+
}), PropTypes.string]),
|
|
231
|
+
"mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
232
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
233
|
+
"description": PropTypes.string,
|
|
234
|
+
"toString": PropTypes.func.isRequired,
|
|
235
|
+
"valueOf": PropTypes.func.isRequired
|
|
236
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
237
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
238
|
+
"description": PropTypes.string,
|
|
239
|
+
"toString": PropTypes.func.isRequired,
|
|
240
|
+
"valueOf": PropTypes.func.isRequired
|
|
241
|
+
}), PropTypes.string]),
|
|
242
|
+
"mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
243
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
244
|
+
"description": PropTypes.string,
|
|
245
|
+
"toString": PropTypes.func.isRequired,
|
|
246
|
+
"valueOf": PropTypes.func.isRequired
|
|
247
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
248
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
249
|
+
"description": PropTypes.string,
|
|
250
|
+
"toString": PropTypes.func.isRequired,
|
|
251
|
+
"valueOf": PropTypes.func.isRequired
|
|
252
|
+
}), PropTypes.string]),
|
|
253
|
+
"mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
254
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
255
|
+
"description": PropTypes.string,
|
|
256
|
+
"toString": PropTypes.func.isRequired,
|
|
257
|
+
"valueOf": PropTypes.func.isRequired
|
|
258
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
259
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
260
|
+
"description": PropTypes.string,
|
|
261
|
+
"toString": PropTypes.func.isRequired,
|
|
262
|
+
"valueOf": PropTypes.func.isRequired
|
|
263
|
+
}), PropTypes.string]),
|
|
264
|
+
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
265
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
266
|
+
"description": PropTypes.string,
|
|
267
|
+
"toString": PropTypes.func.isRequired,
|
|
268
|
+
"valueOf": PropTypes.func.isRequired
|
|
269
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
270
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
271
|
+
"description": PropTypes.string,
|
|
272
|
+
"toString": PropTypes.func.isRequired,
|
|
273
|
+
"valueOf": PropTypes.func.isRequired
|
|
274
|
+
}), PropTypes.string]),
|
|
275
|
+
"reverse": PropTypes.bool,
|
|
276
|
+
"tooltipId": PropTypes.string,
|
|
277
|
+
"useValidationIcon": PropTypes.bool,
|
|
278
|
+
"validationIconId": PropTypes.string,
|
|
279
|
+
"warning": PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
136
280
|
};
|
|
281
|
+
FormField.displayName = "FormField";
|
|
137
282
|
export default FormField;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare const FormFieldStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export interface FieldLineStyleProps {
|
|
3
|
+
inline?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const FieldLineStyle: import("styled-components").StyledComponent<"div", any, FieldLineStyleProps, never>;
|
|
6
|
+
export { FieldLineStyle };
|
|
7
|
+
export default FormFieldStyle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
2
|
import { space } from "styled-system";
|
|
3
|
-
import
|
|
3
|
+
import { baseTheme } from "../../style/themes";
|
|
4
4
|
const FormFieldStyle = styled.div`
|
|
5
5
|
& + & {
|
|
6
6
|
margin-top: 16px;
|
|
@@ -11,20 +11,14 @@ const FormFieldStyle = styled.div`
|
|
|
11
11
|
}
|
|
12
12
|
`;
|
|
13
13
|
FormFieldStyle.defaultProps = {
|
|
14
|
-
theme:
|
|
14
|
+
theme: baseTheme
|
|
15
15
|
};
|
|
16
16
|
const FieldLineStyle = styled.div`
|
|
17
17
|
${({
|
|
18
18
|
inline
|
|
19
|
-
}) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
display: flex;
|
|
23
|
-
`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return "display: block;";
|
|
27
|
-
}}
|
|
19
|
+
}) => css`
|
|
20
|
+
display: ${inline ? "flex" : "block"};
|
|
21
|
+
`}
|
|
28
22
|
`;
|
|
29
23
|
export { FieldLineStyle };
|
|
30
24
|
export default FormFieldStyle;
|
|
@@ -9,8 +9,6 @@ export interface LabelProps extends ValidationProps, StyledLabelProps, StyledLab
|
|
|
9
9
|
help?: React.ReactNode;
|
|
10
10
|
/** Icon type */
|
|
11
11
|
helpIcon?: IconType;
|
|
12
|
-
/** Overrides the default tabindex of the Help component */
|
|
13
|
-
helpTabIndex?: number | string;
|
|
14
12
|
/** A string that represents the ID of another form element */
|
|
15
13
|
htmlFor?: string;
|
|
16
14
|
/** The unique id of the label element */
|
|
@@ -22,6 +20,6 @@ export interface LabelProps extends ValidationProps, StyledLabelProps, StyledLab
|
|
|
22
20
|
/** Id of the validation icon */
|
|
23
21
|
validationIconId?: string;
|
|
24
22
|
}
|
|
25
|
-
export declare const Label: ({ align, children, disabled, error, help, helpIcon,
|
|
26
|
-
declare const _default: React.MemoExoticComponent<({ align, children, disabled, error, help, helpIcon,
|
|
23
|
+
export declare const Label: ({ align, children, disabled, error, help, helpIcon, htmlFor, info, inline, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, }: LabelProps) => JSX.Element;
|
|
24
|
+
declare const _default: React.MemoExoticComponent<({ align, children, disabled, error, help, helpIcon, htmlFor, info, inline, isRequired, labelId, optional, pr, pl, tooltipId, useValidationIcon, validationIconId, warning, width, }: LabelProps) => JSX.Element>;
|
|
27
25
|
export default _default;
|
|
@@ -32,7 +32,6 @@ const Label = ({
|
|
|
32
32
|
error,
|
|
33
33
|
help,
|
|
34
34
|
helpIcon,
|
|
35
|
-
helpTabIndex,
|
|
36
35
|
htmlFor,
|
|
37
36
|
info,
|
|
38
37
|
inline,
|
|
@@ -98,7 +97,6 @@ const Label = ({
|
|
|
98
97
|
|
|
99
98
|
return help && /*#__PURE__*/React.createElement(StyledIconWrapper, wrapperProps, /*#__PURE__*/React.createElement(Help, {
|
|
100
99
|
tooltipId: tooltipId,
|
|
101
|
-
tabIndex: Number(helpTabIndex),
|
|
102
100
|
type: helpIcon,
|
|
103
101
|
isFocused: isFocused
|
|
104
102
|
}, help));
|
|
@@ -129,7 +127,6 @@ Label.propTypes = {
|
|
|
129
127
|
"error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
130
128
|
"help": PropTypes.node,
|
|
131
129
|
"helpIcon": PropTypes.oneOf(["add", "admin", "alert", "analysis", "arrow_down", "arrow_left_boxed", "arrow_left_right_small", "arrow_left_small", "arrow_left", "arrow_right_small", "arrow_right", "arrow_up", "arrow", "attach", "bank", "basket_with_squares", "basket", "bin", "block_arrow_right", "blocked_square", "blocked", "bold", "boxed_shapes", "bulk_destroy", "bullet_list_dotted", "bullet_list_numbers", "bullet_list", "business", "calendar_today", "calendar", "call", "camera", "card_view", "caret_down", "caret_large_down", "caret_large_left", "caret_large_right", "caret_large_up", "caret_left", "caret_right", "caret_up", "cart", "chart_bar", "chart_line", "chart_pie", "chat_notes", "chat", "chevron_down_thick", "chevron_down", "chevron_left_thick", "chevron_left", "chevron_right_thick", "chevron_right", "chevron_up_thick", "chevron_up", "circle_with_dots", "circles_connection", "clock", "close", "coins", "collaborate", "computer_clock", "connect", "contacts", "copy", "create", "credit_card_slash", "credit_card", "cross_circle", "cross", "csv", "delete", "delivery", "disconnect", "disputed", "document_right_align", "document_tick", "document_vertical_lines", "download", "draft", "drag_vertical", "drag", "dropdown", "duplicate", "edit", "edited", "ellipsis_horizontal", "ellipsis_vertical", "email_switch", "email", "entry", "envelope_dollar", "envelope_euro", "error_square", "error", "euro", "expand", "factory", "favourite_lined", "favourite", "fax", "feedback", "file_excel", "file_generic", "file_image", "file_pdf", "file_word", "files_leaning", "filter_new", "filter", "fit_height", "fit_width", "flag", "folder", "gift", "go", "graph", "grid", "help", "hide", "home", "image", "in_progress", "in_transit", "individual", "info", "italic", "key", "ledger_arrow_left", "ledger_arrow_right", "ledger", "lightbulb_off", "lightbulb_on", "link", "list_view", "location", "locked", "logout", "lookup", "marker", "message", "minus_large", "minus", "mobile", "money_bag", "none", "old_warning", "pause_circle", "pause", "pdf", "people_switch", "people", "person_info", "person_tick", "person", "phone", "piggy_bank", "play_circle", "play", "plus_large", "plus", "pound", "print", "progress", "progressed", "question_hollow", "question_mark", "question", "refresh_clock", "refresh", "remove", "sage_coin", "save", "scan", "search", "services", "settings_old", "settings", "share", "shop", "sort_down", "sort_up", "spanner", "split_container", "split", "square_dot", "squares_nine", "stacked_boxes", "stacked_squares", "submitted", "sync", "tag", "talk", "three_boxes", "tick_circle", "tick", "true_tick", "undo", "unlocked", "upload", "uploaded", "video", "view", "warning"]),
|
|
132
|
-
"helpTabIndex": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
133
130
|
"htmlFor": PropTypes.string,
|
|
134
131
|
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
135
132
|
"inline": PropTypes.bool,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import StyledIcon from "../icon/icon.style";
|
|
2
|
+
import StyledLoaderSquare from "../loader/loader-square.style";
|
|
2
3
|
|
|
3
4
|
function makeColors(color) {
|
|
4
5
|
return `
|
|
@@ -6,6 +7,9 @@ function makeColors(color) {
|
|
|
6
7
|
${StyledIcon} {
|
|
7
8
|
color: ${color};
|
|
8
9
|
}
|
|
10
|
+
${StyledLoaderSquare} {
|
|
11
|
+
background-color: ${color};
|
|
12
|
+
}
|
|
9
13
|
`;
|
|
10
14
|
}
|
|
11
15
|
|
|
@@ -19,7 +19,7 @@ const ButtonToggleGroup = ({
|
|
|
19
19
|
error,
|
|
20
20
|
warning,
|
|
21
21
|
info,
|
|
22
|
-
validationOnLabel,
|
|
22
|
+
validationOnLabel = false,
|
|
23
23
|
label,
|
|
24
24
|
labelHelp,
|
|
25
25
|
labelSpacing,
|
|
@@ -32,7 +32,7 @@ const ButtonToggleGroup = ({
|
|
|
32
32
|
onChange,
|
|
33
33
|
onBlur,
|
|
34
34
|
value,
|
|
35
|
-
"data-component": dataComponent,
|
|
35
|
+
"data-component": dataComponent = "button-toggle-group",
|
|
36
36
|
"data-element": dataElement,
|
|
37
37
|
"data-role": dataRole,
|
|
38
38
|
helpAriaLabel,
|
|
@@ -85,10 +85,13 @@ ButtonToggleGroup.propTypes = { ...marginPropTypes,
|
|
|
85
85
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
86
86
|
"data-role": PropTypes.string,
|
|
87
87
|
|
|
88
|
+
/** Unique id for the root element of the component */
|
|
89
|
+
id: PropTypes.string.isRequired,
|
|
90
|
+
|
|
88
91
|
/** Specifies the name prop to be applied to each button in the group */
|
|
89
92
|
name: PropTypes.string.isRequired,
|
|
90
93
|
|
|
91
|
-
/**
|
|
94
|
+
/** Togglable buttons to be rendered. Only accepts children of type ButtonToggle */
|
|
92
95
|
children: (props, propName, componentName) => {
|
|
93
96
|
let error;
|
|
94
97
|
const prop = props[propName];
|
|
@@ -149,21 +152,17 @@ ButtonToggleGroup.propTypes = { ...marginPropTypes,
|
|
|
149
152
|
/** The alignment for the text in the label. */
|
|
150
153
|
labelAlign: PropTypes.string,
|
|
151
154
|
|
|
152
|
-
/** callback to handle change event */
|
|
153
|
-
onChange: PropTypes.func,
|
|
154
|
-
|
|
155
155
|
/** Callback fired when each RadioButton is blurred */
|
|
156
156
|
onBlur: PropTypes.func,
|
|
157
157
|
|
|
158
|
+
/** callback to handle change event */
|
|
159
|
+
onChange: PropTypes.func,
|
|
160
|
+
|
|
158
161
|
/** The value of the Button Toggle Group */
|
|
159
162
|
value: PropTypes.string,
|
|
160
163
|
|
|
161
164
|
/** Aria label for rendered help component */
|
|
162
165
|
helpAriaLabel: PropTypes.string
|
|
163
166
|
};
|
|
164
|
-
ButtonToggleGroup.defaultProps = {
|
|
165
|
-
validationOnLabel: false,
|
|
166
|
-
"data-component": "button-toggle-group"
|
|
167
|
-
};
|
|
168
167
|
ButtonToggleGroup.displayName = "ButtonToggleGroup";
|
|
169
168
|
export default ButtonToggleGroup;
|
|
@@ -17,9 +17,11 @@ export interface ButtonToggleGroupProps extends ValidationProps, MarginProps {
|
|
|
17
17
|
"data-element"?: string;
|
|
18
18
|
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
19
19
|
"data-role"?: string;
|
|
20
|
+
/** Unique id for the root element of the component */
|
|
21
|
+
id: string;
|
|
20
22
|
/** Specifies the name prop to be applied to each button in the group */
|
|
21
23
|
name: string;
|
|
22
|
-
/**
|
|
24
|
+
/** Togglable buttons to be rendered. Only accepts children of type ButtonToggle */
|
|
23
25
|
children?: ButtonToggle | ButtonToggle[];
|
|
24
26
|
/** When true, validation icon will be placed on label instead of being placed on the input */
|
|
25
27
|
validationOnLabel?: boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
import { IconProps } from "../icon";
|
|
4
|
+
export interface IconButtonProps extends MarginProps {
|
|
5
|
+
/** Prop to specify the aria-label of the icon-button component */
|
|
6
|
+
"aria-label"?: string;
|
|
7
|
+
/** Icon meant to be rendered, should be an Icon component */
|
|
8
|
+
children: React.ReactElement<IconProps>;
|
|
9
|
+
/** Callback triggered on blur */
|
|
10
|
+
onBlur?: (ev: React.FocusEvent<HTMLButtonElement>) => void;
|
|
11
|
+
/** Callback triggered on focus */
|
|
12
|
+
onFocus?: (ev: React.FocusEvent<HTMLButtonElement>) => void;
|
|
13
|
+
/** Callback triggered on mouse enter */
|
|
14
|
+
onMouseEnter?: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
15
|
+
/** Callback triggered on mouse leave */
|
|
16
|
+
onMouseLeave?: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
17
|
+
/** Action callback */
|
|
18
|
+
onAction: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
|
|
19
|
+
/** Set the button to disabled */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
23
|
+
export default IconButton;
|