merge transpiling branch into master

This commit is contained in:
ralf 2023-03-20 20:32:09 +01:00
commit d3eed5b738
9 changed files with 3224 additions and 410 deletions

View File

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

View File

@ -3,8 +3,9 @@ import {FormControlMixin} from "@lion/form-core";
import {classMap, css, html, ifDefined, LitElement, TemplateResult} from "@lion/core"; import {classMap, css, html, ifDefined, LitElement, TemplateResult} from "@lion/core";
import shoelace from "../Styles/shoelace"; import shoelace from "../Styles/shoelace";
import {dateStyles} from "./DateStyles"; import {dateStyles} from "./DateStyles";
import "flatpickr/dist/plugins/rangePlugin"; import flatpickr from "flatpickr";
import {formatDate, parseDate} from "./Et2Date"; import {default as rangePlugin} from "flatpickr/dist/plugins/rangePlugin";
import {Et2Date, formatDate, parseDate} from "./Et2Date";
import {egw} from "../../jsapi/egw_global"; import {egw} from "../../jsapi/egw_global";
/** /**
@ -54,6 +55,30 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
super(); super();
} }
getUpdateComplete() {
const p = super.getUpdateComplete();
if(!this.relative)
{
p.then(() => this.setupFlatpickr());
}
return p;
}
protected setupFlatpickr()
{
if(!this.fromElement || !this.fromElement._inputElement) return;
this.fromElement._instance = flatpickr((<Et2Date>this.fromElement).findInputField(), {
...(<Et2Date>this.fromElement).getOptions(),
...{
plugins: [
rangePlugin({
input: this.toElement
})
]
}
});
}
render() render()
{ {
const hasLabel = this.label ? true : false const hasLabel = this.label ? true : false
@ -345,4 +370,4 @@ export class Et2DateRange extends Et2InputWidget(FormControlMixin(LitElement))
]; ];
} }
customElements.define("et2-date-range", Et2DateRange); customElements.define("et2-date-range", Et2DateRange);

View File

@ -11,7 +11,8 @@
import {css} from "@lion/core"; import {css} from "@lion/core";
import {Et2Date} from "./Et2Date"; 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 export class Et2DateTime extends Et2Date
@ -115,7 +116,6 @@ export class Et2DateTime extends Et2Date
*/ */
protected _buttonPlugin() protected _buttonPlugin()
{ {
// @ts-ignore TypeScript can't find ShortcutButtonsPlugin, but rollup does
return ShortcutButtonsPlugin({ return ShortcutButtonsPlugin({
button: [ button: [
{label: this.egw().lang("ok")}, {label: this.egw().lang("ok")},
@ -144,4 +144,4 @@ export class Et2DateTime extends Et2Date
} }
// @ts-ignore TypeScript is not recognizing that Et2DateTime is a LitElement // @ts-ignore TypeScript is not recognizing that Et2DateTime is a LitElement
customElements.define("et2-date-time", Et2DateTime); customElements.define("et2-date-time", Et2DateTime);

View File

@ -87,8 +87,8 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
super(_parentController, _grid); super(_parentController, _grid);
this.setDataProvider(this); this.setDataProvider(this);
this.setRowCallback(this._rowCallback); this.setRowCallback(this._nmRowCallback);
this.setLinkCallback(this._linkCallback); this.setLinkCallback(this._nmLinkCallback);
this.setContext(this); this.setContext(this);
// Copy the egw reference // Copy the egw reference
@ -560,7 +560,7 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
* this special case used to store the rowWidget reference, so that it can * this special case used to store the rowWidget reference, so that it can
* be properly freed. * be properly freed.
*/ */
_rowCallback( _data, _tr, _idx, _entry) _nmRowCallback(_data, _tr, _idx, _entry)
{ {
// Let the row provider fill in the data row -- store the returned // Let the row provider fill in the data row -- store the returned
// rowWidget inside the _entry // rowWidget inside the _entry
@ -585,7 +585,7 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
* *
* @return Array List of action names that valid for the row * @return Array List of action names that valid for the row
*/ */
_linkCallback( _data, _idx, _uid) _nmLinkCallback( _data, _idx, _uid)
{ {
if(_uid.trim() != "") if(_uid.trim() != "")
{ {

View File

@ -13,7 +13,7 @@
et2_core_inputWidget; et2_core_inputWidget;
api.Resumable.resumable; api.Resumable.resumable;
*/ */
import "../Resumable/resumable.js"; import {Resumable} from "../Resumable/resumable.js";
import {et2_inputWidget} from "./et2_core_inputWidget"; import {et2_inputWidget} from "./et2_core_inputWidget";
import {et2_register_widget, WidgetConfig} from "./et2_core_widget"; import {et2_register_widget, WidgetConfig} from "./et2_core_widget";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";

View File

@ -24,7 +24,7 @@ import './fw_browser.js';
import './fw_ui.js'; import './fw_ui.js';
import './fw_classes.js'; import './fw_classes.js';
import '../jsapi/egw_inheritance.js'; import '../jsapi/egw_inheritance.js';
import "sortablejs/Sortable.min.js"; import Sortable from "sortablejs/modular/sortable.complete.esm";
/** /**
* *
* @param {DOMWindow} window * @param {DOMWindow} window

3536
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.14.6", "@babel/core": "^7.14.6",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.14.5", "@babel/preset-typescript": "^7.14.5",
"@interactjs/interactjs": "^1.10.11", "@interactjs/interactjs": "^1.10.11",
"@open-wc/testing": "^3.0.3", "@open-wc/testing": "^3.0.3",
@ -27,7 +28,7 @@
"grunt": "^1.5.3", "grunt": "^1.5.3",
"grunt-contrib-cssmin": "^2.2.1", "grunt-contrib-cssmin": "^2.2.1",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup": "^2.52.2", "rollup": "^2.79.1",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"sinon": "^11.1.2", "sinon": "^11.1.2",
"terser": "^4.8.1", "terser": "^4.8.1",
@ -62,9 +63,11 @@
"@lion/listbox": "^0.12.0", "@lion/listbox": "^0.12.0",
"@lion/select": "^0.15.0", "@lion/select": "^0.15.0",
"@lion/textarea": "^0.14.0", "@lion/textarea": "^0.14.0",
"@rollup/plugin-commonjs": "^24.0.1",
"@shoelace-style/shoelace": "2.0.0-beta.81", "@shoelace-style/shoelace": "2.0.0-beta.81",
"blueimp-gallery": "^3.4.0", "blueimp-gallery": "^3.4.0",
"colortranslator": "^1.9.2", "colortranslator": "^1.9.2",
"core-js": "^3.29.1",
"lit-flatpickr": "^0.3.0", "lit-flatpickr": "^0.3.0",
"shortcut-buttons-flatpickr": "^0.4.0", "shortcut-buttons-flatpickr": "^0.4.0",
"sortablejs": "^1.14.0" "sortablejs": "^1.14.0"
@ -72,4 +75,4 @@
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0"
} }
} }

View File

@ -15,12 +15,13 @@ import { readFileSync, readdirSync, statSync, unlinkSync } from "fs";
//import rimraf from 'rimraf'; //import rimraf from 'rimraf';
import { minify } from 'terser'; import { minify } from 'terser';
import resolve from '@rollup/plugin-node-resolve'; import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
// Best practice: use this // Best practice: use this
//rimraf.sync('./dist/'); //rimraf.sync('./dist/');
//rimraf.sync('./chunks/'); //rimraf.sync('./chunks/');
// remove only chunks older then 2 days, to allow UI to still load them and not require a reload / F5 // remove only chunks older than 2 days, to allow UI to still load them and not require a reload / F5
const rm_older = Date.now() - 48*3600000; const rm_older = Date.now() - 48*3600000;
readdirSync('./chunks').forEach(name => { readdirSync('./chunks').forEach(name => {
const stat = statSync('./chunks/'+name); const stat = statSync('./chunks/'+name);
@ -55,6 +56,11 @@ const config = {
// app.ts/js are added automatic by addAppsConfig() below // app.ts/js are added automatic by addAppsConfig() below
}, },
external: function(id,parentId,isResolved) { external: function(id,parentId,isResolved) {
// core-js used require and needs to be run through RollupJS and NOT treated as external
if (id.includes("/node_modules/core-js/"))
{
return false;
}
if(!isResolved) if(!isResolved)
{ {
return; return;
@ -113,6 +119,8 @@ const config = {
resolve({ resolve({
browser: true browser: true
}), }),
// core-js uses require, which needs to be transformed to es-modules
commonjs(),
{ {
transform (code, id) { transform (code, id) {
if (id.endsWith('.ts')) if (id.endsWith('.ts'))
@ -127,7 +135,22 @@ const config = {
// plugins: stage3Syntax, // plugins: stage3Syntax,
errorRecovery: true errorRecovery: true
}, },
presets: ['@babel/preset-typescript'] presets: [
['@babel/preset-typescript', {
//onlyRemoveTypeImports: true // seems not necessary and generates a lot of warnings about not exported symbols
}],
['@babel/preset-env', {
corejs: {
version: "3"
},
useBuiltIns: "usage",
modules: false,
targets : {
esmodules: true,
safari: "14"
}
}],
]
}, function (err, result) { }, function (err, result) {
if (err) if (err)
return reject(err); return reject(err);
@ -193,4 +216,4 @@ export default function addAppsConfig()
} }
} }
return conf; return conf;
} }