carbon-react 111.8.4 → 111.9.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.
Files changed (59) hide show
  1. package/esm/components/dialog/dialog.style.js +2 -43
  2. package/esm/components/flat-table/flat-table-cell/flat-table-cell.component.js +11 -1
  3. package/esm/components/flat-table/flat-table-cell/flat-table-cell.style.js +3 -1
  4. package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +11 -1
  5. package/esm/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.js +3 -2
  6. package/esm/components/flat-table/flat-table-head/flat-table-head.style.js +8 -7
  7. package/esm/components/flat-table/flat-table-header/flat-table-header.component.js +11 -1
  8. package/esm/components/flat-table/flat-table-header/flat-table-header.d.ts +2 -0
  9. package/esm/components/flat-table/flat-table-header/flat-table-header.style.js +31 -22
  10. package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +46 -19
  11. package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +72 -22
  12. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +31 -6
  13. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +2 -0
  14. package/esm/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +11 -4
  15. package/esm/components/flat-table/flat-table.style.js +68 -19
  16. package/esm/components/form/form.style.js +0 -17
  17. package/esm/components/link-preview/__internal__/placeholder.component.d.ts +2 -0
  18. package/esm/components/link-preview/index.d.ts +2 -2
  19. package/esm/components/link-preview/link-preview.component.d.ts +28 -0
  20. package/esm/components/link-preview/link-preview.component.js +17 -30
  21. package/esm/components/link-preview/link-preview.style.d.ts +11 -0
  22. package/esm/components/sidebar/sidebar.component.js +2 -2
  23. package/esm/components/sidebar/sidebar.config.d.ts +4 -0
  24. package/esm/components/sidebar/sidebar.config.js +5 -1
  25. package/esm/components/sidebar/sidebar.style.d.ts +2 -1
  26. package/esm/components/sidebar/sidebar.style.js +11 -0
  27. package/esm/style/utils/form-style-utils.d.ts +19 -0
  28. package/esm/style/utils/form-style-utils.js +99 -0
  29. package/lib/components/dialog/dialog.style.js +5 -45
  30. package/lib/components/flat-table/flat-table-cell/flat-table-cell.component.js +11 -1
  31. package/lib/components/flat-table/flat-table-cell/flat-table-cell.style.js +3 -1
  32. package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.component.js +11 -1
  33. package/lib/components/flat-table/flat-table-checkbox/flat-table-checkbox.style.js +3 -2
  34. package/lib/components/flat-table/flat-table-head/flat-table-head.style.js +8 -7
  35. package/lib/components/flat-table/flat-table-header/flat-table-header.component.js +11 -1
  36. package/lib/components/flat-table/flat-table-header/flat-table-header.d.ts +2 -0
  37. package/lib/components/flat-table/flat-table-header/flat-table-header.style.js +34 -23
  38. package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +47 -19
  39. package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +72 -22
  40. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.component.js +35 -6
  41. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.d.ts +2 -0
  42. package/lib/components/flat-table/flat-table-row-header/flat-table-row-header.style.js +11 -4
  43. package/lib/components/flat-table/flat-table.style.js +69 -20
  44. package/lib/components/form/form.style.js +0 -17
  45. package/lib/components/link-preview/__internal__/placeholder.component.d.ts +2 -0
  46. package/lib/components/link-preview/index.d.ts +2 -2
  47. package/lib/components/link-preview/link-preview.component.d.ts +28 -0
  48. package/lib/components/link-preview/link-preview.component.js +18 -31
  49. package/lib/components/link-preview/link-preview.style.d.ts +11 -0
  50. package/lib/components/sidebar/sidebar.component.js +2 -2
  51. package/lib/components/sidebar/sidebar.config.d.ts +4 -0
  52. package/lib/components/sidebar/sidebar.config.js +10 -2
  53. package/lib/components/sidebar/sidebar.style.d.ts +2 -1
  54. package/lib/components/sidebar/sidebar.style.js +13 -0
  55. package/lib/style/utils/form-style-utils.d.ts +19 -0
  56. package/lib/style/utils/form-style-utils.js +113 -0
  57. package/package.json +1 -1
  58. package/esm/components/link-preview/link-preview.d.ts +0 -24
  59. package/lib/components/link-preview/link-preview.d.ts +0 -24
