carbon-react 111.8.2 → 111.8.4
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__/input/input-presentation.component.d.ts +3 -1
- package/esm/__internal__/input/input-presentation.component.js +5 -2
- package/esm/__internal__/input/input-presentation.style.d.ts +1 -1
- package/esm/__internal__/input/input-presentation.style.js +10 -3
- package/esm/__internal__/input-behaviour/useInputBehaviour.js +7 -2
- package/esm/__internal__/input-icon-toggle/input-icon-toggle.style.js +0 -2
- package/esm/components/date/date.style.js +5 -0
- 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/select/__internal__/select-text/select-text.component.js +8 -3
- package/esm/components/select/__internal__/select-text/select-text.d.ts +2 -0
- package/esm/components/select/__internal__/select-text/select-text.style.js +4 -1
- package/esm/components/select/multi-select/multi-select.style.js +8 -1
- package/esm/components/select/select-textbox/select-textbox.component.js +3 -2
- package/esm/components/show-edit-pod/show-edit-pod.style.js +1 -1
- package/esm/components/textarea/textarea.component.js +3 -1
- package/esm/components/textarea/textarea.style.d.ts +1 -1
- package/esm/components/textarea/textarea.style.js +10 -5
- package/esm/components/textbox/textbox.component.js +4 -2
- package/esm/locales/en-gb.js +1 -1
- package/lib/__internal__/input/input-presentation.component.d.ts +3 -1
- package/lib/__internal__/input/input-presentation.component.js +5 -2
- package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
- package/lib/__internal__/input/input-presentation.style.js +11 -3
- package/lib/__internal__/input-behaviour/useInputBehaviour.js +7 -2
- package/lib/__internal__/input-icon-toggle/input-icon-toggle.style.js +0 -2
- package/lib/components/date/date.style.js +6 -0
- 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/select/__internal__/select-text/select-text.component.js +8 -3
- package/lib/components/select/__internal__/select-text/select-text.d.ts +2 -0
- package/lib/components/select/__internal__/select-text/select-text.style.js +7 -1
- package/lib/components/select/multi-select/multi-select.style.js +9 -1
- package/lib/components/select/select-textbox/select-textbox.component.js +3 -2
- package/lib/components/show-edit-pod/show-edit-pod.style.js +2 -2
- package/lib/components/textarea/textarea.component.js +3 -1
- package/lib/components/textarea/textarea.style.d.ts +1 -1
- package/lib/components/textarea/textarea.style.js +10 -6
- package/lib/components/textbox/textbox.component.js +4 -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
|
@@ -13,10 +13,12 @@ export interface CommonInputPresentationProps extends ValidationProps {
|
|
|
13
13
|
readOnly?: boolean;
|
|
14
14
|
/** Size of an input */
|
|
15
15
|
size?: Sizes;
|
|
16
|
+
/** If true, the component has an icon rendered inside */
|
|
17
|
+
hasIcon?: boolean;
|
|
16
18
|
}
|
|
17
19
|
export interface InputPresentationProps extends CommonInputPresentationProps {
|
|
18
20
|
/** Content to be rendered before the input */
|
|
19
21
|
positionedChildren?: React.ReactNode;
|
|
20
22
|
}
|
|
21
|
-
declare const InputPresentation: ({ children, positionedChildren, inputWidth, align, disabled, readOnly, size, error, warning, info, }: InputPresentationProps) => JSX.Element;
|
|
23
|
+
declare const InputPresentation: ({ children, positionedChildren, inputWidth, align, disabled, readOnly, size, error, warning, info, hasIcon, }: InputPresentationProps) => JSX.Element;
|
|
22
24
|
export default InputPresentation;
|
|
@@ -14,7 +14,8 @@ const InputPresentation = ({
|
|
|
14
14
|
size = "medium",
|
|
15
15
|
error,
|
|
16
16
|
warning,
|
|
17
|
-
info
|
|
17
|
+
info,
|
|
18
|
+
hasIcon
|
|
18
19
|
}) => {
|
|
19
20
|
const {
|
|
20
21
|
hasFocus,
|
|
@@ -55,7 +56,8 @@ const InputPresentation = ({
|
|
|
55
56
|
warning: warning,
|
|
56
57
|
error: error,
|
|
57
58
|
info: info,
|
|
58
|
-
validationRedesignOptIn: validationRedesignOptIn
|
|
59
|
+
validationRedesignOptIn: validationRedesignOptIn,
|
|
60
|
+
hasIcon: hasIcon
|
|
59
61
|
}, children));
|
|
60
62
|
};
|
|
61
63
|
|
|
@@ -64,6 +66,7 @@ InputPresentation.propTypes = {
|
|
|
64
66
|
"children": PropTypes.node,
|
|
65
67
|
"disabled": PropTypes.bool,
|
|
66
68
|
"error": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
69
|
+
"hasIcon": PropTypes.bool,
|
|
67
70
|
"info": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
68
71
|
"inputWidth": PropTypes.number,
|
|
69
72
|
"positionedChildren": PropTypes.node,
|
|
@@ -2,5 +2,5 @@ import { CommonInputPresentationProps } from "./input-presentation.component";
|
|
|
2
2
|
import { InputContextProps } from "../input-behaviour";
|
|
3
3
|
import { CarbonProviderProps } from "../../components/carbon-provider";
|
|
4
4
|
export declare const StyledInputPresentationContainer: import("styled-components").StyledComponent<"div", any, Pick<CommonInputPresentationProps, "inputWidth">, never>;
|
|
5
|
-
declare const InputPresentationStyle: import("styled-components").StyledComponent<"div", any, Pick<InputContextProps, "hasFocus"> & Pick<CommonInputPresentationProps, "disabled" | "error" | "info" | "warning" | "align" | "readOnly" | "size"> & Pick<CarbonProviderProps, "validationRedesignOptIn">, never>;
|
|
5
|
+
declare const InputPresentationStyle: import("styled-components").StyledComponent<"div", any, Pick<InputContextProps, "hasFocus"> & Pick<CommonInputPresentationProps, "disabled" | "error" | "info" | "warning" | "align" | "readOnly" | "size" | "hasIcon"> & Pick<CarbonProviderProps, "validationRedesignOptIn">, never>;
|
|
6
6
|
export default InputPresentationStyle;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import sizes from "./input-sizes.style";
|
|
3
|
+
import StyledInput from "./input.style";
|
|
3
4
|
export const StyledInputPresentationContainer = styled.div`
|
|
4
5
|
flex: 0 0 ${({
|
|
5
6
|
inputWidth
|
|
@@ -49,11 +50,17 @@ const InputPresentationStyle = styled.div`
|
|
|
49
50
|
width: 100%;
|
|
50
51
|
margin: 0;
|
|
51
52
|
${({
|
|
52
|
-
size
|
|
53
|
+
size,
|
|
54
|
+
hasIcon,
|
|
55
|
+
align
|
|
53
56
|
}) => size && css`
|
|
54
57
|
min-height: ${sizes[size].height};
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
|
|
59
|
+
${StyledInput} {
|
|
60
|
+
padding: 0 ${sizes[size].horizontalPadding};
|
|
61
|
+
${hasIcon && align === "right" && "padding-left: 0;"}
|
|
62
|
+
${hasIcon && align === "left" && "padding-right: 0;"}
|
|
63
|
+
}
|
|
57
64
|
`}
|
|
58
65
|
|
|
59
66
|
${({
|
|
@@ -11,8 +11,13 @@ const useInputBehaviour = blockGroupBehaviour => {
|
|
|
11
11
|
}, []); // use mouse down rather than click to accommodate click and drag events too
|
|
12
12
|
|
|
13
13
|
const onMouseDown = useCallback(() => {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
requestAnimationFrame(() => {
|
|
15
|
+
var _inputRef$current;
|
|
16
|
+
|
|
17
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus({
|
|
18
|
+
preventScroll: true
|
|
19
|
+
});
|
|
20
|
+
});
|
|
16
21
|
}, []);
|
|
17
22
|
const onMouseEnter = useCallback(() => setHasMouseOver(true), []);
|
|
18
23
|
const onMouseLeave = useCallback(() => setHasMouseOver(false), []);
|
|
@@ -2,6 +2,7 @@ import styled from "styled-components";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { margin } from "styled-system";
|
|
4
4
|
import baseTheme from "../../style/themes/base";
|
|
5
|
+
import StyledInput from "../../__internal__/input/input.style";
|
|
5
6
|
import StyledInputPresentation from "../../__internal__/input/input-presentation.style";
|
|
6
7
|
const datePickerWidth = {
|
|
7
8
|
large: "140px",
|
|
@@ -16,6 +17,10 @@ const StyledDateInput = styled.div`
|
|
|
16
17
|
width: ${({
|
|
17
18
|
size
|
|
18
19
|
}) => datePickerWidth[size]};
|
|
20
|
+
|
|
21
|
+
${StyledInput} {
|
|
22
|
+
margin-right: -8px;
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
`;
|
|
21
26
|
StyledDateInput.propTypes = {
|
|
@@ -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;
|
|
@@ -8,53 +8,54 @@ import useLocale from "../../../hooks/__internal__/useLocale";
|
|
|
8
8
|
|
|
9
9
|
const Summary = ({
|
|
10
10
|
type,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
errorCount = 0,
|
|
12
|
+
warningCount = 0
|
|
13
13
|
}) => {
|
|
14
14
|
const l = useLocale();
|
|
15
15
|
const messages = {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
errorCount,
|
|
17
|
+
warningCount
|
|
18
18
|
};
|
|
19
|
-
const message = useMemo(() => l.errors.messages.formSummary(
|
|
19
|
+
const message = useMemo(() => l.errors.messages.formSummary(errorCount, warningCount, type), [l.errors.messages, errorCount, warningCount, type]);
|
|
20
20
|
|
|
21
|
-
if (messages[type]) {
|
|
22
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledMessagePrefix, null, message[0]), /*#__PURE__*/React.createElement(StyledInternalSummary, {
|
|
21
|
+
if (messages[`${type}Count`]) {
|
|
22
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledMessagePrefix, null, message === null || message === void 0 ? void 0 : message[0]), /*#__PURE__*/React.createElement(StyledInternalSummary, {
|
|
23
23
|
type: type,
|
|
24
|
-
"data-element": type
|
|
24
|
+
"data-element": `${type}s`
|
|
25
25
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
26
|
-
type: type
|
|
27
|
-
}), /*#__PURE__*/React.createElement("span", null, message[1])));
|
|
26
|
+
type: type
|
|
27
|
+
}), /*#__PURE__*/React.createElement("span", null, message === null || message === void 0 ? void 0 : message[1])));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return null;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
Summary.propTypes = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
"errorCount": PropTypes.number,
|
|
35
|
+
"type": PropTypes.oneOf(["error", "warning"]).isRequired,
|
|
36
|
+
"warningCount": PropTypes.number
|
|
37
37
|
};
|
|
38
|
+
export { Summary };
|
|
38
39
|
|
|
39
40
|
const FormSummary = ({
|
|
40
41
|
fullWidth,
|
|
41
42
|
...props
|
|
42
43
|
}) => {
|
|
43
44
|
return /*#__PURE__*/React.createElement(StyledFormSummary, {
|
|
44
|
-
showSummary: props.
|
|
45
|
+
showSummary: !!(props.errorCount || props.warningCount),
|
|
45
46
|
"data-element": "form-summary",
|
|
46
47
|
fullWidth: fullWidth
|
|
47
48
|
}, /*#__PURE__*/React.createElement(Summary, _extends({
|
|
48
|
-
type: "
|
|
49
|
+
type: "error"
|
|
49
50
|
}, props)), /*#__PURE__*/React.createElement(Summary, _extends({
|
|
50
|
-
type: "
|
|
51
|
+
type: "warning"
|
|
51
52
|
}, props)), props.children);
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
FormSummary.propTypes = {
|
|
55
|
-
children: PropTypes.node,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
"children": PropTypes.node,
|
|
57
|
+
"errorCount": PropTypes.number,
|
|
58
|
+
"fullWidth": PropTypes.bool,
|
|
59
|
+
"warningCount": PropTypes.number
|
|
59
60
|
};
|
|
60
61
|
export default FormSummary;
|
|
@@ -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 {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import StyledIcon from "../../icon/icon.style";
|
|
4
3
|
import StyledButton from "../../button/button.style";
|
|
5
4
|
export const StyledFormSummary = styled.div`
|
|
@@ -44,12 +43,12 @@ export const StyledInternalSummary = styled.div`
|
|
|
44
43
|
}
|
|
45
44
|
${({
|
|
46
45
|
type
|
|
47
|
-
}) => type === "
|
|
46
|
+
}) => type === "warning" && css`
|
|
48
47
|
color: var(--colorsSemanticCaution650);
|
|
49
48
|
`}
|
|
50
49
|
${({
|
|
51
50
|
type
|
|
52
|
-
}) => type === "
|
|
51
|
+
}) => type === "error" && css`
|
|
53
52
|
color: var(--colorsSemanticNegative600);
|
|
54
53
|
`}
|
|
55
54
|
|
|
@@ -57,20 +56,13 @@ export const StyledInternalSummary = styled.div`
|
|
|
57
56
|
margin-right: 4px;
|
|
58
57
|
${({
|
|
59
58
|
type
|
|
60
|
-
}) => type === "
|
|
59
|
+
}) => type === "warning" && css`
|
|
61
60
|
color: var(--colorsSemanticCaution650);
|
|
62
61
|
`}
|
|
63
62
|
${({
|
|
64
63
|
type
|
|
65
|
-
}) => type === "
|
|
64
|
+
}) => type === "error" && css`
|
|
66
65
|
color: var(--colorsSemanticNegative600);
|
|
67
66
|
`}
|
|
68
67
|
}
|
|
69
|
-
`;
|
|
70
|
-
StyledFormSummary.propTypes = {
|
|
71
|
-
showSummary: PropTypes.bool,
|
|
72
|
-
fullWidth: PropTypes.bool
|
|
73
|
-
};
|
|
74
|
-
StyledInternalSummary.propTypes = {
|
|
75
|
-
type: PropTypes.oneOf(["errors", "warnings"])
|
|
76
|
-
};
|
|
68
|
+
`;
|
|
@@ -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;
|