@omegagrid/grid 0.11.32 → 0.11.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editors/baseEditor.d.ts.map +1 -1
- package/dist/editors/baseEditor.js +6 -3
- package/dist/editors/baseEditor.js.map +1 -1
- package/dist/editors/calendarEditor.d.ts +10 -1
- package/dist/editors/calendarEditor.d.ts.map +1 -1
- package/dist/editors/calendarEditor.js +113 -19
- package/dist/editors/calendarEditor.js.map +1 -1
- package/dist/editors/dateEditor.d.ts +3 -1
- package/dist/editors/dateEditor.d.ts.map +1 -1
- package/dist/editors/dateEditor.js +22 -3
- package/dist/editors/dateEditor.js.map +1 -1
- package/dist/editors/index.d.ts.map +1 -1
- package/dist/editors/index.js +2 -0
- package/dist/editors/index.js.map +1 -1
- package/dist/filters/dateFilter.d.ts +54 -0
- package/dist/filters/dateFilter.d.ts.map +1 -0
- package/dist/filters/dateFilter.js +179 -0
- package/dist/filters/dateFilter.js.map +1 -0
- package/dist/filters/filterFactory.js +3 -3
- package/dist/filters/filterFactory.js.map +1 -1
- package/dist/filters/index.d.ts +1 -2
- package/dist/filters/index.d.ts.map +1 -1
- package/dist/filters/index.js +1 -2
- package/dist/filters/index.js.map +1 -1
- package/dist/renderers/DateTimeRenderer.d.ts.map +1 -1
- package/dist/renderers/DateTimeRenderer.js +3 -1
- package/dist/renderers/DateTimeRenderer.js.map +1 -1
- package/dist/ui/filterLabel.d.ts.map +1 -1
- package/dist/ui/filterLabel.js +0 -27
- package/dist/ui/filterLabel.js.map +1 -1
- package/dist/ui/grid.d.ts +15 -0
- package/dist/ui/grid.d.ts.map +1 -1
- package/dist/ui/grid.editing.d.ts.map +1 -1
- package/dist/ui/grid.editing.js +5 -4
- package/dist/ui/grid.editing.js.map +1 -1
- package/dist/ui/grid.js +39 -4
- package/dist/ui/grid.js.map +1 -1
- package/package.json +7 -7
- package/dist/filters/rangeFilter.d.ts +0 -15
- package/dist/filters/rangeFilter.d.ts.map +0 -1
- package/dist/filters/rangeFilter.js +0 -130
- package/dist/filters/rangeFilter.js.map +0 -1
- package/dist/filters/rangeFilterPopup.d.ts +0 -30
- package/dist/filters/rangeFilterPopup.d.ts.map +0 -1
- package/dist/filters/rangeFilterPopup.js +0 -137
- package/dist/filters/rangeFilterPopup.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseEditor.d.ts","sourceRoot":"","sources":["../../src/editors/baseEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"baseEditor.d.ts","sourceRoot":"","sources":["../../src/editors/baseEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAO,MAAM,KAAK,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,qBAAa,WAAY,SAAQ,KAAK;CAAI;AAE1C,8BAAsB,UAAW,SAAQ,UAAU;IAElD,MAAM,CAAC,UAAU,0BAef;IAEF,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC;IACrB,SAAS,CAAC,MAAM,UAAS;IACzB,SAAS,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAC3C,SAAS,CAAC,eAAe,EAAE,SAAS,CAAC;IACrC,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC;IAEhC,SAAS,CAAC,KAAK,UAAS;IACxB,IAAI,MAAM,YAAwB;IAElC,SAAS,CAAC,MAAM,UAAQ;IACxB,IAAI,OAAO,YAAyB;IAEpC,SAAS,KAAK,eAAe,YAAgE;IAG7F,QAAQ;;IAaR,QAAQ,CAAC,QAAQ,IAAK,OAAO;IAE7B,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAI,IAAI;IAExC,eAAe,IAAK,MAAM;IAI1B,IAAI;IAaJ,iBAAiB;IAKjB,aAAa;IAOb,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,GAAE,OAAc,EAAE,cAAc,UAAO;IAkBpE,MAAM;IAWN,KAAK;IAgBL,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAI,IAAI;IAKhC,UAAU,IAAK,IAAI;CAInB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isValidValue } from "@omegagrid/grid-core";
|
|
2
2
|
import { LitElement, css } from 'lit';
|
|
3
3
|
import { dom } from "@omegagrid/core";
|
|
4
4
|
export class EditorEvent extends Event {
|
|
@@ -7,10 +7,11 @@ export class BaseEditor extends LitElement {
|
|
|
7
7
|
get isOpen() { return this._open; }
|
|
8
8
|
get isValid() { return this._valid; }
|
|
9
9
|
get formulasEnabled() { return this.grid ? this.grid.model.formulasEnabled : true; }
|
|
10
|
+
// an invalid value is marked also when the cell takes it (validation.allowInvalid)
|
|
10
11
|
validate() {
|
|
11
12
|
this._valid = true;
|
|
12
13
|
if (this.activeCell)
|
|
13
|
-
this._valid =
|
|
14
|
+
this._valid = isValidValue(this.activeCellModel, this.getValue());
|
|
14
15
|
this.classList.toggle('invalid', !this._valid);
|
|
15
16
|
return this._valid;
|
|
16
17
|
}
|
|
@@ -51,6 +52,7 @@ export class BaseEditor extends LitElement {
|
|
|
51
52
|
}
|
|
52
53
|
open(grid, initialValue = null, updatePosition = true) {
|
|
53
54
|
this._valid = true;
|
|
55
|
+
this.classList.remove('invalid'); // the editor is shared by the cells, the mark of the previous one must not stay
|
|
54
56
|
this.initialValue = initialValue;
|
|
55
57
|
this._open = true;
|
|
56
58
|
this.grid = grid;
|
|
@@ -81,7 +83,8 @@ export class BaseEditor extends LitElement {
|
|
|
81
83
|
this.grid.table.renderBodyCell(this.activeCellModel);
|
|
82
84
|
this.grid.selecting.showSelector();
|
|
83
85
|
// preventScroll: focus would otherwise natively scroll overflow:hidden
|
|
84
|
-
// ancestors (e.g. og-container) that manage scrolling themselves
|
|
86
|
+
// ancestors (e.g. og-container) that manage scrolling themselves;
|
|
87
|
+
// the editor is still open here: the blur of a text input commits its value (TextEditor)
|
|
85
88
|
this.grid.focus({ preventScroll: true });
|
|
86
89
|
this._open = false;
|
|
87
90
|
this.grid.editing.endEdit();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseEditor.js","sourceRoot":"","sources":["../../src/editors/baseEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,
|
|
1
|
+
{"version":3,"file":"baseEditor.js","sourceRoot":"","sources":["../../src/editors/baseEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGtC,MAAM,OAAO,WAAY,SAAQ,KAAK;CAAI;AAE1C,MAAM,OAAgB,UAAW,SAAQ,UAAU;IA0BlD,IAAI,MAAM,KAAK,OAAO,IAAI,CAAC,KAAK,CAAA,CAAC,CAAC;IAGlC,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IAEpC,IAAc,eAAe,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAA,CAAC,CAAC;IAE7F,mFAAmF;IACnF,QAAQ;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,IAAI,CAAC,UAAU;YAAE,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvF,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;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E,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,EAAC,CACjE,CAAC;YACF,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK;QACJ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACrD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;YACnC,uEAAuE;YACvE,kEAAkE;YAClE,yFAAyF;YACzF,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAC,aAAa,EAAE,IAAI,EAAC,CAAC,CAAC;YACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,QAAQ,CAAC,IAAe;QACvB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,UAAU;QACT,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IACnD,CAAC;;AAlIM,qBAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;EAetB,AAfgB,CAef","sourcesContent":["import { CellModel, CellValueType, isValidValue } from \"@omegagrid/grid-core\";\nimport { LitElement, css } from 'lit';\nimport { dom } from \"@omegagrid/core\";\nimport { Grid } from \"../ui/grid\";\n\nexport class EditorEvent extends Event { }\n\nexport abstract class BaseEditor extends LitElement {\n\n\tstatic baseStyles = css`\n\t\t* { box-sizing: border-box }\n\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tbackground: var(--og-cell-background);\n\t\t\tz-index: 200;\n\t\t}\n\n\t\t:host(.invalid) input {\n\t\t\tcolor: #ff0000;\n\t\t\tborder: 1px solid #ff0000;\n\t\t}\n\t`;\n\n\tprotected grid: Grid;\n\tprotected cancel = false;\n\tprotected activeCell: HTMLTableCellElement;\n\tprotected activeCellModel: CellModel;\n\tprotected initialValue: unknown;\n\t\n\tprotected _open = false;\n\tget isOpen() { return this._open }\n\n\tprotected _valid = true;\n\tget isValid() { return this._valid }\n\n\tprotected get formulasEnabled() { return this.grid ? this.grid.model.formulasEnabled : true }\n\n\t// an invalid value is marked also when the cell takes it (validation.allowInvalid)\n\tvalidate() {\n\t\tthis._valid = true;\n\t\tif (this.activeCell) this._valid = isValidValue(this.activeCellModel, this.getValue());\n\t\tthis.classList.toggle('invalid', !this._valid);\n\t\treturn this._valid;\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.init();\n\t}\n\n\t\n\tabstract getValue() : unknown;\n\n\tabstract setValue(value: unknown) : void;\n\t\n\tgetDisplayValue() : string {\n\t\treturn null;\n\t}\n\n\tinit() {\n\t\tthis.addEventListener('keydown', e => {\n\t\t\tif (e.key == 'Enter') {\n\t\t\t\tthis.close();\n\t\t\t} else if (e.key == 'Escape') {\n\t\t\t\tthis.cancel = true;\n\t\t\t\tthis.close();\n\t\t\t} else {\n\t\t\t\te.stopPropagation();\n\t\t\t}\n\t\t});\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.performUpdate();\n\t}\n\n\talignWithCell() {\n\t\tif (!this.activeCell) return;\n\t\tconst offset = dom.getElementOffset(this.activeCell, this.grid);\n\t\tdom.setPosition(this, {t: offset.top * this.grid.zoom, l: offset.left * this.grid.zoom});\n\t\tdom.setSize(this, {w: this.activeCell.offsetWidth, h: this.activeCell.offsetHeight});\n\t}\n\n\topen(grid: Grid, initialValue: unknown = null, updatePosition = true) {\n\t\tthis._valid = true;\n\t\tthis.classList.remove('invalid'); // the editor is shared by the cells, the mark of the previous one must not stay\n\t\tthis.initialValue = initialValue;\n\t\tthis._open = true;\n\t\tthis.grid = grid;\n\t\tconst cellModel = grid.selecting.activeCell;\n\t\tthis.activeCellModel = cellModel;\n\t\tthis.activeCell = this.grid.table.getCellByModelIndex(cellModel.c, cellModel.r);\n\t\tthis.grid.selector.hide();\n\t\tdom.showElement(this);\n\t\tif (updatePosition) this.alignWithCell();\n\t\tthis.activate(cellModel);\n\t\tif (initialValue !== null) this.setValue(initialValue);\n\t\tdom.zoomElement(this, this.grid.zoom);\n\t\treturn this;\n\t}\n\n\tcommit() {\n\t\tif (this._open && !this.cancel && this.activeCellModel) {\n\t\t\tthis.grid.editing.updateCell(\n\t\t\t\tthis.activeCellModel, \n\t\t\t\t{v: this.getValue() as CellValueType, dv: this.getDisplayValue()}\n\t\t\t);\n\t\t\tthis.grid.rendering.updateCell(this.activeCellModel, true);\n\t\t}\n\t\tthis.cancel = false;\n\t}\n\n\tclose() {\n\t\tif (this._open) {\n\t\t\tthis.deactivate();\n\t\t\tdom.hideElement(this);\n\t\t\tthis.grid.table.renderBodyCell(this.activeCellModel);\n\t\t\tthis.grid.selecting.showSelector();\n\t\t\t// preventScroll: focus would otherwise natively scroll overflow:hidden\n\t\t\t// ancestors (e.g. og-container) that manage scrolling themselves;\n\t\t\t// the editor is still open here: the blur of a text input commits its value (TextEditor)\n\t\t\tthis.grid.focus({preventScroll: true});\n\t\t\tthis._open = false;\n\t\t\tthis.grid.editing.endEdit();\n\t\t}\n\t\tthis.cancel = false;\n\t}\n\n\tactivate(cell: CellModel) : void {\n\t\tthis.activeCellModel = cell;\n\t\tthis.dispatchEvent(new EditorEvent('activate'));\n\t}\n\t\n\tdeactivate() : void {\n\t\tthis.dispatchEvent(new EditorEvent('deactivate'));\n\t}\n\n}"]}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { BaseEditor } from "./baseEditor";
|
|
2
2
|
import { CellModel } from '@omegagrid/grid-core';
|
|
3
3
|
export declare class CalendarEditor extends BaseEditor {
|
|
4
|
+
#private;
|
|
4
5
|
calendar: any;
|
|
6
|
+
protected withTime: boolean;
|
|
7
|
+
protected timeOnly: boolean;
|
|
8
|
+
init(): void;
|
|
5
9
|
setValue(value: number | string | Date): void;
|
|
6
|
-
getValue(): number;
|
|
10
|
+
getValue(): number | Date;
|
|
11
|
+
getDateFormat(cell: CellModel): string;
|
|
7
12
|
activate(cell: CellModel): Promise<void>;
|
|
13
|
+
commit(): void;
|
|
8
14
|
_onChange: () => void;
|
|
15
|
+
_onDropdownClose: () => void;
|
|
16
|
+
_onDocumentKeyDown: (e: KeyboardEvent) => void;
|
|
9
17
|
render: () => import("lit-html").TemplateResult<1>;
|
|
18
|
+
disconnectedCallback(): void;
|
|
10
19
|
close(): void;
|
|
11
20
|
}
|
|
12
21
|
//# sourceMappingURL=calendarEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendarEditor.d.ts","sourceRoot":"","sources":["../../src/editors/calendarEditor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"calendarEditor.d.ts","sourceRoot":"","sources":["../../src/editors/calendarEditor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAoC,MAAM,sBAAsB,CAAC;AAEnF,qBACa,cAAe,SAAQ,UAAU;;IAG7C,QAAQ,EAAE,GAAG,CAAC;IAGd,SAAS,CAAC,QAAQ,UAAS;IAG3B,SAAS,CAAC,QAAQ,UAAS;IAQ3B,IAAI;IAQJ,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAC,MAAM,GAAC,IAAI;IAuBlC,QAAQ,IAAK,MAAM,GAAC,IAAI;IAOxB,aAAa,CAAC,IAAI,EAAE,SAAS;IAMvB,QAAQ,CAAC,IAAI,EAAE,SAAS;IAoB9B,MAAM;IAUN,SAAS,aAGR;IAED,gBAAgB,aAEf;IAGD,kBAAkB,GAAI,GAAG,aAAa,UAKrC;IAED,MAAM,6CAOJ;IAGF,oBAAoB;IAMpB,KAAK;CAgBL"}
|
|
@@ -5,65 +5,159 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
9
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
11
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
12
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
13
|
+
};
|
|
14
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
15
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
16
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
17
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
18
|
+
};
|
|
19
|
+
var _CalendarEditor_changed, _CalendarEditor_typedText, _CalendarEditor_closing;
|
|
8
20
|
import { customElement, query } from 'lit/decorators.js';
|
|
9
21
|
import { dates, utils } from "@omegagrid/core";
|
|
10
22
|
import { getLocale } from "@omegagrid/localize";
|
|
11
23
|
import { BaseEditor } from "./baseEditor";
|
|
12
24
|
import { html } from 'lit';
|
|
13
|
-
import {
|
|
25
|
+
import { getDateTimeFormat, getTimeFormat } from '@omegagrid/grid-core';
|
|
14
26
|
let CalendarEditor = class CalendarEditor extends BaseEditor {
|
|
15
27
|
constructor() {
|
|
16
28
|
super(...arguments);
|
|
29
|
+
// a date and time cell (type dt) and a time cell (type tm) hold a Date, a date cell a serial date
|
|
30
|
+
this.withTime = false;
|
|
31
|
+
// a time cell picks its time of day alone, without the calendar
|
|
32
|
+
this.timeOnly = false;
|
|
33
|
+
// whether the calendar changed the value: an untouched value is not written back (the cell would count as edited)
|
|
34
|
+
_CalendarEditor_changed.set(this, false);
|
|
35
|
+
// a text the editing starts with (the key pressed on the cell): typed into the input of the dropdown when it opens
|
|
36
|
+
_CalendarEditor_typedText.set(this, null);
|
|
37
|
+
// the editing is ending: a change taken over from the input meanwhile does not end it again
|
|
38
|
+
_CalendarEditor_closing.set(this, false);
|
|
39
|
+
// a day pick ends the editing; with time the dropdown stays open for the time row (or shows it alone) and the editing ends with it
|
|
17
40
|
this._onChange = () => {
|
|
18
|
-
this
|
|
41
|
+
__classPrivateFieldSet(this, _CalendarEditor_changed, true, "f");
|
|
42
|
+
if (!this.withTime && !__classPrivateFieldGet(this, _CalendarEditor_closing, "f"))
|
|
43
|
+
this.close();
|
|
44
|
+
};
|
|
45
|
+
this._onDropdownClose = () => {
|
|
46
|
+
if (this.isOpen)
|
|
47
|
+
this.close();
|
|
48
|
+
};
|
|
49
|
+
// the dropdown is not inside the editor: a key pressed after a click in it goes to the document
|
|
50
|
+
this._onDocumentKeyDown = (e) => {
|
|
51
|
+
if (e.key != 'Escape' || !this.isOpen)
|
|
52
|
+
return;
|
|
53
|
+
if (this.calendar.closeInnerList?.())
|
|
54
|
+
return; // the month or year list of the calendar was open: closed alone
|
|
55
|
+
this.cancel = true;
|
|
19
56
|
this.close();
|
|
20
57
|
};
|
|
21
58
|
this.render = () => html `
|
|
22
59
|
<og-calendar-dropdown
|
|
23
60
|
buttonInput
|
|
24
61
|
cross
|
|
25
|
-
@change="${this._onChange}"
|
|
62
|
+
@change="${this._onChange}"
|
|
63
|
+
@dropdown.close="${this._onDropdownClose}">
|
|
26
64
|
</og-calendar-dropdown>
|
|
27
65
|
`;
|
|
28
66
|
}
|
|
67
|
+
init() {
|
|
68
|
+
super.init();
|
|
69
|
+
// Escape with the month or year list of the calendar open (the focus in the input) closes that list alone
|
|
70
|
+
this.addEventListener('keydown', (e) => {
|
|
71
|
+
if (e.key == 'Escape' && this.calendar?.closeInnerList?.())
|
|
72
|
+
e.stopImmediatePropagation();
|
|
73
|
+
}, { capture: true });
|
|
74
|
+
}
|
|
29
75
|
setValue(value) {
|
|
30
76
|
if (value == null) {
|
|
31
77
|
this.calendar.value = null;
|
|
32
78
|
return;
|
|
33
79
|
}
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
if (date) {
|
|
37
|
-
this.calendar.value = date;
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else if (utils.isNumber(value)) {
|
|
42
|
-
this.calendar.value = dates.serialDateToDate(value);
|
|
80
|
+
if (value instanceof Date) {
|
|
81
|
+
this.calendar.value = value;
|
|
43
82
|
return;
|
|
44
83
|
}
|
|
45
|
-
|
|
46
|
-
this.calendar.value = value;
|
|
84
|
+
if (utils.isNumber(value)) {
|
|
85
|
+
this.calendar.value = this.withTime ? dates.serialDateToDateTime(value) : dates.serialDateToDate(value);
|
|
47
86
|
return;
|
|
48
87
|
}
|
|
49
|
-
|
|
88
|
+
const date = this.timeOnly
|
|
89
|
+
? dates.parseTime(value, getLocale())
|
|
90
|
+
: (this.withTime ? dates.parseDateTime(value, getLocale()) : dates.parse(value, getLocale()));
|
|
91
|
+
if (date)
|
|
92
|
+
this.calendar.value = date;
|
|
93
|
+
else
|
|
94
|
+
__classPrivateFieldSet(this, _CalendarEditor_typedText, value, "f"); // not a date yet: the text goes on being typed in the input
|
|
50
95
|
}
|
|
51
96
|
getValue() {
|
|
52
97
|
const date = this.calendar?.value;
|
|
53
|
-
|
|
54
|
-
|
|
98
|
+
if (!date)
|
|
99
|
+
return null;
|
|
100
|
+
return this.withTime ? date : dates.dateToSerialDate(date);
|
|
101
|
+
}
|
|
102
|
+
// the format the cell shows its date in (the dropdown falls back to its own when it is not a date format)
|
|
103
|
+
getDateFormat(cell) {
|
|
104
|
+
const options = cell.model.options;
|
|
105
|
+
return cell.format
|
|
106
|
+
|| (this.timeOnly ? getTimeFormat(options) : (this.withTime ? getDateTimeFormat(options) : options.dateFormat));
|
|
55
107
|
}
|
|
56
108
|
async activate(cell) {
|
|
57
109
|
super.activate(cell);
|
|
58
|
-
|
|
59
|
-
|
|
110
|
+
__classPrivateFieldSet(this, _CalendarEditor_changed, false, "f");
|
|
111
|
+
__classPrivateFieldSet(this, _CalendarEditor_typedText, null, "f");
|
|
112
|
+
this.withTime = cell.type === 'dt' || cell.type === 'tm';
|
|
113
|
+
this.timeOnly = cell.type === 'tm';
|
|
114
|
+
this.calendar.withTime = cell.type === 'dt';
|
|
115
|
+
this.calendar.timeOnly = this.timeOnly;
|
|
116
|
+
this.calendar.dateFormat = this.getDateFormat(cell);
|
|
117
|
+
// the value goes first, the key the editing started with comes next (BaseEditor.open) and is typed on top of it
|
|
60
118
|
this.setValue(cell.value);
|
|
119
|
+
document.addEventListener('keydown', this._onDocumentKeyDown);
|
|
120
|
+
await this.calendar.updateComplete;
|
|
121
|
+
if (!this.isOpen)
|
|
122
|
+
return; // closed meanwhile
|
|
123
|
+
await this.calendar.open(__classPrivateFieldGet(this, _CalendarEditor_typedText, "f"));
|
|
124
|
+
// the keys typed go on in the input of the dropdown
|
|
125
|
+
this.calendar.input?.focus();
|
|
126
|
+
__classPrivateFieldSet(this, _CalendarEditor_typedText, null, "f");
|
|
127
|
+
}
|
|
128
|
+
commit() {
|
|
129
|
+
if (__classPrivateFieldGet(this, _CalendarEditor_changed, "f"))
|
|
130
|
+
super.commit();
|
|
131
|
+
else
|
|
132
|
+
this.cancel = false;
|
|
133
|
+
__classPrivateFieldSet(this, _CalendarEditor_changed, false, "f");
|
|
61
134
|
}
|
|
135
|
+
// a grid removed while the editor is open does not close it: the document listener would keep both alive
|
|
136
|
+
disconnectedCallback() {
|
|
137
|
+
super.disconnectedCallback();
|
|
138
|
+
document.removeEventListener('keydown', this._onDocumentKeyDown);
|
|
139
|
+
}
|
|
140
|
+
// the editing may end outside the dropdown too (a click on another cell): the picked value is kept unless cancelled
|
|
62
141
|
close() {
|
|
142
|
+
document.removeEventListener('keydown', this._onDocumentKeyDown);
|
|
143
|
+
if (this.isOpen && !this.cancel) {
|
|
144
|
+
// a text typed into the input and not left yet: the click elsewhere ends the editing before the input loses the focus
|
|
145
|
+
__classPrivateFieldSet(this, _CalendarEditor_closing, true, "f");
|
|
146
|
+
try {
|
|
147
|
+
this.calendar.commitInput?.();
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
__classPrivateFieldSet(this, _CalendarEditor_closing, false, "f");
|
|
151
|
+
}
|
|
152
|
+
this.commit();
|
|
153
|
+
}
|
|
63
154
|
super.close();
|
|
64
155
|
this.calendar.close();
|
|
65
156
|
}
|
|
66
157
|
};
|
|
158
|
+
_CalendarEditor_changed = new WeakMap();
|
|
159
|
+
_CalendarEditor_typedText = new WeakMap();
|
|
160
|
+
_CalendarEditor_closing = new WeakMap();
|
|
67
161
|
__decorate([
|
|
68
162
|
query('og-calendar-dropdown')
|
|
69
163
|
], CalendarEditor.prototype, "calendar", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendarEditor.js","sourceRoot":"","sources":["../../src/editors/calendarEditor.ts"],"names":[],"mappings":"AAAA,uDAAuD;;;;;;;AAEvD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CA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,CAAC,QAAQ,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,QAAQ;QACP,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAe;QACvB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3B,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QACnC,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC;IACxC,CAAC;IAeJ,KAAK;QACJ,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CAED,CAAA;AAxDA;IADC,KAAK,CAAC,sBAAsB,CAAC;gDAChB;AAHF,cAAc;IAD1B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,cAAc,CA2D1B","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { customElement, query } from 'lit/decorators.js';\nimport { dates, utils } from \"@omegagrid/core\";\nimport { getLocale } from \"@omegagrid/localize\";\nimport { BaseEditor } from \"./baseEditor\";\nimport { html } from 'lit';\nimport { startOfDay } from 'date-fns';\nimport { CellModel } from '@omegagrid/grid-core';\n\n@customElement('og-grid-calendareditor')\nexport class CalendarEditor extends BaseEditor {\n\n\t@query('og-calendar-dropdown')\n\tcalendar: any;\n\n\tsetValue(value: number|string|Date) {\n\t\tif (value == null) {\n\t\t\tthis.calendar.value = null;\n\t\t\treturn;\n\t\t}\n\n\t\tif (utils.isString(value)) {\n\t\t\tconst date = dates.parse(value as string, getLocale());\n\t\t\tif (date) {\n\t\t\t\tthis.calendar.value = date;\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else if (utils.isNumber(value)) {\n\t\t\tthis.calendar.value = dates.serialDateToDate(value as number);\n\t\t\treturn;\n\t\t} else {\n\t\t\tthis.calendar.value = value as Date;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.calendar.value = startOfDay(new Date());\n\t}\n\n\tgetValue() : number {\n\t\tconst date = this.calendar?.value;\n\t\tconsole.log(date);\n\t\treturn date ? dates.dateToSerialDate(date) : null;\n\t}\n\n\tasync activate(cell: CellModel) {\n super.activate(cell);\n\t\tawait this.calendar.updateComplete;\n\t\tawait this.calendar.open();\n this.setValue(cell.value as number);\n }\n\n\t_onChange = () => {\n\t\tthis.commit();\n\t\tthis.close();\n\t}\t\t\n\n\trender = () => html`\n\t\t<og-calendar-dropdown\n\t\t\tbuttonInput\n\t\t\tcross\n\t\t\t@change=\"${this._onChange}\">\n\t\t</og-calendar-dropdown>\n\t`;\n\t\n\tclose() {\n\t\tsuper.close();\n\t\tthis.calendar.close();\n\t}\n\n}"]}
|
|
1
|
+
{"version":3,"file":"calendarEditor.js","sourceRoot":"","sources":["../../src/editors/calendarEditor.ts"],"names":[],"mappings":"AAAA,uDAAuD;;;;;;;;;;;;;;;;;;;AAEvD,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAa,iBAAiB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG5E,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAA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AAK,CAAC,sBAAsB,CAAC;gDAChB;AAHF,cAAc;IAD1B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,cAAc,CA4I1B","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { customElement, query } from 'lit/decorators.js';\nimport { dates, utils } from \"@omegagrid/core\";\nimport { getLocale } from \"@omegagrid/localize\";\nimport { BaseEditor } from \"./baseEditor\";\nimport { html } from 'lit';\nimport { CellModel, getDateTimeFormat, getTimeFormat } from '@omegagrid/grid-core';\n\n@customElement('og-grid-calendareditor')\nexport class CalendarEditor extends BaseEditor {\n\n\t@query('og-calendar-dropdown')\n\tcalendar: any;\n\n\t// a date and time cell (type dt) and a time cell (type tm) hold a Date, a date cell a serial date\n\tprotected withTime = false;\n\n\t// a time cell picks its time of day alone, without the calendar\n\tprotected timeOnly = false;\n\n\t// whether the calendar changed the value: an untouched value is not written back (the cell would count as edited)\n\t#changed = false;\n\n\t// a text the editing starts with (the key pressed on the cell): typed into the input of the dropdown when it opens\n\t#typedText: string = null;\n\n\tinit() {\n\t\tsuper.init();\n\t\t// Escape with the month or year list of the calendar open (the focus in the input) closes that list alone\n\t\tthis.addEventListener('keydown', (e: KeyboardEvent) => {\n\t\t\tif (e.key == 'Escape' && this.calendar?.closeInnerList?.()) e.stopImmediatePropagation();\n\t\t}, {capture: true});\n\t}\n\n\tsetValue(value: number|string|Date) {\n\t\tif (value == null) {\n\t\t\tthis.calendar.value = null;\n\t\t\treturn;\n\t\t}\n\n\t\tif (value instanceof Date) {\n\t\t\tthis.calendar.value = value;\n\t\t\treturn;\n\t\t}\n\n\t\tif (utils.isNumber(value)) {\n\t\t\tthis.calendar.value = this.withTime ? dates.serialDateToDateTime(value as number) : dates.serialDateToDate(value as number);\n\t\t\treturn;\n\t\t}\n\n\t\tconst date = this.timeOnly\n\t\t\t? dates.parseTime(value as string, getLocale())\n\t\t\t: (this.withTime ? dates.parseDateTime(value as string, getLocale()) : dates.parse(value as string, getLocale()));\n\t\tif (date) this.calendar.value = date;\n\t\telse this.#typedText = value as string; // not a date yet: the text goes on being typed in the input\n\t}\n\n\tgetValue() : number|Date {\n\t\tconst date = this.calendar?.value;\n\t\tif (!date) return null;\n\t\treturn this.withTime ? date : dates.dateToSerialDate(date);\n\t}\n\n\t// the format the cell shows its date in (the dropdown falls back to its own when it is not a date format)\n\tgetDateFormat(cell: CellModel) {\n\t\tconst options = cell.model.options;\n\t\treturn cell.format\n\t\t\t|| (this.timeOnly ? getTimeFormat(options) : (this.withTime ? getDateTimeFormat(options) : options.dateFormat));\n\t}\n\n\tasync activate(cell: CellModel) {\n\t\tsuper.activate(cell);\n\t\tthis.#changed = false;\n\t\tthis.#typedText = null;\n\t\tthis.withTime = cell.type === 'dt' || cell.type === 'tm';\n\t\tthis.timeOnly = cell.type === 'tm';\n\t\tthis.calendar.withTime = cell.type === 'dt';\n\t\tthis.calendar.timeOnly = this.timeOnly;\n\t\tthis.calendar.dateFormat = this.getDateFormat(cell);\n\t\t// the value goes first, the key the editing started with comes next (BaseEditor.open) and is typed on top of it\n\t\tthis.setValue(cell.value as number);\n\t\tdocument.addEventListener('keydown', this._onDocumentKeyDown);\n\t\tawait this.calendar.updateComplete;\n\t\tif (!this.isOpen) return; // closed meanwhile\n\t\tawait this.calendar.open(this.#typedText);\n\t\t// the keys typed go on in the input of the dropdown\n\t\tthis.calendar.input?.focus();\n\t\tthis.#typedText = null;\n\t}\n\n\tcommit() {\n\t\tif (this.#changed) super.commit();\n\t\telse this.cancel = false;\n\t\tthis.#changed = false;\n\t}\n\n\t// the editing is ending: a change taken over from the input meanwhile does not end it again\n\t#closing = false;\n\n\t// a day pick ends the editing; with time the dropdown stays open for the time row (or shows it alone) and the editing ends with it\n\t_onChange = () => {\n\t\tthis.#changed = true;\n\t\tif (!this.withTime && !this.#closing) this.close();\n\t}\n\n\t_onDropdownClose = () => {\n\t\tif (this.isOpen) this.close();\n\t}\n\n\t// the dropdown is not inside the editor: a key pressed after a click in it goes to the document\n\t_onDocumentKeyDown = (e: KeyboardEvent) => {\n\t\tif (e.key != 'Escape' || !this.isOpen) return;\n\t\tif (this.calendar.closeInnerList?.()) return; // the month or year list of the calendar was open: closed alone\n\t\tthis.cancel = true;\n\t\tthis.close();\n\t}\n\n\trender = () => html`\n\t\t<og-calendar-dropdown\n\t\t\tbuttonInput\n\t\t\tcross\n\t\t\t@change=\"${this._onChange}\"\n\t\t\t@dropdown.close=\"${this._onDropdownClose}\">\n\t\t</og-calendar-dropdown>\n\t`;\n\n\t// a grid removed while the editor is open does not close it: the document listener would keep both alive\n\tdisconnectedCallback() {\n\t\tsuper.disconnectedCallback();\n\t\tdocument.removeEventListener('keydown', this._onDocumentKeyDown);\n\t}\n\n\t// the editing may end outside the dropdown too (a click on another cell): the picked value is kept unless cancelled\n\tclose() {\n\t\tdocument.removeEventListener('keydown', this._onDocumentKeyDown);\n\t\tif (this.isOpen && !this.cancel) {\n\t\t\t// a text typed into the input and not left yet: the click elsewhere ends the editing before the input loses the focus\n\t\t\tthis.#closing = true;\n\t\t\ttry {\n\t\t\t\tthis.calendar.commitInput?.();\n\t\t\t} finally {\n\t\t\t\tthis.#closing = false;\n\t\t\t}\n\t\t\tthis.commit();\n\t\t}\n\t\tsuper.close();\n\t\tthis.calendar.close();\n\t}\n\n}"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { TextEditor } from "./textEditor";
|
|
2
2
|
import { CellModel } from "@omegagrid/grid-core";
|
|
3
3
|
export declare class DateEditor extends TextEditor {
|
|
4
|
+
protected withTime: boolean;
|
|
5
|
+
protected timeOnly: boolean;
|
|
4
6
|
setValue(value: number | string | Date): void;
|
|
5
|
-
getValue(): number;
|
|
7
|
+
getValue(): number | Date;
|
|
6
8
|
activate(cell: CellModel): void;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=dateEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateEditor.d.ts","sourceRoot":"","sources":["../../src/editors/dateEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,qBACa,UAAW,SAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"dateEditor.d.ts","sourceRoot":"","sources":["../../src/editors/dateEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,qBACa,UAAW,SAAQ,UAAU;IAGzC,SAAS,CAAC,QAAQ,UAAS;IAG3B,SAAS,CAAC,QAAQ,UAAS;IAE3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAC,MAAM,GAAC,IAAI;IAoBlC,QAAQ,IAAK,MAAM,GAAC,IAAI;IAOxB,QAAQ,CAAC,IAAI,EAAE,SAAS;CAOxB"}
|
|
@@ -6,27 +6,46 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { TextEditor } from "./textEditor";
|
|
8
8
|
import { customElement } from 'lit/decorators.js';
|
|
9
|
-
import { dates } from "@omegagrid/core";
|
|
9
|
+
import { dates, utils } from "@omegagrid/core";
|
|
10
10
|
import { getLocale } from "@omegagrid/localize";
|
|
11
11
|
let DateEditor = class DateEditor extends TextEditor {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
// a date and time cell (type dt) holds a Date, a date cell a serial date
|
|
15
|
+
this.withTime = false;
|
|
16
|
+
// a time cell (type tm) holds a Date of its time of day
|
|
17
|
+
this.timeOnly = false;
|
|
18
|
+
}
|
|
12
19
|
setValue(value) {
|
|
13
20
|
if (value == null) {
|
|
14
21
|
this.input.value = '';
|
|
15
22
|
return;
|
|
16
23
|
}
|
|
24
|
+
// a text is shown as it is: the key that started the editing (a date is formatted only from its Date or serial date)
|
|
25
|
+
if (utils.isString(value)) {
|
|
26
|
+
this.input.value = value;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
17
29
|
try {
|
|
18
|
-
this.
|
|
30
|
+
const format = this.timeOnly ? 'HH:mm:ss' : (this.withTime ? 'yyyy-MM-dd HH:mm:ss' : 'yyyy-MM-dd');
|
|
31
|
+
this.input.value = dates.getDateFormatter(getLocale(), format)(value);
|
|
19
32
|
}
|
|
20
33
|
catch (error) {
|
|
21
|
-
this.input.value = value
|
|
34
|
+
this.input.value = value.toString();
|
|
22
35
|
}
|
|
23
36
|
}
|
|
24
37
|
getValue() {
|
|
38
|
+
if (this.timeOnly)
|
|
39
|
+
return dates.parseTime(this.input.value, getLocale());
|
|
40
|
+
if (this.withTime)
|
|
41
|
+
return dates.parseDateTime(this.input.value, getLocale());
|
|
25
42
|
const date = dates.parse(this.input.value, getLocale());
|
|
26
43
|
return date ? dates.dateToSerialDate(date) : null;
|
|
27
44
|
}
|
|
28
45
|
activate(cell) {
|
|
29
46
|
super.activate(cell);
|
|
47
|
+
this.withTime = cell.type === 'dt';
|
|
48
|
+
this.timeOnly = cell.type === 'tm';
|
|
30
49
|
this.setValue(cell.value);
|
|
31
50
|
}
|
|
32
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateEditor.js","sourceRoot":"","sources":["../../src/editors/dateEditor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"dateEditor.js","sourceRoot":"","sources":["../../src/editors/dateEditor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,K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,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7E,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnD,CAAC;IAED,QAAQ,CAAC,IAAe;QACjB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC;IACxC,CAAC;CAEJ,CAAA;AA1CY,UAAU;IADtB,aAAa,CAAC,oBAAoB,CAAC;GACvB,UAAU,CA0CtB","sourcesContent":["import { TextEditor } from \"./textEditor\";\nimport { customElement } from 'lit/decorators.js';\nimport { dates, utils } from \"@omegagrid/core\";\nimport { getLocale } from \"@omegagrid/localize\";\nimport { CellModel } from \"@omegagrid/grid-core\";\n\n@customElement('og-grid-dateeditor')\nexport class DateEditor extends TextEditor {\n\n\t// a date and time cell (type dt) holds a Date, a date cell a serial date\n\tprotected withTime = false;\n\n\t// a time cell (type tm) holds a Date of its time of day\n\tprotected timeOnly = false;\n\n\tsetValue(value: number|string|Date) {\n\t\tif (value == null) {\n\t\t\tthis.input.value = '';\n\t\t\treturn;\n\t\t}\n\n\t\t// a text is shown as it is: the key that started the editing (a date is formatted only from its Date or serial date)\n\t\tif (utils.isString(value)) {\n\t\t\tthis.input.value = value as string;\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst format = this.timeOnly ? 'HH:mm:ss' : (this.withTime ? 'yyyy-MM-dd HH:mm:ss' : 'yyyy-MM-dd');\n\t\t\tthis.input.value = dates.getDateFormatter(getLocale(), format)(value);\n\t\t} catch (error) {\n\t\t\tthis.input.value = value.toString();\n\t\t}\n\t}\n\n\tgetValue() : number|Date {\n\t\tif (this.timeOnly) return dates.parseTime(this.input.value, getLocale());\n\t\tif (this.withTime) return dates.parseDateTime(this.input.value, getLocale());\n\t\tconst date = dates.parse(this.input.value, getLocale());\n\t\treturn date ? dates.dateToSerialDate(date) : null;\n\t}\n\n\tactivate(cell: CellModel) {\n super.activate(cell);\n\t\tthis.withTime = cell.type === 'dt';\n\t\tthis.timeOnly = cell.type === 'tm';\n this.setValue(cell.value as number);\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/D,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/editors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/D,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAEhC,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAa1D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAI,iBAAiB,CAEnE"}
|
package/dist/editors/index.js
CHANGED
|
@@ -19,6 +19,8 @@ const editorMap = new Map([
|
|
|
19
19
|
['s', () => new DropdownEditor()],
|
|
20
20
|
['m', () => new DropdownEditor()],
|
|
21
21
|
['d', (_cell, options) => options?.dateCalendarEditor ? new CalendarEditor() : new DateEditor()],
|
|
22
|
+
['dt', (_cell, options) => options?.dateCalendarEditor ? new CalendarEditor() : new DateEditor()],
|
|
23
|
+
['tm', (_cell, options) => options?.dateCalendarEditor ? new CalendarEditor() : new DateEditor()],
|
|
22
24
|
]);
|
|
23
25
|
export function getEditorFactory(type) {
|
|
24
26
|
return editorMap.get(editorMap.has(type) ? type : 't');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/editors/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAIhC,MAAM,SAAS,GAAG,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,EAAE,GAAG,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC;IAC/B,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,cAAc,EAAE,CAAC;IACjC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,cAAc,EAAE,CAAC;IACjC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,cAAc,EAAE,CAAC;IACjC,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC;IAChG,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC;IACjG,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC;CACjG,CAAC,CAAC;AAEH,MAAM,UAAU,gBAAgB,CAAC,IAAc;IAC9C,OAAO,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAE,CAAC;AACzD,CAAC","sourcesContent":["import { BaseEditor } from \"./baseEditor\";\nimport { CheckboxEditor } from \"./checkboxEditor\";\nimport { NumberEditor } from \"./numberEditor\";\nimport { TextEditor } from \"./textEditor\";\nimport { DropdownEditor } from \"./dropdownEditor\";\nimport { DateEditor } from \"./dateEditor\";\nimport { CalendarEditor } from \"./calendarEditor\";\nimport { CellType, EditorFactory } from \"@omegagrid/grid-core\";\n\nexport * from \"./baseEditor\";\nexport * from \"./checkboxEditor\";\nexport * from \"./numberEditor\";\nexport * from \"./textEditor\";\nexport * from \"./dropdownEditor\";\nexport * from \"./dateEditor\";\nexport * from \"./calendarEditor\";\nexport * from \"./formulaEditor\";\n\nexport type GridEditorFactory = EditorFactory<BaseEditor>;\n\nconst editorMap = new Map<CellType, GridEditorFactory>([\n\t['t', () => new TextEditor()],\n\t['n', () => new NumberEditor()],\n\t['b', () => new CheckboxEditor()],\n\t['s', () => new DropdownEditor()],\n\t['m', () => new DropdownEditor()],\n\t['d', (_cell, options) => options?.dateCalendarEditor ? new CalendarEditor() : new DateEditor()],\n\t['dt', (_cell, options) => options?.dateCalendarEditor ? new CalendarEditor() : new DateEditor()],\n\t['tm', (_cell, options) => options?.dateCalendarEditor ? new CalendarEditor() : new DateEditor()],\n]);\n\nexport function getEditorFactory(type: CellType) : GridEditorFactory {\n\treturn editorMap.get(editorMap.has(type) ? type : 't')!;\n}"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseFilter } from "./baseFilter";
|
|
2
|
+
import { Dropdown } from '@omegagrid/core';
|
|
3
|
+
import { DateFilterType } from '@omegagrid/grid-core';
|
|
4
|
+
/** The `rangechange` event of og-calendar in the range mode (omega-grid does not depend on omega-calendar) */
|
|
5
|
+
type RangeChangeEvent = Event & {
|
|
6
|
+
from: Date;
|
|
7
|
+
to: Date | null;
|
|
8
|
+
};
|
|
9
|
+
/** og-calendar in the range mode, as far as the filter uses it */
|
|
10
|
+
type RangeCalendar = HTMLElement & {
|
|
11
|
+
range: boolean;
|
|
12
|
+
rangeStart: Date | null;
|
|
13
|
+
rangeEnd: Date | null;
|
|
14
|
+
date: Date;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Text filter of the date (d), date and time (dt) and time (tm) columns. The user types a date expression such as
|
|
18
|
+
* `6.11.2026` (the whole day), `6.11.2026..20.11.2026`, `> 6.11.2026`, `11.2026` (the month), `2026` (the year),
|
|
19
|
+
* `6.11.2026 14:00` (the minute), `9:00..17:00` (a time column), `<= 6.11.2026 or 9.11.2026`; see grid-core's
|
|
20
|
+
* `parseDateExpression`. A date column has a calendar button too: a day or a range of days picked in the calendar
|
|
21
|
+
* with two clicks is written into the input and applied. The expression is applied by Enter: the calendar button takes
|
|
22
|
+
* the place of the filter button of the other text filters.
|
|
23
|
+
*/
|
|
24
|
+
export declare class DateFilter extends BaseFilter {
|
|
25
|
+
static styles: import("lit").CSSResult[];
|
|
26
|
+
private inputRef;
|
|
27
|
+
get input(): HTMLInputElement;
|
|
28
|
+
private clearButtonRef;
|
|
29
|
+
get clearButton(): HTMLButtonElement;
|
|
30
|
+
private dropdownRef;
|
|
31
|
+
get calendarDropdown(): Dropdown;
|
|
32
|
+
private calendarRef;
|
|
33
|
+
get calendar(): RangeCalendar;
|
|
34
|
+
get type(): DateFilterType;
|
|
35
|
+
/** a time column has no calendar */
|
|
36
|
+
get hasCalendar(): boolean;
|
|
37
|
+
private get dayFormat();
|
|
38
|
+
private formatDay;
|
|
39
|
+
/** The text of a term: the expression as typed */
|
|
40
|
+
private termText;
|
|
41
|
+
private _apply;
|
|
42
|
+
_onClearClick(): void;
|
|
43
|
+
_onInputKeyDown(e: KeyboardEvent): void;
|
|
44
|
+
_onCalendarOpen: () => void;
|
|
45
|
+
_onInput: () => void;
|
|
46
|
+
private _syncCalendar;
|
|
47
|
+
_onRangeChange: (e: RangeChangeEvent) => void;
|
|
48
|
+
private get examples();
|
|
49
|
+
render: () => import("lit-html").TemplateResult<1>;
|
|
50
|
+
activate(): void;
|
|
51
|
+
deactivate(): void;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=dateFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateFilter.d.ts","sourceRoot":"","sources":["../../src/filters/dateFilter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,QAAQ,EAAS,MAAM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