fix Flatpicker plugin imports for et2-date* widgets

This commit is contained in:
ralf 2023-03-20 13:41:25 +01:00
parent 9b390507cb
commit 1015f057f4
3 changed files with 13 additions and 9 deletions

View File

@ -12,12 +12,12 @@
import {css, html} from "@lion/core";
import 'lit-flatpickr';
import {dateStyles} from "./DateStyles";
import {Instance} from 'flatpickr/dist/types/instance';
import "flatpickr/dist/plugins/scrollPlugin.js";
import "shortcut-buttons-flatpickr/dist/shortcut-buttons-flatpickr";
import type {Instance} from 'flatpickr/dist/types/instance';
import {default as scrollPlugin} from "flatpickr/dist/plugins/scrollPlugin.js";
import {default as ShortcutButtonsPlugin} from "shortcut-buttons-flatpickr/dist/shortcut-buttons-flatpickr";
import flatpickr from "flatpickr";
import {egw} from "../../jsapi/egw_global";
import {HTMLElementWithValue} from "@lion/form-core/types/FormControlMixinTypes";
import type {HTMLElementWithValue} from "@lion/form-core/types/FormControlMixinTypes";
import {Et2Textbox} from "../Et2Textbox/Et2Textbox";
import {Et2ButtonIcon} from "../Et2Button/Et2ButtonIcon";
import {FormControlMixin} from "@lion/form-core";
@ -687,6 +687,11 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(LitFlatpickr))
return formatDate;
}
set format(_format)
{
// ignored, trying to fix TypeError opening a new contact
}
/**
* Inline calendars need a slot
*

View File

@ -4,7 +4,7 @@ import {classMap, css, html, ifDefined, LitElement, TemplateResult} from "@lion/
import shoelace from "../Styles/shoelace";
import {dateStyles} from "./DateStyles";
import flatpickr from "flatpickr";
import "flatpickr/dist/plugins/rangePlugin";
import {default as rangePlugin} from "flatpickr/dist/plugins/rangePlugin";
import {Et2Date, formatDate, parseDate} from "./Et2Date";
import {egw} from "../../jsapi/egw_global";
@ -71,7 +71,6 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
...(<Et2Date>this.fromElement).getOptions(),
...{
plugins: [
// @ts-ignore ts can't find rangePlugin in IDE
rangePlugin({
input: this.toElement
})

View File

@ -11,7 +11,8 @@
import {css} from "@lion/core";
import {Et2Date} from "./Et2Date";
import {Instance} from "flatpickr/dist/types/instance";
import type {Instance} from "flatpickr/dist/types/instance";
import {default as ShortcutButtonsPlugin} from "shortcut-buttons-flatpickr/dist/shortcut-buttons-flatpickr";
export class Et2DateTime extends Et2Date
@ -115,7 +116,6 @@ export class Et2DateTime extends Et2Date
*/
protected _buttonPlugin()
{
// @ts-ignore TypeScript can't find ShortcutButtonsPlugin, but rollup does
return ShortcutButtonsPlugin({
button: [
{label: this.egw().lang("ok")},