@@ -28,6 +28,7 @@ const FlatTableCheckbox = ({
28
28
  selectable = true,
29
29
  onClick,
30
30
  leftPosition,
31
+ rightPosition,
31
32
  cellIndex,
32
33
  reportCellWidth,
33
34
  ariaLabelledBy,
@@ -53,7 +54,9 @@ const FlatTableCheckbox = ({
53
54
  return /*#__PURE__*/_react.default.createElement(_flatTableCheckbox.default, _extends({
54
55
  ref: ref,
55
56
  makeCellSticky: !!reportCellWidth,
56
- leftPosition: leftPosition || 0,
57
+ className: reportCellWidth ? "isSticky" : undefined,
58
+ leftPosition: leftPosition,
59
+ rightPosition: rightPosition,
57
60
  "data-element": dataElement,
58
61
  as: as
59
62
  }, rest), selectable && /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
@@ -93,6 +96,13 @@ FlatTableCheckbox.propTypes = {
93
96
  */
94
97
  leftPosition: _propTypes.default.number,
95
98
 
99
+ /**
100
+ * @private
101
+ * @ignore
102
+ * Sets the right position when sticky column found
103
+ */
104
+ rightPosition: _propTypes.default.number,
105
+
96
106
  /**
97
107
  * @private
98
108
  * @ignore
@@ -19,6 +19,7 @@ const StyledFlatTableCheckbox = _styledComponents.default.td`
19
19
  ${({
20
20
  as,
21
21
  leftPosition,
22
+ rightPosition,
22
23
  makeCellSticky
23
24
  }) => (0, _styledComponents.css)`
24
25
  ${as === "td" && (0, _styledComponents.css)`
@@ -50,7 +51,6 @@ const StyledFlatTableCheckbox = _styledComponents.default.td`
50
51
  left: auto;
51
52
  padding: 0;
52
53
  text-align: left;
53
- top: 0;
54
54
  user-select: none;
55
55
  vertical-align: middle;
56
56
  white-space: nowrap;
@@ -58,7 +58,8 @@ const StyledFlatTableCheckbox = _styledComponents.default.td`
58
58
 
59
59
  ${makeCellSticky && (0, _styledComponents.css)`
60
60
  top: auto;
61
- left: ${leftPosition}px;
61
+ ${leftPosition !== undefined && `left: ${leftPosition}px;`}
62
+ ${rightPosition !== undefined && `right: ${rightPosition}px;`}
62
63
  position: sticky;
63
64
  `}
64
65
  `}
@@ -16,13 +16,14 @@ var _flatTableCheckbox = _interopRequireDefault(require("../flat-table-checkbox/
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
18
  const StyledFlatTableHead = _styledComponents.default.thead`
19
- ${_flatTableRowHeader.StyledFlatTableRowHeader}, ${_flatTableCheckbox.default} {
20
- border-left: none;
21
- border-right: none;
22
- font-weight: 700;
23
- z-index: ${({
24
- theme
25
- }) => theme.zIndex.overlay};
19
+ &&& {
20
+ ${_flatTableCheckbox.default} {
21
+ border-left: none;
22
+ border-right: none;
23
+ }
24
+ ${_flatTableRowHeader.StyledFlatTableRowHeader}, ${_flatTableCheckbox.default} {
25
+ font-weight: 700;
26
+ }
26
27
  }
27
28
  `;
28
29
  StyledFlatTableHead.defaultProps = {
@@ -38,6 +38,7 @@ const FlatTableHeader = ({
38
38
  reportCellWidth,
39
39
  cellIndex,
40
40
  leftPosition,
41
+ rightPosition,
41
42
  ...rest
42
43
  }) => {
43
44
  const ref = (0, _react.useRef)(null);
@@ -51,8 +52,10 @@ const FlatTableHeader = ({
51
52
  }, [reportCellWidth, cellIndex]);
52
53
  return /*#__PURE__*/_react.default.createElement(_flatTableHeader.default, _extends({
53
54
  ref: ref,
54
- leftPosition: leftPosition || 0,
55
+ leftPosition: leftPosition,
56
+ rightPosition: rightPosition,
55
57
  makeCellSticky: !!reportCellWidth,
58
+ className: reportCellWidth ? "isSticky" : undefined,
56
59
  align: align,
57
60
  colorTheme: colorTheme,
58
61
  "data-element": "flat-table-header",
@@ -88,6 +91,13 @@ FlatTableHeader.propTypes = {
88
91
  */
89
92
  leftPosition: _propTypes.default.number,
90
93
 
94
+ /**
95
+ * @private
96
+ * @ignore
97
+ * Sets the right position when sticky column found
98
+ */
99
+ rightPosition: _propTypes.default.number,
100
+
91
101
  /**
92
102
  * @private
93
103
  * @ignore
@@ -15,6 +15,8 @@ export interface FlatTableHeaderProps extends PaddingProps {
15
15
  rowspan?: number | string;
16
16
  /** Sets a custom vertical right border */
17
17
  verticalBorder?: TableBorderSize;
18
+ /** Sets the color of the right border */
19
+ verticalBorderColor?: string;
18
20
  /** Column width, pass a number to set a fixed width in pixels */
19
21
  width?: number;
20
22
  }
@@ -11,6 +11,10 @@ var _styledSystem = require("styled-system");
11
11
 
12
12
  var _flatTableHeaderUtils = _interopRequireDefault(require("./flat-table-header-utils"));
13
13
 
14
+ var _base = _interopRequireDefault(require("../../../style/themes/base"));
15
+
16
+ var _color = require("../../../style/utils/color");
17
+
14
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
19
 
16
20
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -28,9 +32,12 @@ const StyledFlatTableHeader = _styledComponents.default.th`
28
32
  alternativeBgColor,
29
33
  colWidth,
30
34
  leftPosition,
35
+ rightPosition,
31
36
  makeCellSticky,
32
37
  verticalBorder,
33
- colorTheme
38
+ verticalBorderColor,
39
+ colorTheme,
40
+ theme
34
41
  }) => (0, _styledComponents.css)`
35
42
  background-color: transparent;
36
43
  border-width: 0;
@@ -38,7 +45,6 @@ const StyledFlatTableHeader = _styledComponents.default.th`
38
45
  font-weight: 700;
39
46
  left: auto;
40
47
  text-align: ${align};
41
- top: 0;
42
48
  user-select: none;
43
49
  vertical-align: middle;
44
50
  white-space: nowrap;
@@ -74,37 +80,42 @@ const StyledFlatTableHeader = _styledComponents.default.th`
74
80
  `};
75
81
 
76
82
  ${makeCellSticky && (0, _styledComponents.css)`
77
- left: ${leftPosition}px;
78
- position: sticky;
79
- &&& {
80
- z-index: 1002;
81
- }
82
-
83
- &:first-child {
84
- padding-right: 0.395em;
85
-
86
- /* Applies specific styling for Firefox. Increased padding is required to ensure no gap is present between
87
- the th elements. This includes FlatTableHeader and FlatTableRowHeader */
88
- @-moz-document url-prefix() {
89
- padding-right: 2px;
90
- }
83
+ ${leftPosition !== undefined && `left: ${leftPosition}px;`}
84
+ ${rightPosition !== undefined && `right: ${rightPosition}px;`}
85
+ position: sticky;
86
+
87
+ &:first-child {
88
+ padding-right: 0.395em;
89
+
90
+ /* Applies specific styling for Firefox. Increased padding is required to ensure no gap is present between
91
+ the th elements. This includes FlatTableHeader and FlatTableRowHeader */
92
+ @-moz-document url-prefix() {
93
+ padding-right: 2px;
94
+ }
91
95
 
92
- /* Styling for safari. Increased padding is required to ensure no gap is present between
93
- the th elements. This includes FlatTableHeader and FlatTableRowHeader */
94
- @media not all and (min-resolution:.001dpcm) {
95
- @supports (-webkit-appearance:none) and (stroke-color:transparent) {
96
- padding-right: 0.9em;
96
+ /* Styling for safari. Increased padding is required to ensure no gap is present between
97
+ the th elements. This includes FlatTableHeader and FlatTableRowHeader */
98
+ @media not all and (min-resolution:.001dpcm) {
99
+ @supports (-webkit-appearance:none) and (stroke-color:transparent) {
100
+ padding-right: 0.9em;
101
+ }
97
102
  }
98
- }
99
- `}
103
+ `}
100
104
 
101
105
  &&& {
102
106
  ${verticalBorder && (0, _styledComponents.css)`
103
107
  border-right-width: ${verticalBorderSizes[verticalBorder]};
104
108
  `}
109
+
110
+ ${verticalBorderColor && (0, _styledComponents.css)`
111
+ border-right-color: ${(0, _color.toColor)(theme, verticalBorderColor)};
112
+ `}
105
113
  }
106
114
  }
107
115
  `}
108
116
  `;
117
+ StyledFlatTableHeader.defaultProps = {
118
+ theme: _base.default
119
+ };
109
120
  var _default = StyledFlatTableHeader;
110
121
  exports.default = _default;
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
+ var _invariant = _interopRequireDefault(require("invariant"));
13
+
12
14
  var _events = _interopRequireDefault(require("../../../__internal__/utils/helpers/events"));
13
15
 
14
16
  var _flatTableRow = _interopRequireDefault(require("./flat-table-row.style"));
@@ -57,13 +59,24 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
57
59
  let rowRef = (0, _react.useRef)();
58
60
  if (ref) rowRef = ref;
59
61
  const firstColumnExpandable = expandableArea === "firstColumn";
60
- const [stickyCellWidths, setStickyCellWidths] = (0, _react.useState)([]);
62
+ const [leftStickyCellWidths, setLeftStickyCellWidths] = (0, _react.useState)([]);
63
+ const [rightStickyCellWidths, setRightStickyCellWidths] = (0, _react.useState)([]);
61
64
  const [leftPositions, setLeftPositions] = (0, _react.useState)([]);
65
+ const [rightPositions, setRightPositions] = (0, _react.useState)([]);
62
66
  const childrenArray = (0, _react.useMemo)(() => _react.default.Children.toArray(children), [children]);
63
- const rowHeaderIndex = (0, _react.useMemo)(() => childrenArray.findIndex(child => child.type.displayName === _flatTableRowHeader.default.displayName), [childrenArray]);
67
+ const lhsRowHeaderIndex = (0, _react.useMemo)(() => childrenArray.findIndex(child => child.type.displayName === _flatTableRowHeader.default.displayName && child.props.stickyAlignment !== "right"), [childrenArray]);
68
+ const rhsRowHeaderIndex = (0, _react.useMemo)(() => childrenArray.findIndex(child => child.type.displayName === _flatTableRowHeader.default.displayName && child.props.stickyAlignment === "right"), [childrenArray]);
69
+ const noStickyColumnsOverlap = (0, _react.useMemo)(() => {
70
+ const hasLhsColumn = lhsRowHeaderIndex !== -1;
71
+ const hasRhsColumn = rhsRowHeaderIndex !== -1;
72
+ if (!hasLhsColumn || !hasRhsColumn) return true;
73
+ return lhsRowHeaderIndex < rhsRowHeaderIndex;
74
+ }, [lhsRowHeaderIndex, rhsRowHeaderIndex]);
75
+ !noStickyColumnsOverlap ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `Do not render a right hand side \`${_flatTableRowHeader.default.displayName}\` before left hand side \`${_flatTableRowHeader.default.displayName}\``) : (0, _invariant.default)(false) : void 0;
64
76
  const themeContext = (0, _react.useContext)(_flatTable.FlatTableThemeContext);
65
77
  const reportCellWidth = (0, _react.useCallback)((width, index) => {
66
- const copiedArray = stickyCellWidths;
78
+ const isLeftSticky = index < lhsRowHeaderIndex;
79
+ const copiedArray = isLeftSticky ? leftStickyCellWidths : rightStickyCellWidths;
67
80
 
68
81
  if (copiedArray[index] !== undefined) {
69
82
  copiedArray[index] = width;
@@ -71,11 +84,14 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
71
84
  copiedArray.push(width);
72
85
  }
73
86
 
74
- setStickyCellWidths(copiedArray);
75
- }, [stickyCellWidths]);
87
+ if (isLeftSticky) {
88
+ setLeftStickyCellWidths(copiedArray);
89
+ } else {
90
+ setRightStickyCellWidths(copiedArray);
91
+ }
92
+ }, [lhsRowHeaderIndex, leftStickyCellWidths, rightStickyCellWidths]);
76
93
  let interactiveRowProps = {};
77
-
78
- const firstCellIndex = () => childrenArray[0].type === _flatTableCheckbox.default ? 1 : 0;
94
+ const firstCellIndex = childrenArray[0].type === _flatTableCheckbox.default ? 1 : 0;
79
95
 
80
96
  const toggleExpanded = () => setIsExpanded(!isExpanded);
81
97
 
@@ -119,13 +135,22 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
119
135
  }
120
136
  }
121
137
 
138
+ const buildPositionArray = (setter, widthsArray, length) => {
139
+ setter([0, ...Array.from({
140
+ length
141
+ }).map((_, index) => widthsArray.slice(0, index + 1).reduce((a, b) => a + b, 0), 0)]);
142
+ };
143
+
144
+ (0, _react.useLayoutEffect)(() => {
145
+ if (leftStickyCellWidths.length && lhsRowHeaderIndex !== -1) {
146
+ buildPositionArray(setLeftPositions, leftStickyCellWidths, lhsRowHeaderIndex);
147
+ }
148
+ }, [lhsRowHeaderIndex, leftStickyCellWidths]);
122
149
  (0, _react.useLayoutEffect)(() => {
123
- if (stickyCellWidths.length && rowHeaderIndex !== -1) {
124
- setLeftPositions([0, ...Array.from({
125
- length: rowHeaderIndex
126
- }).map((_, index) => stickyCellWidths.slice(0, index + 1).reduce((a, b) => a + b, 0), 0)]);
150
+ if (rightStickyCellWidths.length && rhsRowHeaderIndex !== -1) {
151
+ buildPositionArray(setRightPositions, rightStickyCellWidths, childrenArray.length - (rhsRowHeaderIndex + 1));
127
152
  }
128
- }, [rowHeaderIndex, stickyCellWidths]);
153
+ }, [rhsRowHeaderIndex, rightStickyCellWidths, childrenArray]);
129
154
  (0, _react.useEffect)(() => {
130
155
  setIsExpanded(expanded);
131
156
  }, [expanded]);
@@ -139,9 +164,10 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
139
164
  highlighted: highlighted,
140
165
  selected: selected,
141
166
  onClick: handleClick,
142
- firstCellIndex: firstCellIndex(),
167
+ firstCellIndex: firstCellIndex,
143
168
  ref: rowRef,
144
- rowHeaderIndex: rowHeaderIndex,
169
+ lhsRowHeaderIndex: lhsRowHeaderIndex,
170
+ rhsRowHeaderIndex: rhsRowHeaderIndex,
145
171
  colorTheme: themeContext.colorTheme,
146
172
  size: themeContext.size,
147
173
  stickyOffset: stickyOffset,
@@ -149,15 +175,17 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
149
175
  horizontalBorderColor: horizontalBorderColor,
150
176
  horizontalBorderSize: horizontalBorderSize,
151
177
  applyBorderLeft: applyBorderLeft,
152
- draggable: draggable
178
+ draggable: draggable,
179
+ totalChildren: childrenArray.length
153
180
  }, interactiveRowProps, rest), _react.default.Children.map(children, (child, index) => {
154
181
  return child && /*#__PURE__*/_react.default.cloneElement(child, {
155
- expandable: expandable && index === firstCellIndex(),
156
- onClick: expandable && index === firstCellIndex() && firstColumnExpandable ? () => toggleExpanded() : undefined,
157
- onKeyDown: expandable && index === firstCellIndex() && firstColumnExpandable ? handleCellKeyDown : undefined,
182
+ expandable: expandable && index === firstCellIndex,
183
+ onClick: expandable && index === firstCellIndex && firstColumnExpandable ? () => toggleExpanded() : undefined,
184
+ onKeyDown: expandable && index === firstCellIndex && firstColumnExpandable ? handleCellKeyDown : undefined,
158
185
  cellIndex: index,
159
- reportCellWidth: index < rowHeaderIndex ? reportCellWidth : undefined,
186
+ reportCellWidth: index < lhsRowHeaderIndex || rhsRowHeaderIndex !== -1 && index > rhsRowHeaderIndex ? reportCellWidth : undefined,
160
187
  leftPosition: leftPositions[index],
188
+ rightPosition: rightPositions[childrenArray.length - (index + 1)],
161
189
  ...child.props
162
190
  });
163
191
  }));
@@ -32,22 +32,31 @@ const horizontalBorderSizes = {
32
32
  large: "4px"
33
33
  };
34
34
 
35
- const stickyColumnFocusStyling = (index, theme) => {
35
+ const getLeftStickyStyling = index => index === 0 && (0, _styledComponents.css)`
36
+ &:first-of-type::before {
37
+ border-left: 3px solid var(--colorsSemanticFocus500);
38
+ }
39
+ `;
40
+
41
+ const getRightStickyStyling = (index, totalChildren) => index === totalChildren - 1 && (0, _styledComponents.css)`
42
+ &:last-of-type {
43
+ border-right: 2px solid var(--colorsSemanticFocus500);
44
+ }
45
+ `;
46
+
47
+ const stickyColumnFocusStyling = theme => {
36
48
  return `
37
- border-left: 2px solid
38
- ${index === 0 ? "var(--colorsSemanticFocus500)" : "var(--colorsUtilityMajor100)"};
39
49
  width: calc(100% + 1px);
40
- top: 0;
41
- z-index: ${theme.zIndex.overlay + 2};
50
+ z-index: ${theme.zIndex.overlay};
42
51
  :before {
43
52
  content: "";
44
53
  border-top: 2px solid var(--colorsSemanticFocus500);
45
54
  border-bottom: 2px solid var(--colorsSemanticFocus500);
46
55
  display: block;
47
- left: 0px;
56
+ left: -2px;
48
57
  top: 0px;
49
58
  height: calc(100% - 3px);
50
- width: 101%;
59
+ width: 103%;
51
60
  position: absolute;
52
61
  z-index: ${theme.zIndex.overlay};
53
62
  }
@@ -72,6 +81,20 @@ const borderColor = colorTheme => {
72
81
  }
73
82
  };
74
83
 
84
+ const verticalBorderColor = colorTheme => {
85
+ switch (colorTheme) {
86
+ case "transparent-base":
87
+ return "var(--colorsUtilityMajor025)";
88
+
89
+ case "transparent-white":
90
+ return "var(--colorsUtilityYang100)";
91
+ // default theme is "dark"
92
+
93
+ default:
94
+ return "var(--colorsUtilityMajor100)";
95
+ }
96
+ };
97
+
75
98
  const StyledFlatTableRow = _styledComponents.default.tr`
76
99
  ${({
77
100
  bgColor,
@@ -80,7 +103,9 @@ const StyledFlatTableRow = _styledComponents.default.tr`
80
103
  stickyOffset,
81
104
  isRowInteractive,
82
105
  isFirstColumnInteractive,
83
- rowHeaderIndex,
106
+ lhsRowHeaderIndex,
107
+ rhsRowHeaderIndex,
108
+ totalChildren,
84
109
  firstCellIndex,
85
110
  colorTheme,
86
111
  expandable,
@@ -126,6 +151,31 @@ const StyledFlatTableRow = _styledComponents.default.tr`
126
151
  `}
127
152
  }
128
153
 
154
+ ${_flatTableRowHeader.StyledFlatTableRowHeader} + td {
155
+ border-left: none;
156
+ }
157
+
158
+ ${lhsRowHeaderIndex !== -1 && (0, _styledComponents.css)`
159
+ ${_flatTableRowHeader.StyledFlatTableRowHeader}:nth-child(${lhsRowHeaderIndex + 1}) {
160
+ border-right: 2px solid ${verticalBorderColor(colorTheme)};
161
+ }
162
+ `}
163
+
164
+ ${rhsRowHeaderIndex !== -1 && (0, _styledComponents.css)`
165
+ ${_flatTableRowHeader.StyledFlatTableRowHeader}:nth-child(${rhsRowHeaderIndex + 1}) {
166
+ border-left: 2px solid ${verticalBorderColor(colorTheme)};
167
+ }
168
+ ${_flatTableHeader.default}:nth-child(${rhsRowHeaderIndex}) {
169
+ border-right: none;
170
+ }
171
+ `}
172
+
173
+ ${rhsRowHeaderIndex === totalChildren - 1 && (0, _styledComponents.css)`
174
+ td:last-of-type {
175
+ border-right: none;
176
+ }
177
+ `}
178
+
129
179
  ${_flatTableHeader.default} {
130
180
  border-bottom: 1px solid ${borderColor(colorTheme)};
131
181
 
@@ -178,17 +228,27 @@ const StyledFlatTableRow = _styledComponents.default.tr`
178
228
  }
179
229
  }
180
230
 
231
+ td:first-of-type:not(:nth-child(${lhsRowHeaderIndex + 2}))::before {
232
+ border-left: 3px solid var(--colorsSemanticFocus500);
233
+ }
234
+
235
+ td:last-of-type:not(:nth-child(${rhsRowHeaderIndex})) {
236
+ border-right: 2px solid var(--colorsSemanticFocus500);
237
+ }
238
+
181
239
  ${_flatTableRowHeader.StyledFlatTableRowHeader} {
182
- ${stickyColumnFocusStyling(rowHeaderIndex, theme)}
240
+ ${getLeftStickyStyling(lhsRowHeaderIndex)}
241
+ ${getRightStickyStyling(rhsRowHeaderIndex, totalChildren)}
242
+ ${stickyColumnFocusStyling(theme)}
183
243
  }
184
244
 
185
- ${![-1, 0].includes(rowHeaderIndex) && (0, _styledComponents.css)`
245
+ ${![-1, 0].includes(lhsRowHeaderIndex) && (0, _styledComponents.css)`
186
246
  ${Array.from({
187
- length: rowHeaderIndex
247
+ length: lhsRowHeaderIndex
188
248
  }).map((_, index) => {
189
249
  return `
190
250
  td:nth-of-type(${index + 1}) {
191
- ${stickyColumnFocusStyling(index, theme)}
251
+ ${stickyColumnFocusStyling(theme)}
192
252
  }
193
253
  `;
194
254
  })}
@@ -218,16 +278,6 @@ const StyledFlatTableRow = _styledComponents.default.tr`
218
278
  }
219
279
  `}
220
280
 
221
- ${![-1, 0].includes(rowHeaderIndex) && (0, _styledComponents.css)`
222
- td:nth-of-type(${rowHeaderIndex + 1}) {
223
- border-left: 1px solid
224
- ${customBorderColor || "var(--colorsUtilityMajor100)"};
225
- }
226
-
227
- th:nth-of-type(${rowHeaderIndex + 2}) {
228
- border-left: 1px solid ${customBorderColor || borderColor(colorTheme)};
229
- }
230
- `}
231
281
 
232
282
  ${applyBorderLeft && (0, _styledComponents.css)`
233
283
  th:first-of-type {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
@@ -19,6 +19,10 @@ var _flatTableRowHeader = require("./flat-table-row-header.style");
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
23
+
24
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+
22
26
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
27
 
24
28
  const paddingPropTypes = (0, _utils.filterStyledSystemPaddingProps)(_propTypes2.default.space);
@@ -33,22 +37,32 @@ const FlatTableRowHeader = ({
33
37
  onClick,
34
38
  onKeyDown,
35
39
  leftPosition,
40
+ rightPosition,
36
41
  truncate,
37
42
  title,
43
+ stickyAlignment = "left",
38
44
  ...rest
39
45
  }) => {
46
+ const handleOnClick = (0, _react.useCallback)(ev => {
47
+ if (expandable && onClick) onClick(ev);
48
+ }, [expandable, onClick]);
49
+ const handleOnKeyDown = (0, _react.useCallback)(ev => {
50
+ if (expandable && onKeyDown) onKeyDown(ev);
51
+ }, [expandable, onKeyDown]);
40
52
  return /*#__PURE__*/_react.default.createElement(_flatTableRowHeader.StyledFlatTableRowHeader, _extends({
41
- leftPosition: leftPosition || 0,
53
+ leftPosition: stickyAlignment === "left" ? leftPosition || 0 : undefined,
54
+ rightPosition: stickyAlignment === "right" ? rightPosition || 0 : undefined,
42
55
  align: align,
43
56
  "data-element": "flat-table-row-header",
44
57
  colWidth: width,
45
58
  py: py || "10px",
46
59
  px: px || 3,
47
- onClick: expandable && onClick ? onClick : undefined,
60
+ onClick: handleOnClick,
48
61
  tabIndex: expandable && onClick ? 0 : undefined,
49
- onKeyDown: expandable && onKeyDown ? onKeyDown : undefined,
62
+ onKeyDown: handleOnKeyDown,
50
63
  isTruncated: truncate,
51
- expandable: expandable
64
+ expandable: expandable,
65
+ stickyAlignment: stickyAlignment
52
66
  }, rest), /*#__PURE__*/_react.default.createElement(_flatTableRowHeader.StyledFlatTableRowHeaderContent, {
53
67
  title: truncate && !title && typeof children === "string" ? children : title,
54
68
  expandable: expandable
@@ -98,7 +112,22 @@ FlatTableRowHeader.propTypes = {
98
112
  verticalBorder: _propTypes.default.oneOf(["small", "medium", "large"]),
99
113
 
100
114
  /** Sets a vertical right border color, provide design token, any color from palette or any valid css color value. */
101
- verticalBorderColor: _propTypes.default.string
115
+ verticalBorderColor: _propTypes.default.string,
116
+
117
+ /** Defines whether the column should be sticky on the left or right hand side of the Table */
118
+ stickyAlignment: _propTypes.default.oneOf(["left", "right"]),
119
+
120
+ /**
121
+ * @private
122
+ * @ignore
123
+ */
124
+ leftPosition: _propTypes.default.number,
125
+
126
+ /**
127
+ * @private
128
+ * @ignore
129
+ */
130
+ rightPosition: _propTypes.default.number
102
131
  };
103
132
  FlatTableRowHeader.displayName = "FlatTableRowHeader";
104
133
  var _default = FlatTableRowHeader;
@@ -16,6 +16,8 @@ export interface FlatTableRowHeaderProps extends PaddingProps {
16
16
  verticalBorder?: TableBorderSize;
17
17
  /** Sets the color of the right border */
18
18
  verticalBorderColor?: string;
19
+ /** Defines whether the column should be sticky on the left or right hand side of the Table */
20
+ stickyAlignment?: "left" | "right";
19
21
  }
20
22
 
21
23
  declare function FlatTableRowHeader(
@@ -30,10 +30,12 @@ const StyledFlatTableRowHeader = _styledComponents.default.th`
30
30
  theme,
31
31
  colWidth,
32
32
  leftPosition,
33
+ rightPosition,
33
34
  isTruncated,
34
35
  expandable,
35
36
  verticalBorder,
36
- verticalBorderColor
37
+ verticalBorderColor,
38
+ stickyAlignment
37
39
  }) => (0, _styledComponents.css)`
38
40
  background-color: var(--colorsUtilityYang100);
39
41
  border: 1px solid var(--colorsUtilityMajor100);
@@ -69,14 +71,19 @@ const StyledFlatTableRowHeader = _styledComponents.default.th`
69
71
  ${_styledSystem.padding}
70
72
  }
71
73
 
72
- left: ${leftPosition}px;
74
+ ${leftPosition !== undefined && (0, _styledComponents.css)`
75
+ left: ${leftPosition}px;
76
+ `}
77
+ ${rightPosition !== undefined && (0, _styledComponents.css)`
78
+ right: ${rightPosition}px;
79
+ `}
73
80
 
74
81
  ${verticalBorder && (0, _styledComponents.css)`
75
- border-right-width: ${verticalBorderSizes[verticalBorder]};
82
+ border-${stickyAlignment === "right" ? "left" : "right"}-width: ${verticalBorderSizes[verticalBorder]};
76
83
  `}
77
84
 
78
85
  ${verticalBorderColor && (0, _styledComponents.css)`
79
- border-right-color: ${(0, _color.toColor)(theme, verticalBorderColor)};
86
+ border-${stickyAlignment === "right" ? "left" : "right"}-color: ${(0, _color.toColor)(theme, verticalBorderColor)};
80
87
  `}
81
88
  }
82
89