fixes for transpiling: import instantiated StaticOptions object, not the type

has also the benefit of using a single instance
This commit is contained in:
ralf 2023-03-13 19:38:05 +01:00
parent ebdf3310c2
commit 43dfaa6bc2
5 changed files with 5 additions and 25 deletions

View File

@ -9,7 +9,7 @@
import {css, html, PropertyValues, TemplateResult} from "@lion/core"; import {css, html, PropertyValues, TemplateResult} from "@lion/core";
import {Et2StaticSelectMixin, StaticOptions} from "./StaticOptions"; import {Et2StaticSelectMixin, StaticOptions as so} from "./StaticOptions";
import {Et2widgetWithSelectMixin} from "./Et2WidgetWithSelectMixin"; import {Et2widgetWithSelectMixin} from "./Et2WidgetWithSelectMixin";
import {SelectOption} from "./FindSelectOptions"; import {SelectOption} from "./FindSelectOptions";
import {SlMenuItem, SlSelect} from "@shoelace-style/shoelace"; import {SlMenuItem, SlSelect} from "@shoelace-style/shoelace";
@ -725,12 +725,6 @@ if(typeof customElements.get("lion-validation-feedback") === "undefined")
{ {
customElements.define("lion-validation-feedback", LionValidationFeedback); customElements.define("lion-validation-feedback", LionValidationFeedback);
} }
/**
* Use a single StaticOptions, since it should have no state
* @type {StaticOptions}
*/
const so = new StaticOptions();
export class Et2SelectApp extends Et2StaticSelectMixin(Et2Select) export class Et2SelectApp extends Et2StaticSelectMixin(Et2Select)
{ {

View File

@ -10,7 +10,7 @@
import {css, PropertyValues} from "@lion/core"; import {css, PropertyValues} from "@lion/core";
import {Et2Select} from "./Et2Select"; import {Et2Select} from "./Et2Select";
import {Et2StaticSelectMixin, StaticOptions} from "./StaticOptions"; import {Et2StaticSelectMixin, StaticOptions as so} from "./StaticOptions";
import {cleanSelectOptions} from "./FindSelectOptions"; import {cleanSelectOptions} from "./FindSelectOptions";
/** /**
@ -172,10 +172,4 @@ export class Et2SelectCategory extends Et2StaticSelectMixin(Et2Select)
} }
} }
/**
* Use a single StaticOptions, since it should have no state
* @type {StaticOptions}
*/
const so = new StaticOptions();
customElements.define("et2-select-cat", Et2SelectCategory); customElements.define("et2-select-cat", Et2SelectCategory);

View File

@ -9,7 +9,7 @@
import {Et2Select} from "./Et2Select"; import {Et2Select} from "./Et2Select";
import {Et2StaticSelectMixin, StaticOptions} from "./StaticOptions"; import {Et2StaticSelectMixin, StaticOptions as so} from "./StaticOptions";
import {egw} from "../../jsapi/egw_global"; import {egw} from "../../jsapi/egw_global";
import {SelectOption} from "./FindSelectOptions"; import {SelectOption} from "./FindSelectOptions";
@ -56,10 +56,4 @@ export class Et2SelectCountry extends Et2StaticSelectMixin(Et2Select)
} }
} }
/**
* Use a single StaticOptions, since it should have no state
* @type {StaticOptions}
*/
const so = new StaticOptions();
customElements.define("et2-select-country", Et2SelectCountry); customElements.define("et2-select-country", Et2SelectCountry);

View File

@ -11,12 +11,10 @@
import {css, html, LitElement, repeat, TemplateResult} from "@lion/core"; import {css, html, LitElement, repeat, TemplateResult} from "@lion/core";
import {et2_IDetachedDOM} from "../et2_core_interfaces"; import {et2_IDetachedDOM} from "../et2_core_interfaces";
import {Et2Widget} from "../Et2Widget/Et2Widget"; import {Et2Widget} from "../Et2Widget/Et2Widget";
import {StaticOptions} from "./StaticOptions"; import {StaticOptions as so} from "./StaticOptions";
import {find_select_options, SelectOption} from "./FindSelectOptions"; import {find_select_options, SelectOption} from "./FindSelectOptions";
import {SelectAccountMixin} from "./SelectAccountMixin"; import {SelectAccountMixin} from "./SelectAccountMixin";
const so = new StaticOptions();
/** /**
* This is a stripped-down read-only widget used in nextmatch * This is a stripped-down read-only widget used in nextmatch
* (and other read-only usages) * (and other read-only usages)

View File

@ -103,7 +103,7 @@ export const Et2StaticSelectMixin = <T extends Constructor<Et2WidgetWithSelect>>
* @param {boolean} return_promise true: always return a promise * @param {boolean} return_promise true: always return a promise
* @returns {Object[]|Promise<Object[]>} Array of options, or empty and they'll get filled in later, or Promise * @returns {Object[]|Promise<Object[]>} Array of options, or empty and they'll get filled in later, or Promise
*/ */
export class StaticOptions export const StaticOptions = new class StaticOptionsType
{ {
cached_server_side(widget : Et2SelectWidgets, type : string, options_string, return_promise? : boolean) : SelectOption[]|Promise<SelectOption[]> cached_server_side(widget : Et2SelectWidgets, type : string, options_string, return_promise? : boolean) : SelectOption[]|Promise<SelectOption[]>
{ {