carbon-react 119.12.2 → 120.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/__internal__/input/input-presentation.style.d.ts +1 -1
- package/esm/__spec_helper__/test-utils.d.ts +3 -2
- package/esm/__spec_helper__/test-utils.js +15 -1
- package/esm/components/box/box.component.d.ts +23 -6
- package/esm/components/box/box.component.js +3570 -103
- package/esm/components/box/box.style.d.ts +3 -0
- package/esm/components/box/box.style.js +112 -0
- package/esm/components/dismissible-box/dismissible-box.style.d.ts +2 -1
- package/esm/components/drawer/drawer.style.d.ts +2 -1
- package/esm/components/duelling-picklist/picklist/picklist.style.js +4 -2
- package/esm/components/flat-table/__internal__/build-position-map.d.ts +2 -0
- package/esm/components/flat-table/__internal__/build-position-map.js +14 -0
- package/esm/components/flat-table/__internal__/index.d.ts +2 -0
- package/esm/components/flat-table/__internal__/index.js +2 -0
- package/esm/components/flat-table/__internal__/use-calculate-sticky-cells.d.ts +12 -0
- package/esm/components/flat-table/__internal__/use-calculate-sticky-cells.js +28 -0
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +2 -41
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +26 -25
- package/esm/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +7 -2
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +3 -25
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +21 -14
- package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +3 -1
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.d.ts +4 -0
- package/esm/components/flat-table/flat-table-head/flat-table-head.component.js +21 -24
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.d.ts +2 -26
- package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +15 -13
- package/esm/components/flat-table/flat-table-header/flat-table-header.style.d.ts +3 -1
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-context.d.ts +12 -0
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-context.js +6 -0
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +3 -1
- package/esm/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +17 -3
- package/esm/components/flat-table/flat-table-row/__internal__/sub-row-provider.d.ts +15 -0
- package/esm/components/flat-table/flat-table-row/__internal__/sub-row-provider.js +28 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.d.ts +1 -15
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +85 -74
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.d.ts +4 -1
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +1 -9
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +4 -42
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +33 -20
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +7 -1
- package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +5 -1
- package/esm/components/flat-table/flat-table.component.js +24 -7
- package/esm/components/flat-table/flat-table.style.js +2 -2
- package/esm/components/heading/heading.style.d.ts +4 -9
- package/esm/components/menu/menu-full-screen/menu-full-screen.style.js +2 -2
- package/esm/components/menu/scrollable-block/scrollable-block.style.js +2 -2
- package/esm/components/typography/typography.component.d.ts +25 -15
- package/esm/components/typography/typography.component.js +37 -184
- package/esm/components/typography/typography.style.d.ts +12 -0
- package/esm/components/typography/typography.style.js +190 -0
- package/esm/components/vertical-menu/vertical-menu.style.js +3 -3
- package/esm/style/utils/filter-styled-system-flexbox-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-flexbox-props.js +5 -0
- package/esm/style/utils/filter-styled-system-grid-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-grid-props.js +5 -0
- package/esm/style/utils/filter-styled-system-layout-props.d.ts +3 -0
- package/esm/style/utils/filter-styled-system-layout-props.js +5 -0
- package/esm/style/utils/index.d.ts +4 -1
- package/esm/style/utils/index.js +4 -1
- package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
- package/lib/__spec_helper__/test-utils.d.ts +3 -2
- package/lib/__spec_helper__/test-utils.js +16 -1
- package/lib/components/box/box.component.d.ts +23 -6
- package/lib/components/box/box.component.js +3569 -105
- package/lib/components/box/box.style.d.ts +3 -0
- package/lib/components/box/box.style.js +122 -0
- package/lib/components/dismissible-box/dismissible-box.style.d.ts +2 -1
- package/lib/components/drawer/drawer.style.d.ts +2 -1
- package/lib/components/duelling-picklist/picklist/picklist.style.js +2 -1
- package/lib/components/flat-table/__internal__/build-position-map.d.ts +2 -0
- package/lib/components/flat-table/__internal__/build-position-map.js +21 -0
- package/lib/components/flat-table/__internal__/index.d.ts +2 -0
- package/lib/components/flat-table/__internal__/index.js +20 -0
- package/lib/components/flat-table/__internal__/package.json +6 -0
- package/lib/components/flat-table/__internal__/use-calculate-sticky-cells.d.ts +12 -0
- package/lib/components/flat-table/__internal__/use-calculate-sticky-cells.js +36 -0
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.d.ts +2 -41
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +25 -24
- package/lib/components/flat-table/flat-table-cell/flat-table-cell.style.d.ts +7 -2
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.d.ts +3 -25
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +20 -13
- package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.d.ts +3 -1
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.d.ts +4 -0
- package/lib/components/flat-table/flat-table-head/flat-table-head.component.js +23 -25
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.d.ts +2 -26
- package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +14 -12
- package/lib/components/flat-table/flat-table-header/flat-table-header.style.d.ts +3 -1
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-context.d.ts +12 -0
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-context.js +13 -0
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.d.ts +3 -1
- package/lib/components/flat-table/flat-table-row/__internal__/flat-table-row-draggable.component.js +17 -3
- package/lib/components/flat-table/flat-table-row/__internal__/sub-row-provider.d.ts +15 -0
- package/lib/components/flat-table/flat-table-row/__internal__/sub-row-provider.js +38 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.d.ts +1 -15
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +84 -73
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.d.ts +4 -1
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +1 -9
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.d.ts +4 -42
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +32 -19
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.d.ts +7 -1
- package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +5 -1
- package/lib/components/flat-table/flat-table.component.js +24 -7
- package/lib/components/flat-table/flat-table.style.js +1 -1
- package/lib/components/heading/heading.style.d.ts +4 -9
- package/lib/components/menu/menu-full-screen/menu-full-screen.style.js +1 -1
- package/lib/components/menu/scrollable-block/scrollable-block.style.js +1 -1
- package/lib/components/typography/typography.component.d.ts +25 -15
- package/lib/components/typography/typography.component.js +39 -187
- package/lib/components/typography/typography.style.d.ts +12 -0
- package/lib/components/typography/typography.style.js +200 -0
- package/lib/components/vertical-menu/vertical-menu.style.js +1 -1
- package/lib/style/utils/filter-styled-system-flexbox-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-flexbox-props.js +14 -0
- package/lib/style/utils/filter-styled-system-grid-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-grid-props.js +14 -0
- package/lib/style/utils/filter-styled-system-layout-props.d.ts +3 -0
- package/lib/style/utils/filter-styled-system-layout-props.js +14 -0
- package/lib/style/utils/index.d.ts +4 -1
- package/lib/style/utils/index.js +21 -0
- package/package.json +1 -1
|
@@ -1,65 +1,78 @@
|
|
|
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
|
-
import React, { useCallback,
|
|
2
|
+
import React, { useCallback, useContext, useState, useRef, useEffect } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import Icon from "../../icon";
|
|
5
5
|
import { StyledFlatTableRowHeader, StyledFlatTableRowHeaderContent } from "./flat-table-row-header.style";
|
|
6
6
|
import { FlatTableThemeContext } from "../flat-table.component";
|
|
7
7
|
import guid from "../../../__internal__/utils/helpers/guid";
|
|
8
|
+
import tagComponent from "../../../__internal__/utils/helpers/tags/tags";
|
|
9
|
+
import useCalculateStickyCells from "../__internal__/use-calculate-sticky-cells";
|
|
8
10
|
export const FlatTableRowHeader = ({
|
|
9
11
|
align = "left",
|
|
10
12
|
children,
|
|
11
13
|
width,
|
|
12
14
|
py,
|
|
13
15
|
px,
|
|
14
|
-
expandable = false,
|
|
15
|
-
onClick,
|
|
16
|
-
onKeyDown,
|
|
17
|
-
leftPosition,
|
|
18
|
-
rightPosition,
|
|
19
16
|
truncate,
|
|
20
17
|
title,
|
|
21
18
|
stickyAlignment = "left",
|
|
22
19
|
colspan,
|
|
23
20
|
rowspan,
|
|
21
|
+
id,
|
|
24
22
|
...rest
|
|
25
23
|
}) => {
|
|
26
|
-
const
|
|
24
|
+
const internalId = useRef(id || guid());
|
|
27
25
|
const [tabIndex, setTabIndex] = useState(-1);
|
|
28
26
|
const {
|
|
29
27
|
selectedId
|
|
30
28
|
} = useContext(FlatTableThemeContext);
|
|
29
|
+
const {
|
|
30
|
+
leftPosition,
|
|
31
|
+
rightPosition,
|
|
32
|
+
expandable,
|
|
33
|
+
onClick,
|
|
34
|
+
onKeyDown,
|
|
35
|
+
isFirstCell,
|
|
36
|
+
isExpandableCell
|
|
37
|
+
} = useCalculateStickyCells(internalId.current);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setTabIndex(isExpandableCell && selectedId === internalId.current ? 0 : -1);
|
|
40
|
+
}, [selectedId, isExpandableCell]);
|
|
31
41
|
const handleOnClick = useCallback(ev => {
|
|
32
|
-
if (
|
|
33
|
-
}, [
|
|
42
|
+
if (isExpandableCell && onClick) onClick(ev);
|
|
43
|
+
}, [isExpandableCell, onClick]);
|
|
34
44
|
const handleOnKeyDown = useCallback(ev => {
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}, [selectedId]);
|
|
45
|
+
if (isExpandableCell && onKeyDown) {
|
|
46
|
+
onKeyDown(ev);
|
|
47
|
+
}
|
|
48
|
+
}, [isExpandableCell, onKeyDown]);
|
|
40
49
|
return /*#__PURE__*/React.createElement(StyledFlatTableRowHeader, _extends({
|
|
41
50
|
leftPosition: stickyAlignment === "left" ? leftPosition || 0 : undefined,
|
|
42
51
|
rightPosition: stickyAlignment === "right" ? rightPosition || 0 : undefined,
|
|
43
|
-
align: align
|
|
52
|
+
align: align
|
|
53
|
+
}, tagComponent("flat-table-row-header", {
|
|
44
54
|
"data-element": "flat-table-row-header",
|
|
55
|
+
...rest
|
|
56
|
+
}), {
|
|
45
57
|
width: width,
|
|
46
58
|
py: py || "10px",
|
|
47
59
|
px: px || 3,
|
|
48
60
|
onClick: handleOnClick,
|
|
49
|
-
tabIndex:
|
|
61
|
+
tabIndex: isExpandableCell ? tabIndex : undefined,
|
|
50
62
|
onKeyDown: handleOnKeyDown,
|
|
51
63
|
truncate: truncate,
|
|
52
64
|
expandable: expandable,
|
|
53
|
-
stickyAlignment: stickyAlignment
|
|
54
|
-
id: id.current
|
|
65
|
+
stickyAlignment: stickyAlignment
|
|
55
66
|
}, colspan !== undefined && {
|
|
56
67
|
colSpan: Number(colspan)
|
|
57
68
|
}, rowspan !== undefined && {
|
|
58
69
|
rowSpan: Number(rowspan)
|
|
59
|
-
}, rest
|
|
70
|
+
}, rest, {
|
|
71
|
+
id: internalId.current
|
|
72
|
+
}), /*#__PURE__*/React.createElement(StyledFlatTableRowHeaderContent, {
|
|
60
73
|
title: truncate && !title && typeof children === "string" ? children : title,
|
|
61
74
|
expandable: expandable
|
|
62
|
-
}, expandable && /*#__PURE__*/React.createElement(Icon, {
|
|
75
|
+
}, expandable && isFirstCell && /*#__PURE__*/React.createElement(Icon, {
|
|
63
76
|
type: "chevron_down_thick",
|
|
64
77
|
bgSize: "extra-small",
|
|
65
78
|
mr: "8px"
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { FlatTableRowHeaderProps } from "./flat-table-row-header.component";
|
|
2
|
-
declare const StyledFlatTableRowHeader: import("styled-components").StyledComponent<"th", any,
|
|
2
|
+
declare const StyledFlatTableRowHeader: import("styled-components").StyledComponent<"th", any, {
|
|
3
|
+
"data-sticky-align": "left" | "right" | undefined;
|
|
4
|
+
} & FlatTableRowHeaderProps & {
|
|
5
|
+
expandable?: boolean | undefined;
|
|
6
|
+
leftPosition?: number | undefined;
|
|
7
|
+
rightPosition?: number | undefined;
|
|
8
|
+
}, "data-sticky-align">;
|
|
3
9
|
declare const StyledFlatTableRowHeaderContent: import("styled-components").StyledComponent<"div", any, {
|
|
4
10
|
expandable?: boolean | undefined;
|
|
5
11
|
}, never>;
|
|
@@ -7,7 +7,11 @@ const verticalBorderSizes = {
|
|
|
7
7
|
medium: "2px",
|
|
8
8
|
large: "4px"
|
|
9
9
|
};
|
|
10
|
-
const StyledFlatTableRowHeader = styled.th
|
|
10
|
+
const StyledFlatTableRowHeader = styled.th.attrs(({
|
|
11
|
+
stickyAlignment
|
|
12
|
+
}) => ({
|
|
13
|
+
"data-sticky-align": stickyAlignment
|
|
14
|
+
}))`
|
|
11
15
|
${({
|
|
12
16
|
align,
|
|
13
17
|
theme,
|
|
@@ -7,7 +7,7 @@ import Events from "../../__internal__/utils/helpers/events/events";
|
|
|
7
7
|
export const FlatTableThemeContext = /*#__PURE__*/React.createContext({
|
|
8
8
|
setSelectedId: () => {}
|
|
9
9
|
});
|
|
10
|
-
const FOCUSABLE_ROW_AND_CELL_QUERY = "tbody tr, tbody tr td, tbody tr th";
|
|
10
|
+
const FOCUSABLE_ROW_AND_CELL_QUERY = "tbody tr[tabindex], tbody tr td[tabindex], tbody tr th[tabindex]";
|
|
11
11
|
export const FlatTable = ({
|
|
12
12
|
caption,
|
|
13
13
|
children,
|
|
@@ -98,7 +98,7 @@ export const FlatTable = ({
|
|
|
98
98
|
if (!focusableElements) {
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
const focusableElementsArray = Array.from(focusableElements)
|
|
101
|
+
const focusableElementsArray = Array.from(focusableElements);
|
|
102
102
|
const currentFocusIndex = focusableElementsArray.findIndex(el => el === document.activeElement);
|
|
103
103
|
if (Events.isDownKey(ev)) {
|
|
104
104
|
ev.preventDefault();
|
|
@@ -125,13 +125,30 @@ export const FlatTable = ({
|
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
useLayoutEffect(() => {
|
|
128
|
-
const
|
|
128
|
+
const findSelectedId = () => {
|
|
129
|
+
const firstfocusableElement = tableRef.current?.querySelector(FOCUSABLE_ROW_AND_CELL_QUERY);
|
|
130
|
+
|
|
131
|
+
// if no other menu item is selected, we need to make the first row a tab stop
|
|
132
|
+
if (firstfocusableElement && !selectedId) {
|
|
133
|
+
const currentlySelectedId = firstfocusableElement?.getAttribute("id");
|
|
134
|
+
|
|
135
|
+
/* istanbul ignore else */
|
|
136
|
+
if (currentlySelectedId && selectedId !== currentlySelectedId) {
|
|
137
|
+
setSelectedId(currentlySelectedId);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const observer = new MutationObserver(findSelectedId);
|
|
129
142
|
|
|
130
|
-
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
/* istanbul ignore else */
|
|
144
|
+
if (wrapperRef.current) {
|
|
145
|
+
observer.observe(wrapperRef.current, {
|
|
146
|
+
subtree: true,
|
|
147
|
+
childList: true,
|
|
148
|
+
attributes: true
|
|
149
|
+
});
|
|
134
150
|
}
|
|
151
|
+
return () => observer.disconnect();
|
|
135
152
|
}, [selectedId]);
|
|
136
153
|
return /*#__PURE__*/React.createElement(StyledFlatTableWrapper, _extends({
|
|
137
154
|
ref: wrapperRef,
|
|
@@ -7,7 +7,7 @@ import StyledFlatTableCheckbox from "./flat-table-checkbox/flat-table-checkbox.s
|
|
|
7
7
|
import { baseTheme } from "../../style/themes";
|
|
8
8
|
import { StyledFlatTableCell } from "./flat-table-cell/flat-table-cell.style";
|
|
9
9
|
import cellSizes from "./cell-sizes.style";
|
|
10
|
-
import
|
|
10
|
+
import StyledBox from "../box/box.style";
|
|
11
11
|
import { StyledPagerContainer } from "../pager/pager.style";
|
|
12
12
|
import addFocusStyling from "../../style/utils/add-focus-styling";
|
|
13
13
|
const HEADER_OVERLAY_INCREMENT = 3;
|
|
@@ -93,7 +93,7 @@ const StyledFlatTable = styled.table`
|
|
|
93
93
|
}
|
|
94
94
|
`}
|
|
95
95
|
`;
|
|
96
|
-
const StyledFlatTableWrapper = styled(
|
|
96
|
+
const StyledFlatTableWrapper = styled(StyledBox)`
|
|
97
97
|
border-top-left-radius: var(--borderRadius100);
|
|
98
98
|
border-top-right-radius: var(--borderRadius100);
|
|
99
99
|
${({
|
|
@@ -11,15 +11,10 @@ declare const StyledHeadingBackButton: import("styled-components").StyledCompone
|
|
|
11
11
|
declare type StyledHeadingTitleProps = {
|
|
12
12
|
withMargin?: boolean;
|
|
13
13
|
};
|
|
14
|
-
declare const StyledHeadingTitle: import("styled-components").StyledComponent<
|
|
15
|
-
as: import("react").
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
textTransform: string;
|
|
19
|
-
textDecoration: string;
|
|
20
|
-
lineHeight: string;
|
|
21
|
-
defaultMargin: string;
|
|
22
|
-
} & import("../typography").TypographyProps & StyledHeadingTitleProps, "as" | "textDecoration" | "size" | "lineHeight" | "textTransform" | "weight" | "defaultMargin">;
|
|
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, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
|
|
16
|
+
displayName: string;
|
|
17
|
+
}, any, StyledHeadingTitleProps, never>;
|
|
23
18
|
declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
24
19
|
declare type StyledSubHeaderProps = {
|
|
25
20
|
hasBackLink?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import { baseTheme } from "../../../style/themes";
|
|
3
3
|
import StyledIconButton from "../../icon-button/icon-button.style";
|
|
4
|
-
import
|
|
4
|
+
import StyledBox from "../../box/box.style";
|
|
5
5
|
import StyledSearch from "../../search/search.style";
|
|
6
6
|
import StyledIcon from "../../icon/icon.style";
|
|
7
7
|
import StyledButton from "../../button/button.style";
|
|
@@ -90,7 +90,7 @@ const StyledMenuFullscreen = styled.div`
|
|
|
90
90
|
`}
|
|
91
91
|
`}
|
|
92
92
|
|
|
93
|
-
${
|
|
93
|
+
${StyledBox} {
|
|
94
94
|
&::-webkit-scrollbar {
|
|
95
95
|
width: 16px;
|
|
96
96
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
import StyledMenuItemWrapper from "../menu-item/menu-item.style";
|
|
3
3
|
import menuConfigVariants from "../menu.config";
|
|
4
|
-
import
|
|
4
|
+
import StyledBox from "../../box/box.style";
|
|
5
5
|
import { StyledMenuItem } from "../menu.style";
|
|
6
6
|
import { StyledLink } from "../../link/link.style";
|
|
7
7
|
const StyledScrollableBlock = styled.li`
|
|
@@ -13,7 +13,7 @@ const StyledScrollableBlock = styled.li`
|
|
|
13
13
|
background-color: ${variant === "default" ? menuConfigVariants[menuType].submenuItemBackground : menuConfigVariants[menuType].alternate};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
${
|
|
16
|
+
${StyledBox} {
|
|
17
17
|
border-radius: var(--borderRadius000);
|
|
18
18
|
border-bottom-left-radius: var(--borderRadius100);
|
|
19
19
|
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SpaceProps } from "styled-system";
|
|
3
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
3
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
5
|
export declare type VariantTypes = typeof VARIANT_TYPES[number];
|
|
5
|
-
export interface TypographyProps extends SpaceProps,
|
|
6
|
+
export interface TypographyProps extends SpaceProps, TagProps {
|
|
6
7
|
/** Override the variant component */
|
|
7
8
|
as?: React.ElementType;
|
|
9
|
+
/** Set the ID attribute of the Typography component */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Content to be rendered inside the Typography component */
|
|
12
|
+
children?: React.ReactNode;
|
|
8
13
|
/** The visual style to apply to the component */
|
|
9
14
|
variant?: VariantTypes;
|
|
10
15
|
/** Override the variant font-size */
|
|
@@ -21,22 +26,27 @@ export interface TypographyProps extends SpaceProps, ColorProps {
|
|
|
21
26
|
display?: string;
|
|
22
27
|
/** Override the list-style-type */
|
|
23
28
|
listStyleType?: string;
|
|
24
|
-
/** Override the white-space
|
|
29
|
+
/** Override the white-space */
|
|
25
30
|
whiteSpace?: string;
|
|
26
|
-
/** Override the word-wrap
|
|
31
|
+
/** Override the word-wrap */
|
|
27
32
|
wordWrap?: string;
|
|
28
|
-
/** Override the text-overflow
|
|
33
|
+
/** Override the text-overflow */
|
|
29
34
|
textOverflow?: string;
|
|
30
35
|
/** Apply truncation */
|
|
31
36
|
truncate?: boolean;
|
|
37
|
+
/** Override the color style */
|
|
38
|
+
color?: string;
|
|
39
|
+
/** Override the backgroundColor style */
|
|
40
|
+
backgroundColor?: string;
|
|
41
|
+
/** Override the bg value shorthand for backgroundColor */
|
|
42
|
+
bg?: string;
|
|
43
|
+
/** Override the opacity value */
|
|
44
|
+
opacity?: string | number;
|
|
45
|
+
/** @private @ignore */
|
|
46
|
+
className?: string;
|
|
32
47
|
}
|
|
33
|
-
declare const Typography:
|
|
34
|
-
as:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
textTransform: string;
|
|
38
|
-
textDecoration: string;
|
|
39
|
-
lineHeight: string;
|
|
40
|
-
defaultMargin: string;
|
|
41
|
-
} & TypographyProps, "as" | "textDecoration" | "size" | "lineHeight" | "textTransform" | "weight" | "defaultMargin">;
|
|
48
|
+
export declare const Typography: {
|
|
49
|
+
({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, ...rest }: TypographyProps): React.JSX.Element;
|
|
50
|
+
displayName: string;
|
|
51
|
+
};
|
|
42
52
|
export default Typography;
|
|
@@ -1,202 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
5
|
+
import { filterStyledSystemMarginProps, filterStyledSystemPaddingProps } from "../../style/utils";
|
|
6
|
+
import StyledTypography from "./typography.style";
|
|
6
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return "h1";
|
|
11
|
-
case "segment-header":
|
|
12
|
-
case "segment-header-small":
|
|
13
|
-
case "segment-subheader":
|
|
14
|
-
case "segment-subheader-alt":
|
|
15
|
-
return "h5";
|
|
16
|
-
case "big":
|
|
17
|
-
return "p";
|
|
18
|
-
default:
|
|
19
|
-
return variant;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const getSize = variant => {
|
|
23
|
-
switch (variant) {
|
|
24
|
-
case "h1-large":
|
|
25
|
-
return "32px";
|
|
26
|
-
case "h1":
|
|
27
|
-
return "24px";
|
|
28
|
-
case "h2":
|
|
29
|
-
return "22px";
|
|
30
|
-
case "h3":
|
|
31
|
-
case "segment-header":
|
|
32
|
-
return "20px";
|
|
33
|
-
case "h4":
|
|
34
|
-
case "segment-header-small":
|
|
35
|
-
return "18px";
|
|
36
|
-
case "h5":
|
|
37
|
-
case "segment-subheader":
|
|
38
|
-
case "big":
|
|
39
|
-
return "16px";
|
|
40
|
-
case "small":
|
|
41
|
-
case "sub":
|
|
42
|
-
case "sup":
|
|
43
|
-
return "13px";
|
|
44
|
-
case "segment-subheader-alt":
|
|
45
|
-
case "p":
|
|
46
|
-
case "b":
|
|
47
|
-
case "strong":
|
|
48
|
-
case "em":
|
|
49
|
-
default:
|
|
50
|
-
return "14px";
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const getLineHeight = variant => {
|
|
54
|
-
switch (variant) {
|
|
55
|
-
case "h1-large":
|
|
56
|
-
return "40px";
|
|
57
|
-
case "h1":
|
|
58
|
-
case "segment-subheader":
|
|
59
|
-
return "31px";
|
|
60
|
-
case "h2":
|
|
61
|
-
return "29px";
|
|
62
|
-
case "h3":
|
|
63
|
-
case "segment-header":
|
|
64
|
-
return "26px";
|
|
65
|
-
case "big":
|
|
66
|
-
return "24px";
|
|
67
|
-
case "h4":
|
|
68
|
-
case "segment-header-small":
|
|
69
|
-
return "23px";
|
|
70
|
-
case "small":
|
|
71
|
-
case "sub":
|
|
72
|
-
case "sup":
|
|
73
|
-
return "20px";
|
|
74
|
-
case "h5":
|
|
75
|
-
case "segment-subheader-alt":
|
|
76
|
-
case "p":
|
|
77
|
-
case "b":
|
|
78
|
-
case "strong":
|
|
79
|
-
case "em":
|
|
80
|
-
default:
|
|
81
|
-
return "21px";
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const getWeight = variant => {
|
|
85
|
-
switch (variant) {
|
|
86
|
-
case "h1-large":
|
|
87
|
-
case "h1":
|
|
88
|
-
case "segment-header":
|
|
89
|
-
case "segment-header-small":
|
|
90
|
-
return "900";
|
|
91
|
-
case "h2":
|
|
92
|
-
case "h3":
|
|
93
|
-
case "segment-subheader":
|
|
94
|
-
case "segment-subheader-alt":
|
|
95
|
-
case "b":
|
|
96
|
-
case "em":
|
|
97
|
-
case "strong":
|
|
98
|
-
return "700";
|
|
99
|
-
case "h4":
|
|
100
|
-
case "h5":
|
|
101
|
-
case "p":
|
|
102
|
-
case "small":
|
|
103
|
-
case "big":
|
|
104
|
-
case "sub":
|
|
105
|
-
case "sup":
|
|
106
|
-
default:
|
|
107
|
-
return "400";
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const getTransform = variant => {
|
|
111
|
-
if (variant === "segment-subheader-alt") {
|
|
112
|
-
return "uppercase";
|
|
113
|
-
}
|
|
114
|
-
return "none";
|
|
115
|
-
};
|
|
116
|
-
const getDecoration = variant => {
|
|
117
|
-
if (variant === "em") {
|
|
118
|
-
return "underline";
|
|
119
|
-
}
|
|
120
|
-
return "none";
|
|
121
|
-
};
|
|
122
|
-
let isDeprecationWarningTriggered = false;
|
|
123
|
-
const Typography = styled.span.attrs(({
|
|
124
|
-
variant,
|
|
8
|
+
export const Typography = ({
|
|
9
|
+
"data-component": dataComponent,
|
|
10
|
+
variant = "p",
|
|
125
11
|
as,
|
|
12
|
+
id,
|
|
126
13
|
fontSize,
|
|
127
14
|
fontWeight,
|
|
128
15
|
textTransform,
|
|
129
16
|
lineHeight,
|
|
130
|
-
textDecoration
|
|
131
|
-
}) => {
|
|
132
|
-
return {
|
|
133
|
-
as: as || getAs(variant),
|
|
134
|
-
size: fontSize || getSize(variant),
|
|
135
|
-
weight: fontWeight || getWeight(variant),
|
|
136
|
-
textTransform: textTransform || getTransform(variant),
|
|
137
|
-
textDecoration: textDecoration || getDecoration(variant),
|
|
138
|
-
lineHeight: lineHeight || getLineHeight(variant),
|
|
139
|
-
defaultMargin: variant === "p" ? "0 0 16px" : "0"
|
|
140
|
-
};
|
|
141
|
-
})`
|
|
142
|
-
${() => {
|
|
143
|
-
if (!isDeprecationWarningTriggered) {
|
|
144
|
-
isDeprecationWarningTriggered = true;
|
|
145
|
-
Logger.deprecate("Previous props that could be spread to the `Typography` component are being removed. Only props documented in the intefaces will be supported.");
|
|
146
|
-
}
|
|
147
|
-
return css``;
|
|
148
|
-
}}
|
|
149
|
-
${({
|
|
150
|
-
size,
|
|
151
|
-
weight,
|
|
152
|
-
textTransform,
|
|
153
|
-
lineHeight,
|
|
154
|
-
defaultMargin,
|
|
155
17
|
textDecoration,
|
|
156
18
|
display,
|
|
157
|
-
variant,
|
|
158
19
|
listStyleType,
|
|
159
20
|
whiteSpace,
|
|
160
21
|
wordWrap,
|
|
161
22
|
textOverflow,
|
|
162
|
-
truncate
|
|
163
|
-
|
|
164
|
-
font-style: normal;
|
|
165
|
-
font-size: ${size};
|
|
166
|
-
font-weight: ${weight};
|
|
167
|
-
text-transform: ${textTransform};
|
|
168
|
-
text-decoration: ${textDecoration};
|
|
169
|
-
line-height: ${lineHeight};
|
|
170
|
-
margin: ${defaultMargin};
|
|
171
|
-
padding: 0;
|
|
172
|
-
white-space: ${truncate ? "nowrap" : whiteSpace};
|
|
173
|
-
word-wrap: ${wordWrap};
|
|
174
|
-
text-overflow: ${truncate ? "ellipsis" : textOverflow};
|
|
175
|
-
${truncate && css`
|
|
176
|
-
overflow: hidden;
|
|
177
|
-
`};
|
|
178
|
-
${variant === "sup" && "vertical-align: super;"};
|
|
179
|
-
${variant === "sub" && "vertical-align: sub;"};
|
|
180
|
-
${display && `display: ${display};`};
|
|
181
|
-
${listStyleType && `list-style-type: ${listStyleType};`}; ;
|
|
182
|
-
`}
|
|
183
|
-
${space}
|
|
184
|
-
${({
|
|
185
|
-
color,
|
|
186
|
-
bg,
|
|
23
|
+
truncate,
|
|
24
|
+
color = "blackOpacity90",
|
|
187
25
|
backgroundColor,
|
|
188
|
-
...rest
|
|
189
|
-
}) => styledColor({
|
|
190
|
-
color,
|
|
191
26
|
bg,
|
|
192
|
-
|
|
27
|
+
opacity,
|
|
28
|
+
children,
|
|
29
|
+
className,
|
|
193
30
|
...rest
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
31
|
+
}) => {
|
|
32
|
+
return /*#__PURE__*/React.createElement(StyledTypography, _extends({
|
|
33
|
+
variant: variant,
|
|
34
|
+
as: as,
|
|
35
|
+
id: id,
|
|
36
|
+
fontSize: fontSize,
|
|
37
|
+
fontWeight: fontWeight,
|
|
38
|
+
textTransform: textTransform,
|
|
39
|
+
lineHeight: lineHeight,
|
|
40
|
+
textDecoration: textDecoration,
|
|
41
|
+
display: display,
|
|
42
|
+
listStyleType: listStyleType,
|
|
43
|
+
whiteSpace: whiteSpace,
|
|
44
|
+
wordWrap: wordWrap,
|
|
45
|
+
textOverflow: textOverflow,
|
|
46
|
+
truncate: truncate,
|
|
47
|
+
color: color,
|
|
48
|
+
backgroundColor: backgroundColor,
|
|
49
|
+
bg: bg,
|
|
50
|
+
opacity: opacity,
|
|
51
|
+
className: className
|
|
52
|
+
}, tagComponent(dataComponent, rest), filterStyledSystemMarginProps(rest), filterStyledSystemPaddingProps(rest)), children);
|
|
200
53
|
};
|
|
201
54
|
Typography.displayName = "Typography";
|
|
202
55
|
export default Typography;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TypographyProps } from "./typography.component";
|
|
3
|
+
declare const StyledTypography: import("styled-components").StyledComponent<"span", any, {
|
|
4
|
+
as: import("react").ElementType<any> | undefined;
|
|
5
|
+
size: string;
|
|
6
|
+
weight: string;
|
|
7
|
+
textTransform: string;
|
|
8
|
+
textDecoration: string;
|
|
9
|
+
lineHeight: string;
|
|
10
|
+
defaultMargin: string;
|
|
11
|
+
} & TypographyProps, "as" | "textDecoration" | "size" | "weight" | "textTransform" | "lineHeight" | "defaultMargin">;
|
|
12
|
+
export default StyledTypography;
|