carbon-react 104.54.4 → 104.57.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/esm/__internal__/checkable-input/hidden-checkable-input.component.d.ts +4 -1
- package/esm/__internal__/checkable-input/hidden-checkable-input.component.js +5 -1
- package/esm/__internal__/checkable-input/hidden-checkable-input.d.ts +2 -0
- package/esm/__internal__/form-field/form-field.component.js +3 -3
- package/esm/__internal__/input/input-presentation.component.js +6 -1
- package/esm/__internal__/input/input-presentation.style.d.ts +1 -0
- package/esm/__internal__/input/input-presentation.style.js +3 -2
- package/esm/__internal__/validation-message/index.d.ts +1 -0
- package/esm/__internal__/validation-message/index.js +1 -0
- package/esm/__internal__/validation-message/validation-message.component.d.ts +11 -0
- package/esm/__internal__/validation-message/validation-message.component.js +15 -0
- package/esm/__internal__/validation-message/validation-message.style.d.ts +5 -0
- package/esm/__internal__/validation-message/validation-message.style.js +12 -0
- package/esm/components/carbon-provider/carbon-provider.component.d.ts +5 -1
- package/esm/components/carbon-provider/carbon-provider.component.js +11 -4
- package/esm/components/carbon-provider/carbon-provider.d.ts +1 -0
- package/esm/components/date-range/date-range.style.js +1 -1
- package/esm/components/fieldset/fieldset.component.js +7 -2
- package/esm/components/modal/__internal__/modal-manager.d.ts +2 -2
- package/esm/components/modal/__internal__/modal-manager.js +18 -7
- package/esm/components/numeral-date/numeral-date-context.d.ts +3 -0
- package/esm/components/numeral-date/numeral-date-context.js +2 -0
- package/esm/components/numeral-date/numeral-date.component.js +22 -6
- package/esm/components/switch/switch.component.js +1 -0
- package/esm/components/textarea/textarea.component.js +27 -12
- package/esm/components/textbox/textbox.component.js +36 -15
- package/esm/components/textbox/textbox.d.ts +1 -1
- package/esm/components/textbox/textbox.style.d.ts +2 -0
- package/esm/components/textbox/textbox.style.js +33 -0
- package/esm/style/themes/base/base-theme.config.d.ts +2 -0
- package/esm/style/themes/base/base-theme.config.js +3 -1
- package/esm/style/themes/base/index.d.ts +2 -0
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.d.ts +4 -1
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.js +5 -1
- package/lib/__internal__/checkable-input/hidden-checkable-input.d.ts +2 -0
- package/lib/__internal__/form-field/form-field.component.js +3 -3
- package/lib/__internal__/input/input-presentation.component.js +7 -1
- package/lib/__internal__/input/input-presentation.style.d.ts +1 -0
- package/lib/__internal__/input/input-presentation.style.js +3 -2
- package/lib/__internal__/validation-message/index.d.ts +1 -0
- package/lib/__internal__/validation-message/index.js +15 -0
- package/lib/__internal__/validation-message/package.json +6 -0
- package/lib/__internal__/validation-message/validation-message.component.d.ts +11 -0
- package/lib/__internal__/validation-message/validation-message.component.js +26 -0
- package/lib/__internal__/validation-message/validation-message.style.d.ts +5 -0
- package/lib/__internal__/validation-message/validation-message.style.js +25 -0
- package/lib/components/carbon-provider/carbon-provider.component.d.ts +5 -1
- package/lib/components/carbon-provider/carbon-provider.component.js +18 -5
- package/lib/components/carbon-provider/carbon-provider.d.ts +1 -0
- package/lib/components/date-range/date-range.style.js +1 -1
- package/lib/components/fieldset/fieldset.component.js +8 -2
- package/lib/components/modal/__internal__/modal-manager.d.ts +2 -2
- package/lib/components/modal/__internal__/modal-manager.js +20 -8
- package/lib/components/numeral-date/numeral-date-context.d.ts +3 -0
- package/lib/components/numeral-date/numeral-date-context.js +14 -0
- package/lib/components/numeral-date/numeral-date.component.js +25 -5
- package/lib/components/switch/switch.component.js +1 -0
- package/lib/components/textarea/textarea.component.js +30 -12
- package/lib/components/textbox/textbox.component.js +44 -15
- package/lib/components/textbox/textbox.d.ts +1 -1
- package/lib/components/textbox/textbox.style.d.ts +2 -0
- package/lib/components/textbox/textbox.style.js +49 -0
- package/lib/style/themes/base/base-theme.config.d.ts +2 -0
- package/lib/style/themes/base/base-theme.config.js +3 -1
- package/lib/style/themes/base/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare var _default: React.MemoExoticComponent<{
|
|
2
|
-
({ name, checked, type, value, inputRef, onChange, autoFocus, ...props }: {
|
|
2
|
+
({ name, checked, type, value, inputRef, onChange, autoFocus, role, ...props }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
name: any;
|
|
5
5
|
checked: any;
|
|
@@ -8,6 +8,7 @@ declare var _default: React.MemoExoticComponent<{
|
|
|
8
8
|
inputRef: any;
|
|
9
9
|
onChange: any;
|
|
10
10
|
autoFocus: any;
|
|
11
|
+
role: any;
|
|
11
12
|
}): JSX.Element;
|
|
12
13
|
propTypes: {
|
|
13
14
|
/** Allows component to be focused on page load */
|
|
@@ -28,6 +29,8 @@ declare var _default: React.MemoExoticComponent<{
|
|
|
28
29
|
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
29
30
|
/** HTML type attribute of the input */
|
|
30
31
|
type: PropTypes.Validator<string>;
|
|
32
|
+
/** Role attribute of the input */
|
|
33
|
+
role: PropTypes.Requireable<string>;
|
|
31
34
|
/** Value of the input */
|
|
32
35
|
value: PropTypes.Requireable<string>;
|
|
33
36
|
/** A callback to retrieve the input reference */
|
|
@@ -13,6 +13,7 @@ const HiddenCheckableInput = ({
|
|
|
13
13
|
inputRef,
|
|
14
14
|
onChange,
|
|
15
15
|
autoFocus,
|
|
16
|
+
role,
|
|
16
17
|
...props
|
|
17
18
|
}) => {
|
|
18
19
|
const {
|
|
@@ -57,7 +58,7 @@ const HiddenCheckableInput = ({
|
|
|
57
58
|
"aria-checked": checked,
|
|
58
59
|
checked: checked,
|
|
59
60
|
name: name,
|
|
60
|
-
role: type,
|
|
61
|
+
role: role || type,
|
|
61
62
|
type: type,
|
|
62
63
|
value: value
|
|
63
64
|
}, props, {
|
|
@@ -98,6 +99,9 @@ HiddenCheckableInput.propTypes = {
|
|
|
98
99
|
/** HTML type attribute of the input */
|
|
99
100
|
type: PropTypes.string.isRequired,
|
|
100
101
|
|
|
102
|
+
/** Role attribute of the input */
|
|
103
|
+
role: PropTypes.string,
|
|
104
|
+
|
|
101
105
|
/** Value of the input */
|
|
102
106
|
value: PropTypes.string,
|
|
103
107
|
|
|
@@ -67,9 +67,9 @@ const FormField = ({
|
|
|
67
67
|
labelId: labelId,
|
|
68
68
|
align: labelAlign,
|
|
69
69
|
disabled: disabled,
|
|
70
|
-
error: error,
|
|
71
|
-
warning: warning,
|
|
72
|
-
info: info,
|
|
70
|
+
error: !rest.validationRedesignOptIn && error,
|
|
71
|
+
warning: !rest.validationRedesignOptIn && warning,
|
|
72
|
+
info: !rest.validationRedesignOptIn && info,
|
|
73
73
|
help: labelHelp,
|
|
74
74
|
tooltipId: tooltipId,
|
|
75
75
|
helpTabIndex: helpTabIndex,
|
|
@@ -2,6 +2,7 @@ import React, { useContext } from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import InputPresentationStyle, { StyledInputPresentationContainer } from "./input-presentation.style";
|
|
4
4
|
import { InputContext, InputGroupContext } from "../input-behaviour";
|
|
5
|
+
import { NewValidationContext } from "../../components/carbon-provider/carbon-provider.component";
|
|
5
6
|
|
|
6
7
|
const InputPresentation = ({
|
|
7
8
|
children,
|
|
@@ -21,6 +22,9 @@ const InputPresentation = ({
|
|
|
21
22
|
onMouseEnter,
|
|
22
23
|
onMouseLeave
|
|
23
24
|
} = useContext(InputContext);
|
|
25
|
+
const {
|
|
26
|
+
validationRedesignOptIn
|
|
27
|
+
} = useContext(NewValidationContext);
|
|
24
28
|
const {
|
|
25
29
|
onMouseEnter: onGroupMouseEnter,
|
|
26
30
|
onMouseLeave: onGroupMouseLeave
|
|
@@ -50,7 +54,8 @@ const InputPresentation = ({
|
|
|
50
54
|
size: size,
|
|
51
55
|
warning: warning,
|
|
52
56
|
error: error,
|
|
53
|
-
info: info
|
|
57
|
+
info: info,
|
|
58
|
+
validationRedesignOptIn: validationRedesignOptIn
|
|
54
59
|
}, children));
|
|
55
60
|
};
|
|
56
61
|
|
|
@@ -70,7 +70,8 @@ function stylingForValidations({
|
|
|
70
70
|
error,
|
|
71
71
|
warning,
|
|
72
72
|
info,
|
|
73
|
-
disabled
|
|
73
|
+
disabled,
|
|
74
|
+
validationRedesignOptIn
|
|
74
75
|
}) {
|
|
75
76
|
let validationColor;
|
|
76
77
|
|
|
@@ -81,7 +82,7 @@ function stylingForValidations({
|
|
|
81
82
|
if (error) {
|
|
82
83
|
validationColor = "var(--colorsSemanticNegative500)";
|
|
83
84
|
} else if (warning) {
|
|
84
|
-
validationColor = "var(--colorsSemanticCaution500)";
|
|
85
|
+
validationColor = validationRedesignOptIn ? "var(--colorsUtilityMajor300)" : "var(--colorsSemanticCaution500)";
|
|
85
86
|
} else if (info) {
|
|
86
87
|
validationColor = "var(--colorsSemanticInfo500)";
|
|
87
88
|
} else {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./validation-message.component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./validation-message.component";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ValidationMessageProps {
|
|
3
|
+
/** Indicate that error has occurred
|
|
4
|
+
Pass string to display hint with error */
|
|
5
|
+
error?: boolean | string;
|
|
6
|
+
/** Indicate that warning has occurred
|
|
7
|
+
Pass string to display hint with warning */
|
|
8
|
+
warning?: boolean | string;
|
|
9
|
+
}
|
|
10
|
+
declare const ValidationMessage: ({ error, warning }: ValidationMessageProps) => JSX.Element | null;
|
|
11
|
+
export default ValidationMessage;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import StyledValidationMessage from "./validation-message.style";
|
|
3
|
+
|
|
4
|
+
const ValidationMessage = ({
|
|
5
|
+
error,
|
|
6
|
+
warning
|
|
7
|
+
}) => {
|
|
8
|
+
const validation = error || warning;
|
|
9
|
+
const isStringValidation = typeof validation === "string";
|
|
10
|
+
return isStringValidation ? /*#__PURE__*/React.createElement(StyledValidationMessage, {
|
|
11
|
+
isWarning: !!(!error && warning)
|
|
12
|
+
}, validation) : null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default ValidationMessage;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
const StyledValidationMessage = styled.p`
|
|
3
|
+
${({
|
|
4
|
+
isWarning
|
|
5
|
+
}) => css`
|
|
6
|
+
color: ${isWarning ? "var(--colorsSemanticCaution600)" : "var(--colorsSemanticNegative500)"};
|
|
7
|
+
font-weight: ${isWarning ? "regular" : "bold"};
|
|
8
|
+
margin-top: 0px;
|
|
9
|
+
margin-bottom: 8px;
|
|
10
|
+
`}
|
|
11
|
+
`;
|
|
12
|
+
export default StyledValidationMessage;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
export const NewValidationContext: React.Context<{}>;
|
|
1
2
|
export default CarbonProvider;
|
|
2
|
-
|
|
3
|
+
import React from "react";
|
|
4
|
+
declare function CarbonProvider({ children, theme, validationRedesignOptIn, }: {
|
|
3
5
|
children: any;
|
|
4
6
|
theme?: import("../../style/themes/base").ThemeObject | undefined;
|
|
7
|
+
validationRedesignOptIn?: boolean | undefined;
|
|
5
8
|
}): JSX.Element;
|
|
6
9
|
declare namespace CarbonProvider {
|
|
7
10
|
namespace propTypes {
|
|
8
11
|
const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
9
12
|
const theme: PropTypes.Requireable<object>;
|
|
13
|
+
const validationRedesignOptIn: PropTypes.Requireable<boolean>;
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
import PropTypes from "prop-types";
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { createContext } from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { ThemeProvider } from "styled-components";
|
|
4
4
|
import mintTheme from "../../style/themes/mint";
|
|
5
5
|
import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider";
|
|
6
|
+
export const NewValidationContext = /*#__PURE__*/createContext({});
|
|
6
7
|
|
|
7
8
|
const CarbonProvider = ({
|
|
8
9
|
children,
|
|
9
|
-
theme = mintTheme
|
|
10
|
+
theme = mintTheme,
|
|
11
|
+
validationRedesignOptIn = false
|
|
10
12
|
}) => /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
11
13
|
theme: theme
|
|
12
|
-
}, /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null,
|
|
14
|
+
}, /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, /*#__PURE__*/React.createElement(NewValidationContext.Provider, {
|
|
15
|
+
value: {
|
|
16
|
+
validationRedesignOptIn
|
|
17
|
+
}
|
|
18
|
+
}, children)));
|
|
13
19
|
|
|
14
20
|
CarbonProvider.propTypes = {
|
|
15
21
|
children: PropTypes.node.isRequired,
|
|
16
|
-
theme: PropTypes.object
|
|
22
|
+
theme: PropTypes.object,
|
|
23
|
+
validationRedesignOptIn: PropTypes.bool
|
|
17
24
|
};
|
|
18
25
|
export default CarbonProvider;
|
|
@@ -7,6 +7,7 @@ import { validProps } from "../../__internal__/utils/ether";
|
|
|
7
7
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
8
8
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
9
9
|
import { FieldsetStyle, LegendContainerStyle, FieldsetContentStyle } from "./fieldset.style";
|
|
10
|
+
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
10
11
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
11
12
|
|
|
12
13
|
const Fieldset = props => {
|
|
@@ -25,12 +26,16 @@ const Fieldset = props => {
|
|
|
25
26
|
propTypes: Fieldset.propTypes,
|
|
26
27
|
props
|
|
27
28
|
});
|
|
28
|
-
return /*#__PURE__*/React.createElement(
|
|
29
|
+
return /*#__PURE__*/React.createElement(NewValidationContext.Provider, {
|
|
30
|
+
value: {
|
|
31
|
+
validationRedesignOptIn: false
|
|
32
|
+
}
|
|
33
|
+
}, /*#__PURE__*/React.createElement(FieldsetStyle, _extends({}, tagComponent("fieldset", props), safeProps, {
|
|
29
34
|
m: 0
|
|
30
35
|
}, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement(FieldsetContentStyle, {
|
|
31
36
|
"data-component": "fieldset-style",
|
|
32
37
|
inline: props.inline
|
|
33
|
-
}, legend(), props.children));
|
|
38
|
+
}, legend(), props.children)));
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
Fieldset.propTypes = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default ModalManager;
|
|
2
|
-
|
|
3
|
-
declare class ModalManagerInstance {
|
|
2
|
+
export class ModalManagerInstance {
|
|
4
3
|
addModal: (modal: any, setTriggerRefocusFlag: any) => void;
|
|
5
4
|
isTopmost(modal: any): boolean;
|
|
6
5
|
removeModal(modal: any): void;
|
|
7
6
|
clearList(): void;
|
|
8
7
|
#private;
|
|
9
8
|
}
|
|
9
|
+
declare const ModalManager: ModalManagerInstance;
|
|
@@ -6,17 +6,17 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
6
6
|
|
|
7
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
|
|
9
|
-
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
|
10
|
-
|
|
11
|
-
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
|
12
|
-
|
|
13
9
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
14
10
|
|
|
15
11
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
16
12
|
|
|
13
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
14
|
+
|
|
15
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
|
16
|
+
|
|
17
17
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
18
18
|
|
|
19
|
-
function
|
|
19
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
|
20
20
|
|
|
21
21
|
var _modalList = /*#__PURE__*/new WeakMap();
|
|
22
22
|
|
|
@@ -30,7 +30,7 @@ let ModalManagerInstance = /*#__PURE__*/function () {
|
|
|
30
30
|
|
|
31
31
|
_modalList.set(this, {
|
|
32
32
|
writable: true,
|
|
33
|
-
value:
|
|
33
|
+
value: void 0
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
_defineProperty(this, "addModal", (modal, setTriggerRefocusFlag) => {
|
|
@@ -48,6 +48,14 @@ let ModalManagerInstance = /*#__PURE__*/function () {
|
|
|
48
48
|
setTriggerRefocusFlag
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
|
+
|
|
52
|
+
// Due to possibility of multiple carbon versions using it
|
|
53
|
+
// it is necessary to maintain same structure in this global variable
|
|
54
|
+
if (!window.__CARBON_INTERNALS_MODAL_LIST) {
|
|
55
|
+
window.__CARBON_INTERNALS_MODAL_LIST = [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
_createClass(ModalManagerInstance, [{
|
|
@@ -91,7 +99,9 @@ let ModalManagerInstance = /*#__PURE__*/function () {
|
|
|
91
99
|
}, {
|
|
92
100
|
key: "clearList",
|
|
93
101
|
value: function clearList() {
|
|
94
|
-
|
|
102
|
+
window.__CARBON_INTERNALS_MODAL_LIST = [];
|
|
103
|
+
|
|
104
|
+
_classPrivateFieldSet(this, _modalList, window.__CARBON_INTERNALS_MODAL_LIST);
|
|
95
105
|
}
|
|
96
106
|
}]);
|
|
97
107
|
|
|
@@ -107,4 +117,5 @@ function _getTopModal2() {
|
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
const ModalManager = new ModalManagerInstance();
|
|
120
|
+
export { ModalManagerInstance };
|
|
110
121
|
export default ModalManager;
|
|
@@ -1,6 +1,6 @@
|
|
|
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, { useState, useEffect, useRef } from "react";
|
|
3
|
+
import React, { useContext, useState, useEffect, useRef } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
6
|
import invariant from "invariant";
|
|
@@ -8,11 +8,15 @@ import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
|
8
8
|
import Events from "../../__internal__/utils/helpers/events";
|
|
9
9
|
import { StyledNumeralDate, StyledDateField } from "./numeral-date.style";
|
|
10
10
|
import Textbox from "../textbox";
|
|
11
|
+
import { StyledHintText } from "../textbox/textbox.style";
|
|
12
|
+
import ValidationMessage from "../../__internal__/validation-message";
|
|
11
13
|
import guid from "../../__internal__/utils/helpers/guid";
|
|
12
14
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
13
15
|
import FormField from "../../__internal__/form-field";
|
|
14
16
|
import { InputGroupBehaviour } from "../../__internal__/input-behaviour";
|
|
15
17
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
18
|
+
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
19
|
+
import NumeralDateContext from "./numeral-date-context";
|
|
16
20
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
17
21
|
const ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
|
|
18
22
|
|
|
@@ -62,6 +66,9 @@ const NumeralDate = ({
|
|
|
62
66
|
...rest
|
|
63
67
|
}) => {
|
|
64
68
|
const l = useLocale();
|
|
69
|
+
const {
|
|
70
|
+
validationRedesignOptIn
|
|
71
|
+
} = useContext(NewValidationContext);
|
|
65
72
|
const {
|
|
66
73
|
current: uniqueId
|
|
67
74
|
} = useRef(id || guid());
|
|
@@ -162,8 +169,12 @@ const NumeralDate = ({
|
|
|
162
169
|
labelSpacing: labelSpacing,
|
|
163
170
|
fieldHelp: fieldHelp,
|
|
164
171
|
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
|
|
165
|
-
isRequired: required
|
|
166
|
-
|
|
172
|
+
isRequired: required,
|
|
173
|
+
validationRedesignOptIn: validationRedesignOptIn
|
|
174
|
+
}, filterStyledSystemMarginProps(rest)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
175
|
+
error: internalError,
|
|
176
|
+
warning: internalWarning
|
|
177
|
+
}), /*#__PURE__*/React.createElement(StyledNumeralDate, {
|
|
167
178
|
name: name,
|
|
168
179
|
onKeyPress: onKeyPress,
|
|
169
180
|
"data-component": "numeral-date"
|
|
@@ -173,7 +184,12 @@ const NumeralDate = ({
|
|
|
173
184
|
const validation = error || warning || info;
|
|
174
185
|
const isStringValidation = typeof validation === "string";
|
|
175
186
|
const hasValidationIcon = isStringValidation && validation.length;
|
|
176
|
-
return /*#__PURE__*/React.createElement(
|
|
187
|
+
return /*#__PURE__*/React.createElement(NumeralDateContext.Provider, {
|
|
188
|
+
value: {
|
|
189
|
+
disableErrorBorder: index !== 0
|
|
190
|
+
},
|
|
191
|
+
key: datePart
|
|
192
|
+
}, /*#__PURE__*/React.createElement(StyledDateField, {
|
|
177
193
|
key: datePart,
|
|
178
194
|
isYearInput: datePart.length === 4,
|
|
179
195
|
isMiddle: isMiddle,
|
|
@@ -196,14 +212,14 @@ const NumeralDate = ({
|
|
|
196
212
|
info: !!info
|
|
197
213
|
}, required && {
|
|
198
214
|
required
|
|
199
|
-
}, isEnd && !validationOnLabel && {
|
|
215
|
+
}, isEnd && !validationRedesignOptIn && !validationOnLabel && {
|
|
200
216
|
error: internalError,
|
|
201
217
|
warning: internalWarning,
|
|
202
218
|
info
|
|
203
219
|
}, {
|
|
204
220
|
size: size,
|
|
205
221
|
tooltipPosition: tooltipPosition
|
|
206
|
-
})));
|
|
222
|
+
}))));
|
|
207
223
|
})))));
|
|
208
224
|
};
|
|
209
225
|
|
|
@@ -15,6 +15,9 @@ import StyledTextarea from "./textarea.style";
|
|
|
15
15
|
import LocaleContext from "../../__internal__/i18n-context";
|
|
16
16
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
17
17
|
import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
|
|
18
|
+
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
19
|
+
import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
|
|
20
|
+
import ValidationMessage from "../../__internal__/validation-message";
|
|
18
21
|
|
|
19
22
|
const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
20
23
|
|
|
@@ -59,6 +62,12 @@ const Textarea = ({
|
|
|
59
62
|
...props
|
|
60
63
|
}) => {
|
|
61
64
|
const locale = useContext(LocaleContext);
|
|
65
|
+
const {
|
|
66
|
+
validationRedesignOptIn
|
|
67
|
+
} = useContext(NewValidationContext);
|
|
68
|
+
|
|
69
|
+
const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
|
|
70
|
+
|
|
62
71
|
const {
|
|
63
72
|
current: id
|
|
64
73
|
} = useRef(idProp || guid());
|
|
@@ -134,7 +143,7 @@ const Textarea = ({
|
|
|
134
143
|
"data-role": dataRole,
|
|
135
144
|
"data-element": dataElement
|
|
136
145
|
}, filterStyledSystemMarginProps(props)), /*#__PURE__*/React.createElement(FormField, {
|
|
137
|
-
fieldHelp: fieldHelp,
|
|
146
|
+
fieldHelp: computeLabelPropValues(fieldHelp),
|
|
138
147
|
fieldHelpId: fieldHelpId,
|
|
139
148
|
error: error,
|
|
140
149
|
warning: warning,
|
|
@@ -143,15 +152,19 @@ const Textarea = ({
|
|
|
143
152
|
labelId: labelId,
|
|
144
153
|
disabled: disabled,
|
|
145
154
|
id: id,
|
|
146
|
-
labelInline: labelInline,
|
|
147
|
-
labelAlign: labelAlign,
|
|
148
|
-
labelWidth: labelWidth,
|
|
149
|
-
labelHelp: labelHelp,
|
|
155
|
+
labelInline: computeLabelPropValues(labelInline),
|
|
156
|
+
labelAlign: computeLabelPropValues(labelAlign),
|
|
157
|
+
labelWidth: computeLabelPropValues(labelWidth),
|
|
158
|
+
labelHelp: computeLabelPropValues(labelHelp),
|
|
150
159
|
labelSpacing: labelSpacing,
|
|
151
160
|
isRequired: props.required,
|
|
152
|
-
useValidationIcon: validationOnLabel,
|
|
153
|
-
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint
|
|
154
|
-
|
|
161
|
+
useValidationIcon: computeLabelPropValues(validationOnLabel),
|
|
162
|
+
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
|
|
163
|
+
validationRedesignOptIn: validationRedesignOptIn
|
|
164
|
+
}, validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
165
|
+
error: error,
|
|
166
|
+
warning: warning
|
|
167
|
+
}), /*#__PURE__*/React.createElement(InputPresentation, {
|
|
155
168
|
size: size,
|
|
156
169
|
disabled: disabled,
|
|
157
170
|
readOnly: readOnly,
|
|
@@ -159,10 +172,12 @@ const Textarea = ({
|
|
|
159
172
|
error: error,
|
|
160
173
|
warning: warning,
|
|
161
174
|
info: info
|
|
162
|
-
}, /*#__PURE__*/React.createElement(
|
|
175
|
+
}, validationRedesignOptIn && (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
|
|
176
|
+
warning: !!(!error && warning)
|
|
177
|
+
}), /*#__PURE__*/React.createElement(Input, _extends({
|
|
163
178
|
"aria-invalid": !!error,
|
|
164
179
|
"aria-labelledby": ariaLabelledBy,
|
|
165
|
-
"aria-describedby": ariaDescribedBy,
|
|
180
|
+
"aria-describedby": validationRedesignOptIn ? undefined : ariaDescribedBy,
|
|
166
181
|
autoFocus: autoFocus,
|
|
167
182
|
name: name,
|
|
168
183
|
value: value,
|
|
@@ -185,8 +200,8 @@ const Textarea = ({
|
|
|
185
200
|
error: error,
|
|
186
201
|
warning: warning,
|
|
187
202
|
info: info,
|
|
188
|
-
validationIconId: validationIconId,
|
|
189
|
-
useValidationIcon: !validationOnLabel
|
|
203
|
+
validationIconId: validationRedesignOptIn ? undefined : validationIconId,
|
|
204
|
+
useValidationIcon: !(validationRedesignOptIn || validationOnLabel)
|
|
190
205
|
}))), characterCount())));
|
|
191
206
|
};
|
|
192
207
|
|
|
@@ -1,6 +1,6 @@
|
|
|
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 from "react";
|
|
3
|
+
import React, { useContext } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
6
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
@@ -13,6 +13,10 @@ import StyledPrefix from "./__internal__/prefix.style";
|
|
|
13
13
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
14
14
|
import useCharacterCount from "../../hooks/__internal__/useCharacterCount";
|
|
15
15
|
import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility/useInputAccessibility";
|
|
16
|
+
import { ErrorBorder, StyledHintText } from "./textbox.style";
|
|
17
|
+
import ValidationMessage from "../../__internal__/validation-message";
|
|
18
|
+
import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
|
|
19
|
+
import NumeralDateContext from "../numeral-date/numeral-date-context";
|
|
16
20
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
17
21
|
|
|
18
22
|
const Textbox = ({
|
|
@@ -70,6 +74,15 @@ const Textbox = ({
|
|
|
70
74
|
...props
|
|
71
75
|
}) => {
|
|
72
76
|
const [maxLength, characterCount] = useCharacterCount(value, characterLimit, warnOverLimit, enforceCharacterLimit);
|
|
77
|
+
const {
|
|
78
|
+
validationRedesignOptIn
|
|
79
|
+
} = useContext(NewValidationContext);
|
|
80
|
+
const {
|
|
81
|
+
disableErrorBorder
|
|
82
|
+
} = useContext(NumeralDateContext);
|
|
83
|
+
|
|
84
|
+
const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
|
|
85
|
+
|
|
73
86
|
const {
|
|
74
87
|
labelId: internalLabelId,
|
|
75
88
|
validationIconId,
|
|
@@ -90,29 +103,35 @@ const Textbox = ({
|
|
|
90
103
|
tooltipPosition: tooltipPosition
|
|
91
104
|
}, /*#__PURE__*/React.createElement(InputBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({
|
|
92
105
|
disabled: disabled,
|
|
93
|
-
fieldHelp: fieldHelp,
|
|
94
106
|
fieldHelpId: fieldHelpId,
|
|
107
|
+
fieldHelp: computeLabelPropValues(fieldHelp),
|
|
95
108
|
error: error,
|
|
96
109
|
warning: warning,
|
|
97
110
|
info: info,
|
|
98
111
|
label: label,
|
|
99
112
|
labelId: labelId,
|
|
100
|
-
labelAlign: labelAlign,
|
|
101
|
-
labelHelp: labelHelp,
|
|
102
|
-
labelInline: labelInline,
|
|
113
|
+
labelAlign: computeLabelPropValues(labelAlign),
|
|
114
|
+
labelHelp: computeLabelPropValues(labelHelp),
|
|
115
|
+
labelInline: computeLabelPropValues(labelInline),
|
|
103
116
|
labelSpacing: labelSpacing,
|
|
104
|
-
labelWidth: labelWidth,
|
|
117
|
+
labelWidth: computeLabelPropValues(labelWidth),
|
|
105
118
|
id: id,
|
|
106
|
-
reverse: reverse,
|
|
119
|
+
reverse: computeLabelPropValues(reverse),
|
|
107
120
|
isOptional: isOptional,
|
|
108
|
-
useValidationIcon: validationOnLabel,
|
|
121
|
+
useValidationIcon: computeLabelPropValues(validationOnLabel),
|
|
109
122
|
adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
|
|
110
123
|
isRequired: required,
|
|
111
124
|
"data-component": dataComponent,
|
|
112
125
|
"data-role": dataRole,
|
|
113
126
|
"data-element": dataElement,
|
|
114
|
-
validationIconId: validationIconId
|
|
115
|
-
|
|
127
|
+
validationIconId: validationRedesignOptIn ? undefined : validationIconId,
|
|
128
|
+
validationRedesignOptIn: validationRedesignOptIn,
|
|
129
|
+
size: size,
|
|
130
|
+
readOnly: readOnly
|
|
131
|
+
}, filterStyledSystemMarginProps(props)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
132
|
+
error: error,
|
|
133
|
+
warning: warning
|
|
134
|
+
}), /*#__PURE__*/React.createElement(InputPresentation, {
|
|
116
135
|
align: align,
|
|
117
136
|
disabled: disabled,
|
|
118
137
|
readOnly: readOnly,
|
|
@@ -122,15 +141,17 @@ const Textbox = ({
|
|
|
122
141
|
info: info,
|
|
123
142
|
inputWidth: inputWidth || 100 - labelWidth,
|
|
124
143
|
positionedChildren: positionedChildren
|
|
125
|
-
}, leftChildren, prefix
|
|
144
|
+
}, leftChildren, prefix && /*#__PURE__*/React.createElement(StyledPrefix, {
|
|
126
145
|
"data-element": "textbox-prefix"
|
|
127
|
-
}, prefix)
|
|
146
|
+
}, prefix), validationRedesignOptIn && !disableErrorBorder && (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
|
|
147
|
+
warning: !!(!error && warning)
|
|
148
|
+
}), /*#__PURE__*/React.createElement(Input, _extends({}, required && {
|
|
128
149
|
required
|
|
129
150
|
}, {
|
|
130
151
|
align: align,
|
|
131
152
|
"aria-invalid": !!error,
|
|
132
153
|
"aria-labelledby": labelId,
|
|
133
|
-
"aria-describedby": ariaDescribedBy,
|
|
154
|
+
"aria-describedby": validationRedesignOptIn ? undefined : ariaDescribedBy,
|
|
134
155
|
autoFocus: autoFocus,
|
|
135
156
|
deferTimeout: deferTimeout,
|
|
136
157
|
disabled: disabled,
|
|
@@ -158,9 +179,9 @@ const Textbox = ({
|
|
|
158
179
|
onMouseDown: iconOnMouseDown || onMouseDown,
|
|
159
180
|
readOnly: readOnly,
|
|
160
181
|
size: size,
|
|
161
|
-
useValidationIcon: !validationOnLabel,
|
|
182
|
+
useValidationIcon: !(validationRedesignOptIn || validationOnLabel),
|
|
162
183
|
warning: warning,
|
|
163
|
-
validationIconId: validationIconId
|
|
184
|
+
validationIconId: validationRedesignOptIn ? undefined : validationIconId
|
|
164
185
|
}))), characterCount));
|
|
165
186
|
};
|
|
166
187
|
|