carbon-react 110.1.2 → 110.2.1
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__/character-count/character-count.component.d.ts +8 -25
- package/esm/__internal__/character-count/character-count.component.js +12 -18
- package/esm/__internal__/character-count/character-count.style.d.ts +3 -1
- package/esm/__internal__/character-count/character-count.style.js +4 -0
- package/esm/__internal__/form-field/form-field.component.d.ts +5 -1
- package/esm/__internal__/form-field/form-field.component.js +8 -5
- package/esm/__internal__/input/index.d.ts +1 -1
- package/esm/__internal__/utils/helpers/tags/tags.d.ts +5 -2
- package/esm/__spec_helper__/test-utils.d.ts +3 -2
- package/esm/__spec_helper__/test-utils.js +17 -1
- package/esm/components/box/box.component.d.ts +4 -2
- package/esm/components/box/box.component.js +2 -1
- package/esm/components/dismissible-box/dismissible-box.component.js +398 -0
- package/esm/components/numeral-date/numeral-date-context.d.ts +6 -0
- package/esm/components/portal/portal.d.ts +15 -12
- package/esm/components/portal/portal.js +3 -13
- package/esm/components/select/multi-select/multi-select.component.js +1 -1
- package/esm/components/select/select-list/select-list.component.js +20 -11
- package/esm/components/textarea/textarea.component.js +6 -27
- package/esm/components/textarea/textarea.d.ts +2 -1
- package/esm/components/textbox/__internal__/prefix.style.d.ts +2 -0
- package/esm/components/textbox/index.d.ts +2 -1
- package/esm/components/textbox/index.js +1 -1
- package/esm/components/textbox/textbox.component.d.ts +92 -0
- package/esm/components/textbox/textbox.component.js +533 -197
- package/esm/components/textbox/textbox.style.d.ts +5 -0
- package/esm/components/textbox/textbox.style.js +0 -12
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
- package/esm/hooks/__internal__/useCharacterCount/useCharacterCount.js +7 -6
- package/esm/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +6 -5
- package/esm/style/utils/filter-out-position-props.d.ts +3 -0
- package/esm/style/utils/filter-out-position-props.js +5 -0
- package/lib/__internal__/character-count/character-count.component.d.ts +8 -25
- package/lib/__internal__/character-count/character-count.component.js +13 -23
- package/lib/__internal__/character-count/character-count.style.d.ts +3 -1
- package/lib/__internal__/character-count/character-count.style.js +7 -0
- package/lib/__internal__/form-field/form-field.component.d.ts +5 -1
- package/lib/__internal__/form-field/form-field.component.js +8 -5
- package/lib/__internal__/input/index.d.ts +1 -1
- package/lib/__internal__/utils/helpers/tags/tags.d.ts +5 -2
- package/lib/__spec_helper__/test-utils.d.ts +3 -2
- package/lib/__spec_helper__/test-utils.js +20 -2
- package/lib/components/box/box.component.d.ts +4 -2
- package/lib/components/box/box.component.js +1 -0
- package/lib/components/dismissible-box/dismissible-box.component.js +398 -0
- package/lib/components/numeral-date/numeral-date-context.d.ts +6 -0
- package/lib/components/portal/portal.d.ts +15 -12
- package/lib/components/portal/portal.js +3 -14
- package/lib/components/select/multi-select/multi-select.component.js +1 -1
- package/lib/components/select/select-list/select-list.component.js +20 -11
- package/lib/components/textarea/textarea.component.js +6 -27
- package/lib/components/textarea/textarea.d.ts +2 -1
- package/lib/components/textbox/__internal__/prefix.style.d.ts +2 -0
- package/lib/components/textbox/index.d.ts +2 -1
- package/lib/components/textbox/index.js +2 -10
- package/lib/components/textbox/textbox.component.d.ts +92 -0
- package/lib/components/textbox/textbox.component.js +534 -201
- package/lib/components/textbox/textbox.style.d.ts +5 -0
- package/lib/components/textbox/textbox.style.js +1 -16
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.d.ts +1 -1
- package/lib/hooks/__internal__/useCharacterCount/useCharacterCount.js +7 -6
- package/lib/hooks/__internal__/useInputAccessibility/useInputAccessibility.d.ts +6 -5
- package/lib/style/utils/filter-out-position-props.d.ts +3 -0
- package/lib/style/utils/filter-out-position-props.js +18 -0
- package/package.json +1 -1
- package/esm/components/textbox/textbox.d.ts +0 -125
- package/lib/components/textbox/textbox.d.ts +0 -125
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
const ErrorBorder = styled.span`
|
|
4
3
|
${({
|
|
5
4
|
warning
|
|
@@ -19,15 +18,4 @@ const StyledHintText = styled.p`
|
|
|
19
18
|
color: var(--colorsUtilityYin055);
|
|
20
19
|
font-size: 14px;
|
|
21
20
|
`;
|
|
22
|
-
StyledHintText.defaultProps = {
|
|
23
|
-
size: "medium"
|
|
24
|
-
};
|
|
25
|
-
ErrorBorder.propTypes = {
|
|
26
|
-
warning: PropTypes.bool,
|
|
27
|
-
size: PropTypes.string
|
|
28
|
-
};
|
|
29
|
-
ErrorBorder.defaultProps = {
|
|
30
|
-
warning: false,
|
|
31
|
-
size: "medium"
|
|
32
|
-
};
|
|
33
21
|
export { StyledHintText, ErrorBorder };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const useCharacterCount: (value
|
|
2
|
+
declare const useCharacterCount: (value?: string, characterLimit?: number | undefined, warnOverLimit?: boolean, enforceCharacterLimit?: boolean) => [number | undefined, JSX.Element | null];
|
|
3
3
|
export default useCharacterCount;
|
|
@@ -4,19 +4,20 @@ import useLocale from "../useLocale";
|
|
|
4
4
|
|
|
5
5
|
const getFormatNumber = (value, locale) => new Intl.NumberFormat(locale).format(value);
|
|
6
6
|
|
|
7
|
-
const useCharacterCount = (value, characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
|
|
7
|
+
const useCharacterCount = (value = "", characterLimit, warnOverLimit = false, enforceCharacterLimit = true) => {
|
|
8
|
+
const isCharacterLimitValid = typeof characterLimit === "number" && !Number.isNaN(characterLimit);
|
|
8
9
|
const l = useLocale();
|
|
9
10
|
const isOverLimit = useMemo(() => {
|
|
10
|
-
if (value &&
|
|
11
|
-
return value.length >
|
|
11
|
+
if (value && isCharacterLimitValid) {
|
|
12
|
+
return value.length > characterLimit;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
return false;
|
|
15
|
-
}, [value, characterLimit]);
|
|
16
|
-
return [enforceCharacterLimit &&
|
|
16
|
+
}, [value, characterLimit, isCharacterLimitValid]);
|
|
17
|
+
return [enforceCharacterLimit && isCharacterLimitValid ? characterLimit : undefined, isCharacterLimitValid ? /*#__PURE__*/React.createElement(CharacterCount, {
|
|
17
18
|
isOverLimit: isOverLimit && warnOverLimit,
|
|
18
19
|
value: getFormatNumber(value.length, l.locale()),
|
|
19
|
-
limit: getFormatNumber(
|
|
20
|
+
limit: getFormatNumber(characterLimit, l.locale()),
|
|
20
21
|
"data-element": "character-limit"
|
|
21
22
|
}) : null];
|
|
22
23
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export default function useInputAccessibility({ id, error, warning, info, label, fieldHelp, }: {
|
|
2
3
|
id: string;
|
|
3
|
-
error?: string;
|
|
4
|
-
warning?: string;
|
|
5
|
-
info?: string;
|
|
6
|
-
label?:
|
|
7
|
-
fieldHelp?:
|
|
4
|
+
error?: string | boolean;
|
|
5
|
+
warning?: string | boolean;
|
|
6
|
+
info?: string | boolean;
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
fieldHelp?: React.ReactNode;
|
|
8
9
|
}): {
|
|
9
10
|
labelId?: string;
|
|
10
11
|
validationIconId?: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import filterObjectProperties from "../../__internal__/filter-object-properties";
|
|
2
|
+
export const positionPropertyNames = ["top", "right", "bottom", "left", "position"];
|
|
3
|
+
export default function filterStyledSystemPositionProps(originalObject) {
|
|
4
|
+
return filterObjectProperties(originalObject, positionPropertyNames);
|
|
5
|
+
}
|
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export default _default;
|
|
8
|
-
import React from "react";
|
|
9
|
-
export function CharacterCount({ value, limit, theme, ...props }: {
|
|
10
|
-
[x: string]: any;
|
|
11
|
-
value: any;
|
|
12
|
-
limit: any;
|
|
13
|
-
theme: any;
|
|
14
|
-
}): JSX.Element;
|
|
15
|
-
export namespace CharacterCount {
|
|
16
|
-
namespace propTypes {
|
|
17
|
-
const value: PropTypes.Validator<string>;
|
|
18
|
-
const limit: PropTypes.Validator<string>;
|
|
19
|
-
const theme: PropTypes.Requireable<object>;
|
|
20
|
-
}
|
|
21
|
-
namespace defaultProps {
|
|
22
|
-
export { baseTheme as theme };
|
|
23
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface CharacterCountProps {
|
|
3
|
+
value: string;
|
|
4
|
+
limit: string;
|
|
5
|
+
isOverLimit: boolean;
|
|
6
|
+
"data-element"?: string;
|
|
24
7
|
}
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
declare const CharacterCount: ({ value, limit, isOverLimit, "data-element": dataElement, }: CharacterCountProps) => JSX.Element;
|
|
9
|
+
export default CharacterCount;
|
|
@@ -3,42 +3,32 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var _styledComponents = require("styled-components");
|
|
13
|
-
|
|
14
|
-
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
15
|
-
|
|
16
12
|
var _characterCount = _interopRequireDefault(require("./character-count.style"));
|
|
17
13
|
|
|
18
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
15
|
|
|
20
|
-
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); }
|
|
21
|
-
|
|
22
16
|
const CharacterCount = ({
|
|
23
17
|
value,
|
|
24
18
|
limit,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}) => /*#__PURE__*/_react.default.createElement(_characterCount.default,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
isOverLimit,
|
|
20
|
+
"data-element": dataElement
|
|
21
|
+
}) => /*#__PURE__*/_react.default.createElement(_characterCount.default, {
|
|
22
|
+
"aria-live": "polite",
|
|
23
|
+
isOverLimit: isOverLimit,
|
|
24
|
+
"data-element": dataElement
|
|
25
|
+
}, `${value}/${limit}`);
|
|
31
26
|
|
|
32
|
-
exports.CharacterCount = CharacterCount;
|
|
33
27
|
CharacterCount.propTypes = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
"data-element": _propTypes.default.string,
|
|
29
|
+
"isOverLimit": _propTypes.default.bool.isRequired,
|
|
30
|
+
"limit": _propTypes.default.string.isRequired,
|
|
31
|
+
"value": _propTypes.default.string.isRequired
|
|
37
32
|
};
|
|
38
|
-
|
|
39
|
-
theme: _base.default
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var _default = (0, _styledComponents.withTheme)(CharacterCount);
|
|
43
|
-
|
|
33
|
+
var _default = CharacterCount;
|
|
44
34
|
exports.default = _default;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
declare const StyledCharacterCount: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
isOverLimit: boolean;
|
|
3
|
+
}, never>;
|
|
1
4
|
export default StyledCharacterCount;
|
|
2
|
-
declare const StyledCharacterCount: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -7,6 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
+
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
10
14
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
11
15
|
|
|
12
16
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -26,5 +30,8 @@ const StyledCharacterCount = _styledComponents.default.div`
|
|
|
26
30
|
font-weight: 700;
|
|
27
31
|
`}
|
|
28
32
|
`;
|
|
33
|
+
StyledCharacterCount.defaultProps = {
|
|
34
|
+
theme: _base.default
|
|
35
|
+
};
|
|
29
36
|
var _default = StyledCharacterCount;
|
|
30
37
|
exports.default = _default;
|
|
@@ -32,6 +32,10 @@ interface CommonFormFieldProps extends MarginProps, ValidationProps {
|
|
|
32
32
|
reverse?: boolean;
|
|
33
33
|
/** Id of the validation icon */
|
|
34
34
|
validationIconId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* @private @ignore
|
|
37
|
+
* Flag dedicating if latest validation design should be used */
|
|
38
|
+
validationRedesignOptIn?: boolean;
|
|
35
39
|
}
|
|
36
40
|
export interface FormFieldProps extends CommonFormFieldProps, TagProps {
|
|
37
41
|
/** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
|
|
@@ -53,7 +57,7 @@ export interface FormFieldProps extends CommonFormFieldProps, TagProps {
|
|
|
53
57
|
useValidationIcon?: boolean;
|
|
54
58
|
}
|
|
55
59
|
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;
|
|
60
|
+
({ children, "data-component": dataComponent, disabled, fieldHelp: fieldHelpContent, fieldHelpInline, error, warning, info, tooltipId, fieldHelpId, label, labelId, labelAlign, labelHelp, labelHelpIcon, labelInline, labelSpacing, labelWidth, id, reverse, isOptional, useValidationIcon, adaptiveLabelBreakpoint, isRequired, validationIconId, validationRedesignOptIn, ...rest }: FormFieldProps): JSX.Element;
|
|
57
61
|
displayName: string;
|
|
58
62
|
};
|
|
59
63
|
export default FormField;
|
|
@@ -35,6 +35,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
35
35
|
|
|
36
36
|
const FormField = ({
|
|
37
37
|
children,
|
|
38
|
+
"data-component": dataComponent,
|
|
38
39
|
disabled,
|
|
39
40
|
fieldHelp: fieldHelpContent,
|
|
40
41
|
fieldHelpInline,
|
|
@@ -58,6 +59,7 @@ const FormField = ({
|
|
|
58
59
|
adaptiveLabelBreakpoint,
|
|
59
60
|
isRequired,
|
|
60
61
|
validationIconId,
|
|
62
|
+
validationRedesignOptIn,
|
|
61
63
|
...rest
|
|
62
64
|
}) => {
|
|
63
65
|
const invalidValidationProp = (0, _react.useMemo)(() => {
|
|
@@ -93,15 +95,15 @@ const FormField = ({
|
|
|
93
95
|
labelWidth: labelWidth,
|
|
94
96
|
id: fieldHelpId
|
|
95
97
|
}, fieldHelpContent) : null;
|
|
96
|
-
return /*#__PURE__*/_react.default.createElement(_formField.default, _extends({}, (0, _tags.default)(
|
|
98
|
+
return /*#__PURE__*/_react.default.createElement(_formField.default, _extends({}, (0, _tags.default)(dataComponent, rest), marginProps), /*#__PURE__*/_react.default.createElement(_formField.FieldLineStyle, {
|
|
97
99
|
inline: inlineLabel
|
|
98
100
|
}, reverse && children, label && /*#__PURE__*/_react.default.createElement(_label.default, {
|
|
99
101
|
labelId: labelId,
|
|
100
102
|
align: labelAlign,
|
|
101
103
|
disabled: disabled,
|
|
102
|
-
error: !
|
|
103
|
-
warning: !
|
|
104
|
-
info: !
|
|
104
|
+
error: !validationRedesignOptIn && error,
|
|
105
|
+
warning: !validationRedesignOptIn && warning,
|
|
106
|
+
info: !validationRedesignOptIn && info,
|
|
105
107
|
help: labelHelp,
|
|
106
108
|
tooltipId: tooltipId,
|
|
107
109
|
htmlFor: id,
|
|
@@ -120,7 +122,7 @@ const FormField = ({
|
|
|
120
122
|
FormField.propTypes = {
|
|
121
123
|
"adaptiveLabelBreakpoint": _propTypes.default.number,
|
|
122
124
|
"children": _propTypes.default.node,
|
|
123
|
-
"data-component": _propTypes.default.string
|
|
125
|
+
"data-component": _propTypes.default.string,
|
|
124
126
|
"data-element": _propTypes.default.string,
|
|
125
127
|
"data-role": _propTypes.default.string,
|
|
126
128
|
"disabled": _propTypes.default.bool,
|
|
@@ -298,6 +300,7 @@ FormField.propTypes = {
|
|
|
298
300
|
"tooltipId": _propTypes.default.string,
|
|
299
301
|
"useValidationIcon": _propTypes.default.bool,
|
|
300
302
|
"validationIconId": _propTypes.default.string,
|
|
303
|
+
"validationRedesignOptIn": _propTypes.default.bool,
|
|
301
304
|
"warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool])
|
|
302
305
|
};
|
|
303
306
|
FormField.displayName = "FormField";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Input from "./input.component";
|
|
2
2
|
import InputPresentation from "./input-presentation.component";
|
|
3
|
-
export type { InputProps } from "./input.component";
|
|
3
|
+
export type { InputProps, CommonInputProps } from "./input.component";
|
|
4
4
|
export { Input, InputPresentation };
|
|
5
5
|
export default Input;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
interface DataProps {
|
|
2
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
2
3
|
"data-element"?: string;
|
|
4
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
3
5
|
"data-role"?: string;
|
|
4
6
|
[restKeys: string]: any;
|
|
5
7
|
}
|
|
6
8
|
export interface TagProps extends DataProps {
|
|
7
|
-
|
|
9
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
10
|
+
"data-component"?: string;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
13
|
* Builds props object containing top level data tags
|
|
11
14
|
*/
|
|
12
|
-
declare function tagComponent(componentName: string, props: DataProps): TagProps;
|
|
15
|
+
declare function tagComponent(componentName: string | undefined, props: DataProps): TagProps;
|
|
13
16
|
export default tagComponent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ReactWrapper, ShallowWrapper } from "enzyme";
|
|
3
|
-
import { LayoutProps, FlexboxProps, BackgroundProps } from "styled-system";
|
|
3
|
+
import { LayoutProps, FlexboxProps, BackgroundProps, PositionProps } from "styled-system";
|
|
4
4
|
import { ReactTestRendererJSON } from "react-test-renderer";
|
|
5
5
|
import { mockMatchMedia } from "./mock-match-media";
|
|
6
6
|
declare const toCSSCase: (str: string) => string;
|
|
@@ -47,5 +47,6 @@ declare const testStyledSystemWidth: (component: (widthProperties?: {
|
|
|
47
47
|
declare const testStyledSystemLayout: (component: (layoutProperties?: LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
48
48
|
declare const testStyledSystemFlexBox: (component: (flexboxProperties?: FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
49
49
|
declare const testStyledSystemBackground: (component: (backgroundProperties?: BackgroundProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Background<import("styled-system").TLengthStyledSystem>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
|
+
declare const testStyledSystemPosition: (component: (positionProperties?: PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined) => JSX.Element, styleContainer?: ((wrapper: ReactWrapper) => ReactWrapper) | undefined) => void;
|
|
50
51
|
declare const expectConsoleOutput: (message: string, type?: "warn" | "error") => () => void;
|
|
51
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground, expectConsoleOutput, };
|
|
52
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground, testStyledSystemPosition, expectConsoleOutput, };
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "mockMatchMedia", {
|
|
|
9
9
|
return _mockMatchMedia.mockMatchMedia;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
exports.expectConsoleOutput = exports.testStyledSystemBackground = exports.testStyledSystemFlexBox = exports.testStyledSystemLayout = exports.testStyledSystemWidth = exports.testStyledSystemColor = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemSpacing = exports.carbonThemesJestTable = exports.simulate = exports.click = exports.listFrom = exports.assertHoverTraversal = exports.assertKeyboardTraversal = exports.keyboard = exports.makeArrayKeys = exports.childrenFrom = exports.selectedItemOf = exports.hoverList = exports.toCSSCase = exports.assertStyleMatch = exports.getDefaultValue = void 0;
|
|
12
|
+
exports.expectConsoleOutput = exports.testStyledSystemPosition = exports.testStyledSystemBackground = exports.testStyledSystemFlexBox = exports.testStyledSystemLayout = exports.testStyledSystemWidth = exports.testStyledSystemColor = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemSpacing = exports.carbonThemesJestTable = exports.simulate = exports.click = exports.listFrom = exports.assertHoverTraversal = exports.assertKeyboardTraversal = exports.keyboard = exports.makeArrayKeys = exports.childrenFrom = exports.selectedItemOf = exports.hoverList = exports.toCSSCase = exports.assertStyleMatch = exports.getDefaultValue = void 0;
|
|
13
13
|
|
|
14
14
|
var _enzyme = require("enzyme");
|
|
15
15
|
|
|
@@ -148,6 +148,7 @@ const widthProps = ["width", "width", "200px"];
|
|
|
148
148
|
const layoutProps = [widthProps, ["height", "height", "200px"], ["minWidth", "min-width", "120px"], ["maxWidth", "max-width", "120px"], ["minHeight", "min-height", "120px"], ["maxHeight", "max-height", "120px"], ["size", "width", "120px"], ["size", "height", "120px"], ["display", "display", "inline-block"], ["verticalAlign", "vertical-align", "baseline"], ["overflow", "overflow", "hidden"], ["overflowX", "overflow-x", "hidden"], ["overflowY", "overflow-y", "hidden"]];
|
|
149
149
|
const flexBoxProps = [["alignItems", "alignItems", "center"], ["alignContent", "alignContent", "center"], ["justifyItems", "justifyItems", "center"], ["justifyContent", "justifyContent", "center"], ["flexWrap", "flexWrap", "wrap"], ["flexDirection", "flexDirection", "row-reverse"], ["flex", "flex", "1"], ["flexGrow", "flexGrow", "1"], ["flexShrink", "flexShrink", "1"], ["flexBasis", "flexBasis", "100px"], ["justifySelf", "justifySelf", "center"], ["alignSelf", "alignSelf", "center"], ["order", "order", "1"]];
|
|
150
150
|
const backgroundProps = [["background", "background", "lightblue url('foo.jpg') no-repeat fixed center"], ["backgroundImage", "background-image", "url(foo.jpg)"], ["backgroundSize", "background-size", "center"], ["backgroundRepeat", "background-repeat", "no-repeat"]];
|
|
151
|
+
const positionProps = [["top", "0px"], ["bottom", "0px"], ["right", "0px"], ["left", "0px"], ["position", "fixed"], ["position", "sticky"], ["position", "absolute"], ["position", "static"], ["position", "relative"]];
|
|
151
152
|
|
|
152
153
|
const getDefaultValue = value => {
|
|
153
154
|
const spaceArrayLength = _baseTheme.space.length - 1;
|
|
@@ -358,10 +359,27 @@ const testStyledSystemBackground = (component, styleContainer) => {
|
|
|
358
359
|
}, styleContainer ? styleContainer(wrapper) : wrapper);
|
|
359
360
|
});
|
|
360
361
|
});
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
exports.testStyledSystemBackground = testStyledSystemBackground;
|
|
365
|
+
|
|
366
|
+
const testStyledSystemPosition = (component, styleContainer) => {
|
|
367
|
+
describe.each(positionProps)('when a prop is specified using the "%s" styled system props', (styledSystemProp, value) => {
|
|
368
|
+
it(`then ${styledSystemProp} should have been set correctly`, () => {
|
|
369
|
+
const props = {
|
|
370
|
+
[styledSystemProp]: value
|
|
371
|
+
};
|
|
372
|
+
const wrapper = (0, _enzyme.mount)(component({ ...props
|
|
373
|
+
}));
|
|
374
|
+
assertStyleMatch({
|
|
375
|
+
[styledSystemProp]: value
|
|
376
|
+
}, styleContainer ? styleContainer(wrapper) : wrapper);
|
|
377
|
+
});
|
|
378
|
+
});
|
|
361
379
|
}; // this util will catch that a console output occurred without polluting the output when running the unit tests
|
|
362
380
|
|
|
363
381
|
|
|
364
|
-
exports.
|
|
382
|
+
exports.testStyledSystemPosition = testStyledSystemPosition;
|
|
365
383
|
|
|
366
384
|
const expectConsoleOutput = (message, type = "error") => {
|
|
367
385
|
if (!message) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SpaceProps, LayoutProps, FlexboxProps, ColorProps } from "styled-system";
|
|
2
|
+
import { SpaceProps, LayoutProps, FlexboxProps, ColorProps, PositionProps } from "styled-system";
|
|
3
3
|
export declare type OverflowWrap = "break-word" | "anywhere";
|
|
4
4
|
export declare type ScrollVariant = "light" | "dark";
|
|
5
5
|
export declare type BoxSizing = "content-box" | "border-box";
|
|
6
|
-
export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorProps {
|
|
6
|
+
export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorProps, Omit<PositionProps, "zIndex"> {
|
|
7
7
|
as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
|
|
8
8
|
/** String to set Box content break strategy. Note "anywhere" is not supported in Safari */
|
|
9
9
|
overflowWrap?: OverflowWrap;
|
|
@@ -11,6 +11,8 @@ export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorPr
|
|
|
11
11
|
scrollVariant?: ScrollVariant;
|
|
12
12
|
/** set the box-sizing attribute of the Box component */
|
|
13
13
|
boxSizing?: BoxSizing;
|
|
14
|
+
/** Allows a tabindex to be specified */
|
|
15
|
+
tabIndex?: number | string;
|
|
14
16
|
}
|
|
15
17
|
declare const Box: import("styled-components").StyledComponent<"div", any, BoxProps, never>;
|
|
16
18
|
export default Box;
|