carbon-react 111.8.2 → 111.8.3
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/components/form/__internal__/form-summary.component.d.ts +18 -13
- package/esm/components/form/__internal__/form-summary.component.js +21 -20
- package/esm/components/form/__internal__/form-summary.style.d.ts +11 -3
- package/esm/components/form/__internal__/form-summary.style.js +5 -13
- package/esm/components/form/form.component.d.ts +35 -20
- package/esm/components/form/form.component.js +329 -47
- package/esm/components/form/form.config.d.ts +2 -1
- package/esm/components/form/form.config.js +0 -1
- package/esm/components/form/form.style.d.ts +21 -6
- package/esm/components/form/form.style.js +1 -17
- package/esm/components/form/index.d.ts +2 -1
- package/esm/components/menu/__internal__/spec-helper/index.js +4 -3
- package/esm/components/menu/__internal__/submenu/submenu.component.js +21 -4
- package/esm/components/menu/menu-item/menu-item.component.js +10 -2
- package/esm/components/menu/menu.component.js +19 -9
- package/esm/components/menu/menu.context.d.ts +2 -0
- package/esm/components/menu/menu.context.js +5 -1
- package/esm/components/show-edit-pod/show-edit-pod.style.js +1 -1
- package/esm/locales/en-gb.js +1 -1
- package/lib/components/form/__internal__/form-summary.component.d.ts +18 -13
- package/lib/components/form/__internal__/form-summary.component.js +22 -21
- package/lib/components/form/__internal__/form-summary.style.d.ts +11 -3
- package/lib/components/form/__internal__/form-summary.style.js +5 -14
- package/lib/components/form/form.component.d.ts +35 -20
- package/lib/components/form/form.component.js +330 -49
- package/lib/components/form/form.config.d.ts +2 -1
- package/lib/components/form/form.config.js +0 -1
- package/lib/components/form/form.style.d.ts +21 -6
- package/lib/components/form/form.style.js +1 -19
- package/lib/components/form/index.d.ts +2 -1
- package/lib/components/menu/__internal__/spec-helper/index.js +5 -3
- package/lib/components/menu/__internal__/submenu/submenu.component.js +21 -4
- package/lib/components/menu/menu-item/menu-item.component.js +10 -2
- package/lib/components/menu/menu.component.js +19 -9
- package/lib/components/menu/menu.context.d.ts +2 -0
- package/lib/components/menu/menu.context.js +5 -1
- package/lib/components/show-edit-pod/show-edit-pod.style.js +2 -2
- package/lib/locales/en-gb.js +1 -1
- package/package.json +1 -1
- package/esm/components/form/__internal__/form-summary.d.ts +0 -16
- package/esm/components/form/form.d.ts +0 -35
- package/lib/components/form/__internal__/form-summary.d.ts +0 -16
- package/lib/components/form/form.d.ts +0 -35
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const
|
|
1
|
+
import { FormButtonAlignment } from "./form.config";
|
|
2
|
+
interface StyledFormContentProps {
|
|
3
|
+
stickyFooter?: boolean;
|
|
4
|
+
isInModal?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const StyledFormContent: import("styled-components").StyledComponent<"div", any, StyledFormContentProps, never>;
|
|
7
|
+
interface ButtonProps extends StyledFormContentProps {
|
|
8
|
+
buttonAlignment?: FormButtonAlignment;
|
|
9
|
+
fullWidthButtons?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const StyledFormFooter: import("styled-components").StyledComponent<"div", any, ButtonProps, never>;
|
|
12
|
+
interface StyledFormProps extends StyledFormContentProps {
|
|
13
|
+
height?: string;
|
|
14
|
+
fieldSpacing: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
15
|
+
isInSidebar?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const StyledForm: import("styled-components").StyledComponent<"form", any, StyledFormProps, never>;
|
|
18
|
+
export declare const StyledRightButtons: import("styled-components").StyledComponent<"div", any, ButtonProps, never>;
|
|
19
|
+
export declare const StyledFullWidthButtons: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
20
|
+
export declare const StyledLeftButtons: import("styled-components").StyledComponent<"div", any, ButtonProps, never>;
|
|
21
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import { space } from "styled-system";
|
|
4
3
|
import StyledFormField from "../../__internal__/form-field/form-field.style";
|
|
5
4
|
import { StyledFieldset } from "../../__internal__/fieldset/fieldset.style";
|
|
@@ -7,7 +6,6 @@ import StyledButton from "../button/button.style";
|
|
|
7
6
|
import baseTheme from "../../style/themes/base";
|
|
8
7
|
import { FieldsetStyle } from "../fieldset/fieldset.style";
|
|
9
8
|
import StyledInlineInputs from "../inline-inputs/inline-inputs.style";
|
|
10
|
-
import { FORM_BUTTON_ALIGNMENTS } from "./form.config";
|
|
11
9
|
import StyledSearch from "../search/search.style";
|
|
12
10
|
import StyledTextarea from "../textarea/textarea.style";
|
|
13
11
|
export const StyledFormContent = styled.div`
|
|
@@ -67,6 +65,7 @@ const formBottomMargins = fieldSpacing => ({
|
|
|
67
65
|
3: "var(--spacing300)",
|
|
68
66
|
4: "var(--spacing400)",
|
|
69
67
|
5: "var(--spacing500)",
|
|
68
|
+
6: "var(--spacing600)",
|
|
70
69
|
7: "var(--spacing700)"
|
|
71
70
|
})[fieldSpacing]; // Accounts for height of the header of Modal parent, the height form footer and some additional spacing
|
|
72
71
|
|
|
@@ -178,21 +177,6 @@ export const StyledLeftButtons = styled.div`
|
|
|
178
177
|
margin-right: 0;
|
|
179
178
|
}
|
|
180
179
|
`;
|
|
181
|
-
StyledForm.propTypes = {
|
|
182
|
-
theme: PropTypes.object,
|
|
183
|
-
stickyFooter: PropTypes.bool,
|
|
184
|
-
fieldSpacing: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 7])
|
|
185
|
-
};
|
|
186
180
|
StyledForm.defaultProps = {
|
|
187
181
|
theme: baseTheme
|
|
188
|
-
};
|
|
189
|
-
StyledLeftButtons.propTypes = {
|
|
190
|
-
buttonAlignment: PropTypes.oneOf(FORM_BUTTON_ALIGNMENTS)
|
|
191
|
-
};
|
|
192
|
-
StyledRightButtons.propTypes = {
|
|
193
|
-
buttonAlignment: PropTypes.oneOf(FORM_BUTTON_ALIGNMENTS)
|
|
194
|
-
};
|
|
195
|
-
StyledFormFooter.propTypes = {
|
|
196
|
-
buttonAlignment: PropTypes.oneOf(FORM_BUTTON_ALIGNMENTS),
|
|
197
|
-
stickyFooter: PropTypes.bool
|
|
198
182
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./form";
|
|
1
|
+
export { default } from "./form.component";
|
|
2
|
+
export type { FormProps } from "./form.component";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { act } from "react-dom/test-utils";
|
|
2
2
|
import StyledMenuItemWrapper from "../../menu-item/menu-item.style";
|
|
3
|
+
import { StyledSubmenuWrapper } from "../submenu/submenu.style";
|
|
3
4
|
const events = {
|
|
4
5
|
space: {
|
|
5
6
|
key: " ",
|
|
@@ -7,12 +8,12 @@ const events = {
|
|
|
7
8
|
}
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
const openSubmenu = wrapper => {
|
|
11
|
-
const menuWrapper = wrapper.find(
|
|
11
|
+
const openSubmenu = (wrapper, index = 0) => {
|
|
12
|
+
const menuWrapper = wrapper.find(StyledSubmenuWrapper).at(index);
|
|
12
13
|
const menuItem = menuWrapper.exists("a") ? menuWrapper.find("a") : menuWrapper.find("button");
|
|
13
14
|
menuItem.getDOMNode().focus();
|
|
14
15
|
act(() => {
|
|
15
|
-
|
|
16
|
+
menuWrapper.find(StyledMenuItemWrapper).props().onKeyDown(events.space);
|
|
16
17
|
});
|
|
17
18
|
wrapper.update();
|
|
18
19
|
};
|
|
@@ -29,12 +29,15 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
29
29
|
onSubmenuOpen,
|
|
30
30
|
onSubmenuClose,
|
|
31
31
|
onClick,
|
|
32
|
+
indexInMenu,
|
|
32
33
|
...rest
|
|
33
34
|
}, ref) => {
|
|
34
35
|
const [blockDoubleFocus, setBlockDoubleFocus] = useState(false);
|
|
35
36
|
const menuContext = useContext(MenuContext);
|
|
36
37
|
const {
|
|
37
|
-
inFullscreenView
|
|
38
|
+
inFullscreenView,
|
|
39
|
+
openSubmenuIndex,
|
|
40
|
+
setOpenSubmenuIndex
|
|
38
41
|
} = menuContext;
|
|
39
42
|
const [submenuOpen, setSubmenuOpen] = useState(false);
|
|
40
43
|
const [submenuFocusIndex, setSubmenuFocusIndex] = useState(undefined);
|
|
@@ -78,15 +81,26 @@ const Submenu = /*#__PURE__*/React.forwardRef(({
|
|
|
78
81
|
}, [startCharacterTimeout]);
|
|
79
82
|
const openSubmenu = useCallback(() => {
|
|
80
83
|
setSubmenuOpen(true);
|
|
84
|
+
setOpenSubmenuIndex(indexInMenu);
|
|
81
85
|
if (onSubmenuOpen) onSubmenuOpen();
|
|
82
|
-
}, [onSubmenuOpen]);
|
|
86
|
+
}, [onSubmenuOpen, indexInMenu, setOpenSubmenuIndex]);
|
|
83
87
|
const closeSubmenu = useCallback(() => {
|
|
84
88
|
setSubmenuOpen(false);
|
|
89
|
+
|
|
90
|
+
if (openSubmenuIndex === indexInMenu) {
|
|
91
|
+
setOpenSubmenuIndex(null);
|
|
92
|
+
}
|
|
93
|
+
|
|
85
94
|
if (onSubmenuClose) onSubmenuClose();
|
|
86
95
|
setSubmenuFocusIndex(undefined);
|
|
87
96
|
setBlockDoubleFocus(false);
|
|
88
97
|
setCharacterString("");
|
|
89
|
-
}, [onSubmenuClose]);
|
|
98
|
+
}, [onSubmenuClose, setOpenSubmenuIndex, indexInMenu, openSubmenuIndex]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (openSubmenuIndex !== indexInMenu) {
|
|
101
|
+
closeSubmenu();
|
|
102
|
+
}
|
|
103
|
+
}, [openSubmenuIndex, indexInMenu, closeSubmenu]);
|
|
90
104
|
const handleKeyDown = useCallback((event, index = submenuFocusIndex) => {
|
|
91
105
|
if (!submenuOpen) {
|
|
92
106
|
if (Events.isEnterKey(event) || Events.isSpaceKey(event) || Events.isDownKey(event) || Events.isUpKey(event)) {
|
|
@@ -350,6 +364,9 @@ Submenu.propTypes = {
|
|
|
350
364
|
onSubmenuClose: PropTypes.func,
|
|
351
365
|
|
|
352
366
|
/** Callback triggered when the top-level menu item is clicked */
|
|
353
|
-
onClick: PropTypes.func
|
|
367
|
+
onClick: PropTypes.func,
|
|
368
|
+
|
|
369
|
+
/** index of child in the parent menu */
|
|
370
|
+
indexInMenu: PropTypes.number
|
|
354
371
|
};
|
|
355
372
|
export default Submenu;
|
|
@@ -33,12 +33,13 @@ const MenuItem = ({
|
|
|
33
33
|
onSubmenuClose,
|
|
34
34
|
overrideColor,
|
|
35
35
|
rel,
|
|
36
|
+
isFocused,
|
|
36
37
|
...rest
|
|
37
38
|
}) => {
|
|
38
39
|
const menuContext = useContext(MenuContext);
|
|
39
40
|
const submenuContext = useContext(SubmenuContext);
|
|
40
41
|
const ref = useRef(null);
|
|
41
|
-
const focusFromMenu =
|
|
42
|
+
const focusFromMenu = isFocused;
|
|
42
43
|
const focusFromSubmenu = submenuContext.isFocused;
|
|
43
44
|
const isChildSearch = useRef(false);
|
|
44
45
|
const childRef = useRef();
|
|
@@ -238,6 +239,13 @@ MenuItem.propTypes = {
|
|
|
238
239
|
onSubmenuClose: PropTypes.func,
|
|
239
240
|
|
|
240
241
|
/** @ignore @private */
|
|
241
|
-
overrideColor: PropTypes.bool
|
|
242
|
+
overrideColor: PropTypes.bool,
|
|
243
|
+
|
|
244
|
+
/** @ignore @private */
|
|
245
|
+
isFocused: PropTypes.bool,
|
|
246
|
+
|
|
247
|
+
/** @ignore @private */
|
|
248
|
+
indexInMenu: PropTypes.number
|
|
242
249
|
};
|
|
250
|
+
MenuItem.displayName = "MenuItem";
|
|
243
251
|
export default MenuItem;
|
|
@@ -14,6 +14,7 @@ const Menu = ({
|
|
|
14
14
|
...rest
|
|
15
15
|
}) => {
|
|
16
16
|
const [focusedItemIndex, setFocusedItemIndex] = useState(undefined);
|
|
17
|
+
const [openSubmenuIndex, setOpenSubmenuIndex] = useState(null);
|
|
17
18
|
const ref = useRef();
|
|
18
19
|
const handleKeyDown = useCallback(event => {
|
|
19
20
|
const newIndex = menuKeyboardNavigation(event, React.Children.toArray(children));
|
|
@@ -38,17 +39,26 @@ const Menu = ({
|
|
|
38
39
|
}, rest, {
|
|
39
40
|
ref: ref,
|
|
40
41
|
role: "list"
|
|
41
|
-
}), React.
|
|
42
|
+
}), /*#__PURE__*/React.createElement(MenuContext.Provider, {
|
|
43
|
+
value: {
|
|
44
|
+
menuType,
|
|
45
|
+
handleKeyDown,
|
|
46
|
+
inMenu: true,
|
|
47
|
+
openSubmenuIndex,
|
|
48
|
+
setOpenSubmenuIndex
|
|
49
|
+
}
|
|
50
|
+
}, React.Children.map(children, (child, index) => {
|
|
42
51
|
const isFocused = focusedItemIndex === index;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
handleKeyDown: ev => handleKeyDown(ev, index),
|
|
52
|
+
|
|
53
|
+
if ( /*#__PURE__*/React.isValidElement(child) && child.type.displayName === "MenuItem" && child.props.submenu) {
|
|
54
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
47
55
|
isFocused,
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
56
|
+
indexInMenu: index
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return child;
|
|
61
|
+
})));
|
|
52
62
|
};
|
|
53
63
|
|
|
54
64
|
Menu.propTypes = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
-
import { StyledFormFooter } from "../form/form.style
|
|
2
|
+
import { StyledFormFooter } from "../form/form.style";
|
|
3
3
|
import { StyledContent } from "../pod/pod.style.js";
|
|
4
4
|
import Pod from "../pod";
|
|
5
5
|
const StyledPod = styled(Pod)`
|
package/esm/locales/en-gb.js
CHANGED
|
@@ -41,7 +41,7 @@ const enGB = {
|
|
|
41
41
|
const isErrorPlural = isSingular(errors) && !warnings ? "is" : "are";
|
|
42
42
|
const isWarningPlural = isSingular(warnings) ? "is" : "are";
|
|
43
43
|
|
|
44
|
-
if (errors && warnings && type === "
|
|
44
|
+
if (errors && warnings && type === "warning") {
|
|
45
45
|
return ["and", `${warnings} ${warningPlural}`];
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { StyledInternalSummaryProps } from "./form-summary.style";
|
|
3
|
+
interface SummaryProps extends StyledInternalSummaryProps {
|
|
4
|
+
errorCount?: number;
|
|
5
|
+
warningCount?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface FormSummaryProps {
|
|
8
|
+
/** Child elements */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
/** The total number of errors present in the form */
|
|
11
|
+
errorCount?: number;
|
|
12
|
+
/** The total number of warnings present in the form */
|
|
13
|
+
warningCount?: number;
|
|
14
|
+
/** Applies full width styling */
|
|
15
|
+
fullWidth?: boolean;
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
export declare const Summary: ({ type, errorCount, warningCount, }: SummaryProps) => JSX.Element | null;
|
|
18
|
+
declare const FormSummary: ({ fullWidth, ...props }: FormSummaryProps) => JSX.Element;
|
|
19
|
+
export default FormSummary;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.Summary = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
@@ -25,32 +25,33 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
25
25
|
|
|
26
26
|
const Summary = ({
|
|
27
27
|
type,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
errorCount = 0,
|
|
29
|
+
warningCount = 0
|
|
30
30
|
}) => {
|
|
31
31
|
const l = (0, _useLocale.default)();
|
|
32
32
|
const messages = {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
errorCount,
|
|
34
|
+
warningCount
|
|
35
35
|
};
|
|
36
|
-
const message = (0, _react.useMemo)(() => l.errors.messages.formSummary(
|
|
36
|
+
const message = (0, _react.useMemo)(() => l.errors.messages.formSummary(errorCount, warningCount, type), [l.errors.messages, errorCount, warningCount, type]);
|
|
37
37
|
|
|
38
|
-
if (messages[type]) {
|
|
39
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_formSummary.StyledMessagePrefix, null, message[0]), /*#__PURE__*/_react.default.createElement(_formSummary.StyledInternalSummary, {
|
|
38
|
+
if (messages[`${type}Count`]) {
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_formSummary.StyledMessagePrefix, null, message === null || message === void 0 ? void 0 : message[0]), /*#__PURE__*/_react.default.createElement(_formSummary.StyledInternalSummary, {
|
|
40
40
|
type: type,
|
|
41
|
-
"data-element": type
|
|
41
|
+
"data-element": `${type}s`
|
|
42
42
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
43
|
-
type: type
|
|
44
|
-
}), /*#__PURE__*/_react.default.createElement("span", null, message[1])));
|
|
43
|
+
type: type
|
|
44
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, message === null || message === void 0 ? void 0 : message[1])));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
return null;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
exports.Summary = Summary;
|
|
50
51
|
Summary.propTypes = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
"errorCount": _propTypes.default.number,
|
|
53
|
+
"type": _propTypes.default.oneOf(["error", "warning"]).isRequired,
|
|
54
|
+
"warningCount": _propTypes.default.number
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
const FormSummary = ({
|
|
@@ -58,21 +59,21 @@ const FormSummary = ({
|
|
|
58
59
|
...props
|
|
59
60
|
}) => {
|
|
60
61
|
return /*#__PURE__*/_react.default.createElement(_formSummary.StyledFormSummary, {
|
|
61
|
-
showSummary: props.
|
|
62
|
+
showSummary: !!(props.errorCount || props.warningCount),
|
|
62
63
|
"data-element": "form-summary",
|
|
63
64
|
fullWidth: fullWidth
|
|
64
65
|
}, /*#__PURE__*/_react.default.createElement(Summary, _extends({
|
|
65
|
-
type: "
|
|
66
|
+
type: "error"
|
|
66
67
|
}, props)), /*#__PURE__*/_react.default.createElement(Summary, _extends({
|
|
67
|
-
type: "
|
|
68
|
+
type: "warning"
|
|
68
69
|
}, props)), props.children);
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
FormSummary.propTypes = {
|
|
72
|
-
children: _propTypes.default.node,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
"children": _propTypes.default.node,
|
|
74
|
+
"errorCount": _propTypes.default.number,
|
|
75
|
+
"fullWidth": _propTypes.default.bool,
|
|
76
|
+
"warningCount": _propTypes.default.number
|
|
76
77
|
};
|
|
77
78
|
var _default = FormSummary;
|
|
78
79
|
exports.default = _default;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare type StyledFormSummaryProps = {
|
|
2
|
+
showSummary?: boolean;
|
|
3
|
+
fullWidth?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const StyledFormSummary: import("styled-components").StyledComponent<"div", any, StyledFormSummaryProps, never>;
|
|
6
|
+
export declare const StyledMessagePrefix: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare type StyledInternalSummaryProps = {
|
|
8
|
+
type: "error" | "warning";
|
|
9
|
+
};
|
|
10
|
+
export declare const StyledInternalSummary: import("styled-components").StyledComponent<"div", any, StyledInternalSummaryProps, never>;
|
|
11
|
+
export {};
|
|
@@ -7,8 +7,6 @@ exports.StyledInternalSummary = exports.StyledMessagePrefix = exports.StyledForm
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _icon = _interopRequireDefault(require("../../icon/icon.style"));
|
|
13
11
|
|
|
14
12
|
var _button = _interopRequireDefault(require("../../button/button.style"));
|
|
@@ -63,12 +61,12 @@ const StyledInternalSummary = _styledComponents.default.div`
|
|
|
63
61
|
}
|
|
64
62
|
${({
|
|
65
63
|
type
|
|
66
|
-
}) => type === "
|
|
64
|
+
}) => type === "warning" && (0, _styledComponents.css)`
|
|
67
65
|
color: var(--colorsSemanticCaution650);
|
|
68
66
|
`}
|
|
69
67
|
${({
|
|
70
68
|
type
|
|
71
|
-
}) => type === "
|
|
69
|
+
}) => type === "error" && (0, _styledComponents.css)`
|
|
72
70
|
color: var(--colorsSemanticNegative600);
|
|
73
71
|
`}
|
|
74
72
|
|
|
@@ -76,21 +74,14 @@ const StyledInternalSummary = _styledComponents.default.div`
|
|
|
76
74
|
margin-right: 4px;
|
|
77
75
|
${({
|
|
78
76
|
type
|
|
79
|
-
}) => type === "
|
|
77
|
+
}) => type === "warning" && (0, _styledComponents.css)`
|
|
80
78
|
color: var(--colorsSemanticCaution650);
|
|
81
79
|
`}
|
|
82
80
|
${({
|
|
83
81
|
type
|
|
84
|
-
}) => type === "
|
|
82
|
+
}) => type === "error" && (0, _styledComponents.css)`
|
|
85
83
|
color: var(--colorsSemanticNegative600);
|
|
86
84
|
`}
|
|
87
85
|
}
|
|
88
86
|
`;
|
|
89
|
-
exports.StyledInternalSummary = StyledInternalSummary;
|
|
90
|
-
StyledFormSummary.propTypes = {
|
|
91
|
-
showSummary: _propTypes.default.bool,
|
|
92
|
-
fullWidth: _propTypes.default.bool
|
|
93
|
-
};
|
|
94
|
-
StyledInternalSummary.propTypes = {
|
|
95
|
-
type: _propTypes.default.oneOf(["errors", "warnings"])
|
|
96
|
-
};
|
|
87
|
+
exports.StyledInternalSummary = StyledInternalSummary;
|
|
@@ -1,21 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SpaceProps } from "styled-system";
|
|
3
|
+
import { FormButtonAlignment } from "./form.config";
|
|
4
|
+
export interface FormProps extends SpaceProps {
|
|
5
|
+
/** Alignment of buttons */
|
|
6
|
+
buttonAlignment?: FormButtonAlignment;
|
|
7
|
+
/** Child elements */
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
/** The total number of errors present in the form */
|
|
10
|
+
errorCount?: number;
|
|
11
|
+
/** Spacing between form fields, given number will be multiplied by base spacing unit (8) */
|
|
12
|
+
fieldSpacing?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
13
|
+
/** Additional buttons rendered on the left side of the save button */
|
|
14
|
+
leftSideButtons?: React.ReactNode;
|
|
15
|
+
/** Disable HTML5 validation */
|
|
16
|
+
noValidate?: boolean;
|
|
17
|
+
/** Callback passed to the form element */
|
|
18
|
+
onSubmit?: React.FormEventHandler;
|
|
19
|
+
/** Additional buttons rendered on the right side of the save button */
|
|
20
|
+
rightSideButtons?: React.ReactNode;
|
|
21
|
+
/** Save button to be rendered */
|
|
22
|
+
saveButton?: React.ReactNode;
|
|
23
|
+
/** Enables the sticky footer. */
|
|
24
|
+
stickyFooter?: boolean;
|
|
25
|
+
/** The total number of warnings present in the form */
|
|
26
|
+
warningCount?: number;
|
|
27
|
+
/** Height of the form (any valid CSS value) */
|
|
28
|
+
height?: string;
|
|
29
|
+
/** Applies styling for full width buttons. Please note that you will still need to pass the `fullWidth` prop to the button you compose */
|
|
30
|
+
fullWidthButtons?: boolean;
|
|
21
31
|
}
|
|
32
|
+
export declare const Form: {
|
|
33
|
+
({ children, saveButton, leftSideButtons, rightSideButtons, errorCount, warningCount, onSubmit, buttonAlignment, stickyFooter, fieldSpacing, noValidate, height, fullWidthButtons, ...rest }: FormProps): JSX.Element;
|
|
34
|
+
displayName: string;
|
|
35
|
+
};
|
|
36
|
+
export default Form;
|