Refactor #6677 - For DataTable
parent
b331cbf894
commit
6b8f98afda
|
@ -490,25 +490,34 @@ export default {
|
|||
updateStickyPosition() {
|
||||
if (this.columnProp('frozen')) {
|
||||
let align = this.columnProp('alignFrozen');
|
||||
let isRTL = this.$parentInstance.$parentInstance.isRTL;
|
||||
|
||||
if (align === 'right') {
|
||||
let right = 0;
|
||||
let pos = 0;
|
||||
let next = getNextElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||
|
||||
if (next) {
|
||||
right = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||
}
|
||||
|
||||
this.styleObject.right = right + 'px';
|
||||
if (isRTL) {
|
||||
this.styleObject.left = pos + 'px';
|
||||
} else {
|
||||
this.styleObject.right = pos + 'px';
|
||||
}
|
||||
} else {
|
||||
let left = 0;
|
||||
let pos = 0;
|
||||
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||
|
||||
if (prev) {
|
||||
left = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||
}
|
||||
|
||||
this.styleObject.left = left + 'px';
|
||||
if (isRTL) {
|
||||
this.styleObject.right = pos + 'px';
|
||||
} else {
|
||||
this.styleObject.left = pos + 'px';
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -378,7 +378,8 @@ export default {
|
|||
d_editingMeta: {},
|
||||
d_filters: this.cloneFilters(this.filters),
|
||||
d_columns: new HelperSet({ type: 'Column' }),
|
||||
d_columnGroups: new HelperSet({ type: 'ColumnGroup' })
|
||||
d_columnGroups: new HelperSet({ type: 'ColumnGroup' }),
|
||||
isRTL: false
|
||||
};
|
||||
},
|
||||
rowTouched: false,
|
||||
|
@ -399,6 +400,7 @@ export default {
|
|||
columnWidthsState: null,
|
||||
tableWidthState: null,
|
||||
columnWidthsRestored: false,
|
||||
mutationObserver: null,
|
||||
watch: {
|
||||
first(newValue) {
|
||||
this.d_first = newValue;
|
||||
|
@ -451,6 +453,9 @@ export default {
|
|||
if (this.editMode === 'row' && this.dataKey && !this.d_editingRowKeys) {
|
||||
this.updateEditingRowKeys(this.editingRows);
|
||||
}
|
||||
|
||||
this.updateDirection();
|
||||
this.observeDirectionChanges();
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.unbindColumnResizeEvents();
|
||||
|
@ -458,6 +463,10 @@ export default {
|
|||
|
||||
this.d_columns.clear();
|
||||
this.d_columnGroups.clear();
|
||||
|
||||
if (this.mutationObserver) {
|
||||
this.mutationObserver.disconnect();
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
if (this.isStateful()) {
|
||||
|
@ -469,6 +478,19 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
updateDirection() {
|
||||
this.isRTL = !!this.$el.closest('[dir="rtl"]');
|
||||
},
|
||||
observeDirectionChanges() {
|
||||
const targetNode = document.documentElement;
|
||||
const config = { attributes: true, attributeFilter: ['dir'] };
|
||||
|
||||
this.mutationObserver = new MutationObserver(() => {
|
||||
this.updateDirection();
|
||||
});
|
||||
|
||||
this.mutationObserver.observe(targetNode, config);
|
||||
},
|
||||
columnProp(col, prop) {
|
||||
return getVNodeProp(col, prop);
|
||||
},
|
||||
|
@ -1258,7 +1280,7 @@ export default {
|
|||
this.$refs.resizeHelper.style.display = 'block';
|
||||
},
|
||||
onColumnResizeEnd() {
|
||||
let delta = this.$refs.resizeHelper.offsetLeft - this.lastResizeHelperX;
|
||||
let delta = this.isRTL ? this.lastResizeHelperX - this.$refs.resizeHelper.offsetLeft : this.$refs.resizeHelper.offsetLeft - this.lastResizeHelperX;
|
||||
let columnWidth = this.resizeColumnElement.offsetWidth;
|
||||
let newColumnWidth = columnWidth + delta;
|
||||
let minWidth = this.resizeColumnElement.style.minWidth || 15;
|
||||
|
|
|
@ -67,25 +67,34 @@ export default {
|
|||
updateStickyPosition() {
|
||||
if (this.columnProp('frozen')) {
|
||||
let align = this.columnProp('alignFrozen');
|
||||
let isRTL = this.$parentInstance.$parentInstance.isRTL;
|
||||
|
||||
if (align === 'right') {
|
||||
let right = 0;
|
||||
let pos = 0;
|
||||
let next = getNextElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||
|
||||
if (next) {
|
||||
right = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||
}
|
||||
|
||||
this.styleObject.right = right + 'px';
|
||||
if (isRTL) {
|
||||
this.styleObject.left = pos + 'px';
|
||||
} else {
|
||||
this.styleObject.right = pos + 'px';
|
||||
}
|
||||
} else {
|
||||
let left = 0;
|
||||
let pos = 0;
|
||||
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||
|
||||
if (prev) {
|
||||
left = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||
}
|
||||
|
||||
this.styleObject.left = left + 'px';
|
||||
if (isRTL) {
|
||||
this.styleObject.right = pos + 'px';
|
||||
} else {
|
||||
this.styleObject.left = pos + 'px';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,25 +277,34 @@ export default {
|
|||
updateStickyPosition() {
|
||||
if (this.columnProp('frozen')) {
|
||||
let align = this.columnProp('alignFrozen');
|
||||
let isRTL = this.$parentInstance.$parentInstance.isRTL;
|
||||
|
||||
if (align === 'right') {
|
||||
let right = 0;
|
||||
let pos = 0;
|
||||
let next = getNextElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||
|
||||
if (next) {
|
||||
right = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||
}
|
||||
|
||||
this.styleObject.right = right + 'px';
|
||||
if (isRTL) {
|
||||
this.styleObject.left = pos + 'px';
|
||||
} else {
|
||||
this.styleObject.right = pos + 'px';
|
||||
}
|
||||
} else {
|
||||
let left = 0;
|
||||
let pos = 0;
|
||||
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||
|
||||
if (prev) {
|
||||
left = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||
}
|
||||
|
||||
this.styleObject.left = left + 'px';
|
||||
if (isRTL) {
|
||||
this.styleObject.right = pos + 'px';
|
||||
} else {
|
||||
this.styleObject.left = pos + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
let filterRow = this.$el.parentElement.nextElementSibling;
|
||||
|
|
|
@ -15,7 +15,7 @@ const theme = ({ dt }) => `
|
|||
}
|
||||
|
||||
.p-datatable-scrollable-table > .p-datatable-thead {
|
||||
top: 0;
|
||||
inset-block-start: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ const theme = ({ dt }) => `
|
|||
z-index: 1;
|
||||
}
|
||||
|
||||
.p-datatable-scrollable-table>.p-datatable-tfoot {
|
||||
bottom: 0;
|
||||
.p-datatable-scrollable-table > .p-datatable-tfoot {
|
||||
inset-block-end: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
|
@ -85,12 +85,12 @@ const theme = ({ dt }) => `
|
|||
.p-datatable-column-resizer {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
inset-block-start: 0;
|
||||
inset-inline-end: 0;
|
||||
margin: 0;
|
||||
width: ${dt('datatable.column.resizer.width')};
|
||||
height: 100%;
|
||||
padding: 0px;
|
||||
padding: 0;
|
||||
cursor: col-resize;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
@ -190,12 +190,12 @@ const theme = ({ dt }) => `
|
|||
}
|
||||
|
||||
.p-datatable-filter-constraint-separator {
|
||||
border-top: 1px solid ${dt('datatable.filter.constraint.separator.border.color')};
|
||||
border-block-start: 1px solid ${dt('datatable.filter.constraint.separator.border.color')};
|
||||
}
|
||||
|
||||
.p-datatable-popover-filter {
|
||||
display: inline-flex;
|
||||
margin-left: auto;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.p-datatable-filter-overlay-popover {
|
||||
|
@ -223,11 +223,11 @@ const theme = ({ dt }) => `
|
|||
}
|
||||
|
||||
.p-datatable-filter-rule {
|
||||
border-bottom: 1px solid ${dt('datatable.filter.rule.border.color')};
|
||||
border-block-end: 1px solid ${dt('datatable.filter.rule.border.color')};
|
||||
}
|
||||
|
||||
.p-datatable-filter-rule:last-child {
|
||||
border-bottom: 0 none;
|
||||
border-block-end: 0 none;
|
||||
}
|
||||
|
||||
.p-datatable-filter-add-rule-button {
|
||||
|
@ -253,8 +253,8 @@ const theme = ({ dt }) => `
|
|||
transform: none !important;
|
||||
min-height: 0;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
left: 0;
|
||||
inset-block-start: 0;
|
||||
inset-inline-start: 0;
|
||||
}
|
||||
|
||||
.p-datatable-paginator-top {
|
||||
|
@ -295,7 +295,7 @@ const theme = ({ dt }) => `
|
|||
border-width: 0 0 1px 0;
|
||||
color: ${dt('datatable.header.cell.color')};
|
||||
font-weight: normal;
|
||||
text-align: left;
|
||||
text-align: start;
|
||||
transition: background ${dt('datatable.transition.duration')}, color ${dt('datatable.transition.duration')}, border-color ${dt('datatable.transition.duration')},
|
||||
outline-color ${dt('datatable.transition.duration')}, box-shadow ${dt('datatable.transition.duration')};
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ const theme = ({ dt }) => `
|
|||
}
|
||||
|
||||
.p-datatable-tbody > tr > td {
|
||||
text-align: left;
|
||||
text-align: start;
|
||||
border-color: ${dt('datatable.body.cell.border.color')};
|
||||
border-style: solid;
|
||||
border-width: 0 0 1px 0;
|
||||
|
@ -331,11 +331,11 @@ const theme = ({ dt }) => `
|
|||
}
|
||||
|
||||
.p-datatable-tbody > tr:has(+ .p-datatable-row-selected) > td {
|
||||
border-bottom-color: ${dt('datatable.body.cell.selected.border.color')};
|
||||
border-block-end-color: ${dt('datatable.body.cell.selected.border.color')};
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr.p-datatable-row-selected > td {
|
||||
border-bottom-color: ${dt('datatable.body.cell.selected.border.color')};
|
||||
border-block-end-color: ${dt('datatable.body.cell.selected.border.color')};
|
||||
}
|
||||
|
||||
.p-datatable-tbody > tr:focus-visible,
|
||||
|
@ -346,7 +346,7 @@ const theme = ({ dt }) => `
|
|||
}
|
||||
|
||||
.p-datatable-tfoot > tr > td {
|
||||
text-align: left;
|
||||
text-align: start;
|
||||
padding: ${dt('datatable.footer.cell.padding')};
|
||||
border-color: ${dt('datatable.footer.cell.border.color')};
|
||||
border-style: solid;
|
||||
|
@ -530,11 +530,11 @@ const theme = ({ dt }) => `
|
|||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
.p-datatable.p-datatable-lg .p-datatable-tbody>tr>td {
|
||||
.p-datatable.p-datatable-lg .p-datatable-tbody > tr > td {
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
.p-datatable.p-datatable-lg .p-datatable-tfoot>tr>td {
|
||||
.p-datatable.p-datatable-lg .p-datatable-tfoot > tr > td {
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
|
@ -568,7 +568,7 @@ const theme = ({ dt }) => `
|
|||
|
||||
.p-datatable-tbody > tr.p-datatable-row-selected .p-datatable-row-toggle-button:hover {
|
||||
background: ${dt('datatable.row.toggle.button.selected.hover.background')};
|
||||
${dt('datatable.row.toggle.button.selected.hover.color')};
|
||||
color: ${dt('datatable.row.toggle.button.selected.hover.color')};
|
||||
}
|
||||
|
||||
.p-datatable-row-toggle-button:focus-visible {
|
||||
|
@ -576,6 +576,10 @@ const theme = ({ dt }) => `
|
|||
outline: ${dt('datatable.row.toggle.button.focus.ring.width')} ${dt('datatable.row.toggle.button.focus.ring.style')} ${dt('datatable.row.toggle.button.focus.ring.color')};
|
||||
outline-offset: ${dt('datatable.row.toggle.button.focus.ring.offset')};
|
||||
}
|
||||
|
||||
.p-datatable-row-toggle-icon:dir(rtl) {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
`;
|
||||
|
||||
const classes = {
|
||||
|
|
Loading…
Reference in New Issue