+
{frozenView}
{scrollableView}
@@ -1091,7 +1094,7 @@ export const TreeTable = React.forwardRef((inProps, ref) => {
const resizeHelperProps = mergeProps(
{
className: ptCallbacks.cx('resizeHelper'),
- style: ptCallbacks.sx('resizeHelper')
+ style: { display: 'none' }
},
ptCallbacks.ptm('resizeHelper')
);
@@ -1105,7 +1108,7 @@ export const TreeTable = React.forwardRef((inProps, ref) => {
const reorderIndicatorUpProps = mergeProps(
{
className: ptCallbacks.cx('reorderIndicatorUp'),
- style: ptCallbacks.sx('reorderIndicatorUp')
+ style: { position: 'absolute', display: 'none' }
},
ptCallbacks.ptm('reorderIndicatorUp')
);
@@ -1116,7 +1119,7 @@ export const TreeTable = React.forwardRef((inProps, ref) => {
{reorderIndicatorUpIcon}
);
- const reorderIndicatorDownProps = { className: ptCallbacks.sx('reorderIndicatorDown'), style: ptCallbacks.sx('reorderIndicatorDown') };
+ const reorderIndicatorDownProps = { className: ptCallbacks.sx('reorderIndicatorDown'), style: { position: 'absolute', display: 'none' } };
const reorderIndicatorDownIconProps = mergeProps(ptCallbacks.ptm('reorderIndicatorDownIcon'));
const reorderIndicatorDownIcon = IconUtils.getJSXIcon(props.reorderIndicatorDownIcon ||
, { ...reorderIndicatorDownIconProps }, { props });
const reorderIndicatorDown = props.reorderableColumns && (
diff --git a/components/lib/treetable/TreeTableBase.js b/components/lib/treetable/TreeTableBase.js
index 7e6f2e7631..85023b7421 100644
--- a/components/lib/treetable/TreeTableBase.js
+++ b/components/lib/treetable/TreeTableBase.js
@@ -204,16 +204,6 @@ const classes = {
scrollableColgroup: 'p-treetable-scrollable-colgroup'
};
-const inlineStyles = {
- resizeHelper: { display: 'none' },
- reorderIndicatorUp: { position: 'absolute', display: 'none' },
- reorderIndicatorDown: { position: 'absolute', display: 'none' },
- rowToggler: ({ rowProps: props }) => ({ marginLeft: props.level * 16 + 'px', visibility: props.node.leaf === false || (props.node.children && props.node.children.length) ? 'visible' : 'hidden' }),
- scrollableBody: ({ scrolaableProps: props }) => (!props.frozen && props.scrollHeight ? { overflowY: 'scroll' } : undefined),
- scrollableBodyTable: { top: '0' },
- scrollable: ({ width, left }) => ({ width: width, left: left })
-};
-
export const TreeTableBase = ComponentBase.extend({
defaultProps: {
__TYPE: 'TreeTable',
@@ -303,7 +293,6 @@ export const TreeTableBase = ComponentBase.extend({
},
css: {
classes,
- styles,
- inlineStyles
+ styles
}
});
diff --git a/components/lib/treetable/TreeTableBody.js b/components/lib/treetable/TreeTableBody.js
index dc9409ad3c..3cddcbbab7 100644
--- a/components/lib/treetable/TreeTableBody.js
+++ b/components/lib/treetable/TreeTableBody.js
@@ -38,7 +38,7 @@ export const TreeTableBody = React.memo((props) => {
const targetNode = event.target.nodeName;
- if (targetNode === 'INPUT' || targetNode === 'BUTTON' || targetNode === 'A' || DomHandler.hasClass(event.target, 'p-clickable')) {
+ if (targetNode === 'INPUT' || targetNode === 'BUTTON' || targetNode === 'A' || DomHandler.getAttribute(event.target, 'data-pc-section') === 'columnresizer') {
return;
}
@@ -229,16 +229,16 @@ export const TreeTableBody = React.memo((props) => {
},
ptm('emptyMessage')
);
- const bodyCellProps = mergeProps(
+ const emptyMessageCellProps = mergeProps(
{
colSpan
},
- ptm('bodyCell')
+ ptm('emptyMessageCell')
);
return (
- {content} |
+ {content} |
);
}
diff --git a/components/lib/treetable/TreeTableBodyCell.js b/components/lib/treetable/TreeTableBodyCell.js
index 4896360da4..93862456bf 100644
--- a/components/lib/treetable/TreeTableBodyCell.js
+++ b/components/lib/treetable/TreeTableBodyCell.js
@@ -13,18 +13,29 @@ export const TreeTableBodyCell = (props) => {
const tabIndexTimeout = React.useRef(null);
const getColumnProp = (name) => ColumnBase.getCProp(props.column, name);
const getColumnProps = (column) => ColumnBase.getCProps(column);
- const { ptmo, cx } = props.ptCallbacks;
+ const { ptm, ptmo, cx } = props.ptCallbacks;
const getColumnPTOptions = (key) => {
+ const isSingleSelectionMode = props.metaData.props.selectionMode === 'single';
+ const isMultipleSelectionMode = props.metaData.props.selectionMode === 'multiple';
const cProps = getColumnProps(props.column);
-
- return ptmo(getColumnProp('pt'), key, {
+ const columnMetadata = {
props: cProps,
parent: props.metaData,
state: {
editing: editingState
+ },
+ context: {
+ index: props.index,
+ selectable: isSingleSelectionMode || isMultipleSelectionMode,
+ selected: props.selected,
+ scrollable: props.metaData.props.scrollable,
+ frozen: getColumnProp('frozen'),
+ showGridlines: props.metaData.props.showGridlines
}
- });
+ };
+
+ return mergeProps(ptm(`column.${key}`, { column: columnMetadata }), ptm(`column.${key}`, columnMetadata), ptmo(cProps, key, columnMetadata));
};
const field = getColumnProp('field') || `field_${props.index}`;
@@ -222,8 +233,8 @@ export const TreeTableBodyCell = (props) => {
onClick: (e) => onClick(e),
onKeyDown: (e) => onKeyDown(e)
},
- getColumnPTOptions('bodyCell'),
- getColumnPTOptions('root')
+ getColumnPTOptions('root'),
+ getColumnPTOptions('bodyCell')
);
return (
diff --git a/components/lib/treetable/TreeTableFooter.js b/components/lib/treetable/TreeTableFooter.js
index fc056db7e3..a253c16418 100644
--- a/components/lib/treetable/TreeTableFooter.js
+++ b/components/lib/treetable/TreeTableFooter.js
@@ -16,10 +16,12 @@ export const TreeTableFooter = React.memo((props) => {
};
const getColumnPTOptions = (column, key) => {
- return ptmo(getColumnProp(column, 'pt'), key, {
+ const columnMetadata = {
props: getColumnProps(column),
parent: props.metaData
- });
+ };
+
+ return mergeProps(ptm(`column.${key}`, { column: columnMetadata }), ptm(`column.${key}`, columnMetadata), ptmo(getColumnProps(column), key, columnMetadata));
};
const createFooterCell = (column, index) => {
diff --git a/components/lib/treetable/TreeTableHeader.js b/components/lib/treetable/TreeTableHeader.js
index 6d7bdea7f1..45eb5053b6 100644
--- a/components/lib/treetable/TreeTableHeader.js
+++ b/components/lib/treetable/TreeTableHeader.js
@@ -13,24 +13,20 @@ export const TreeTableHeader = React.memo((props) => {
const { ptm, ptmo, cx } = props.ptCallbacks;
const filterTimeout = React.useRef(null);
- const getColumnProps = (column) => {
- return ptmo(ColumnBase.getCProps(column));
+ const getColumnProp = (column, ...args) => {
+ return column ? (typeof args[0] === 'string' ? ColumnBase.getCProp(column, args[0]) : ColumnBase.getCProp(args[0] || column, args[1])) : null;
};
+ const getColumnProps = (column) => ColumnBase.getCProps(column);
+
const getColumnPTOptions = (column, key, params) => {
- return ptmo(ColumnBase.getCProp(column, 'pt'), key, {
+ const columnMetadata = {
props: getColumnProps(column),
parent: props.metaData,
...params
- });
- };
-
- const ptHeaderCellOptions = (column) => {
- return {
- context: {
- frozen: getColumnProp(column, 'frozen')
- }
};
+
+ return mergeProps(ptm(`column.${key}`, { column: columnMetadata }), ptm(`column.${key}`, columnMetadata), ptmo(getColumnProps(column), key, columnMetadata));
};
const onHeaderClick = (event, column) => {
@@ -38,10 +34,10 @@ export const TreeTableHeader = React.memo((props) => {
const targetNode = event.target;
if (
- DomHandler.hasClass(targetNode, 'p-sortable-column') ||
- DomHandler.hasClass(targetNode, 'p-column-title') ||
- DomHandler.hasClass(targetNode, 'p-sortable-column-icon') ||
- DomHandler.hasClass(targetNode.parentElement, 'p-sortable-column-icon')
+ DomHandler.getAttribute(targetNode, 'data-p-sortable-column') === true ||
+ DomHandler.getAttribute(targetNode, 'data-pc-section') === 'headertitle' ||
+ DomHandler.getAttribute(targetNode, 'data-pc-section') === 'sorticon' ||
+ DomHandler.getAttribute(targetNode.parentElement, 'data-pc-section') === 'sorticon'
) {
props.onSort({
originalEvent: event,
@@ -168,17 +164,17 @@ export const TreeTableHeader = React.memo((props) => {
}
};
- const getColumnProp = (column, ...args) => {
- return column ? (typeof args[0] === 'string' ? ColumnBase.getCProp(column, args[0]) : ColumnBase.getCProp(args[0] || column, args[1])) : null;
- };
-
const createSortIcon = (column, sorted, sortOrder) => {
if (getColumnProp(column, 'sortable')) {
const sortIconProps = mergeProps(
{
className: cx('sortIcon')
},
- getColumnPTOptions(column, 'sortIcon')
+ getColumnPTOptions(column, 'sortIcon', {
+ context: {
+ sorted
+ }
+ })
);
let icon = sorted ? sortOrder < 0 ?
:
:
;
let sortIcon = IconUtils.getJSXIcon(props.sortIcon || icon, { ...sortIconProps }, { props, sorted, sortOrder });
@@ -257,10 +253,17 @@ export const TreeTableHeader = React.memo((props) => {
className: classNames(cx('headerCell', { options }), getColumnProp(column, 'filterHeaderClassName')),
style: getColumnProp(column, 'filterHeaderStyle') || getColumnProp(column, 'style'),
rowSpan: getColumnProp(column, 'rowSpan'),
- colSpan: getColumnProp(column, 'colSpan')
+ colSpan: getColumnProp(column, 'colSpan'),
+ 'data-p-sortable-column': getColumnProp(column, 'sortable'),
+ 'data-p-resizable-column': props.resizableColumns,
+ 'data-p-frozen-column': getColumnProp(column, 'frozen')
},
- getColumnPTOptions(column, 'headerCell', ptHeaderCellOptions(column)),
- getColumnPTOptions(column, 'root')
+ getColumnPTOptions(column, 'root'),
+ getColumnPTOptions(column, 'headerCell', {
+ context: {
+ frozen: getColumnProp(column, 'frozen')
+ }
+ })
);
return
{filterElement} | ;
@@ -299,10 +302,20 @@ export const TreeTableHeader = React.memo((props) => {
onDragStart: (e) => onDragStart(e, column),
onDragOver: (e) => onDragOver(e, column),
onDragLeave: (e) => onDragLeave(e, column),
- onDrop: (e) => onDrop(e, column)
+ onDrop: (e) => onDrop(e, column),
+ 'data-p-sortable-column': getColumnProp(column, 'sortable'),
+ 'data-p-resizable-column': props.resizableColumns,
+ 'data-p-highlight': sorted,
+ 'data-p-frozen-column': getColumnProp(column, 'frozen')
},
- getColumnPTOptions(column, 'headerCell'),
- getColumnPTOptions(column, 'root')
+ getColumnPTOptions(column, 'root'),
+ getColumnPTOptions(column, 'headerCell', {
+ context: {
+ sorted,
+ frozen,
+ resizable: props.resizableColumns
+ }
+ })
);
return (
diff --git a/components/lib/treetable/TreeTableRow.js b/components/lib/treetable/TreeTableRow.js
index 0c302551fe..879eecb2a4 100644
--- a/components/lib/treetable/TreeTableRow.js
+++ b/components/lib/treetable/TreeTableRow.js
@@ -15,50 +15,65 @@ export const TreeTableRow = React.memo((props) => {
const checkboxBoxRef = React.useRef(null);
const nodeTouched = React.useRef(false);
const expanded = props.expandedKeys ? props.expandedKeys[props.node.key] !== undefined : false;
+
+ const getColumnProp = (column, name) => {
+ return ColumnBase.getCProp(column, name);
+ };
+
const getColumnProps = (column) => ColumnBase.getCProps(column);
const { ptm, ptmo, cx, sx, isUnstyled } = props.ptCallbacks;
const getColumnPTOptions = (column, key) => {
- return ptmo(ColumnBase.getCProp(column, 'pt'), key, {
- props: getColumnProps(column),
- parent: props.metaData
- });
+ const cProps = getColumnProps(column);
+ const columnMetadata = {
+ props: cProps,
+ parent: props.metaData,
+ context: {
+ index: props.rowIndex,
+ selectable: props.node.selectable !== false,
+ selected: isSelected(),
+ frozen: getColumnProp(column, 'frozen'),
+ scrollable: props.metaData.props.scrollable
+ }
+ };
+
+ return mergeProps(ptm(`column.${key}`, { column: columnMetadata }), ptm(`column.${key}`, columnMetadata), ptmo(cProps, key, columnMetadata));
};
const getColumnCheckboxPTOptions = (column, key) => {
- return ptmo(ColumnBase.getCProp(column, 'pt'), key, {
- props: getColumnProps(column),
+ const cProps = getColumnProps(column);
+
+ const columnMetadata = {
+ props: cProps,
parent: props.metaData,
context: {
checked: isChecked(),
partialChecked: isPartialChecked()
}
- });
+ };
+
+ return mergeProps(ptm(`column.${key}`, { column: columnMetadata }), ptm(`column.${key}`, columnMetadata), ptmo(cProps, key, columnMetadata));
};
const getRowPTOptions = (key) => {
- return ptmo(props.pt, key, {
- props: props,
- parent: props.metaData,
+ const rowMetadata = {
context: {
index: props.index,
- selected: props.selected,
- selectable: props.metaData.props.rowHover,
+ selected: isSelected(),
+ selectable: props.node.selectable !== false,
frozen: getColumnProp('frozen'),
scrollable: props.metaData.props.scrollable,
showGridlines: props.metaData.props.showGridlines
}
- });
+ };
+
+ return ptm(key, rowMetadata);
};
const isLeaf = () => {
return props.node.leaf === false ? false : !(props.node.children && props.node.children.length);
};
- const getColumnProp = (column, name) => {
- return ColumnBase.getCProp(column, name);
- };
-
const onTogglerClick = (event) => {
expanded ? collapse(event) : expand(event);
@@ -343,7 +358,7 @@ export const TreeTableRow = React.memo((props) => {
className: cx('rowToggler'),
onClick: (e) => onTogglerClick(e),
tabIndex: -1,
- style: sx('rowToggler', { rowProps: props }),
+ style: { marginLeft: props.level * 16 + 'px', visibility: props.node.leaf === false || (props.node.children && props.node.children.length) ? 'visible' : 'hidden' },
'aria-label': label
},
getColumnPTOptions(column, 'rowToggler')
@@ -525,7 +540,8 @@ export const TreeTableRow = React.memo((props) => {
onContextMenu: (e) => onRightClick(e),
onKeyDown: (e) => onKeyDown(e),
onMouseEnter: (e) => onMouseEnter(e),
- onMouseLeave: (e) => onMouseLeave(e)
+ onMouseLeave: (e) => onMouseLeave(e),
+ 'data-p-highlight': isSelected()
},
getRowPTOptions('row')
);
diff --git a/components/lib/treetable/TreeTableScrollableView.js b/components/lib/treetable/TreeTableScrollableView.js
index d701dfcd94..6fd92069c7 100644
--- a/components/lib/treetable/TreeTableScrollableView.js
+++ b/components/lib/treetable/TreeTableScrollableView.js
@@ -37,7 +37,7 @@ export const TreeTableScrollableView = React.memo((props) => {
if (element) {
let el = element;
- while (el && !DomHandler.hasClass(el, 'p-treetable')) {
+ while (el && !(DomHandler.getAttribute(el, 'data-pc-section') === 'root' || DomHandler.getAttribute(el, 'data-pc-name') === 'treetable')) {
el = el.parentElement;
}
@@ -110,7 +110,7 @@ export const TreeTableScrollableView = React.memo((props) => {
const scrollableProps = mergeProps(
{
className: cx('scrollable', { scrolaableProps: props }),
- style: sx('scrollable', { width, left })
+ style: { width, left }
},
ptm('scrollable')
);
@@ -140,7 +140,7 @@ export const TreeTableScrollableView = React.memo((props) => {
const scrollableBodyProps = mergeProps(
{
className: cx('scrollableBody'),
- style: sx('scrollableBody', { scrolaableProps: props }),
+ style: !props.frozen && props.scrollHeight ? { overflowY: 'scroll' } : undefined,
onScroll: (e) => onBodyScroll(e)
},
ptm('scrollableBody')
@@ -148,7 +148,7 @@ export const TreeTableScrollableView = React.memo((props) => {
const scrollableBodyTableProps = mergeProps(
{
- style: sx('scrollableBodyTable'),
+ style: { top: '0' },
className: cx('scrollableBodyTable')
},
ptm('scrollableBodyTable')
diff --git a/components/lib/treetable/treetable.d.ts b/components/lib/treetable/treetable.d.ts
index d57c8b713b..3ddf208b01 100644
--- a/components/lib/treetable/treetable.d.ts
+++ b/components/lib/treetable/treetable.d.ts
@@ -84,6 +84,10 @@ export interface TreeTablePassThroughOptions {
* Uses to pass attributes to the empty message's DOM element.
*/
emptyMessage?: TreeTablePassThroughType
>;
+ /**
+ * Uses to pass attributes to the empty message cell's DOM element.
+ */
+ emptyMessageCell?: TreeTablePassThroughType>;
/**
* Uses to pass attributes to the body cell's DOM element.
*/