carbon-react 106.0.2 → 106.0.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/__internal__/input/index.d.ts +5 -5
- package/esm/__internal__/input/input-presentation.component.d.ts +21 -27
- package/esm/__internal__/input/input-presentation.component.js +7 -20
- package/esm/__internal__/input/input-presentation.style.d.ts +5 -8
- package/esm/__internal__/input/input-presentation.style.js +37 -53
- package/esm/__internal__/input/input-sizes.style.d.ts +8 -18
- package/esm/__internal__/input/input-sizes.style.js +3 -2
- package/esm/__internal__/input/input.component.d.ts +39 -2
- package/esm/__internal__/input/input.component.js +84 -66
- package/esm/__internal__/input/input.style.d.ts +2 -1
- package/esm/__internal__/input/input.style.js +0 -4
- package/esm/__internal__/input-behaviour/index.d.ts +2 -1
- package/esm/__internal__/input-behaviour/input-behaviour.component.d.ts +7 -10
- package/esm/__internal__/input-behaviour/input-behaviour.component.js +2 -7
- package/esm/__internal__/input-behaviour/input-group-behaviour.component.d.ts +8 -12
- package/esm/__internal__/input-behaviour/input-group-behaviour.component.js +1 -7
- package/esm/__internal__/input-behaviour/useInputBehaviour.d.ts +14 -10
- package/esm/__internal__/label/label.d.ts +1 -1
- package/esm/components/badge/badge.component.d.ts +10 -13
- package/esm/components/badge/badge.component.js +60 -24
- package/esm/components/badge/badge.style.d.ts +7 -5
- package/esm/components/badge/index.d.ts +2 -1
- package/esm/components/carbon-provider/carbon-provider.component.d.ts +8 -14
- package/esm/components/carbon-provider/carbon-provider.component.js +110 -14
- package/esm/components/carbon-provider/index.d.ts +2 -1
- package/esm/components/date-range/date-range.style.js +2 -2
- package/esm/components/decimal/decimal.component.js +2 -1
- package/esm/components/heading/heading.style.d.ts +1 -2
- package/esm/components/inline-inputs/index.d.ts +2 -1
- package/esm/components/inline-inputs/index.js +1 -1
- package/esm/components/inline-inputs/inline-inputs.component.d.ts +25 -22
- package/esm/components/inline-inputs/inline-inputs.component.js +96 -60
- package/esm/components/inline-inputs/inline-inputs.config.d.ts +1 -1
- package/esm/components/inline-inputs/inline-inputs.style.d.ts +5 -3
- package/esm/components/inline-inputs/inline-inputs.style.js +2 -2
- package/esm/components/link/index.d.ts +1 -2
- package/esm/components/link/link.component.d.ts +37 -2
- package/esm/components/link/link.component.js +1243 -124
- package/esm/components/link/link.config.d.ts +2 -2
- package/esm/components/link/link.style.d.ts +7 -2
- package/esm/components/link/link.style.js +0 -5
- package/esm/components/pager/pager.style.d.ts +1 -2
- package/esm/components/pod/pod.style.d.ts +1 -2
- package/esm/components/simple-color-picker/simple-color-input/simple-color-input.style.d.ts +1 -1
- package/esm/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +1 -2
- package/esm/components/tile-select/tile-select.style.d.ts +1 -1
- package/lib/__internal__/input/index.d.ts +5 -5
- package/lib/__internal__/input/input-presentation.component.d.ts +21 -27
- package/lib/__internal__/input/input-presentation.component.js +7 -23
- package/lib/__internal__/input/input-presentation.style.d.ts +5 -8
- package/lib/__internal__/input/input-presentation.style.js +37 -54
- package/lib/__internal__/input/input-sizes.style.d.ts +8 -18
- package/lib/__internal__/input/input-sizes.style.js +2 -1
- package/lib/__internal__/input/input.component.d.ts +39 -2
- package/lib/__internal__/input/input.component.js +85 -69
- package/lib/__internal__/input/input.style.d.ts +2 -1
- package/lib/__internal__/input/input.style.js +0 -7
- package/lib/__internal__/input-behaviour/index.d.ts +2 -1
- package/lib/__internal__/input-behaviour/input-behaviour.component.d.ts +7 -10
- package/lib/__internal__/input-behaviour/input-behaviour.component.js +3 -10
- package/lib/__internal__/input-behaviour/input-group-behaviour.component.d.ts +8 -12
- package/lib/__internal__/input-behaviour/input-group-behaviour.component.js +2 -10
- package/lib/__internal__/input-behaviour/useInputBehaviour.d.ts +14 -10
- package/lib/__internal__/label/label.d.ts +1 -1
- package/lib/components/badge/badge.component.d.ts +10 -13
- package/lib/components/badge/badge.component.js +51 -29
- package/lib/components/badge/badge.style.d.ts +7 -5
- package/lib/components/badge/index.d.ts +2 -1
- package/lib/components/carbon-provider/carbon-provider.component.d.ts +8 -14
- package/lib/components/carbon-provider/carbon-provider.component.js +115 -20
- package/lib/components/carbon-provider/index.d.ts +2 -1
- package/lib/components/date-range/date-range.style.js +4 -4
- package/lib/components/decimal/decimal.component.js +2 -1
- package/lib/components/heading/heading.style.d.ts +1 -2
- package/lib/components/inline-inputs/index.d.ts +2 -1
- package/lib/components/inline-inputs/index.js +10 -2
- package/lib/components/inline-inputs/inline-inputs.component.d.ts +25 -22
- package/lib/components/inline-inputs/inline-inputs.component.js +143 -68
- package/lib/components/inline-inputs/inline-inputs.config.d.ts +1 -1
- package/lib/components/inline-inputs/inline-inputs.style.d.ts +5 -3
- package/lib/components/inline-inputs/inline-inputs.style.js +2 -2
- package/lib/components/link/index.d.ts +1 -2
- package/lib/components/link/link.component.d.ts +37 -2
- package/lib/components/link/link.component.js +764 -146
- package/lib/components/link/link.config.d.ts +2 -2
- package/lib/components/link/link.style.d.ts +7 -2
- package/lib/components/link/link.style.js +0 -6
- package/lib/components/pager/pager.style.d.ts +1 -2
- package/lib/components/pod/pod.style.d.ts +1 -2
- package/lib/components/simple-color-picker/simple-color-input/simple-color-input.style.d.ts +1 -1
- package/lib/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +1 -2
- package/lib/components/tile-select/tile-select.style.d.ts +1 -1
- package/package.json +1 -1
- package/esm/__internal__/input/extract-props/extract-props.d.ts +0 -1
- package/esm/__internal__/input/extract-props/extract-props.js +0 -11
- package/esm/__internal__/input/extract-props/index.d.ts +0 -1
- package/esm/__internal__/input/extract-props/index.js +0 -1
- package/esm/__internal__/input/input-presentation.d.ts +0 -24
- package/esm/__internal__/input/input.d.ts +0 -54
- package/esm/components/badge/badge.d.ts +0 -14
- package/esm/components/carbon-provider/carbon-provider.d.ts +0 -12
- package/esm/components/inline-inputs/inline-inputs.d.ts +0 -30
- package/esm/components/link/link.d.ts +0 -47
- package/lib/__internal__/input/extract-props/extract-props.d.ts +0 -1
- package/lib/__internal__/input/extract-props/extract-props.js +0 -18
- package/lib/__internal__/input/extract-props/index.d.ts +0 -1
- package/lib/__internal__/input/extract-props/index.js +0 -15
- package/lib/__internal__/input/extract-props/package.json +0 -6
- package/lib/__internal__/input/input-presentation.d.ts +0 -24
- package/lib/__internal__/input/input.d.ts +0 -54
- package/lib/components/badge/badge.d.ts +0 -14
- package/lib/components/carbon-provider/carbon-provider.d.ts +0 -12
- package/lib/components/inline-inputs/inline-inputs.d.ts +0 -30
- package/lib/components/link/link.d.ts +0 -47
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const LINK_POSITIONS: string[];
|
|
2
|
-
export const LINK_ALIGNMENTS: string[];
|
|
1
|
+
export declare const LINK_POSITIONS: string[];
|
|
2
|
+
export declare const LINK_ALIGNMENTS: string[];
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { LinkProps } from "./link.component";
|
|
2
|
+
interface StyledLinkProps extends Pick<LinkProps, "isSkipLink" | "iconAlign" | "disabled"> {
|
|
3
|
+
hasContent: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const StyledLink: import("styled-components").StyledComponent<"span", any, StyledLinkProps, never>;
|
|
6
|
+
declare const StyledContent: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
7
|
+
export { StyledLink, StyledContent };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import baseTheme from "../../style/themes/base";
|
|
4
3
|
import StyledIcon from "../icon/icon.style";
|
|
5
4
|
const StyledLink = styled.span`
|
|
@@ -82,9 +81,5 @@ StyledLink.defaultProps = {
|
|
|
82
81
|
disabled: false,
|
|
83
82
|
hasContent: true
|
|
84
83
|
};
|
|
85
|
-
StyledLink.propTypes = {
|
|
86
|
-
disabled: PropTypes.bool,
|
|
87
|
-
hasContent: PropTypes.bool
|
|
88
|
-
};
|
|
89
84
|
const StyledContent = styled.span``;
|
|
90
85
|
export { StyledLink, StyledContent };
|
|
@@ -3,8 +3,7 @@ export const StyledPagerSizeOptions: import("styled-components").StyledComponent
|
|
|
3
3
|
export const StyledPagerSizeOptionsInner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
export const StyledPagerNavigation: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
5
|
export const StyledPagerNavInner: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
-
export const StyledPagerLinkStyles: import("styled-components").StyledComponent<
|
|
6
|
+
export const StyledPagerLinkStyles: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../link/link.component").LinkProps & import("react").RefAttributes<HTMLLinkElement | HTMLButtonElement>>, any, {}, never>;
|
|
7
7
|
export const StyledPagerNoSelect: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
8
8
|
export const StyledPagerSummary: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
9
|
export const StyledSelectContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
-
import Link from "../link";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const StyledBlock: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
2
|
export const StyledContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
-
export const StyledEditAction: import("styled-components").StyledComponent<
|
|
3
|
+
export const StyledEditAction: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../link/link.component").LinkProps & import("react").RefAttributes<HTMLLinkElement | HTMLButtonElement>>, any, {}, never>;
|
|
4
4
|
export const StyledActionsContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
5
|
export const StyledDeleteButton: import("styled-components").StyledComponent<typeof IconButton, any, {}, never>;
|
|
6
6
|
export const StyledUndoButton: import("styled-components").StyledComponent<typeof IconButton, any, {}, never>;
|
|
@@ -9,5 +9,4 @@ export const StyledPod: import("styled-components").StyledComponent<"div", any,
|
|
|
9
9
|
export const StyledHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
10
|
export const StyledSubtitle: import("styled-components").StyledComponent<"h5", any, {}, never>;
|
|
11
11
|
export const StyledTitle: import("styled-components").StyledComponent<"h4", any, {}, never>;
|
|
12
|
-
import Link from "../link";
|
|
13
12
|
import IconButton from "../icon-button";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export default StyledSimpleColorInput;
|
|
2
|
-
declare const StyledSimpleColorInput: import("styled-components").StyledComponent<
|
|
2
|
+
declare const StyledSimpleColorInput: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../../__internal__/input").InputProps & import("react").RefAttributes<HTMLInputElement>>, any, {}, never>;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export default StyledEditorLink;
|
|
2
|
-
declare const StyledEditorLink: import("styled-components").StyledComponent<
|
|
3
|
-
import Link from "../../../link";
|
|
2
|
+
declare const StyledEditorLink: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../../link/link.component").LinkProps & import("react").RefAttributes<HTMLLinkElement | HTMLButtonElement>>, any, {}, never>;
|
|
@@ -2,7 +2,7 @@ export const StyledTileSelectFieldset: import("styled-components").StyledCompone
|
|
|
2
2
|
export const StyledGroupDescription: import("styled-components").StyledComponent<"p", any, {}, never>;
|
|
3
3
|
export const StyledTileSelectContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
export const StyledTileSelect: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
-
export const StyledTileSelectInput: import("styled-components").StyledComponent<
|
|
5
|
+
export const StyledTileSelectInput: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../__internal__/input").InputProps & import("react").RefAttributes<HTMLInputElement>>, any, {}, never>;
|
|
6
6
|
export const StyledTitleContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
7
|
export const StyledTitle: import("styled-components").StyledComponent<"h3", any, {}, never>;
|
|
8
8
|
export const StyledSubtitle: import("styled-components").StyledComponent<"h4", any, {}, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import Input from "./input.component";
|
|
2
|
+
import InputPresentation from "./input-presentation.component";
|
|
3
|
+
export type { InputProps } from "./input.component";
|
|
4
|
+
export { Input, InputPresentation };
|
|
5
|
+
export default Input;
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
disabled
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const readOnly: PropTypes.Requireable<boolean>;
|
|
21
|
-
const positionedChildren: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
22
|
-
const size: PropTypes.Requireable<string>;
|
|
23
|
-
const error: PropTypes.Requireable<string | boolean>;
|
|
24
|
-
const warning: PropTypes.Requireable<string | boolean>;
|
|
25
|
-
const info: PropTypes.Requireable<string | boolean>;
|
|
26
|
-
}
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ValidationPropTypes } from "../validations";
|
|
3
|
+
export declare type Sizes = "small" | "medium" | "large";
|
|
4
|
+
export interface CommonInputPresentationProps extends ValidationPropTypes {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** If true, the component will be disabled */
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** The default value alignment on the input */
|
|
9
|
+
align?: string;
|
|
10
|
+
/** The width of the input as a percentage */
|
|
11
|
+
inputWidth?: number;
|
|
12
|
+
/** If true, the component will be read-only */
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
/** Size of an input */
|
|
15
|
+
size?: Sizes;
|
|
16
|
+
}
|
|
17
|
+
export interface InputPresentationProps extends CommonInputPresentationProps {
|
|
18
|
+
/** Content to be rendered before the input */
|
|
19
|
+
positionedChildren?: React.ReactNode;
|
|
27
20
|
}
|
|
28
|
-
|
|
21
|
+
declare const InputPresentation: ({ children, positionedChildren, inputWidth, align, disabled, readOnly, size, error, warning, info, }: InputPresentationProps) => JSX.Element;
|
|
22
|
+
export default InputPresentation;
|
|
@@ -7,16 +7,12 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _inputPresentation = _interopRequireWildcard(require("./input-presentation.style"));
|
|
13
11
|
|
|
14
12
|
var _inputBehaviour = require("../input-behaviour");
|
|
15
13
|
|
|
16
14
|
var _carbonProvider = require("../../components/carbon-provider/carbon-provider.component");
|
|
17
15
|
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
16
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
21
17
|
|
|
22
18
|
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; }
|
|
@@ -28,7 +24,7 @@ const InputPresentation = ({
|
|
|
28
24
|
align,
|
|
29
25
|
disabled,
|
|
30
26
|
readOnly,
|
|
31
|
-
size,
|
|
27
|
+
size = "medium",
|
|
32
28
|
error,
|
|
33
29
|
warning,
|
|
34
30
|
info
|
|
@@ -47,14 +43,14 @@ const InputPresentation = ({
|
|
|
47
43
|
onMouseLeave: onGroupMouseLeave
|
|
48
44
|
} = (0, _react.useContext)(_inputBehaviour.InputGroupContext);
|
|
49
45
|
|
|
50
|
-
const handleMouseEnter =
|
|
51
|
-
if (onMouseEnter) onMouseEnter(
|
|
52
|
-
if (onGroupMouseEnter) onGroupMouseEnter(
|
|
46
|
+
const handleMouseEnter = () => {
|
|
47
|
+
if (onMouseEnter) onMouseEnter();
|
|
48
|
+
if (onGroupMouseEnter) onGroupMouseEnter();
|
|
53
49
|
};
|
|
54
50
|
|
|
55
|
-
const handleMouseLeave =
|
|
56
|
-
if (onMouseLeave) onMouseLeave(
|
|
57
|
-
if (onGroupMouseLeave) onGroupMouseLeave(
|
|
51
|
+
const handleMouseLeave = () => {
|
|
52
|
+
if (onMouseLeave) onMouseLeave();
|
|
53
|
+
if (onGroupMouseLeave) onGroupMouseLeave();
|
|
58
54
|
};
|
|
59
55
|
|
|
60
56
|
return /*#__PURE__*/_react.default.createElement(_inputPresentation.StyledInputPresentationContainer, {
|
|
@@ -76,17 +72,5 @@ const InputPresentation = ({
|
|
|
76
72
|
}, children));
|
|
77
73
|
};
|
|
78
74
|
|
|
79
|
-
InputPresentation.propTypes = {
|
|
80
|
-
children: _propTypes.default.node,
|
|
81
|
-
align: _propTypes.default.string,
|
|
82
|
-
disabled: _propTypes.default.bool,
|
|
83
|
-
inputWidth: _propTypes.default.number,
|
|
84
|
-
readOnly: _propTypes.default.bool,
|
|
85
|
-
positionedChildren: _propTypes.default.node,
|
|
86
|
-
size: _propTypes.default.oneOf(["small", "medium", "large"]),
|
|
87
|
-
error: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
|
|
88
|
-
warning: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
|
|
89
|
-
info: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string])
|
|
90
|
-
};
|
|
91
75
|
var _default = InputPresentation;
|
|
92
76
|
exports.default = _default;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { CommonInputPresentationProps } from "./input-presentation.component";
|
|
2
|
+
import { InputContextProps } from "../input-behaviour";
|
|
3
|
+
import { CarbonProviderProps } from "../../components/carbon-provider";
|
|
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" | "align" | "error" | "info" | "warning" | "readOnly" | "size"> & Pick<CarbonProviderProps, "validationRedesignOptIn">, never>;
|
|
2
6
|
export default InputPresentationStyle;
|
|
3
|
-
declare const InputPresentationStyle: import("styled-components").StyledComponent<"div", any, {
|
|
4
|
-
error: any;
|
|
5
|
-
warning: any;
|
|
6
|
-
info: any;
|
|
7
|
-
disabled: any;
|
|
8
|
-
validationRedesignOptIn: any;
|
|
9
|
-
}, never>;
|
|
@@ -7,8 +7,6 @@ exports.default = exports.StyledInputPresentationContainer = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _inputSizes = _interopRequireDefault(require("./input-sizes.style"));
|
|
13
11
|
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -25,6 +23,37 @@ const StyledInputPresentationContainer = _styledComponents.default.div`
|
|
|
25
23
|
position: relative;
|
|
26
24
|
`;
|
|
27
25
|
exports.StyledInputPresentationContainer = StyledInputPresentationContainer;
|
|
26
|
+
|
|
27
|
+
function stylingForValidations({
|
|
28
|
+
error,
|
|
29
|
+
warning,
|
|
30
|
+
info,
|
|
31
|
+
disabled,
|
|
32
|
+
validationRedesignOptIn
|
|
33
|
+
}) {
|
|
34
|
+
let validationColor;
|
|
35
|
+
|
|
36
|
+
if (disabled) {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (error) {
|
|
41
|
+
validationColor = "var(--colorsSemanticNegative500)";
|
|
42
|
+
} else if (warning) {
|
|
43
|
+
validationColor = validationRedesignOptIn ? "var(--colorsUtilityMajor300)" : "var(--colorsSemanticCaution500)";
|
|
44
|
+
} else if (info) {
|
|
45
|
+
validationColor = "var(--colorsSemanticInfo500)";
|
|
46
|
+
} else {
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (0, _styledComponents.css)`
|
|
51
|
+
border-color: ${validationColor} !important;
|
|
52
|
+
z-index: 1;
|
|
53
|
+
${error && `box-shadow: inset 1px 1px 0 ${validationColor}, inset -1px -1px 0 ${validationColor};`}
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
|
|
28
57
|
const InputPresentationStyle = _styledComponents.default.div`
|
|
29
58
|
align-items: stretch;
|
|
30
59
|
background: var(--colorsUtilityYang100);
|
|
@@ -35,15 +64,13 @@ const InputPresentationStyle = _styledComponents.default.div`
|
|
|
35
64
|
flex-wrap: wrap;
|
|
36
65
|
width: 100%;
|
|
37
66
|
margin: 0;
|
|
38
|
-
|
|
39
|
-
size
|
|
40
|
-
}) => _inputSizes.default[size].height};
|
|
41
|
-
padding-left: ${({
|
|
42
|
-
size
|
|
43
|
-
}) => _inputSizes.default[size].horizontalPadding};
|
|
44
|
-
padding-right: ${({
|
|
67
|
+
${({
|
|
45
68
|
size
|
|
46
|
-
}) =>
|
|
69
|
+
}) => size && (0, _styledComponents.css)`
|
|
70
|
+
min-height: ${_inputSizes.default[size].height};
|
|
71
|
+
padding-left: ${_inputSizes.default[size].horizontalPadding};
|
|
72
|
+
padding-right: ${_inputSizes.default[size].horizontalPadding};
|
|
73
|
+
`}
|
|
47
74
|
|
|
48
75
|
${({
|
|
49
76
|
disabled
|
|
@@ -82,49 +109,5 @@ const InputPresentationStyle = _styledComponents.default.div`
|
|
|
82
109
|
display: none !important;
|
|
83
110
|
}
|
|
84
111
|
`;
|
|
85
|
-
|
|
86
|
-
function stylingForValidations({
|
|
87
|
-
error,
|
|
88
|
-
warning,
|
|
89
|
-
info,
|
|
90
|
-
disabled,
|
|
91
|
-
validationRedesignOptIn
|
|
92
|
-
}) {
|
|
93
|
-
let validationColor;
|
|
94
|
-
|
|
95
|
-
if (disabled) {
|
|
96
|
-
return "";
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (error) {
|
|
100
|
-
validationColor = "var(--colorsSemanticNegative500)";
|
|
101
|
-
} else if (warning) {
|
|
102
|
-
validationColor = validationRedesignOptIn ? "var(--colorsUtilityMajor300)" : "var(--colorsSemanticCaution500)";
|
|
103
|
-
} else if (info) {
|
|
104
|
-
validationColor = "var(--colorsSemanticInfo500)";
|
|
105
|
-
} else {
|
|
106
|
-
return "";
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return (0, _styledComponents.css)`
|
|
110
|
-
border-color: ${validationColor} !important;
|
|
111
|
-
z-index: 1;
|
|
112
|
-
${error && `box-shadow: inset 1px 1px 0 ${validationColor}, inset -1px -1px 0 ${validationColor};`}
|
|
113
|
-
`;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
InputPresentationStyle.defaultProps = {
|
|
117
|
-
size: "medium"
|
|
118
|
-
};
|
|
119
|
-
InputPresentationStyle.propTypes = {
|
|
120
|
-
align: _propTypes.default.string,
|
|
121
|
-
disabled: _propTypes.default.bool,
|
|
122
|
-
hasFocus: _propTypes.default.bool,
|
|
123
|
-
readOnly: _propTypes.default.bool,
|
|
124
|
-
size: _propTypes.default.oneOf(["small", "medium", "large"]),
|
|
125
|
-
error: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
|
|
126
|
-
warning: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string]),
|
|
127
|
-
info: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string])
|
|
128
|
-
};
|
|
129
112
|
var _default = InputPresentationStyle;
|
|
130
113
|
exports.default = _default;
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const horizontalPadding: string;
|
|
5
|
-
}
|
|
6
|
-
namespace medium {
|
|
7
|
-
const height_1: string;
|
|
8
|
-
export { height_1 as height };
|
|
9
|
-
const horizontalPadding_1: string;
|
|
10
|
-
export { horizontalPadding_1 as horizontalPadding };
|
|
11
|
-
}
|
|
12
|
-
namespace large {
|
|
13
|
-
const height_2: string;
|
|
14
|
-
export { height_2 as height };
|
|
15
|
-
const horizontalPadding_2: string;
|
|
16
|
-
export { horizontalPadding_2 as horizontalPadding };
|
|
17
|
-
}
|
|
1
|
+
interface SizesProps {
|
|
2
|
+
height: string;
|
|
3
|
+
horizontalPadding: string;
|
|
18
4
|
}
|
|
19
|
-
|
|
5
|
+
interface InputSizesInterface {
|
|
6
|
+
[key: string]: SizesProps;
|
|
7
|
+
}
|
|
8
|
+
declare const InputSizes: InputSizesInterface;
|
|
9
|
+
export default InputSizes;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
7
|
+
const InputSizes = {
|
|
8
8
|
small: {
|
|
9
9
|
height: "var(--sizing400)",
|
|
10
10
|
horizontalPadding: "var(--spacing100)"
|
|
@@ -18,4 +18,5 @@ var _default = {
|
|
|
18
18
|
horizontalPadding: "var(--spacing200)"
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
+
var _default = InputSizes;
|
|
21
22
|
exports.default = _default;
|
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
export default Input;
|
|
2
|
-
declare const Input: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
3
1
|
import React from "react";
|
|
2
|
+
export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
|
|
3
|
+
align?: "right" | "left";
|
|
4
|
+
/** If true the Component will be focused when rendered */
|
|
5
|
+
autoFocus?: boolean;
|
|
6
|
+
/** If true, the component will be disabled */
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** HTML id attribute of the input */
|
|
9
|
+
id?: string;
|
|
10
|
+
/** A callback to retrieve the input reference */
|
|
11
|
+
inputRef?: (input: React.RefObject<HTMLInputElement>) => void;
|
|
12
|
+
/** Name of the input */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Specify a callback triggered on blur */
|
|
15
|
+
onBlur?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
16
|
+
/** Specify a callback triggered on change */
|
|
17
|
+
onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
+
/** pecify a callback triggered on click */
|
|
19
|
+
onClick?: (ev: React.MouseEvent<HTMLInputElement>) => void;
|
|
20
|
+
/** Specify a callback triggered on focus */
|
|
21
|
+
onFocus?: (ev: React.FocusEvent<HTMLInputElement>) => void;
|
|
22
|
+
/** Specify a callback triggered on keyDown */
|
|
23
|
+
onKeyDown?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
24
|
+
/** Placeholder string to be displayed in input */
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
/** If true, the component will be read-only */
|
|
27
|
+
readOnly?: boolean;
|
|
28
|
+
/** Flag to configure component as mandatory */
|
|
29
|
+
required?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface InputProps extends CommonInputProps {
|
|
32
|
+
/** Integer to determine a timeout for the defered callback */
|
|
33
|
+
deferTimeout?: number;
|
|
34
|
+
/** Defered callback to be called after the onChange event */
|
|
35
|
+
onChangeDeferred?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
|
|
36
|
+
/** HTML type attribute of the input */
|
|
37
|
+
type?: string;
|
|
38
|
+
}
|
|
39
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
40
|
+
export default Input;
|
|
@@ -7,9 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _input = _interopRequireDefault(require("./input.style"));
|
|
10
|
+
var _input2 = _interopRequireDefault(require("./input.style"));
|
|
13
11
|
|
|
14
12
|
var _inputBehaviour = require("../input-behaviour");
|
|
15
13
|
|
|
@@ -21,6 +19,28 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
21
19
|
|
|
22
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); }
|
|
23
21
|
|
|
22
|
+
function selectTextOnFocus(input) {
|
|
23
|
+
// setTimeout is required so the dom has a chance to place the cursor in the input
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
if (input !== null && input !== void 0 && input.current) {
|
|
26
|
+
const {
|
|
27
|
+
selectionStart,
|
|
28
|
+
selectionEnd,
|
|
29
|
+
value
|
|
30
|
+
} = input.current;
|
|
31
|
+
const {
|
|
32
|
+
length
|
|
33
|
+
} = value; // only select text if cursor is at the very end or the very start of the value
|
|
34
|
+
|
|
35
|
+
if (selectionStart === 0 && selectionEnd === 0 || selectionStart === length && selectionEnd === length) {
|
|
36
|
+
if (document.activeElement === input.current) {
|
|
37
|
+
input.current.setSelectionRange(0, length);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
24
44
|
const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
25
45
|
align,
|
|
26
46
|
placeholder,
|
|
@@ -43,59 +63,95 @@ const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
43
63
|
const groupContext = (0, _react.useContext)(_inputBehaviour.InputGroupContext);
|
|
44
64
|
const deferredTimeout = (0, _react.useRef)(null);
|
|
45
65
|
let input = (0, _react.useRef)(null);
|
|
46
|
-
|
|
66
|
+
|
|
67
|
+
if (ref) {
|
|
68
|
+
input = ref;
|
|
69
|
+
}
|
|
70
|
+
|
|
47
71
|
(0, _react.useEffect)(() => {
|
|
48
|
-
if (autoFocus && input.current)
|
|
72
|
+
if (autoFocus && input.current) {
|
|
73
|
+
input.current.focus();
|
|
74
|
+
}
|
|
49
75
|
}, [autoFocus, input]);
|
|
50
76
|
(0, _react.useEffect)(() => {
|
|
51
|
-
if (inputRef)
|
|
77
|
+
if (inputRef) {
|
|
78
|
+
inputRef(input);
|
|
79
|
+
}
|
|
52
80
|
}, [input, inputRef]);
|
|
53
81
|
(0, _react.useEffect)(() => {
|
|
54
|
-
if (context.inputRef)
|
|
82
|
+
if (context.inputRef) {
|
|
83
|
+
context.inputRef(input);
|
|
84
|
+
}
|
|
55
85
|
}, [context, input]);
|
|
56
86
|
(0, _react.useEffect)(() => {
|
|
57
|
-
if (disabled && context.onBlur)
|
|
87
|
+
if (disabled && context.onBlur) {
|
|
88
|
+
context.onBlur();
|
|
89
|
+
}
|
|
58
90
|
}, [disabled, context]);
|
|
59
91
|
|
|
60
92
|
const handleClick = ev => {
|
|
61
|
-
|
|
62
|
-
|
|
93
|
+
var _input, _input$current;
|
|
94
|
+
|
|
95
|
+
if (onClick) {
|
|
96
|
+
onClick(ev);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
(_input = input) === null || _input === void 0 ? void 0 : (_input$current = _input.current) === null || _input$current === void 0 ? void 0 : _input$current.focus();
|
|
63
100
|
};
|
|
64
101
|
|
|
65
102
|
const handleFocus = ev => {
|
|
66
|
-
if (onFocus)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
103
|
+
if (onFocus) {
|
|
104
|
+
onFocus(ev);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (context.onFocus) {
|
|
108
|
+
context.onFocus();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (groupContext.onFocus) {
|
|
112
|
+
groupContext.onFocus();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (type === "text") {
|
|
116
|
+
selectTextOnFocus(input);
|
|
117
|
+
}
|
|
70
118
|
};
|
|
71
119
|
|
|
72
120
|
const handleBlur = ev => {
|
|
73
|
-
if (onBlur)
|
|
74
|
-
|
|
75
|
-
|
|
121
|
+
if (onBlur) {
|
|
122
|
+
onBlur(ev);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (context.onBlur) {
|
|
126
|
+
context.onBlur();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (groupContext.onBlur) {
|
|
130
|
+
groupContext.onBlur();
|
|
131
|
+
}
|
|
76
132
|
};
|
|
77
133
|
|
|
78
|
-
const handleDeferred =
|
|
79
|
-
currentTarget,
|
|
80
|
-
target
|
|
81
|
-
}) => {
|
|
134
|
+
const handleDeferred = ev => {
|
|
82
135
|
if (onChangeDeferred) {
|
|
83
|
-
|
|
136
|
+
if (deferredTimeout.current) {
|
|
137
|
+
clearTimeout(deferredTimeout.current);
|
|
138
|
+
}
|
|
139
|
+
|
|
84
140
|
deferredTimeout.current = setTimeout(() => {
|
|
85
|
-
onChangeDeferred(
|
|
86
|
-
currentTarget,
|
|
87
|
-
target
|
|
88
|
-
});
|
|
141
|
+
onChangeDeferred(ev);
|
|
89
142
|
}, deferTimeout || 750);
|
|
90
143
|
}
|
|
91
144
|
};
|
|
92
145
|
|
|
93
146
|
const handleChange = ev => {
|
|
94
|
-
if (onChange)
|
|
147
|
+
if (onChange) {
|
|
148
|
+
onChange(ev);
|
|
149
|
+
}
|
|
150
|
+
|
|
95
151
|
handleDeferred(ev);
|
|
96
152
|
};
|
|
97
153
|
|
|
98
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
154
|
+
return /*#__PURE__*/_react.default.createElement(_input2.default, _extends({}, rest, {
|
|
99
155
|
"aria-labelledby": context.ariaLabelledBy,
|
|
100
156
|
align: align,
|
|
101
157
|
placeholder: placeholder,
|
|
@@ -113,46 +169,6 @@ const Input = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
113
169
|
}));
|
|
114
170
|
});
|
|
115
171
|
|
|
116
|
-
Input.
|
|
117
|
-
align: _propTypes.default.oneOf(["right", "left"]),
|
|
118
|
-
placeholder: _propTypes.default.string,
|
|
119
|
-
disabled: _propTypes.default.bool,
|
|
120
|
-
readOnly: _propTypes.default.bool,
|
|
121
|
-
className: _propTypes.default.string,
|
|
122
|
-
id: _propTypes.default.string,
|
|
123
|
-
|
|
124
|
-
/** A callback to retrieve the input reference */
|
|
125
|
-
inputRef: _propTypes.default.func,
|
|
126
|
-
name: _propTypes.default.string,
|
|
127
|
-
onBlur: _propTypes.default.func,
|
|
128
|
-
onClick: _propTypes.default.func,
|
|
129
|
-
onKeyDown: _propTypes.default.func,
|
|
130
|
-
onFocus: _propTypes.default.func,
|
|
131
|
-
autoFocus: _propTypes.default.bool,
|
|
132
|
-
onChange: _propTypes.default.func,
|
|
133
|
-
onChangeDeferred: _propTypes.default.func,
|
|
134
|
-
deferTimeout: _propTypes.default.number,
|
|
135
|
-
type: _propTypes.default.string
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
function selectTextOnFocus(input) {
|
|
139
|
-
// setTimeout is required so the dom has a chance to place the cursor in the input
|
|
140
|
-
setTimeout(() => {
|
|
141
|
-
if (input.current) {
|
|
142
|
-
const {
|
|
143
|
-
length
|
|
144
|
-
} = input.current.value;
|
|
145
|
-
const cursorStart = input.current.selectionStart;
|
|
146
|
-
const cursorEnd = input.current.selectionEnd; // only select text if cursor is at the very end or the very start of the value
|
|
147
|
-
|
|
148
|
-
if (cursorStart === 0 && cursorEnd === 0 || cursorStart === length && cursorEnd === length) {
|
|
149
|
-
if (document.activeElement === input.current) {
|
|
150
|
-
input.current.setSelectionRange(0, length);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
172
|
+
Input.displayName = "Input";
|
|
157
173
|
var _default = Input;
|
|
158
174
|
exports.default = _default;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { CommonInputProps } from "./input.component";
|
|
2
|
+
declare const StyledInput: import("styled-components").StyledComponent<"input", any, Pick<CommonInputProps, "disabled" | "align" | "readOnly">, never>;
|
|
1
3
|
export default StyledInput;
|
|
2
|
-
declare const StyledInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|