communications app, popup lib

This commit is contained in:
2023-04-08 11:46:20 +08:00
parent 449196b491
commit f85d4c9903
25 changed files with 746 additions and 279 deletions

View File

@@ -1,7 +1,7 @@
import { global, isPositive, isMobile, throttle, truncate } from "../utility";
import { nullOrEmpty } from "../utility/strings";
import { r } from "../utility/lgres";
import { createElement, createElementInit } from "../functions";
import { createElement } from "../functions";
import { createIcon } from "./icon";
import { createCheckbox } from "./checkbox";
import { setTooltip } from "./tooltip";
@@ -85,7 +85,7 @@ class GridDropdownColumn extends GridColumn {
return drop.create();
}
static getDrop(element) {
static #getDrop(element) {
const dropGlobal = global[SymbolDropdown];
if (dropGlobal == null) {
return null;
@@ -98,7 +98,7 @@ class GridDropdownColumn extends GridColumn {
return drop;
}
static getSource(item, col) {
static #getSource(item, col) {
let source = col.source;
if (typeof source === 'function') {
source = source(item);
@@ -106,23 +106,37 @@ class GridDropdownColumn extends GridColumn {
return source;
}
static #setValue(source, element, val) {
const data = source?.find(v => v.value === val);
if (data != null) {
val = data.text;
}
super.setValue(element, val);
}
static setValue(element, val, item, col) {
if (element.tagName !== 'DIV') {
let source = this.getSource(item, col);
const data = source?.find(v => v.value === val);
if (data != null) {
val = data.text;
let source = this.#getSource(item, col);
if (source instanceof Promise) {
source.then(s => this.#setValue(s, element, val));
} else {
this.#setValue(source, element, val);
}
super.setValue(element, val);
return;
}
const drop = this.getDrop(element);
const drop = this.#getDrop(element);
if (drop == null) {
return;
}
if (drop.source == null || drop.source.length === 0) {
let source = this.getSource(item, col);
if (source != null) {
let source = this.#getSource(item, col);
if (source instanceof Promise) {
source.then(s => {
drop.source = s;
drop.select(val, true);
})
return;
} else if (source != null) {
drop.source = source;
}
}
@@ -134,7 +148,7 @@ class GridDropdownColumn extends GridColumn {
}
static setEnabled(element, enabled) {
const drop = this.getDrop(element);
const drop = this.#getDrop(element);
if (drop == null) {
return;
}
@@ -316,7 +330,7 @@ class Grid {
get selectedIndex() { return (this.#selectedIndexes && this.#selectedIndexes[0]) ?? -1 }
get loading() { return this.#refs.loading?.style.visibility === 'visible' }
get loading() { return this.#refs.loading?.style?.visibility === 'visible' }
set loading(flag) {
if (this.#refs.loading == null) {
return;