carbon-react 142.11.7 → 142.11.8
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/flat-table/__internal__/build-position-map.js +2 -0
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.d.ts +2 -1
- package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +13 -2
- package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +2 -1
- package/esm/components/flat-table/flat-table.component.d.ts +2 -1
- package/esm/components/flat-table/flat-table.component.js +9 -4
- package/esm/components/textarea/textarea.component.js +1 -1
- package/lib/components/flat-table/__internal__/build-position-map.js +2 -0
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.d.ts +2 -1
- package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +13 -2
- package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +2 -1
- package/lib/components/flat-table/flat-table.component.d.ts +2 -1
- package/lib/components/flat-table/flat-table.component.js +9 -4
- package/lib/components/textarea/textarea.component.js +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,8 @@ export default ((array, propertyName) => array.reduce((acc, _, index) => {
|
|
|
5
5
|
acc[currentId] = 0;
|
|
6
6
|
} else {
|
|
7
7
|
const previousId = array[index - 1].getAttribute("id");
|
|
8
|
+
|
|
9
|
+
/* istanbul ignore else */
|
|
8
10
|
if (previousId) {
|
|
9
11
|
acc[currentId] = acc[previousId] + array[index - 1][propertyName];
|
|
10
12
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags";
|
|
2
3
|
import { TableBorderSize } from "..";
|
|
3
4
|
import { FlatTableRowDraggableProps } from "./__internal__/flat-table-row-draggable.component";
|
|
4
|
-
export interface FlatTableRowProps {
|
|
5
|
+
export interface FlatTableRowProps extends Omit<TagProps, "data-component"> {
|
|
5
6
|
/** Overrides default cell color, provide design token, any color from palette or any valid css color value. */
|
|
6
7
|
bgColor?: string;
|
|
7
8
|
/** Array of FlatTableHeader or FlatTableCell. FlatTableRowHeader could also be passed. */
|
|
@@ -29,6 +29,8 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
|
|
|
29
29
|
draggable,
|
|
30
30
|
findItem,
|
|
31
31
|
moveItem,
|
|
32
|
+
"data-element": dataElement,
|
|
33
|
+
"data-role": dataRole,
|
|
32
34
|
...rest
|
|
33
35
|
}, ref) => {
|
|
34
36
|
const internalId = useRef(id ? String(id) : guid());
|
|
@@ -158,12 +160,17 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
|
|
|
158
160
|
};
|
|
159
161
|
}, [addRow, removeRow]);
|
|
160
162
|
const isFirstSubRow = firstRowId === internalId.current;
|
|
163
|
+
const getDataElement = () => {
|
|
164
|
+
if (dataElement) return dataElement;
|
|
165
|
+
return isSubRow ? "flat-table-sub-row" : "flat-table-row";
|
|
166
|
+
};
|
|
161
167
|
const rowComponent = () => /*#__PURE__*/React.createElement(StyledFlatTableRow, _extends({
|
|
162
168
|
isInSidebar: isInSidebar,
|
|
163
169
|
expandable: expandable,
|
|
164
170
|
isSubRow: isSubRow,
|
|
165
171
|
isFirstSubRow: isFirstSubRow,
|
|
166
|
-
"data-element":
|
|
172
|
+
"data-element": getDataElement(),
|
|
173
|
+
"data-role": dataRole,
|
|
167
174
|
highlighted: highlighted,
|
|
168
175
|
selected: selected,
|
|
169
176
|
onClick: handleClick,
|
|
@@ -183,7 +190,9 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
|
|
|
183
190
|
"data-selected": selected && expandableArea === "wholeRow",
|
|
184
191
|
"data-highlighted": highlighted && expandableArea === "wholeRow",
|
|
185
192
|
rowHeight: rowRef?.current?.offsetHeight
|
|
186
|
-
}, interactiveRowProps, rest
|
|
193
|
+
}, interactiveRowProps, rest, {
|
|
194
|
+
"data-component": "flat-table-row"
|
|
195
|
+
}), /*#__PURE__*/React.createElement(FlatTableRowContext.Provider, {
|
|
187
196
|
value: {
|
|
188
197
|
firstCellId,
|
|
189
198
|
expandable,
|
|
@@ -208,6 +217,8 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
208
217
|
FlatTableRow.propTypes = {
|
|
209
218
|
"bgColor": PropTypes.string,
|
|
210
219
|
"children": PropTypes.node,
|
|
220
|
+
"data-element": PropTypes.string,
|
|
221
|
+
"data-role": PropTypes.string,
|
|
211
222
|
"draggable": PropTypes.bool,
|
|
212
223
|
"expandable": PropTypes.bool,
|
|
213
224
|
"expandableArea": PropTypes.oneOf(["firstColumn", "wholeRow"]),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
3
|
import * as DesignTokens from "@sage/design-tokens/js/base/common";
|
|
4
|
-
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
|
+
export interface FlatTableProps extends MarginProps, Omit<TagProps, "data-component"> {
|
|
5
6
|
/** The HTML id of the element that contains a description of this table. */
|
|
6
7
|
ariaDescribedby?: string;
|
|
7
8
|
/** A string to render as the table's caption */
|
|
@@ -108,6 +108,8 @@ export const FlatTable = ({
|
|
|
108
108
|
} else {
|
|
109
109
|
// it may be that an element within the row currently has focus
|
|
110
110
|
const index = findParentIndexOfFocusedChild(focusableElementsArray);
|
|
111
|
+
|
|
112
|
+
/* istanbul ignore else */
|
|
111
113
|
if (index !== -1 && index < focusableElementsArray.length) {
|
|
112
114
|
focusableElementsArray[index + 1]?.focus();
|
|
113
115
|
}
|
|
@@ -135,7 +137,6 @@ export const FlatTable = ({
|
|
|
135
137
|
};
|
|
136
138
|
return /*#__PURE__*/React.createElement(StyledFlatTableWrapper, _extends({
|
|
137
139
|
ref: wrapperRef,
|
|
138
|
-
"data-component": "flat-table-wrapper",
|
|
139
140
|
"data-role": "flat-table-wrapper",
|
|
140
141
|
isInSidebar: isInSidebar,
|
|
141
142
|
hasStickyHead: hasStickyHead,
|
|
@@ -160,7 +161,9 @@ export const FlatTable = ({
|
|
|
160
161
|
lastColRowSpanIndex: lastColRowSpanIndex,
|
|
161
162
|
onKeyDown: handleKeyDown,
|
|
162
163
|
isFocused: focused
|
|
163
|
-
}, rest
|
|
164
|
+
}, rest, {
|
|
165
|
+
"data-component": "flat-table-wrapper"
|
|
166
|
+
}), /*#__PURE__*/React.createElement(StyledTableContainer, {
|
|
164
167
|
ref: container,
|
|
165
168
|
onFocus: () => {
|
|
166
169
|
if (container.current === document.activeElement) {
|
|
@@ -170,7 +173,8 @@ export const FlatTable = ({
|
|
|
170
173
|
onBlur: () => setFocused(false),
|
|
171
174
|
tabIndex: 0,
|
|
172
175
|
overflowX: overflowX,
|
|
173
|
-
width: width
|
|
176
|
+
width: width,
|
|
177
|
+
"data-role": "flat-table-container"
|
|
174
178
|
}, /*#__PURE__*/React.createElement(StyledFlatTable, _extends({
|
|
175
179
|
ref: tableRef,
|
|
176
180
|
"data-component": "flat-table"
|
|
@@ -181,7 +185,8 @@ export const FlatTable = ({
|
|
|
181
185
|
getTabStopElementId
|
|
182
186
|
}
|
|
183
187
|
}, children))), footer && /*#__PURE__*/React.createElement(StyledFlatTableFooter, {
|
|
184
|
-
hasStickyFooter: hasStickyFooter
|
|
188
|
+
hasStickyFooter: hasStickyFooter,
|
|
189
|
+
"data-role": "flat-table-footer"
|
|
185
190
|
}, footer));
|
|
186
191
|
};
|
|
187
192
|
FlatTable.displayName = "FlatTable";
|
|
@@ -116,7 +116,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
|
|
|
116
116
|
scrollElement = scrollElement?.parentElement || null;
|
|
117
117
|
}
|
|
118
118
|
const scrollPosition = scrollElement?.scrollTop;
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
// Set the height so all content is shown
|
|
121
121
|
textarea.style.height = `${Math.max(textarea.scrollHeight, textareaMinHeight)}px`;
|
|
122
122
|
if (scrollElement && scrollPosition) {
|
|
@@ -11,6 +11,8 @@ var _default = (array, propertyName) => array.reduce((acc, _, index) => {
|
|
|
11
11
|
acc[currentId] = 0;
|
|
12
12
|
} else {
|
|
13
13
|
const previousId = array[index - 1].getAttribute("id");
|
|
14
|
+
|
|
15
|
+
/* istanbul ignore else */
|
|
14
16
|
if (previousId) {
|
|
15
17
|
acc[currentId] = acc[previousId] + array[index - 1][propertyName];
|
|
16
18
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { TagProps } from "../../../__internal__/utils/helpers/tags";
|
|
2
3
|
import { TableBorderSize } from "..";
|
|
3
4
|
import { FlatTableRowDraggableProps } from "./__internal__/flat-table-row-draggable.component";
|
|
4
|
-
export interface FlatTableRowProps {
|
|
5
|
+
export interface FlatTableRowProps extends Omit<TagProps, "data-component"> {
|
|
5
6
|
/** Overrides default cell color, provide design token, any color from palette or any valid css color value. */
|
|
6
7
|
bgColor?: string;
|
|
7
8
|
/** Array of FlatTableHeader or FlatTableCell. FlatTableRowHeader could also be passed. */
|
|
@@ -38,6 +38,8 @@ const FlatTableRow = exports.FlatTableRow = /*#__PURE__*/_react.default.forwardR
|
|
|
38
38
|
draggable,
|
|
39
39
|
findItem,
|
|
40
40
|
moveItem,
|
|
41
|
+
"data-element": dataElement,
|
|
42
|
+
"data-role": dataRole,
|
|
41
43
|
...rest
|
|
42
44
|
}, ref) => {
|
|
43
45
|
const internalId = (0, _react.useRef)(id ? String(id) : (0, _guid.default)());
|
|
@@ -167,12 +169,17 @@ const FlatTableRow = exports.FlatTableRow = /*#__PURE__*/_react.default.forwardR
|
|
|
167
169
|
};
|
|
168
170
|
}, [addRow, removeRow]);
|
|
169
171
|
const isFirstSubRow = firstRowId === internalId.current;
|
|
172
|
+
const getDataElement = () => {
|
|
173
|
+
if (dataElement) return dataElement;
|
|
174
|
+
return isSubRow ? "flat-table-sub-row" : "flat-table-row";
|
|
175
|
+
};
|
|
170
176
|
const rowComponent = () => /*#__PURE__*/_react.default.createElement(_flatTableRow.default, _extends({
|
|
171
177
|
isInSidebar: isInSidebar,
|
|
172
178
|
expandable: expandable,
|
|
173
179
|
isSubRow: isSubRow,
|
|
174
180
|
isFirstSubRow: isFirstSubRow,
|
|
175
|
-
"data-element":
|
|
181
|
+
"data-element": getDataElement(),
|
|
182
|
+
"data-role": dataRole,
|
|
176
183
|
highlighted: highlighted,
|
|
177
184
|
selected: selected,
|
|
178
185
|
onClick: handleClick,
|
|
@@ -192,7 +199,9 @@ const FlatTableRow = exports.FlatTableRow = /*#__PURE__*/_react.default.forwardR
|
|
|
192
199
|
"data-selected": selected && expandableArea === "wholeRow",
|
|
193
200
|
"data-highlighted": highlighted && expandableArea === "wholeRow",
|
|
194
201
|
rowHeight: rowRef?.current?.offsetHeight
|
|
195
|
-
}, interactiveRowProps, rest
|
|
202
|
+
}, interactiveRowProps, rest, {
|
|
203
|
+
"data-component": "flat-table-row"
|
|
204
|
+
}), /*#__PURE__*/_react.default.createElement(_flatTableRow2.default.Provider, {
|
|
196
205
|
value: {
|
|
197
206
|
firstCellId,
|
|
198
207
|
expandable,
|
|
@@ -217,6 +226,8 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
217
226
|
FlatTableRow.propTypes = {
|
|
218
227
|
"bgColor": _propTypes.default.string,
|
|
219
228
|
"children": _propTypes.default.node,
|
|
229
|
+
"data-element": _propTypes.default.string,
|
|
230
|
+
"data-role": _propTypes.default.string,
|
|
220
231
|
"draggable": _propTypes.default.bool,
|
|
221
232
|
"expandable": _propTypes.default.bool,
|
|
222
233
|
"expandableArea": _propTypes.default.oneOf(["firstColumn", "wholeRow"]),
|
|
@@ -242,7 +242,8 @@ const StyledFlatTableRow = _styledComponents.default.tr`
|
|
|
242
242
|
border: none;
|
|
243
243
|
}
|
|
244
244
|
`}
|
|
245
|
-
${!theme.focusRedesignOptOut &&
|
|
245
|
+
${!theme.focusRedesignOptOut && /* istanbul ignore next */
|
|
246
|
+
(0, _styledComponents.css)`
|
|
246
247
|
position: -webkit-sticky;
|
|
247
248
|
:after {
|
|
248
249
|
border: none;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
3
|
import * as DesignTokens from "@sage/design-tokens/js/base/common";
|
|
4
|
-
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
5
|
+
export interface FlatTableProps extends MarginProps, Omit<TagProps, "data-component"> {
|
|
5
6
|
/** The HTML id of the element that contains a description of this table. */
|
|
6
7
|
ariaDescribedby?: string;
|
|
7
8
|
/** A string to render as the table's caption */
|
|
@@ -117,6 +117,8 @@ const FlatTable = ({
|
|
|
117
117
|
} else {
|
|
118
118
|
// it may be that an element within the row currently has focus
|
|
119
119
|
const index = findParentIndexOfFocusedChild(focusableElementsArray);
|
|
120
|
+
|
|
121
|
+
/* istanbul ignore else */
|
|
120
122
|
if (index !== -1 && index < focusableElementsArray.length) {
|
|
121
123
|
focusableElementsArray[index + 1]?.focus();
|
|
122
124
|
}
|
|
@@ -144,7 +146,6 @@ const FlatTable = ({
|
|
|
144
146
|
};
|
|
145
147
|
return /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableWrapper, _extends({
|
|
146
148
|
ref: wrapperRef,
|
|
147
|
-
"data-component": "flat-table-wrapper",
|
|
148
149
|
"data-role": "flat-table-wrapper",
|
|
149
150
|
isInSidebar: isInSidebar,
|
|
150
151
|
hasStickyHead: hasStickyHead,
|
|
@@ -169,7 +170,9 @@ const FlatTable = ({
|
|
|
169
170
|
lastColRowSpanIndex: lastColRowSpanIndex,
|
|
170
171
|
onKeyDown: handleKeyDown,
|
|
171
172
|
isFocused: focused
|
|
172
|
-
}, rest
|
|
173
|
+
}, rest, {
|
|
174
|
+
"data-component": "flat-table-wrapper"
|
|
175
|
+
}), /*#__PURE__*/_react.default.createElement(_flatTable.StyledTableContainer, {
|
|
173
176
|
ref: container,
|
|
174
177
|
onFocus: () => {
|
|
175
178
|
if (container.current === document.activeElement) {
|
|
@@ -179,7 +182,8 @@ const FlatTable = ({
|
|
|
179
182
|
onBlur: () => setFocused(false),
|
|
180
183
|
tabIndex: 0,
|
|
181
184
|
overflowX: overflowX,
|
|
182
|
-
width: width
|
|
185
|
+
width: width,
|
|
186
|
+
"data-role": "flat-table-container"
|
|
183
187
|
}, /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTable, _extends({
|
|
184
188
|
ref: tableRef,
|
|
185
189
|
"data-component": "flat-table"
|
|
@@ -190,7 +194,8 @@ const FlatTable = ({
|
|
|
190
194
|
getTabStopElementId
|
|
191
195
|
}
|
|
192
196
|
}, children))), footer && /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableFooter, {
|
|
193
|
-
hasStickyFooter: hasStickyFooter
|
|
197
|
+
hasStickyFooter: hasStickyFooter,
|
|
198
|
+
"data-role": "flat-table-footer"
|
|
194
199
|
}, footer));
|
|
195
200
|
};
|
|
196
201
|
exports.FlatTable = FlatTable;
|
|
@@ -125,7 +125,7 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
|
|
|
125
125
|
scrollElement = scrollElement?.parentElement || null;
|
|
126
126
|
}
|
|
127
127
|
const scrollPosition = scrollElement?.scrollTop;
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
// Set the height so all content is shown
|
|
130
130
|
textarea.style.height = `${Math.max(textarea.scrollHeight, textareaMinHeight)}px`;
|
|
131
131
|
if (scrollElement && scrollPosition) {
|