fix(ts_web): resolve TypeScript nullability and event typing issues across web components
This commit is contained in:
@@ -203,7 +203,7 @@ export class DeesDataviewCodebox extends DeesElement {
|
||||
</style>
|
||||
<div
|
||||
class="mainbox"
|
||||
@contextmenu="${(eventArg) => {
|
||||
@contextmenu="${(eventArg: MouseEvent) => {
|
||||
DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
||||
{
|
||||
name: 'About',
|
||||
@@ -241,7 +241,7 @@ export class DeesDataviewCodebox extends DeesElement {
|
||||
private codeToDisplayStore = '';
|
||||
private highlightJs: HLJSApi | null = null;
|
||||
|
||||
public async updated(_changedProperties) {
|
||||
public async updated(_changedProperties: Map<string, any>) {
|
||||
super.updated(_changedProperties);
|
||||
console.log('highlighting now');
|
||||
console.log(this.childNodes);
|
||||
@@ -267,11 +267,11 @@ export class DeesDataviewCodebox extends DeesElement {
|
||||
this.highlightJs = await DeesServiceLibLoader.getInstance().loadHighlightJs();
|
||||
}
|
||||
|
||||
const localCodeNode = this.shadowRoot.querySelector('code');
|
||||
const localCodeNode = this.shadowRoot!.querySelector('code');
|
||||
const highlightedHtml = this.highlightJs.highlight(this.codeToDisplayStore, {
|
||||
language: this.progLang,
|
||||
ignoreIllegals: true,
|
||||
});
|
||||
localCodeNode.innerHTML = highlightedHtml.value;
|
||||
localCodeNode!.innerHTML = highlightedHtml.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export class DeesDataviewStatusobject extends DeesElement {
|
||||
public static demo = demoFunc;
|
||||
public static demoGroups = ['Data View'];
|
||||
|
||||
@property({ type: Object }) accessor statusObject: tsclass.code.IStatusObject;
|
||||
@property({ type: Object }) accessor statusObject!: tsclass.code.IStatusObject;
|
||||
|
||||
public static styles = [
|
||||
themeDefaultStyles,
|
||||
@@ -259,7 +259,7 @@ export class DeesDataviewStatusobject extends DeesElement {
|
||||
await navigator.clipboard.writeText(JSON.stringify(this.statusObject, null, 2));
|
||||
|
||||
// Show feedback
|
||||
const button = this.shadowRoot.querySelector('.copyMain') as HTMLElement;
|
||||
const button = this.shadowRoot!.querySelector('.copyMain') as HTMLElement;
|
||||
const originalText = button.textContent;
|
||||
button.textContent = 'Copied!';
|
||||
|
||||
|
||||
@@ -878,7 +878,7 @@ export class DeesStatsGrid extends DeesElement {
|
||||
|
||||
private renderTile(tile: IStatsTile): TemplateResult {
|
||||
const hasActions = tile.actions && tile.actions.length > 0;
|
||||
const clickable = hasActions && tile.actions.length === 1;
|
||||
const clickable = hasActions && tile.actions!.length === 1;
|
||||
const columnSpan = tile.columnSpan && tile.columnSpan > 1 ? tile.columnSpan : undefined;
|
||||
|
||||
return html`
|
||||
|
||||
@@ -52,12 +52,12 @@ export class DeesTable<T> extends DeesElement {
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
accessor key: string;
|
||||
accessor key!: string;
|
||||
|
||||
@property({
|
||||
type: String,
|
||||
})
|
||||
accessor label: string;
|
||||
accessor label!: string;
|
||||
|
||||
@property({
|
||||
type: Boolean,
|
||||
@@ -83,7 +83,7 @@ export class DeesTable<T> extends DeesElement {
|
||||
type: String,
|
||||
reflect: true,
|
||||
})
|
||||
accessor dataName: string;
|
||||
accessor dataName!: string;
|
||||
|
||||
|
||||
@property({
|
||||
@@ -127,7 +127,7 @@ export class DeesTable<T> extends DeesElement {
|
||||
@property({
|
||||
type: Object,
|
||||
})
|
||||
accessor selectedDataRow: T;
|
||||
accessor selectedDataRow!: T;
|
||||
|
||||
@property({
|
||||
type: Array,
|
||||
@@ -359,7 +359,7 @@ export class DeesTable<T> extends DeesElement {
|
||||
if (elementArg.tagName === 'TR') {
|
||||
return elementArg;
|
||||
} else {
|
||||
return getTr(elementArg.parentElement);
|
||||
return getTr(elementArg.parentElement!);
|
||||
}
|
||||
};
|
||||
return html`
|
||||
@@ -393,8 +393,8 @@ export class DeesTable<T> extends DeesElement {
|
||||
}}
|
||||
@drop=${async (eventArg: DragEvent) => {
|
||||
eventArg.preventDefault();
|
||||
const newFiles = [];
|
||||
for (const file of Array.from(eventArg.dataTransfer.files)) {
|
||||
const newFiles: File[] = [];
|
||||
for (const file of Array.from(eventArg.dataTransfer!.files)) {
|
||||
this.files.push(file);
|
||||
newFiles.push(file);
|
||||
this.requestUpdate();
|
||||
@@ -548,8 +548,8 @@ export class DeesTable<T> extends DeesElement {
|
||||
type: ['header'],
|
||||
actionFunc: async () => {
|
||||
console.log('open search');
|
||||
const searchGrid = this.shadowRoot.querySelector('.searchGrid');
|
||||
searchGrid.classList.toggle('hidden');
|
||||
const searchGrid = this.shadowRoot!.querySelector('.searchGrid');
|
||||
searchGrid!.classList.toggle('hidden');
|
||||
}
|
||||
});
|
||||
console.log(this.dataActions);
|
||||
@@ -609,7 +609,7 @@ export class DeesTable<T> extends DeesElement {
|
||||
const domtools = await this.domtoolsPromise;
|
||||
await domtools.convenience.smartdelay.delayFor(0);
|
||||
// Get the table element
|
||||
const table = this.shadowRoot.querySelector('table');
|
||||
const table = this.shadowRoot!.querySelector('table');
|
||||
if (!table) return;
|
||||
|
||||
// Get the first row's cells to measure the widths
|
||||
@@ -718,7 +718,7 @@ export class DeesTable<T> extends DeesElement {
|
||||
if (!this._rowIdMap.has(key)) {
|
||||
this._rowIdMap.set(key, String(++this._rowIdCounter));
|
||||
}
|
||||
return this._rowIdMap.get(key);
|
||||
return this._rowIdMap.get(key)!;
|
||||
}
|
||||
|
||||
private isRowSelected(row: T): boolean {
|
||||
@@ -818,7 +818,7 @@ export class DeesTable<T> extends DeesElement {
|
||||
input.blur();
|
||||
}
|
||||
if (saveArg) {
|
||||
itemArg[key] = input.value as any; // Convert string to T (you might need better type casting depending on your data structure)
|
||||
(itemArg as any)[key] = input.value as any; // Convert string to T (you might need better type casting depending on your data structure)
|
||||
this.changeSubject.next(this);
|
||||
}
|
||||
input.remove();
|
||||
|
||||
Reference in New Issue
Block a user