carbon-react 121.1.0 → 122.0.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/button/button.component.d.ts +2 -1
- package/esm/components/button/button.component.js +6 -0
- package/esm/components/heading/heading.style.d.ts +1 -1
- package/esm/components/pod/pod.component.d.ts +1 -1
- package/esm/components/pod/pod.component.js +4 -19
- package/esm/components/pod/pod.style.d.ts +1 -1
- package/esm/components/pod/pod.style.js +1 -1
- package/esm/components/typography/typography.component.d.ts +4 -2
- package/esm/components/typography/typography.component.js +3 -1
- package/esm/components/typography/typography.style.js +5 -0
- package/lib/components/button/button.component.d.ts +2 -1
- package/lib/components/button/button.component.js +6 -0
- package/lib/components/heading/heading.style.d.ts +1 -1
- package/lib/components/pod/pod.component.d.ts +1 -1
- package/lib/components/pod/pod.component.js +4 -19
- package/lib/components/pod/pod.style.d.ts +1 -1
- package/lib/components/pod/pod.style.js +1 -1
- package/lib/components/typography/typography.component.d.ts +4 -2
- package/lib/components/typography/typography.component.js +3 -1
- package/lib/components/typography/typography.style.js +5 -0
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
3
|
import { IconType } from "../icon";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
4
5
|
import { TooltipPositions } from "../tooltip/tooltip.config";
|
|
5
6
|
export declare type ButtonTypes = "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground";
|
|
6
7
|
export declare type SizeOptions = "small" | "medium" | "large";
|
|
7
8
|
export declare type ButtonIconPosition = "before" | "after";
|
|
8
|
-
export interface ButtonProps extends SpaceProps {
|
|
9
|
+
export interface ButtonProps extends SpaceProps, TagProps {
|
|
9
10
|
/**
|
|
10
11
|
* Prop to specify the aria-label attribute of the component
|
|
11
12
|
* Defaults to the iconType, when the component has only an icon
|
|
@@ -176,6 +176,9 @@ Button.propTypes = {
|
|
|
176
176
|
"aria-label": PropTypes.string,
|
|
177
177
|
"buttonType": PropTypes.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
178
178
|
"children": PropTypes.node,
|
|
179
|
+
"data-component": PropTypes.string,
|
|
180
|
+
"data-element": PropTypes.string,
|
|
181
|
+
"data-role": PropTypes.string,
|
|
179
182
|
"destructive": PropTypes.bool,
|
|
180
183
|
"disabled": PropTypes.bool,
|
|
181
184
|
"forwardRef": PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
@@ -523,6 +526,9 @@ ButtonWithForwardRef.propTypes = {
|
|
|
523
526
|
"aria-label": PropTypes.string,
|
|
524
527
|
"buttonType": PropTypes.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
525
528
|
"children": PropTypes.node,
|
|
529
|
+
"data-component": PropTypes.string,
|
|
530
|
+
"data-element": PropTypes.string,
|
|
531
|
+
"data-role": PropTypes.string,
|
|
526
532
|
"destructive": PropTypes.bool,
|
|
527
533
|
"disabled": PropTypes.bool,
|
|
528
534
|
"forwardRef": PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
@@ -12,7 +12,7 @@ declare type StyledHeadingTitleProps = {
|
|
|
12
12
|
withMargin?: boolean;
|
|
13
13
|
};
|
|
14
14
|
declare const StyledHeadingTitle: import("styled-components").StyledComponent<{
|
|
15
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
15
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
}, any, StyledHeadingTitleProps, never>;
|
|
18
18
|
declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -25,7 +25,7 @@ export interface PodProps extends MarginProps {
|
|
|
25
25
|
/** A component to render as a Pod footer */
|
|
26
26
|
footer?: string | React.ReactNode;
|
|
27
27
|
/** Supplies an edit action to the pod */
|
|
28
|
-
onEdit?:
|
|
28
|
+
onEdit?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
|
29
29
|
/** Supplies a delete action to the pod */
|
|
30
30
|
onDelete?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
|
31
31
|
/** Supplies an undo action to the pod in soft delete state. */
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import React, { useState, useMemo } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
import Logger from "../../__internal__/utils/logger";
|
|
5
4
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
6
5
|
import { StyledBlock, StyledContent, StyledEditAction, StyledActionsContainer, StyledDeleteButton, StyledUndoButton, StyledFooter, StyledPod, StyledHeader, StyledSubtitle, StyledTitle } from "./pod.style";
|
|
7
6
|
import Icon from "../icon";
|
|
8
7
|
import Event from "../../__internal__/utils/helpers/events";
|
|
9
|
-
let deprecationOnEditStringWarnTriggered = false;
|
|
10
|
-
let deprecationOnEditObjectWarnTriggered = false;
|
|
11
8
|
const Pod = /*#__PURE__*/React.forwardRef(({
|
|
12
9
|
"data-element": dataElement,
|
|
13
10
|
"data-role": dataRole,
|
|
@@ -31,14 +28,6 @@ const Pod = /*#__PURE__*/React.forwardRef(({
|
|
|
31
28
|
variant = "primary",
|
|
32
29
|
...rest
|
|
33
30
|
}, ref) => {
|
|
34
|
-
if (!deprecationOnEditStringWarnTriggered && typeof onEdit === "string") {
|
|
35
|
-
deprecationOnEditStringWarnTriggered = true;
|
|
36
|
-
Logger.deprecate("Support for passing strings to the `onEdit` prop of the `Pod` component is now deprecated. Please only pass event handlers to `onEdit`.");
|
|
37
|
-
}
|
|
38
|
-
if (!deprecationOnEditObjectWarnTriggered && typeof onEdit === "object") {
|
|
39
|
-
deprecationOnEditObjectWarnTriggered = true;
|
|
40
|
-
Logger.deprecate("Support for passing objects to the `onEdit` prop of the `Pod` component is now deprecated. Please only pass event handlers to `onEdit`.");
|
|
41
|
-
}
|
|
42
31
|
const [isEditFocused, setEditFocused] = useState(false);
|
|
43
32
|
const [isEditHovered, setEditHovered] = useState(false);
|
|
44
33
|
const [isDeleteFocused, setDeleteFocused] = useState(false);
|
|
@@ -58,10 +47,8 @@ const Pod = /*#__PURE__*/React.forwardRef(({
|
|
|
58
47
|
onMouseLeave: () => setEditHovered(false),
|
|
59
48
|
onFocus: () => setEditFocused(true),
|
|
60
49
|
onBlur: () => setEditFocused(false),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
onKeyDown: processPodAction(onEdit)
|
|
64
|
-
})
|
|
50
|
+
onClick: onEdit && processPodAction(onEdit),
|
|
51
|
+
onKeyDown: onEdit && processPodAction(onEdit)
|
|
65
52
|
};
|
|
66
53
|
return /*#__PURE__*/React.createElement(StyledPod, _extends({
|
|
67
54
|
alignTitle: alignTitle,
|
|
@@ -131,9 +118,7 @@ const Pod = /*#__PURE__*/React.forwardRef(({
|
|
|
131
118
|
noBorder: !border,
|
|
132
119
|
size: size,
|
|
133
120
|
variant: variant
|
|
134
|
-
},
|
|
135
|
-
href: onEdit
|
|
136
|
-
} : onEdit), /*#__PURE__*/React.createElement(Icon, {
|
|
121
|
+
}), /*#__PURE__*/React.createElement(Icon, {
|
|
137
122
|
type: "edit"
|
|
138
123
|
})), !softDelete && onDelete && /*#__PURE__*/React.createElement(StyledDeleteButton, {
|
|
139
124
|
"aria-label": l.actions.delete(),
|
|
@@ -320,7 +305,7 @@ Pod.propTypes = {
|
|
|
320
305
|
"valueOf": PropTypes.func.isRequired
|
|
321
306
|
}), PropTypes.string]),
|
|
322
307
|
"onDelete": PropTypes.func,
|
|
323
|
-
"onEdit": PropTypes.
|
|
308
|
+
"onEdit": PropTypes.func,
|
|
324
309
|
"onUndo": PropTypes.func,
|
|
325
310
|
"size": PropTypes.oneOf(["extra-large", "extra-small", "large", "medium", "small"]),
|
|
326
311
|
"softDelete": PropTypes.bool,
|
|
@@ -32,7 +32,7 @@ interface CommonPodButtonProps extends Pick<PodProps, "internalEditButton"> {
|
|
|
32
32
|
interface StyledEditActionProps extends CommonPodButtonProps {
|
|
33
33
|
displayOnlyOnHover?: boolean;
|
|
34
34
|
}
|
|
35
|
-
declare const StyledEditAction: import("styled-components").StyledComponent<"
|
|
35
|
+
declare const StyledEditAction: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, StyledEditActionProps, never>;
|
|
36
36
|
declare const StyledDeleteButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, CommonPodButtonProps, never>;
|
|
37
37
|
declare const StyledUndoButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, CommonPodButtonProps, never>;
|
|
38
38
|
interface StyledHeaderProps extends Pick<PodProps, "alignTitle" | "internalEditButton"> {
|
|
@@ -152,7 +152,7 @@ const actionButtonBackgrounds = {
|
|
|
152
152
|
transparent: "var(--colorsActionMajorTransparent)",
|
|
153
153
|
tile: "var(--colorsActionMajorYang100)"
|
|
154
154
|
};
|
|
155
|
-
const StyledEditAction = styled
|
|
155
|
+
const StyledEditAction = styled(IconButton)`
|
|
156
156
|
&& {
|
|
157
157
|
${({
|
|
158
158
|
displayOnlyOnHover,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
-
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
4
|
+
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "span", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
5
5
|
export declare type VariantTypes = typeof VARIANT_TYPES[number];
|
|
6
6
|
export interface TypographyProps extends SpaceProps, TagProps {
|
|
7
7
|
/** Override the variant component */
|
|
@@ -30,6 +30,8 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
30
30
|
whiteSpace?: string;
|
|
31
31
|
/** Override the word-wrap */
|
|
32
32
|
wordWrap?: string;
|
|
33
|
+
/** Override the text-align */
|
|
34
|
+
textAlign?: string;
|
|
33
35
|
/** Override the text-overflow */
|
|
34
36
|
textOverflow?: string;
|
|
35
37
|
/** Apply truncation */
|
|
@@ -49,7 +51,7 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
49
51
|
screenReaderOnly?: boolean;
|
|
50
52
|
}
|
|
51
53
|
export declare const Typography: {
|
|
52
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
54
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
53
55
|
displayName: string;
|
|
54
56
|
};
|
|
55
57
|
export default Typography;
|
|
@@ -4,7 +4,7 @@ import PropTypes from "prop-types";
|
|
|
4
4
|
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
5
5
|
import { filterStyledSystemMarginProps, filterStyledSystemPaddingProps } from "../../style/utils";
|
|
6
6
|
import StyledTypography from "./typography.style";
|
|
7
|
-
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
7
|
+
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "span", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
8
8
|
export const Typography = ({
|
|
9
9
|
"data-component": dataComponent,
|
|
10
10
|
variant = "p",
|
|
@@ -19,6 +19,7 @@ export const Typography = ({
|
|
|
19
19
|
listStyleType,
|
|
20
20
|
whiteSpace,
|
|
21
21
|
wordWrap,
|
|
22
|
+
textAlign,
|
|
22
23
|
textOverflow,
|
|
23
24
|
truncate,
|
|
24
25
|
color = "blackOpacity90",
|
|
@@ -43,6 +44,7 @@ export const Typography = ({
|
|
|
43
44
|
listStyleType: listStyleType,
|
|
44
45
|
whiteSpace: whiteSpace,
|
|
45
46
|
wordWrap: wordWrap,
|
|
47
|
+
textAlign: textAlign,
|
|
46
48
|
textOverflow: textOverflow,
|
|
47
49
|
truncate: truncate,
|
|
48
50
|
color: color,
|
|
@@ -42,6 +42,7 @@ const getSize = variant => {
|
|
|
42
42
|
return "13px";
|
|
43
43
|
case "segment-subheader-alt":
|
|
44
44
|
case "p":
|
|
45
|
+
case "span":
|
|
45
46
|
case "b":
|
|
46
47
|
case "strong":
|
|
47
48
|
case "em":
|
|
@@ -73,6 +74,7 @@ const getLineHeight = variant => {
|
|
|
73
74
|
case "h5":
|
|
74
75
|
case "segment-subheader-alt":
|
|
75
76
|
case "p":
|
|
77
|
+
case "span":
|
|
76
78
|
case "b":
|
|
77
79
|
case "strong":
|
|
78
80
|
case "em":
|
|
@@ -98,6 +100,7 @@ const getWeight = variant => {
|
|
|
98
100
|
case "h4":
|
|
99
101
|
case "h5":
|
|
100
102
|
case "p":
|
|
103
|
+
case "span":
|
|
101
104
|
case "small":
|
|
102
105
|
case "big":
|
|
103
106
|
case "sub":
|
|
@@ -149,6 +152,7 @@ const StyledTypography = styled.span.attrs(({
|
|
|
149
152
|
listStyleType,
|
|
150
153
|
whiteSpace,
|
|
151
154
|
wordWrap,
|
|
155
|
+
textAlign,
|
|
152
156
|
textOverflow,
|
|
153
157
|
truncate,
|
|
154
158
|
screenReaderOnly
|
|
@@ -163,6 +167,7 @@ const StyledTypography = styled.span.attrs(({
|
|
|
163
167
|
padding: 0;
|
|
164
168
|
white-space: ${truncate ? "nowrap" : whiteSpace};
|
|
165
169
|
word-wrap: ${wordWrap};
|
|
170
|
+
text-align: ${textAlign};
|
|
166
171
|
text-overflow: ${truncate ? "ellipsis" : textOverflow};
|
|
167
172
|
${truncate && css`
|
|
168
173
|
overflow: hidden;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
3
|
import { IconType } from "../icon";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
4
5
|
import { TooltipPositions } from "../tooltip/tooltip.config";
|
|
5
6
|
export declare type ButtonTypes = "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground";
|
|
6
7
|
export declare type SizeOptions = "small" | "medium" | "large";
|
|
7
8
|
export declare type ButtonIconPosition = "before" | "after";
|
|
8
|
-
export interface ButtonProps extends SpaceProps {
|
|
9
|
+
export interface ButtonProps extends SpaceProps, TagProps {
|
|
9
10
|
/**
|
|
10
11
|
* Prop to specify the aria-label attribute of the component
|
|
11
12
|
* Defaults to the iconType, when the component has only an icon
|
|
@@ -185,6 +185,9 @@ Button.propTypes = {
|
|
|
185
185
|
"aria-label": _propTypes.default.string,
|
|
186
186
|
"buttonType": _propTypes.default.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
187
187
|
"children": _propTypes.default.node,
|
|
188
|
+
"data-component": _propTypes.default.string,
|
|
189
|
+
"data-element": _propTypes.default.string,
|
|
190
|
+
"data-role": _propTypes.default.string,
|
|
188
191
|
"destructive": _propTypes.default.bool,
|
|
189
192
|
"disabled": _propTypes.default.bool,
|
|
190
193
|
"forwardRef": _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
@@ -533,6 +536,9 @@ ButtonWithForwardRef.propTypes = {
|
|
|
533
536
|
"aria-label": _propTypes.default.string,
|
|
534
537
|
"buttonType": _propTypes.default.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
535
538
|
"children": _propTypes.default.node,
|
|
539
|
+
"data-component": _propTypes.default.string,
|
|
540
|
+
"data-element": _propTypes.default.string,
|
|
541
|
+
"data-role": _propTypes.default.string,
|
|
536
542
|
"destructive": _propTypes.default.bool,
|
|
537
543
|
"disabled": _propTypes.default.bool,
|
|
538
544
|
"forwardRef": _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
@@ -12,7 +12,7 @@ declare type StyledHeadingTitleProps = {
|
|
|
12
12
|
withMargin?: boolean;
|
|
13
13
|
};
|
|
14
14
|
declare const StyledHeadingTitle: import("styled-components").StyledComponent<{
|
|
15
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
15
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
}, any, StyledHeadingTitleProps, never>;
|
|
18
18
|
declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -25,7 +25,7 @@ export interface PodProps extends MarginProps {
|
|
|
25
25
|
/** A component to render as a Pod footer */
|
|
26
26
|
footer?: string | React.ReactNode;
|
|
27
27
|
/** Supplies an edit action to the pod */
|
|
28
|
-
onEdit?:
|
|
28
|
+
onEdit?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
|
29
29
|
/** Supplies a delete action to the pod */
|
|
30
30
|
onDelete?: (ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
|
|
31
31
|
/** Supplies an undo action to the pod in soft delete state. */
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
10
9
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
11
10
|
var _pod = require("./pod.style");
|
|
12
11
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
@@ -15,8 +14,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
17
16
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
18
|
-
let deprecationOnEditStringWarnTriggered = false;
|
|
19
|
-
let deprecationOnEditObjectWarnTriggered = false;
|
|
20
17
|
const Pod = /*#__PURE__*/_react.default.forwardRef(({
|
|
21
18
|
"data-element": dataElement,
|
|
22
19
|
"data-role": dataRole,
|
|
@@ -40,14 +37,6 @@ const Pod = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
40
37
|
variant = "primary",
|
|
41
38
|
...rest
|
|
42
39
|
}, ref) => {
|
|
43
|
-
if (!deprecationOnEditStringWarnTriggered && typeof onEdit === "string") {
|
|
44
|
-
deprecationOnEditStringWarnTriggered = true;
|
|
45
|
-
_logger.default.deprecate("Support for passing strings to the `onEdit` prop of the `Pod` component is now deprecated. Please only pass event handlers to `onEdit`.");
|
|
46
|
-
}
|
|
47
|
-
if (!deprecationOnEditObjectWarnTriggered && typeof onEdit === "object") {
|
|
48
|
-
deprecationOnEditObjectWarnTriggered = true;
|
|
49
|
-
_logger.default.deprecate("Support for passing objects to the `onEdit` prop of the `Pod` component is now deprecated. Please only pass event handlers to `onEdit`.");
|
|
50
|
-
}
|
|
51
40
|
const [isEditFocused, setEditFocused] = (0, _react.useState)(false);
|
|
52
41
|
const [isEditHovered, setEditHovered] = (0, _react.useState)(false);
|
|
53
42
|
const [isDeleteFocused, setDeleteFocused] = (0, _react.useState)(false);
|
|
@@ -67,10 +56,8 @@ const Pod = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
67
56
|
onMouseLeave: () => setEditHovered(false),
|
|
68
57
|
onFocus: () => setEditFocused(true),
|
|
69
58
|
onBlur: () => setEditFocused(false),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
onKeyDown: processPodAction(onEdit)
|
|
73
|
-
})
|
|
59
|
+
onClick: onEdit && processPodAction(onEdit),
|
|
60
|
+
onKeyDown: onEdit && processPodAction(onEdit)
|
|
74
61
|
};
|
|
75
62
|
return /*#__PURE__*/_react.default.createElement(_pod.StyledPod, _extends({
|
|
76
63
|
alignTitle: alignTitle,
|
|
@@ -140,9 +127,7 @@ const Pod = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
140
127
|
noBorder: !border,
|
|
141
128
|
size: size,
|
|
142
129
|
variant: variant
|
|
143
|
-
},
|
|
144
|
-
href: onEdit
|
|
145
|
-
} : onEdit), /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
130
|
+
}), /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
146
131
|
type: "edit"
|
|
147
132
|
})), !softDelete && onDelete && /*#__PURE__*/_react.default.createElement(_pod.StyledDeleteButton, {
|
|
148
133
|
"aria-label": l.actions.delete(),
|
|
@@ -329,7 +314,7 @@ Pod.propTypes = {
|
|
|
329
314
|
"valueOf": _propTypes.default.func.isRequired
|
|
330
315
|
}), _propTypes.default.string]),
|
|
331
316
|
"onDelete": _propTypes.default.func,
|
|
332
|
-
"onEdit": _propTypes.default.
|
|
317
|
+
"onEdit": _propTypes.default.func,
|
|
333
318
|
"onUndo": _propTypes.default.func,
|
|
334
319
|
"size": _propTypes.default.oneOf(["extra-large", "extra-small", "large", "medium", "small"]),
|
|
335
320
|
"softDelete": _propTypes.default.bool,
|
|
@@ -32,7 +32,7 @@ interface CommonPodButtonProps extends Pick<PodProps, "internalEditButton"> {
|
|
|
32
32
|
interface StyledEditActionProps extends CommonPodButtonProps {
|
|
33
33
|
displayOnlyOnHover?: boolean;
|
|
34
34
|
}
|
|
35
|
-
declare const StyledEditAction: import("styled-components").StyledComponent<"
|
|
35
|
+
declare const StyledEditAction: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, StyledEditActionProps, never>;
|
|
36
36
|
declare const StyledDeleteButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, CommonPodButtonProps, never>;
|
|
37
37
|
declare const StyledUndoButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon-button").IconButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, CommonPodButtonProps, never>;
|
|
38
38
|
interface StyledHeaderProps extends Pick<PodProps, "alignTitle" | "internalEditButton"> {
|
|
@@ -166,7 +166,7 @@ const actionButtonBackgrounds = {
|
|
|
166
166
|
transparent: "var(--colorsActionMajorTransparent)",
|
|
167
167
|
tile: "var(--colorsActionMajorYang100)"
|
|
168
168
|
};
|
|
169
|
-
const StyledEditAction = _styledComponents.default.
|
|
169
|
+
const StyledEditAction = (0, _styledComponents.default)(_iconButton.default)`
|
|
170
170
|
&& {
|
|
171
171
|
${({
|
|
172
172
|
displayOnlyOnHover,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SpaceProps } from "styled-system";
|
|
3
3
|
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
-
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
4
|
+
declare const VARIANT_TYPES: readonly ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "span", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
5
5
|
export declare type VariantTypes = typeof VARIANT_TYPES[number];
|
|
6
6
|
export interface TypographyProps extends SpaceProps, TagProps {
|
|
7
7
|
/** Override the variant component */
|
|
@@ -30,6 +30,8 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
30
30
|
whiteSpace?: string;
|
|
31
31
|
/** Override the word-wrap */
|
|
32
32
|
wordWrap?: string;
|
|
33
|
+
/** Override the text-align */
|
|
34
|
+
textAlign?: string;
|
|
33
35
|
/** Override the text-overflow */
|
|
34
36
|
textOverflow?: string;
|
|
35
37
|
/** Apply truncation */
|
|
@@ -49,7 +51,7 @@ export interface TypographyProps extends SpaceProps, TagProps {
|
|
|
49
51
|
screenReaderOnly?: boolean;
|
|
50
52
|
}
|
|
51
53
|
export declare const Typography: {
|
|
52
|
-
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
54
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, ...rest }: TypographyProps): React.JSX.Element;
|
|
53
55
|
displayName: string;
|
|
54
56
|
};
|
|
55
57
|
export default Typography;
|
|
@@ -11,7 +11,7 @@ var _utils = require("../../style/utils");
|
|
|
11
11
|
var _typography = _interopRequireDefault(require("./typography.style"));
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
14
|
-
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
14
|
+
const VARIANT_TYPES = ["h1-large", "h1", "h2", "h3", "h4", "h5", "segment-header", "segment-header-small", "segment-subheader", "segment-subheader-alt", "p", "span", "small", "big", "sup", "sub", "strong", "b", "em", "ul", "ol"];
|
|
15
15
|
const Typography = ({
|
|
16
16
|
"data-component": dataComponent,
|
|
17
17
|
variant = "p",
|
|
@@ -26,6 +26,7 @@ const Typography = ({
|
|
|
26
26
|
listStyleType,
|
|
27
27
|
whiteSpace,
|
|
28
28
|
wordWrap,
|
|
29
|
+
textAlign,
|
|
29
30
|
textOverflow,
|
|
30
31
|
truncate,
|
|
31
32
|
color = "blackOpacity90",
|
|
@@ -50,6 +51,7 @@ const Typography = ({
|
|
|
50
51
|
listStyleType: listStyleType,
|
|
51
52
|
whiteSpace: whiteSpace,
|
|
52
53
|
wordWrap: wordWrap,
|
|
54
|
+
textAlign: textAlign,
|
|
53
55
|
textOverflow: textOverflow,
|
|
54
56
|
truncate: truncate,
|
|
55
57
|
color: color,
|
|
@@ -51,6 +51,7 @@ const getSize = variant => {
|
|
|
51
51
|
return "13px";
|
|
52
52
|
case "segment-subheader-alt":
|
|
53
53
|
case "p":
|
|
54
|
+
case "span":
|
|
54
55
|
case "b":
|
|
55
56
|
case "strong":
|
|
56
57
|
case "em":
|
|
@@ -82,6 +83,7 @@ const getLineHeight = variant => {
|
|
|
82
83
|
case "h5":
|
|
83
84
|
case "segment-subheader-alt":
|
|
84
85
|
case "p":
|
|
86
|
+
case "span":
|
|
85
87
|
case "b":
|
|
86
88
|
case "strong":
|
|
87
89
|
case "em":
|
|
@@ -107,6 +109,7 @@ const getWeight = variant => {
|
|
|
107
109
|
case "h4":
|
|
108
110
|
case "h5":
|
|
109
111
|
case "p":
|
|
112
|
+
case "span":
|
|
110
113
|
case "small":
|
|
111
114
|
case "big":
|
|
112
115
|
case "sub":
|
|
@@ -158,6 +161,7 @@ const StyledTypography = _styledComponents.default.span.attrs(({
|
|
|
158
161
|
listStyleType,
|
|
159
162
|
whiteSpace,
|
|
160
163
|
wordWrap,
|
|
164
|
+
textAlign,
|
|
161
165
|
textOverflow,
|
|
162
166
|
truncate,
|
|
163
167
|
screenReaderOnly
|
|
@@ -172,6 +176,7 @@ const StyledTypography = _styledComponents.default.span.attrs(({
|
|
|
172
176
|
padding: 0;
|
|
173
177
|
white-space: ${truncate ? "nowrap" : whiteSpace};
|
|
174
178
|
word-wrap: ${wordWrap};
|
|
179
|
+
text-align: ${textAlign};
|
|
175
180
|
text-overflow: ${truncate ? "ellipsis" : textOverflow};
|
|
176
181
|
${truncate && (0, _styledComponents.css)`
|
|
177
182
|
overflow: hidden;
|