Refactor #6826 - For DataTable
parent
41c86c8737
commit
b267464d60
|
@ -490,7 +490,6 @@ export default {
|
||||||
updateStickyPosition() {
|
updateStickyPosition() {
|
||||||
if (this.columnProp('frozen')) {
|
if (this.columnProp('frozen')) {
|
||||||
let align = this.columnProp('alignFrozen');
|
let align = this.columnProp('alignFrozen');
|
||||||
let isRTL = this.$parentInstance.$parentInstance.isRTL;
|
|
||||||
|
|
||||||
if (align === 'right') {
|
if (align === 'right') {
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
|
@ -500,11 +499,7 @@ export default {
|
||||||
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRTL) {
|
this.styleObject.insetInlineEnd = pos + 'px';
|
||||||
this.styleObject.left = pos + 'px';
|
|
||||||
} else {
|
|
||||||
this.styleObject.right = pos + 'px';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||||
|
@ -513,11 +508,7 @@ export default {
|
||||||
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRTL) {
|
this.styleObject.insetInlineStart = pos + 'px';
|
||||||
this.styleObject.right = pos + 'px';
|
|
||||||
} else {
|
|
||||||
this.styleObject.left = pos + 'px';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -329,6 +329,7 @@ import {
|
||||||
getOuterHeight,
|
getOuterHeight,
|
||||||
getOuterWidth,
|
getOuterWidth,
|
||||||
isClickable,
|
isClickable,
|
||||||
|
isRTL,
|
||||||
removeClass,
|
removeClass,
|
||||||
setAttribute
|
setAttribute
|
||||||
} from '@primeuix/utils/dom';
|
} from '@primeuix/utils/dom';
|
||||||
|
@ -410,8 +411,7 @@ export default {
|
||||||
d_editingMeta: {},
|
d_editingMeta: {},
|
||||||
d_filters: this.cloneFilters(this.filters),
|
d_filters: this.cloneFilters(this.filters),
|
||||||
d_columns: new HelperSet({ type: 'Column' }),
|
d_columns: new HelperSet({ type: 'Column' }),
|
||||||
d_columnGroups: new HelperSet({ type: 'ColumnGroup' }),
|
d_columnGroups: new HelperSet({ type: 'ColumnGroup' })
|
||||||
isRTL: false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
rowTouched: false,
|
rowTouched: false,
|
||||||
|
@ -432,7 +432,6 @@ export default {
|
||||||
columnWidthsState: null,
|
columnWidthsState: null,
|
||||||
tableWidthState: null,
|
tableWidthState: null,
|
||||||
columnWidthsRestored: false,
|
columnWidthsRestored: false,
|
||||||
mutationObserver: null,
|
|
||||||
watch: {
|
watch: {
|
||||||
first(newValue) {
|
first(newValue) {
|
||||||
this.d_first = newValue;
|
this.d_first = newValue;
|
||||||
|
@ -485,9 +484,6 @@ export default {
|
||||||
if (this.editMode === 'row' && this.dataKey && !this.d_editingRowKeys) {
|
if (this.editMode === 'row' && this.dataKey && !this.d_editingRowKeys) {
|
||||||
this.updateEditingRowKeys(this.editingRows);
|
this.updateEditingRowKeys(this.editingRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateDirection();
|
|
||||||
this.observeDirectionChanges();
|
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
this.unbindColumnResizeEvents();
|
this.unbindColumnResizeEvents();
|
||||||
|
@ -495,10 +491,6 @@ export default {
|
||||||
|
|
||||||
this.d_columns.clear();
|
this.d_columns.clear();
|
||||||
this.d_columnGroups.clear();
|
this.d_columnGroups.clear();
|
||||||
|
|
||||||
if (this.mutationObserver) {
|
|
||||||
this.mutationObserver.disconnect();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
if (this.isStateful()) {
|
if (this.isStateful()) {
|
||||||
|
@ -510,19 +502,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
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) {
|
columnProp(col, prop) {
|
||||||
return getVNodeProp(col, prop);
|
return getVNodeProp(col, prop);
|
||||||
},
|
},
|
||||||
|
@ -1312,7 +1291,7 @@ export default {
|
||||||
this.$refs.resizeHelper.style.display = 'block';
|
this.$refs.resizeHelper.style.display = 'block';
|
||||||
},
|
},
|
||||||
onColumnResizeEnd() {
|
onColumnResizeEnd() {
|
||||||
let delta = this.isRTL ? this.lastResizeHelperX - this.$refs.resizeHelper.offsetLeft : this.$refs.resizeHelper.offsetLeft - this.lastResizeHelperX;
|
let delta = isRTL(this.$el) ? this.lastResizeHelperX - this.$refs.resizeHelper.offsetLeft : this.$refs.resizeHelper.offsetLeft - this.lastResizeHelperX;
|
||||||
let columnWidth = this.resizeColumnElement.offsetWidth;
|
let columnWidth = this.resizeColumnElement.offsetWidth;
|
||||||
let newColumnWidth = columnWidth + delta;
|
let newColumnWidth = columnWidth + delta;
|
||||||
let minWidth = this.resizeColumnElement.style.minWidth || 15;
|
let minWidth = this.resizeColumnElement.style.minWidth || 15;
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { getNextElementSibling, getOuterWidth, getPreviousElementSibling } from '@primeuix/utils/dom';
|
||||||
import BaseComponent from '@primevue/core/basecomponent';
|
import BaseComponent from '@primevue/core/basecomponent';
|
||||||
import { getVNodeProp } from '@primevue/core/utils';
|
import { getVNodeProp } from '@primevue/core/utils';
|
||||||
import { getNextElementSibling, getOuterWidth, getPreviousElementSibling } from '@primeuix/utils/dom';
|
|
||||||
import { mergeProps } from 'vue';
|
import { mergeProps } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -67,7 +67,6 @@ export default {
|
||||||
updateStickyPosition() {
|
updateStickyPosition() {
|
||||||
if (this.columnProp('frozen')) {
|
if (this.columnProp('frozen')) {
|
||||||
let align = this.columnProp('alignFrozen');
|
let align = this.columnProp('alignFrozen');
|
||||||
let isRTL = this.$parentInstance.$parentInstance.isRTL;
|
|
||||||
|
|
||||||
if (align === 'right') {
|
if (align === 'right') {
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
|
@ -77,11 +76,7 @@ export default {
|
||||||
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRTL) {
|
this.styleObject.insetInlineEnd = pos + 'px';
|
||||||
this.styleObject.left = pos + 'px';
|
|
||||||
} else {
|
|
||||||
this.styleObject.right = pos + 'px';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||||
|
@ -90,11 +85,7 @@ export default {
|
||||||
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRTL) {
|
this.styleObject.insetInlineStart = pos + 'px';
|
||||||
this.styleObject.right = pos + 'px';
|
|
||||||
} else {
|
|
||||||
this.styleObject.left = pos + 'px';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,7 +277,6 @@ export default {
|
||||||
updateStickyPosition() {
|
updateStickyPosition() {
|
||||||
if (this.columnProp('frozen')) {
|
if (this.columnProp('frozen')) {
|
||||||
let align = this.columnProp('alignFrozen');
|
let align = this.columnProp('alignFrozen');
|
||||||
let isRTL = this.$parentInstance.$parentInstance.isRTL;
|
|
||||||
|
|
||||||
if (align === 'right') {
|
if (align === 'right') {
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
|
@ -287,11 +286,7 @@ export default {
|
||||||
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
pos = getOuterWidth(next) + parseFloat(next.style.right || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRTL) {
|
this.styleObject.insetInlineEnd = pos + 'px';
|
||||||
this.styleObject.left = pos + 'px';
|
|
||||||
} else {
|
|
||||||
this.styleObject.right = pos + 'px';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let pos = 0;
|
let pos = 0;
|
||||||
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
let prev = getPreviousElementSibling(this.$el, '[data-p-frozen-column="true"]');
|
||||||
|
@ -300,11 +295,7 @@ export default {
|
||||||
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
pos = getOuterWidth(prev) + parseFloat(prev.style.left || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRTL) {
|
this.styleObject.insetInlineStart = pos + 'px';
|
||||||
this.styleObject.right = pos + 'px';
|
|
||||||
} else {
|
|
||||||
this.styleObject.left = pos + 'px';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let filterRow = this.$el.parentElement.nextElementSibling;
|
let filterRow = this.$el.parentElement.nextElementSibling;
|
||||||
|
|
Loading…
Reference in New Issue