carbon-react 144.13.0 → 144.15.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/components/decimal/decimal.component.d.ts +1 -1
- package/esm/components/decimal/decimal.component.js +5 -0
- package/esm/components/grouped-character/grouped-character.component.js +10 -3
- package/esm/components/step-sequence/index.d.ts +4 -0
- package/esm/components/step-sequence/index.js +2 -0
- package/esm/components/step-sequence/step-sequence-item/index.d.ts +2 -0
- package/esm/components/step-sequence/step-sequence-item/index.js +1 -0
- package/esm/components/step-sequence/step-sequence-item/step-sequence-item.component.d.ts +19 -0
- package/esm/components/step-sequence/step-sequence-item/step-sequence-item.component.js +43 -0
- package/esm/components/step-sequence/step-sequence-item/step-sequence-item.style.d.ts +6 -0
- package/esm/components/step-sequence/step-sequence-item/step-sequence-item.style.js +96 -0
- package/esm/components/step-sequence/step-sequence.component.d.ts +13 -0
- package/esm/components/step-sequence/step-sequence.component.js +23 -0
- package/esm/components/step-sequence/step-sequence.style.d.ts +4 -0
- package/esm/components/step-sequence/step-sequence.style.js +21 -0
- package/lib/components/decimal/decimal.component.d.ts +1 -1
- package/lib/components/decimal/decimal.component.js +5 -0
- package/lib/components/grouped-character/grouped-character.component.js +10 -3
- package/lib/components/step-sequence/index.d.ts +4 -0
- package/lib/components/step-sequence/index.js +20 -0
- package/lib/components/step-sequence/package.json +6 -0
- package/lib/components/step-sequence/step-sequence-item/index.d.ts +2 -0
- package/lib/components/step-sequence/step-sequence-item/index.js +13 -0
- package/lib/components/step-sequence/step-sequence-item/package.json +6 -0
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.component.d.ts +19 -0
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.component.js +53 -0
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.style.d.ts +6 -0
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.style.js +105 -0
- package/lib/components/step-sequence/step-sequence.component.d.ts +13 -0
- package/lib/components/step-sequence/step-sequence.component.js +31 -0
- package/lib/components/step-sequence/step-sequence.style.d.ts +4 -0
- package/lib/components/step-sequence/step-sequence.style.js +29 -0
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ export interface DecimalProps extends Omit<CommonTextboxProps, "onChange" | "onB
|
|
|
25
25
|
onChange?: (ev: CustomEvent) => void;
|
|
26
26
|
/** Handler for blur event */
|
|
27
27
|
onBlur?: (ev: CustomEvent) => void;
|
|
28
|
-
/** Handler for key press event */
|
|
28
|
+
/** [Deprecated] Handler for key press event */
|
|
29
29
|
onKeyPress?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
30
30
|
/** The input name */
|
|
31
31
|
name?: string;
|
|
@@ -7,6 +7,7 @@ import LocaleContext from "../../__internal__/i18n-context";
|
|
|
7
7
|
import usePrevious from "../../hooks/__internal__/usePrevious";
|
|
8
8
|
import Logger from "../../__internal__/utils/logger";
|
|
9
9
|
let deprecateUncontrolledWarnTriggered = false;
|
|
10
|
+
let deprecateOnKeyPressWarnTriggered = false;
|
|
10
11
|
const Decimal = /*#__PURE__*/React.forwardRef(({
|
|
11
12
|
align = "right",
|
|
12
13
|
defaultValue,
|
|
@@ -166,6 +167,10 @@ const Decimal = /*#__PURE__*/React.forwardRef(({
|
|
|
166
167
|
deprecateUncontrolledWarnTriggered = true;
|
|
167
168
|
Logger.deprecate("Uncontrolled behaviour in `Decimal` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
|
|
168
169
|
}
|
|
170
|
+
if (!deprecateOnKeyPressWarnTriggered && onKeyPress) {
|
|
171
|
+
deprecateOnKeyPressWarnTriggered = true;
|
|
172
|
+
Logger.deprecate("`onKeyPress` prop in `Decimal` is deprecated and will soon be removed, please use `onKeyDown` instead.");
|
|
173
|
+
}
|
|
169
174
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Textbox, _extends({
|
|
170
175
|
onKeyPress: onKeyPress,
|
|
171
176
|
align: align,
|
|
@@ -27,6 +27,7 @@ const GroupedCharacter = /*#__PURE__*/React.forwardRef(({
|
|
|
27
27
|
groups,
|
|
28
28
|
onBlur,
|
|
29
29
|
onChange,
|
|
30
|
+
onKeyDown,
|
|
30
31
|
separator: rawSeparator,
|
|
31
32
|
value: externalValue,
|
|
32
33
|
...rest
|
|
@@ -90,7 +91,7 @@ const GroupedCharacter = /*#__PURE__*/React.forwardRef(({
|
|
|
90
91
|
onBlur(modifiedEvent);
|
|
91
92
|
}
|
|
92
93
|
};
|
|
93
|
-
const
|
|
94
|
+
const handleKeyDown = ev => {
|
|
94
95
|
const {
|
|
95
96
|
selectionStart,
|
|
96
97
|
selectionEnd
|
|
@@ -98,16 +99,22 @@ const GroupedCharacter = /*#__PURE__*/React.forwardRef(({
|
|
|
98
99
|
|
|
99
100
|
/* istanbul ignore next */
|
|
100
101
|
const hasSelection = (selectionEnd ?? 0) - (selectionStart ?? 0) > 0;
|
|
101
|
-
|
|
102
|
+
|
|
103
|
+
// check if the key pressed is a character key
|
|
104
|
+
const isCharacterKey = ev.key.length === 1;
|
|
105
|
+
if (isCharacterKey && maxRawLength === value.length && !hasSelection) {
|
|
102
106
|
ev.preventDefault();
|
|
103
107
|
}
|
|
108
|
+
if (onKeyDown) {
|
|
109
|
+
onKeyDown(ev);
|
|
110
|
+
}
|
|
104
111
|
};
|
|
105
112
|
return /*#__PURE__*/React.createElement(Textbox, _extends({}, rest, {
|
|
106
113
|
value: value,
|
|
107
114
|
formattedValue: formatValue(value),
|
|
108
115
|
onChange: handleChange,
|
|
109
116
|
onBlur: handleBlur,
|
|
110
|
-
|
|
117
|
+
onKeyDown: handleKeyDown,
|
|
111
118
|
ref: ref
|
|
112
119
|
}));
|
|
113
120
|
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as StepSequence } from "./step-sequence.component";
|
|
2
|
+
export type { StepSequenceProps } from "./step-sequence.component";
|
|
3
|
+
export { default as StepSequenceItem } from "./step-sequence-item";
|
|
4
|
+
export type { StepSequenceItemProps } from "./step-sequence-item";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./step-sequence-item.component";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface StepSequenceItemProps {
|
|
3
|
+
/** Aria label */
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
/** Hidden label to be displayed if item is complete */
|
|
6
|
+
hiddenCompleteLabel?: string;
|
|
7
|
+
/** Hidden label to be displayed if item is current */
|
|
8
|
+
hiddenCurrentLabel?: string;
|
|
9
|
+
/** Value to be displayed before text for incomplete steps */
|
|
10
|
+
indicator: string;
|
|
11
|
+
/** Flag to hide the indicator for incomplete steps */
|
|
12
|
+
hideIndicator?: boolean;
|
|
13
|
+
/** Status for the step */
|
|
14
|
+
status?: "complete" | "current" | "incomplete";
|
|
15
|
+
/** Content to be displayed */
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare const StepSequenceItem: ({ hideIndicator, indicator, status, hiddenCompleteLabel, hiddenCurrentLabel, children, ariaLabel, ...rest }: StepSequenceItemProps) => React.JSX.Element;
|
|
19
|
+
export default StepSequenceItem;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { StyledStepSequenceItem, StyledStepSequenceItemContent, StyledStepSequenceItemIndicator, StyledStepSequenceItemHiddenLabel } from "./step-sequence-item.style";
|
|
5
|
+
import Icon from "../../icon";
|
|
6
|
+
import { StepSequenceContext } from "../step-sequence.component";
|
|
7
|
+
export const StepSequenceItem = ({
|
|
8
|
+
hideIndicator = false,
|
|
9
|
+
indicator,
|
|
10
|
+
status = "incomplete",
|
|
11
|
+
hiddenCompleteLabel,
|
|
12
|
+
hiddenCurrentLabel,
|
|
13
|
+
children,
|
|
14
|
+
ariaLabel,
|
|
15
|
+
...rest
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
orientation
|
|
19
|
+
} = useContext(StepSequenceContext);
|
|
20
|
+
const indicatorText = () => {
|
|
21
|
+
return !hideIndicator ? /*#__PURE__*/React.createElement(StyledStepSequenceItemIndicator, null, indicator) : null;
|
|
22
|
+
};
|
|
23
|
+
const icon = () => status === "complete" ? /*#__PURE__*/React.createElement(Icon, {
|
|
24
|
+
type: "tick"
|
|
25
|
+
}) : indicatorText();
|
|
26
|
+
const hiddenLabel = () => {
|
|
27
|
+
if (hiddenCompleteLabel && status === "complete") {
|
|
28
|
+
return /*#__PURE__*/React.createElement(StyledStepSequenceItemHiddenLabel, null, hiddenCompleteLabel);
|
|
29
|
+
}
|
|
30
|
+
if (hiddenCurrentLabel && status === "current") {
|
|
31
|
+
return /*#__PURE__*/React.createElement(StyledStepSequenceItemHiddenLabel, null, hiddenCurrentLabel);
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
return /*#__PURE__*/React.createElement(StyledStepSequenceItem, _extends({
|
|
36
|
+
"data-component": "step-sequence-item",
|
|
37
|
+
orientation: orientation,
|
|
38
|
+
status: status,
|
|
39
|
+
key: `step-seq-item-${indicator}`,
|
|
40
|
+
"aria-label": ariaLabel
|
|
41
|
+
}, rest), hiddenLabel(), /*#__PURE__*/React.createElement(StyledStepSequenceItemContent, null, icon(), /*#__PURE__*/React.createElement("span", null, children)));
|
|
42
|
+
};
|
|
43
|
+
export default StepSequenceItem;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StepSequenceProps } from "../step-sequence.component";
|
|
2
|
+
import { StepSequenceItemProps } from "./step-sequence-item.component";
|
|
3
|
+
export declare const StyledStepSequenceItem: import("styled-components").StyledComponent<"li", any, Pick<StepSequenceItemProps, "status"> & Pick<StepSequenceProps, "orientation">, never>;
|
|
4
|
+
export declare const StyledStepSequenceItemContent: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
5
|
+
export declare const StyledStepSequenceItemHiddenLabel: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
6
|
+
export declare const StyledStepSequenceItemIndicator: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import StyledIcon from "../../icon/icon.style";
|
|
3
|
+
export const StyledStepSequenceItem = styled.li`
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
flex-grow: 1;
|
|
7
|
+
text-align: right;
|
|
8
|
+
list-style-type: none;
|
|
9
|
+
color: var(--colorsUtilityYin055);
|
|
10
|
+
|
|
11
|
+
${({
|
|
12
|
+
orientation,
|
|
13
|
+
status
|
|
14
|
+
}) => {
|
|
15
|
+
const side = orientation === "vertical" ? "left" : "top";
|
|
16
|
+
return css`
|
|
17
|
+
&::before {
|
|
18
|
+
content: "";
|
|
19
|
+
flex-grow: 1;
|
|
20
|
+
display: block;
|
|
21
|
+
margin: 0 16px;
|
|
22
|
+
border-${side}: var(--sizing025) dashed var(--colorsUtilityYin055);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
& span {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
${StyledIcon} {
|
|
32
|
+
margin-right: 8px;
|
|
33
|
+
color: var(--colorsBaseTheme, var(--colorsSemanticPositive500));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:first-child {
|
|
37
|
+
flex-grow: 0;
|
|
38
|
+
|
|
39
|
+
&::before {
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
${status === "current" && css`
|
|
45
|
+
color: var(--colorsUtilityYin090);
|
|
46
|
+
|
|
47
|
+
&::before {
|
|
48
|
+
border-${side}-color: var(--colorsUtilityYin090);
|
|
49
|
+
border-${side}-style: solid;
|
|
50
|
+
}
|
|
51
|
+
`}
|
|
52
|
+
|
|
53
|
+
${status === "complete" && css`
|
|
54
|
+
color: var(--colorsBaseTheme, var(--colorsSemanticPositive500));
|
|
55
|
+
|
|
56
|
+
&::before {
|
|
57
|
+
border-${side}-color: var(
|
|
58
|
+
--colorsBaseTheme,
|
|
59
|
+
var(--colorsSemanticPositive500)
|
|
60
|
+
);
|
|
61
|
+
border-${side}-style: solid;
|
|
62
|
+
}
|
|
63
|
+
`}
|
|
64
|
+
|
|
65
|
+
${orientation === "vertical" && css`
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
align-items: flex-start;
|
|
68
|
+
|
|
69
|
+
&::before {
|
|
70
|
+
flex-grow: 0;
|
|
71
|
+
border-left-width: var(--sizing025);
|
|
72
|
+
height: 100%;
|
|
73
|
+
min-height: var(--sizing300);
|
|
74
|
+
margin: 12px 8px;
|
|
75
|
+
}
|
|
76
|
+
`}
|
|
77
|
+
`;
|
|
78
|
+
}}
|
|
79
|
+
`;
|
|
80
|
+
export const StyledStepSequenceItemContent = styled.span`
|
|
81
|
+
display: flex;
|
|
82
|
+
`;
|
|
83
|
+
export const StyledStepSequenceItemHiddenLabel = styled.span`
|
|
84
|
+
position: absolute !important;
|
|
85
|
+
height: 1px;
|
|
86
|
+
width: 1px;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
89
|
+
`;
|
|
90
|
+
export const StyledStepSequenceItemIndicator = styled.span`
|
|
91
|
+
display: block;
|
|
92
|
+
min-width: 16px;
|
|
93
|
+
height: 16px;
|
|
94
|
+
margin-right: 8px;
|
|
95
|
+
text-align: center;
|
|
96
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SpaceProps } from "styled-system";
|
|
3
|
+
export declare const StepSequenceContext: React.Context<{
|
|
4
|
+
orientation: "horizontal" | "vertical";
|
|
5
|
+
}>;
|
|
6
|
+
export interface StepSequenceProps extends SpaceProps {
|
|
7
|
+
/** Step sequence items to be rendered */
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
/** The direction that step sequence items should be rendered */
|
|
10
|
+
orientation?: "horizontal" | "vertical";
|
|
11
|
+
}
|
|
12
|
+
export declare const StepSequence: ({ children, orientation, ...props }: StepSequenceProps) => React.JSX.Element;
|
|
13
|
+
export default StepSequence;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import StyledStepSequence from "./step-sequence.style";
|
|
5
|
+
export const StepSequenceContext = /*#__PURE__*/React.createContext({
|
|
6
|
+
orientation: "horizontal"
|
|
7
|
+
});
|
|
8
|
+
export const StepSequence = ({
|
|
9
|
+
children,
|
|
10
|
+
orientation = "horizontal",
|
|
11
|
+
...props
|
|
12
|
+
}) => {
|
|
13
|
+
return /*#__PURE__*/React.createElement(StyledStepSequence, _extends({
|
|
14
|
+
"data-component": "step-sequence",
|
|
15
|
+
orientation: orientation,
|
|
16
|
+
p: 0
|
|
17
|
+
}, props), /*#__PURE__*/React.createElement(StepSequenceContext.Provider, {
|
|
18
|
+
value: {
|
|
19
|
+
orientation
|
|
20
|
+
}
|
|
21
|
+
}, children));
|
|
22
|
+
};
|
|
23
|
+
export default StepSequence;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SpaceProps } from "styled-system";
|
|
2
|
+
import { StepSequenceProps } from "./step-sequence.component";
|
|
3
|
+
declare const StyledStepSequence: import("styled-components").StyledComponent<"ol", any, Pick<StepSequenceProps, "orientation"> & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
4
|
+
export default StyledStepSequence;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { space } from "styled-system";
|
|
3
|
+
import { baseTheme } from "../../style/themes";
|
|
4
|
+
const StyledStepSequence = styled.ol`
|
|
5
|
+
display: flex;
|
|
6
|
+
margin: 0;
|
|
7
|
+
font-weight: var(--fontWeights500);
|
|
8
|
+
|
|
9
|
+
${({
|
|
10
|
+
orientation
|
|
11
|
+
}) => orientation === "vertical" && css`
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
height: 100%;
|
|
14
|
+
`}
|
|
15
|
+
|
|
16
|
+
${space}
|
|
17
|
+
`;
|
|
18
|
+
StyledStepSequence.defaultProps = {
|
|
19
|
+
theme: baseTheme
|
|
20
|
+
};
|
|
21
|
+
export default StyledStepSequence;
|
|
@@ -25,7 +25,7 @@ export interface DecimalProps extends Omit<CommonTextboxProps, "onChange" | "onB
|
|
|
25
25
|
onChange?: (ev: CustomEvent) => void;
|
|
26
26
|
/** Handler for blur event */
|
|
27
27
|
onBlur?: (ev: CustomEvent) => void;
|
|
28
|
-
/** Handler for key press event */
|
|
28
|
+
/** [Deprecated] Handler for key press event */
|
|
29
29
|
onKeyPress?: (ev: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
30
30
|
/** The input name */
|
|
31
31
|
name?: string;
|
|
@@ -16,6 +16,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
16
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
17
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
18
18
|
let deprecateUncontrolledWarnTriggered = false;
|
|
19
|
+
let deprecateOnKeyPressWarnTriggered = false;
|
|
19
20
|
const Decimal = exports.Decimal = /*#__PURE__*/_react.default.forwardRef(({
|
|
20
21
|
align = "right",
|
|
21
22
|
defaultValue,
|
|
@@ -175,6 +176,10 @@ const Decimal = exports.Decimal = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
175
176
|
deprecateUncontrolledWarnTriggered = true;
|
|
176
177
|
_logger.default.deprecate("Uncontrolled behaviour in `Decimal` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
|
|
177
178
|
}
|
|
179
|
+
if (!deprecateOnKeyPressWarnTriggered && onKeyPress) {
|
|
180
|
+
deprecateOnKeyPressWarnTriggered = true;
|
|
181
|
+
_logger.default.deprecate("`onKeyPress` prop in `Decimal` is deprecated and will soon be removed, please use `onKeyDown` instead.");
|
|
182
|
+
}
|
|
178
183
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({
|
|
179
184
|
onKeyPress: onKeyPress,
|
|
180
185
|
align: align,
|
|
@@ -36,6 +36,7 @@ const GroupedCharacter = exports.GroupedCharacter = /*#__PURE__*/_react.default.
|
|
|
36
36
|
groups,
|
|
37
37
|
onBlur,
|
|
38
38
|
onChange,
|
|
39
|
+
onKeyDown,
|
|
39
40
|
separator: rawSeparator,
|
|
40
41
|
value: externalValue,
|
|
41
42
|
...rest
|
|
@@ -99,7 +100,7 @@ const GroupedCharacter = exports.GroupedCharacter = /*#__PURE__*/_react.default.
|
|
|
99
100
|
onBlur(modifiedEvent);
|
|
100
101
|
}
|
|
101
102
|
};
|
|
102
|
-
const
|
|
103
|
+
const handleKeyDown = ev => {
|
|
103
104
|
const {
|
|
104
105
|
selectionStart,
|
|
105
106
|
selectionEnd
|
|
@@ -107,16 +108,22 @@ const GroupedCharacter = exports.GroupedCharacter = /*#__PURE__*/_react.default.
|
|
|
107
108
|
|
|
108
109
|
/* istanbul ignore next */
|
|
109
110
|
const hasSelection = (selectionEnd ?? 0) - (selectionStart ?? 0) > 0;
|
|
110
|
-
|
|
111
|
+
|
|
112
|
+
// check if the key pressed is a character key
|
|
113
|
+
const isCharacterKey = ev.key.length === 1;
|
|
114
|
+
if (isCharacterKey && maxRawLength === value.length && !hasSelection) {
|
|
111
115
|
ev.preventDefault();
|
|
112
116
|
}
|
|
117
|
+
if (onKeyDown) {
|
|
118
|
+
onKeyDown(ev);
|
|
119
|
+
}
|
|
113
120
|
};
|
|
114
121
|
return /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({}, rest, {
|
|
115
122
|
value: value,
|
|
116
123
|
formattedValue: formatValue(value),
|
|
117
124
|
onChange: handleChange,
|
|
118
125
|
onBlur: handleBlur,
|
|
119
|
-
|
|
126
|
+
onKeyDown: handleKeyDown,
|
|
120
127
|
ref: ref
|
|
121
128
|
}));
|
|
122
129
|
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as StepSequence } from "./step-sequence.component";
|
|
2
|
+
export type { StepSequenceProps } from "./step-sequence.component";
|
|
3
|
+
export { default as StepSequenceItem } from "./step-sequence-item";
|
|
4
|
+
export type { StepSequenceItemProps } from "./step-sequence-item";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "StepSequence", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _stepSequence.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "StepSequenceItem", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _stepSequenceItem.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _stepSequence = _interopRequireDefault(require("./step-sequence.component"));
|
|
19
|
+
var _stepSequenceItem = _interopRequireDefault(require("./step-sequence-item"));
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _stepSequenceItem.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _stepSequenceItem = _interopRequireDefault(require("./step-sequence-item.component"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface StepSequenceItemProps {
|
|
3
|
+
/** Aria label */
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
/** Hidden label to be displayed if item is complete */
|
|
6
|
+
hiddenCompleteLabel?: string;
|
|
7
|
+
/** Hidden label to be displayed if item is current */
|
|
8
|
+
hiddenCurrentLabel?: string;
|
|
9
|
+
/** Value to be displayed before text for incomplete steps */
|
|
10
|
+
indicator: string;
|
|
11
|
+
/** Flag to hide the indicator for incomplete steps */
|
|
12
|
+
hideIndicator?: boolean;
|
|
13
|
+
/** Status for the step */
|
|
14
|
+
status?: "complete" | "current" | "incomplete";
|
|
15
|
+
/** Content to be displayed */
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export declare const StepSequenceItem: ({ hideIndicator, indicator, status, hiddenCompleteLabel, hiddenCurrentLabel, children, ariaLabel, ...rest }: StepSequenceItemProps) => React.JSX.Element;
|
|
19
|
+
export default StepSequenceItem;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.StepSequenceItem = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _stepSequenceItem = require("./step-sequence-item.style");
|
|
10
|
+
var _icon = _interopRequireDefault(require("../../icon"));
|
|
11
|
+
var _stepSequence = require("../step-sequence.component");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
16
|
+
const StepSequenceItem = ({
|
|
17
|
+
hideIndicator = false,
|
|
18
|
+
indicator,
|
|
19
|
+
status = "incomplete",
|
|
20
|
+
hiddenCompleteLabel,
|
|
21
|
+
hiddenCurrentLabel,
|
|
22
|
+
children,
|
|
23
|
+
ariaLabel,
|
|
24
|
+
...rest
|
|
25
|
+
}) => {
|
|
26
|
+
const {
|
|
27
|
+
orientation
|
|
28
|
+
} = (0, _react.useContext)(_stepSequence.StepSequenceContext);
|
|
29
|
+
const indicatorText = () => {
|
|
30
|
+
return !hideIndicator ? /*#__PURE__*/_react.default.createElement(_stepSequenceItem.StyledStepSequenceItemIndicator, null, indicator) : null;
|
|
31
|
+
};
|
|
32
|
+
const icon = () => status === "complete" ? /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
33
|
+
type: "tick"
|
|
34
|
+
}) : indicatorText();
|
|
35
|
+
const hiddenLabel = () => {
|
|
36
|
+
if (hiddenCompleteLabel && status === "complete") {
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement(_stepSequenceItem.StyledStepSequenceItemHiddenLabel, null, hiddenCompleteLabel);
|
|
38
|
+
}
|
|
39
|
+
if (hiddenCurrentLabel && status === "current") {
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(_stepSequenceItem.StyledStepSequenceItemHiddenLabel, null, hiddenCurrentLabel);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/_react.default.createElement(_stepSequenceItem.StyledStepSequenceItem, _extends({
|
|
45
|
+
"data-component": "step-sequence-item",
|
|
46
|
+
orientation: orientation,
|
|
47
|
+
status: status,
|
|
48
|
+
key: `step-seq-item-${indicator}`,
|
|
49
|
+
"aria-label": ariaLabel
|
|
50
|
+
}, rest), hiddenLabel(), /*#__PURE__*/_react.default.createElement(_stepSequenceItem.StyledStepSequenceItemContent, null, icon(), /*#__PURE__*/_react.default.createElement("span", null, children)));
|
|
51
|
+
};
|
|
52
|
+
exports.StepSequenceItem = StepSequenceItem;
|
|
53
|
+
var _default = exports.default = StepSequenceItem;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StepSequenceProps } from "../step-sequence.component";
|
|
2
|
+
import { StepSequenceItemProps } from "./step-sequence-item.component";
|
|
3
|
+
export declare const StyledStepSequenceItem: import("styled-components").StyledComponent<"li", any, Pick<StepSequenceItemProps, "status"> & Pick<StepSequenceProps, "orientation">, never>;
|
|
4
|
+
export declare const StyledStepSequenceItemContent: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
5
|
+
export declare const StyledStepSequenceItemHiddenLabel: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
6
|
+
export declare const StyledStepSequenceItemIndicator: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledStepSequenceItemIndicator = exports.StyledStepSequenceItemHiddenLabel = exports.StyledStepSequenceItemContent = exports.StyledStepSequenceItem = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
+
var _icon = _interopRequireDefault(require("../../icon/icon.style"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
const StyledStepSequenceItem = exports.StyledStepSequenceItem = _styledComponents.default.li`
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
flex-grow: 1;
|
|
16
|
+
text-align: right;
|
|
17
|
+
list-style-type: none;
|
|
18
|
+
color: var(--colorsUtilityYin055);
|
|
19
|
+
|
|
20
|
+
${({
|
|
21
|
+
orientation,
|
|
22
|
+
status
|
|
23
|
+
}) => {
|
|
24
|
+
const side = orientation === "vertical" ? "left" : "top";
|
|
25
|
+
return (0, _styledComponents.css)`
|
|
26
|
+
&::before {
|
|
27
|
+
content: "";
|
|
28
|
+
flex-grow: 1;
|
|
29
|
+
display: block;
|
|
30
|
+
margin: 0 16px;
|
|
31
|
+
border-${side}: var(--sizing025) dashed var(--colorsUtilityYin055);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
& span {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
${_icon.default} {
|
|
41
|
+
margin-right: 8px;
|
|
42
|
+
color: var(--colorsBaseTheme, var(--colorsSemanticPositive500));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:first-child {
|
|
46
|
+
flex-grow: 0;
|
|
47
|
+
|
|
48
|
+
&::before {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
${status === "current" && (0, _styledComponents.css)`
|
|
54
|
+
color: var(--colorsUtilityYin090);
|
|
55
|
+
|
|
56
|
+
&::before {
|
|
57
|
+
border-${side}-color: var(--colorsUtilityYin090);
|
|
58
|
+
border-${side}-style: solid;
|
|
59
|
+
}
|
|
60
|
+
`}
|
|
61
|
+
|
|
62
|
+
${status === "complete" && (0, _styledComponents.css)`
|
|
63
|
+
color: var(--colorsBaseTheme, var(--colorsSemanticPositive500));
|
|
64
|
+
|
|
65
|
+
&::before {
|
|
66
|
+
border-${side}-color: var(
|
|
67
|
+
--colorsBaseTheme,
|
|
68
|
+
var(--colorsSemanticPositive500)
|
|
69
|
+
);
|
|
70
|
+
border-${side}-style: solid;
|
|
71
|
+
}
|
|
72
|
+
`}
|
|
73
|
+
|
|
74
|
+
${orientation === "vertical" && (0, _styledComponents.css)`
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
align-items: flex-start;
|
|
77
|
+
|
|
78
|
+
&::before {
|
|
79
|
+
flex-grow: 0;
|
|
80
|
+
border-left-width: var(--sizing025);
|
|
81
|
+
height: 100%;
|
|
82
|
+
min-height: var(--sizing300);
|
|
83
|
+
margin: 12px 8px;
|
|
84
|
+
}
|
|
85
|
+
`}
|
|
86
|
+
`;
|
|
87
|
+
}}
|
|
88
|
+
`;
|
|
89
|
+
const StyledStepSequenceItemContent = exports.StyledStepSequenceItemContent = _styledComponents.default.span`
|
|
90
|
+
display: flex;
|
|
91
|
+
`;
|
|
92
|
+
const StyledStepSequenceItemHiddenLabel = exports.StyledStepSequenceItemHiddenLabel = _styledComponents.default.span`
|
|
93
|
+
position: absolute !important;
|
|
94
|
+
height: 1px;
|
|
95
|
+
width: 1px;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
98
|
+
`;
|
|
99
|
+
const StyledStepSequenceItemIndicator = exports.StyledStepSequenceItemIndicator = _styledComponents.default.span`
|
|
100
|
+
display: block;
|
|
101
|
+
min-width: 16px;
|
|
102
|
+
height: 16px;
|
|
103
|
+
margin-right: 8px;
|
|
104
|
+
text-align: center;
|
|
105
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SpaceProps } from "styled-system";
|
|
3
|
+
export declare const StepSequenceContext: React.Context<{
|
|
4
|
+
orientation: "horizontal" | "vertical";
|
|
5
|
+
}>;
|
|
6
|
+
export interface StepSequenceProps extends SpaceProps {
|
|
7
|
+
/** Step sequence items to be rendered */
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
/** The direction that step sequence items should be rendered */
|
|
10
|
+
orientation?: "horizontal" | "vertical";
|
|
11
|
+
}
|
|
12
|
+
export declare const StepSequence: ({ children, orientation, ...props }: StepSequenceProps) => React.JSX.Element;
|
|
13
|
+
export default StepSequence;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.StepSequenceContext = exports.StepSequence = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _stepSequence = _interopRequireDefault(require("./step-sequence.style"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
12
|
+
const StepSequenceContext = exports.StepSequenceContext = /*#__PURE__*/_react.default.createContext({
|
|
13
|
+
orientation: "horizontal"
|
|
14
|
+
});
|
|
15
|
+
const StepSequence = ({
|
|
16
|
+
children,
|
|
17
|
+
orientation = "horizontal",
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_stepSequence.default, _extends({
|
|
21
|
+
"data-component": "step-sequence",
|
|
22
|
+
orientation: orientation,
|
|
23
|
+
p: 0
|
|
24
|
+
}, props), /*#__PURE__*/_react.default.createElement(StepSequenceContext.Provider, {
|
|
25
|
+
value: {
|
|
26
|
+
orientation
|
|
27
|
+
}
|
|
28
|
+
}, children));
|
|
29
|
+
};
|
|
30
|
+
exports.StepSequence = StepSequence;
|
|
31
|
+
var _default = exports.default = StepSequence;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SpaceProps } from "styled-system";
|
|
2
|
+
import { StepSequenceProps } from "./step-sequence.component";
|
|
3
|
+
declare const StyledStepSequence: import("styled-components").StyledComponent<"ol", any, Pick<StepSequenceProps, "orientation"> & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
|
|
4
|
+
export default StyledStepSequence;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
+
var _styledSystem = require("styled-system");
|
|
9
|
+
var _themes = require("../../style/themes");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
const StyledStepSequence = _styledComponents.default.ol`
|
|
13
|
+
display: flex;
|
|
14
|
+
margin: 0;
|
|
15
|
+
font-weight: var(--fontWeights500);
|
|
16
|
+
|
|
17
|
+
${({
|
|
18
|
+
orientation
|
|
19
|
+
}) => orientation === "vertical" && (0, _styledComponents.css)`
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
height: 100%;
|
|
22
|
+
`}
|
|
23
|
+
|
|
24
|
+
${_styledSystem.space}
|
|
25
|
+
`;
|
|
26
|
+
StyledStepSequence.defaultProps = {
|
|
27
|
+
theme: _themes.baseTheme
|
|
28
|
+
};
|
|
29
|
+
var _default = exports.default = StyledStepSequence;
|