[scss] migrate @import to @use.
[grid] isExpandable. [popup] showInput, options.
This commit is contained in:
1 parent
409333993b
commit
6de354ad47
27 files changed
+113
-5083
No files matched your search
+50
-25
@@ -72,13 +72,13 @@ let r = lang;
|
||||
/**
|
||||
* 键值字典
|
||||
* @template T
|
||||
* @typedef {{[key: string]: T}} KeyMap
|
||||
* @typedef {Object.<string, T>} KeyMap
|
||||
*/
|
||||
|
||||
/**
|
||||
* 索引字典
|
||||
* @template T
|
||||
* @typedef {{[index: number]: T}} IndexMap
|
||||
* @typedef {Object.<number, T>} IndexMap
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -1018,8 +1018,8 @@ export class Grid {
|
||||
*/
|
||||
sortArray = null;
|
||||
/**
|
||||
* 是否支持点击扩展
|
||||
* @type {boolean}
|
||||
* 是否支持点击扩展,或行数据中支持点击扩展的字段
|
||||
* @type {boolean | string}
|
||||
* @default false
|
||||
* @ignore
|
||||
*/
|
||||
@@ -1167,7 +1167,7 @@ export class Grid {
|
||||
* @property {number} [sortIndex=-1] - 排序列的索引
|
||||
* @property {GridColumnDirection} [sortDirection=GridColumnDirection.Ascending] - 排序方式,正数升序,负数倒序
|
||||
* @property {GridColumnSortDefinition[]} [sortArray] - 排序列数组
|
||||
* @property {boolean} [expandable=false] - 是否支持点击扩展
|
||||
* @property {boolean | string} [expandable=false] - 是否支持点击扩展,或行数据中支持点击扩展的字段
|
||||
* @property {GridExpandableObjectCallback} [expandableGenerator] - 扩展行生成器
|
||||
*/
|
||||
constructor(container, getText) {
|
||||
@@ -1177,6 +1177,19 @@ export class Grid {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全局是否可支持点击扩展
|
||||
* @readonly
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isExpandable() {
|
||||
const flag = this.expandable;
|
||||
if (typeof flag === 'string') {
|
||||
return flag != null;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Grid 的页面元素
|
||||
* @readonly
|
||||
@@ -1514,7 +1527,7 @@ export class Grid {
|
||||
return;
|
||||
}
|
||||
const rowIndex = parent.classList.contains('ui-grid-total-row') ? -1 : this._tableRows.indexOf(parent);
|
||||
let colIndex = indexOfParent(target) - (this.expandable ? 1 : 0);
|
||||
let colIndex = indexOfParent(target) - (this.isExpandable ? 1 : 0);
|
||||
if (colIndex >= this.columns.length) {
|
||||
colIndex = -1;
|
||||
}
|
||||
@@ -2680,9 +2693,10 @@ export class Grid {
|
||||
const header = createElement('tr');
|
||||
thead.appendChild(header);
|
||||
const sizer = this._var.refs.sizer;
|
||||
let left = this.expandable ? ExpandableWidth : 0;
|
||||
const expandable = this.isExpandable;
|
||||
let left = expandable ? ExpandableWidth : 0;
|
||||
const readonly = this.readonly;
|
||||
if (this.expandable) {
|
||||
if (expandable) {
|
||||
header.appendChild(createElement('th', th => {
|
||||
th.className = 'ui-expandable sticky';
|
||||
const w = `${ExpandableWidth}px`;
|
||||
@@ -2866,7 +2880,7 @@ export class Grid {
|
||||
width += col.width + 1;
|
||||
}
|
||||
}
|
||||
if (this.expandable) {
|
||||
if (this.isExpandable) {
|
||||
width += ExpandableWidth;
|
||||
}
|
||||
table.style.width = `${width}px`;
|
||||
@@ -2891,8 +2905,9 @@ export class Grid {
|
||||
tfoot.addEventListener('dblclick', e => this._onRowDblClicked(e));
|
||||
const footer = createElement('tr', 'ui-grid-row ui-grid-total-row');
|
||||
tfoot.appendChild(footer);
|
||||
let left = this.expandable ? ExpandableWidth : 0;
|
||||
if (this.expandable) {
|
||||
const expandable = this.isExpandable;
|
||||
let left = expandable ? ExpandableWidth : 0;
|
||||
if (expandable) {
|
||||
footer.appendChild(createElement('td', td => {
|
||||
td.className = 'ui-expandable sticky';
|
||||
const w = `${ExpandableWidth}px`;
|
||||
@@ -2955,6 +2970,7 @@ export class Grid {
|
||||
count -= exists;
|
||||
if (count > 0) {
|
||||
const readonly = this.readonly;
|
||||
const expandable = this.isExpandable;
|
||||
for (let i = 0; i < count; ++i) {
|
||||
const row = createElement('tr', 'ui-grid-row');
|
||||
if (this.rowDraggable) {
|
||||
@@ -2990,8 +3006,8 @@ export class Grid {
|
||||
}
|
||||
const virtualRow = { cells: {} };
|
||||
this._var.virtualRows[exists + i] = virtualRow;
|
||||
let left = this.expandable ? ExpandableWidth : 0;
|
||||
if (this.expandable) {
|
||||
let left = expandable ? ExpandableWidth : 0;
|
||||
if (expandable) {
|
||||
const icon = createIcon('fa-solid', 'caret-right');
|
||||
icon.dataset.expanded = '0';
|
||||
row.appendChild(createElement('td', td => {
|
||||
@@ -3082,7 +3098,9 @@ export class Grid {
|
||||
_fillRows(rows, cols, widths) {
|
||||
const startIndex = this._var.startIndex;
|
||||
const selectedIndexes = this._var.selectedIndexes;
|
||||
const offset = this.expandable ? 1 : 0;
|
||||
const expandable = this.isExpandable;
|
||||
const expandableKey = typeof this.expandable === 'string' ? this.expandable : null;
|
||||
const offset = expandable ? 1 : 0;
|
||||
const readonly = this.readonly;
|
||||
rows.forEach((row, i) => {
|
||||
const vals = this._var.currentSource[startIndex + i];
|
||||
@@ -3109,8 +3127,11 @@ export class Grid {
|
||||
const stateChanged = virtualRow.editing !== selected;
|
||||
virtualRow.editing = selected;
|
||||
// data
|
||||
if (this.expandable) {
|
||||
const expanded = vals.__expanded;
|
||||
if (expandable) {
|
||||
const iconCell = row.children[0];
|
||||
const t = typeof expandableKey === 'string' ? item[expandableKey] : true;
|
||||
iconCell.children[0].style.display = t ? '' : 'none';
|
||||
const expanded = t && vals.__expanded;
|
||||
let rowExpanded = row.nextElementSibling;
|
||||
if (rowExpanded?.className !== 'ui-grid-row-expanded') {
|
||||
rowExpanded = null;
|
||||
@@ -3141,8 +3162,7 @@ export class Grid {
|
||||
rowExpanded.style.display = 'none';
|
||||
}
|
||||
}
|
||||
const iconCell = row.children[0];
|
||||
if (iconCell.children[0].dataset.expanded !== (expanded ? '1' : '0')) {
|
||||
if (t && iconCell.children[0].dataset.expanded !== (expanded ? '1' : '0')) {
|
||||
const icon = createIcon('fa-solid', expanded ? 'caret-down' : 'caret-right');
|
||||
icon.dataset.expanded = expanded ? '1' : '0';
|
||||
iconCell.replaceChildren(icon);
|
||||
@@ -3410,7 +3430,8 @@ export class Grid {
|
||||
element.style.maxWidth = w;
|
||||
element.style.minWidth = w;
|
||||
// element.style.cssText += `width: ${w}; max-width: ${w}; min-width: ${w}`;
|
||||
let left = this.expandable ? ExpandableWidth : 0;
|
||||
const expandable = this.isExpandable;
|
||||
let left = expandable ? ExpandableWidth : 0;
|
||||
if (col.isfixed) {
|
||||
left = element.offsetLeft + width;
|
||||
let l = left;
|
||||
@@ -3423,7 +3444,7 @@ export class Grid {
|
||||
}
|
||||
}
|
||||
}
|
||||
const offset = this.expandable ? 1 : 0;
|
||||
const offset = expandable ? 1 : 0;
|
||||
for (let row of this._tableRows) {
|
||||
element = row.children[index + offset];
|
||||
if (element != null) {
|
||||
@@ -3571,7 +3592,7 @@ export class Grid {
|
||||
const children = this._headerCells;
|
||||
const rows = this._tableRows;
|
||||
const columns = this.columns;
|
||||
const offset = this.expandable ? 1 : 0;
|
||||
const offset = this.isExpandable ? 1 : 0;
|
||||
if (targetIndex > 1) {
|
||||
targetIndex = orderIndex - 1;
|
||||
// const current = columns[index];
|
||||
@@ -4194,7 +4215,7 @@ export class Grid {
|
||||
if (e.currentTarget.classList.contains('sticky')) {
|
||||
return;
|
||||
}
|
||||
const index = indexOfParent(e.currentTarget) - (this.expandable ? 1 : 0);
|
||||
const index = indexOfParent(e.currentTarget) - (this.isExpandable ? 1 : 0);
|
||||
const cx = getClientX(e);
|
||||
const window = this.window ?? global;
|
||||
const clearEvents = attr => {
|
||||
@@ -4260,7 +4281,7 @@ export class Grid {
|
||||
_onResizeStart(e, col) {
|
||||
const cx = getClientX(e);
|
||||
const width = col.width;
|
||||
const index = indexOfParent(e.currentTarget.parentElement) - (this.expandable ? 1 : 0);
|
||||
const index = indexOfParent(e.currentTarget.parentElement) - (this.isExpandable ? 1 : 0);
|
||||
const window = this.window ?? global;
|
||||
const clearEvents = attr => {
|
||||
for (let event of ['mousemove', 'mouseup']) {
|
||||
@@ -4277,7 +4298,11 @@ export class Grid {
|
||||
clearEvents(attr);
|
||||
}
|
||||
attr.resizing = width;
|
||||
attr.sizing = true;
|
||||
const resizemove = e => {
|
||||
if (!attr.sizing) {
|
||||
return;
|
||||
}
|
||||
const cx2 = getClientX(e);
|
||||
const val = width + (cx2 - cx);
|
||||
if (val < MiniColumnWidth) {
|
||||
@@ -4316,7 +4341,7 @@ export class Grid {
|
||||
_onAutoResize(e, col) {
|
||||
const th = e.currentTarget.parentElement;
|
||||
const index = indexOfParent(th);
|
||||
const offset = this.expandable ? 1 : 0;
|
||||
const offset = this.isExpandable ? 1 : 0;
|
||||
let width = th.querySelector('div:first-child').scrollWidth;
|
||||
for (let row of this._tableRows) {
|
||||
const element = row.children[index + offset].children[0];
|
||||
@@ -4677,7 +4702,7 @@ export class Grid {
|
||||
}
|
||||
// 调整其他列的可用性
|
||||
const row = this._tableRows[index];
|
||||
const offset = this.expandable ? 1 : 0;
|
||||
const offset = this.isExpandable ? 1 : 0;
|
||||
this.columns.forEach((c, j) => {
|
||||
const cache = this._var.enabledDict[c.key];
|
||||
if (cache !== true && cache !== col.key) {
|
||||
|
||||
Reference in new issue
Block a user