@omegagrid/grid 0.11.33 → 0.11.35

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.
@@ -4,7 +4,7 @@ export declare class DateEditor extends TextEditor {
4
4
  protected withTime: boolean;
5
5
  protected timeOnly: boolean;
6
6
  setValue(value: number | string | Date): void;
7
- getValue(): number | Date;
7
+ getValue(): number | Date | string;
8
8
  activate(cell: CellModel): void;
9
9
  }
10
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;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"}
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;IAqBlC,QAAQ,IAAK,MAAM,GAAC,IAAI,GAAC,MAAM;IAS/B,QAAQ,CAAC,IAAI,EAAE,SAAS;CAOxB"}
@@ -34,13 +34,17 @@ let DateEditor = class DateEditor extends TextEditor {
34
34
  this.input.value = value.toString();
35
35
  }
36
36
  }
37
+ // a text the editor cannot read is committed as it is, like a pasted one: the cell keeps it as an invalid date (CellModel.isInvalidDate)
37
38
  getValue() {
39
+ const text = this.input.value;
40
+ if (!text.trim())
41
+ return null;
38
42
  if (this.timeOnly)
39
- return dates.parseTime(this.input.value, getLocale());
43
+ return dates.parseTime(text, getLocale()) ?? text;
40
44
  if (this.withTime)
41
- return dates.parseDateTime(this.input.value, getLocale());
42
- const date = dates.parse(this.input.value, getLocale());
43
- return date ? dates.dateToSerialDate(date) : null;
45
+ return dates.parseDateTime(text, getLocale()) ?? text;
46
+ const date = dates.parse(text, getLocale());
47
+ return date ? dates.dateToSerialDate(date) : text;
44
48
  }
45
49
  activate(cell) {
46
50
  super.activate(cell);
@@ -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,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIzC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAEN,yEAAyE;QAC/D,aAAQ,GAAG,KAAK,CAAC;QAE3B,wDAAwD;QAC9C,aAAQ,GAAG,KAAK,CAAC;IAoC5B,CAAC;IAlCA,QAAQ,CAAC,KAAyB;QACjC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;YACtB,OAAO;QACR,CAAC;QAED,qHAAqH;QACrH,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC,KAAK,CAAC,KAAK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,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
+ {"version":3,"file":"dateEditor.js","sourceRoot":"","sources":["../../src/editors/dateEditor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE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;YAAE,OAAO,IAAI,CAAC;QAC9B,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,IAAI,IAAI,CAAC;QACrE,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,IAAI,IAAI,CAAC;QACzE,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC5C,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;AA7CY,UAAU;IADtB,aAAa,CAAC,oBAAoB,CAAC;GACvB,UAAU,CA6CtB","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\t// a text the editor cannot read is committed as it is, like a pasted one: the cell keeps it as an invalid date (CellModel.isInvalidDate)\n\tgetValue() : number|Date|string {\n\t\tconst text = this.input.value;\n\t\tif (!text.trim()) return null;\n\t\tif (this.timeOnly) return dates.parseTime(text, getLocale()) ?? text;\n\t\tif (this.withTime) return dates.parseDateTime(text, getLocale()) ?? text;\n\t\tconst date = dates.parse(text, getLocale());\n\t\treturn date ? dates.dateToSerialDate(date) : text;\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"]}
@@ -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,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAG3E,8GAA8G;AAC9G,KAAK,gBAAgB,GAAG,KAAK,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,EAAE,EAAE,IAAI,GAAC,IAAI,CAAA;CAAE,CAAC;AAE9D,kEAAkE;AAClE,KAAK,aAAa,GAAG,WAAW,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,IAAI,GAAC,IAAI,CAAC;IAAC,QAAQ,EAAE,IAAI,GAAC,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAE9G;;;;;;;GAOG;AACH,qBACa,UAAW,SAAQ,UAAU;IAEzC,MAAM,CAAC,MAAM,4BAsCV;IAEH,OAAO,CAAC,QAAQ,CAAiC;IACjD,IAAI,KAAK,qBAAiC;IAE1C,OAAO,CAAC,cAAc,CAAkC;IACxD,IAAI,WAAW,sBAAuC;IAEtD,OAAO,CAAC,WAAW,CAAyB;IAC5C,IAAI,gBAAgB,aAAoC;IAExD,OAAO,CAAC,WAAW,CAA8B;IACjD,IAAI,QAAQ,kBAAoC;IAEhD,IAAI,IAAI,IAAI,cAAc,CAGzB;IAED,oCAAoC;IACpC,IAAI,WAAW,YAAgC;IAG/C,OAAO,KAAK,SAAS,GAAmC;IAExD,OAAO,CAAC,SAAS;IAEjB,kDAAkD;IAClD,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,MAAM;IASd,aAAa;IAKb,eAAe,CAAC,CAAC,EAAE,aAAa;IAShC,eAAe,aAA8B;IAE7C,QAAQ,aAEP;IAED,OAAO,CAAC,aAAa;IAcrB,cAAc,GAAI,GAAG,gBAAgB,UAMpC;IAED,OAAO,KAAK,QAAQ,GAMnB;IAED,MAAM,6CAiBJ;IAEF,QAAQ;IAQR,UAAU;CAKV"}
@@ -0,0 +1,179 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import constants from "../constants";
8
+ import { customElement } from 'lit/decorators.js';
9
+ import { BaseFilter } from "./baseFilter";
10
+ import { html, css } from 'lit';
11
+ import { createRef, ref } from 'lit/directives/ref.js';
12
+ import { msg } from '@omegagrid/localize';
13
+ import { dates } from '@omegagrid/core';
14
+ import { parseDateExpression } from '@omegagrid/grid-core';
15
+ import { isSameDay, startOfDay, subMilliseconds } from 'date-fns';
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
+ let DateFilter = class DateFilter extends BaseFilter {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.inputRef = createRef();
28
+ this.clearButtonRef = createRef();
29
+ this.dropdownRef = createRef();
30
+ this.calendarRef = createRef();
31
+ // the calendar shows the days of the typed expression picked, when it is a single day or a range of days: when it
32
+ // opens, and as the text is edited while it is open
33
+ this._onCalendarOpen = () => this._syncCalendar();
34
+ this._onInput = () => {
35
+ if (this.calendarDropdown?.isOpen)
36
+ this._syncCalendar();
37
+ };
38
+ // the second click completes the range: it is written into the input and applied
39
+ this._onRangeChange = (e) => {
40
+ if (!e.to || !this.input)
41
+ return;
42
+ this.input.value = isSameDay(e.from, e.to) ? this.formatDay(e.from) : `${this.formatDay(e.from)}..${this.formatDay(e.to)}`;
43
+ this.calendarDropdown?.close();
44
+ this._apply();
45
+ this.deactivate();
46
+ };
47
+ this.render = () => html `
48
+ <div class="filter-inner">
49
+ <input ${ref(this.inputRef)}
50
+ type="text"
51
+ title="${msg('Examples:')} ${this.examples}"
52
+ @keydown="${this._onInputKeyDown}"
53
+ @input="${this._onInput}"
54
+ .value="${this.termText(this.currentValue)}">
55
+ ${this.hasCalendar ? html `
56
+ <og-dropdown ${ref(this.dropdownRef)} icon="calendar-days" color="accent" alignment="right" noCaret
57
+ title="${msg('Pick a day or a range of days: the first click starts it, the second ends it')}"
58
+ @dropdown.open="${this._onCalendarOpen}">
59
+ <og-calendar ${ref(this.calendarRef)} slot="content" range @rangechange="${this._onRangeChange}"></og-calendar>
60
+ </og-dropdown>
61
+ ` : ''}
62
+ <og-button icon="xmark" color="red" ${ref(this.clearButtonRef)} @mousedown="${this._onClearClick}"></og-button>
63
+ </div>
64
+ `;
65
+ }
66
+ get input() { return this.inputRef.value; }
67
+ get clearButton() { return this.clearButtonRef.value; }
68
+ get calendarDropdown() { return this.dropdownRef.value; }
69
+ get calendar() { return this.calendarRef.value; }
70
+ get type() {
71
+ const t = this.columnModel?.type;
72
+ return (t === 'dt' || t === 'tm') ? t : 'd';
73
+ }
74
+ /** a time column has no calendar */
75
+ get hasCalendar() { return this.type !== 'tm'; }
76
+ // the format the calendar writes a day in: the date format of the locale, read back by the parser
77
+ get dayFormat() { return dates.getDateFormat(); }
78
+ formatDay(day) { return dates.format(day, this.dayFormat); }
79
+ /** The text of a term: the expression as typed */
80
+ termText(term) {
81
+ return term == null ? '' : term.toString();
82
+ }
83
+ _apply() {
84
+ const value = (this.input?.value ?? '').trim();
85
+ if (value === '') {
86
+ this.clearFilter();
87
+ }
88
+ else {
89
+ this.filter(value);
90
+ }
91
+ }
92
+ _onClearClick() {
93
+ if (this.input)
94
+ this.input.value = '';
95
+ this.clearFilter();
96
+ }
97
+ _onInputKeyDown(e) {
98
+ if (e.key == 'Enter') {
99
+ this._apply();
100
+ this.deactivate();
101
+ }
102
+ }
103
+ _syncCalendar() {
104
+ const calendar = this.calendar;
105
+ if (!calendar)
106
+ return;
107
+ const groups = parseDateExpression(this.input?.value ?? '', this.type);
108
+ const bounds = groups?.length === 1 ? groups[0] : null;
109
+ const from = bounds?.find(b => b.op === '>=')?.value ?? null;
110
+ const before = bounds?.find(b => b.op === '<')?.value ?? null;
111
+ calendar.rangeStart = from;
112
+ calendar.rangeEnd = from && before ? startOfDay(subMilliseconds(before, 1)) : null; // the last day of the range
113
+ // the calendar shows the month of the start, of today without one
114
+ calendar.date = startOfDay(from ?? new Date());
115
+ }
116
+ get examples() {
117
+ if (this.type === 'tm')
118
+ return '9:00, 9:00..17:00, >= 12:00, < 8:00 or > 16:00';
119
+ const day = this.formatDay(new Date(2026, 10, 6));
120
+ const other = this.formatDay(new Date(2026, 10, 20));
121
+ const time = this.type === 'dt' ? `, ${day} 14:00` : '';
122
+ return `${day}, ${day}..${other}, > ${day}, 11.2026, 2026, != 2026${time}`;
123
+ }
124
+ activate() {
125
+ super.activate();
126
+ if (this.input) {
127
+ this.input.value = this.termText(this.currentValue);
128
+ }
129
+ setTimeout(() => this.input?.select(), 100);
130
+ }
131
+ deactivate() {
132
+ this.calendarDropdown?.close();
133
+ super.deactivate();
134
+ }
135
+ };
136
+ DateFilter.styles = [...BaseFilter.styles, css `
137
+ .filter-inner {
138
+ height: 100%;
139
+ display: flex;
140
+ flex-direction: row;
141
+ overflow: hidden;
142
+ }
143
+
144
+ input {
145
+ border-width: 0;
146
+ outline: none;
147
+ height: 100%;
148
+ flex: 1;
149
+ width: 100%;
150
+ min-width: 0;
151
+ background-color: var(--og-background-color);
152
+ color: var(--og-text-color);
153
+ }
154
+
155
+ og-button, og-dropdown {
156
+ flex: 0;
157
+ min-width: 18px;
158
+ max-width: 18px;
159
+ padding: 0;
160
+ text-align: center;
161
+ border-width: 0;
162
+ border-radius: 0;
163
+ height: 100%;
164
+ }
165
+
166
+ og-dropdown {
167
+ display: flex;
168
+ }
169
+
170
+ og-calendar {
171
+ width: 300px;
172
+ height: 260px;
173
+ }
174
+ `];
175
+ DateFilter = __decorate([
176
+ customElement(`${constants.PREFIX}-filter-date`)
177
+ ], DateFilter);
178
+ export { Date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AG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,OAAO,GAAG,GAAG,KAAK,GAAG,KAAK,KAAK,OAAO,GAAG,2BAA2B,IAAI,EAAE,CAAC;IAC5E,CAAC;IAqBD,QAAQ;QACP,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,CAAC;QACD,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED,UAAU;QACT,IAAI,CAAC,gBAAgB,EAAE,KAAK,EAAE,CAAC;QAC/B,KAAK,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;;AA/JM,iBAAM,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCzC,CAAC,AAtCW,CAsCV;AAxCS,UAAU;IADtB,aAAa,CAAC,GAAG,SAAS,CAAC,MAAM,cAAc,CAAC;GACpC,UAAU,CAmKtB","sourcesContent":["import constants from \"../constants\";\nimport { customElement } from 'lit/decorators.js';\nimport { BaseFilter } from \"./baseFilter\";\nimport { html, css } from 'lit';\nimport { createRef, ref } from 'lit/directives/ref.js';\nimport { msg } from '@omegagrid/localize';\nimport { Dropdown, dates } from '@omegagrid/core';\nimport { DateFilterType, parseDateExpression } from '@omegagrid/grid-core';\nimport { isSameDay, startOfDay, subMilliseconds } from 'date-fns';\n\n/** The `rangechange` event of og-calendar in the range mode (omega-grid does not depend on omega-calendar) */\ntype RangeChangeEvent = Event & { from: Date, to: Date|null };\n\n/** og-calendar in the range mode, as far as the filter uses it */\ntype RangeCalendar = HTMLElement & { range: boolean, rangeStart: Date|null, rangeEnd: Date|null, date: Date };\n\n/**\n * Text filter of the date (d), date and time (dt) and time (tm) columns. The user types a date expression such as\n * `6.11.2026` (the whole day), `6.11.2026..20.11.2026`, `> 6.11.2026`, `11.2026` (the month), `2026` (the year),\n * `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\n * `parseDateExpression`. A date column has a calendar button too: a day or a range of days picked in the calendar\n * with two clicks is written into the input and applied. The expression is applied by Enter: the calendar button takes\n * the place of the filter button of the other text filters.\n */\n@customElement(`${constants.PREFIX}-filter-date`)\nexport class DateFilter extends BaseFilter {\n\n\tstatic styles = [...BaseFilter.styles, css`\n\t\t.filter-inner {\n\t\t\theight: 100%;\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: row;\n\t\t\toverflow: hidden;\n\t\t}\n\n\t\tinput {\n\t\t\tborder-width: 0;\n\t\t\toutline: none;\n\t\t\theight: 100%;\n\t\t\tflex: 1;\n\t\t\twidth: 100%;\n\t\t\tmin-width: 0;\n\t\t\tbackground-color: var(--og-background-color);\n\t\t\tcolor: var(--og-text-color);\n\t\t}\n\n\t\tog-button, og-dropdown {\n\t\t\tflex: 0;\n\t\t\tmin-width: 18px;\n\t\t\tmax-width: 18px;\n\t\t\tpadding: 0;\n\t\t\ttext-align: center;\n\t\t\tborder-width: 0;\n\t\t\tborder-radius: 0;\n\t\t\theight: 100%;\n\t\t}\n\n\t\tog-dropdown {\n\t\t\tdisplay: flex;\n\t\t}\n\n\t\tog-calendar {\n\t\t\twidth: 300px;\n\t\t\theight: 260px;\n\t\t}\n\t`];\n\n\tprivate inputRef = createRef<HTMLInputElement>();\n\tget input() { return this.inputRef.value }\n\n\tprivate clearButtonRef = createRef<HTMLButtonElement>();\n\tget clearButton() { return this.clearButtonRef.value }\n\n\tprivate dropdownRef = createRef<Dropdown>();\n\tget calendarDropdown() { return this.dropdownRef.value }\n\n\tprivate calendarRef = createRef<RangeCalendar>();\n\tget calendar() { return this.calendarRef.value }\n\n\tget type(): DateFilterType {\n\t\tconst t = this.columnModel?.type;\n\t\treturn (t === 'dt' || t === 'tm') ? t : 'd';\n\t}\n\n\t/** a time column has no calendar */\n\tget hasCalendar() { return this.type !== 'tm' }\n\n\t// the format the calendar writes a day in: the date format of the locale, read back by the parser\n\tprivate get dayFormat() { return dates.getDateFormat() }\n\n\tprivate formatDay(day: Date) { return dates.format(day, this.dayFormat) }\n\n\t/** The text of a term: the expression as typed */\n\tprivate termText(term: unknown): string {\n\t\treturn term == null ? '' : term.toString();\n\t}\n\n\tprivate _apply() {\n\t\tconst value = (this.input?.value ?? '').trim();\n\t\tif (value === '') {\n\t\t\tthis.clearFilter();\n\t\t} else {\n\t\t\tthis.filter(value);\n\t\t}\n\t}\n\n\t_onClearClick() {\n\t\tif (this.input) this.input.value = '';\n\t\tthis.clearFilter();\n\t}\n\n\t_onInputKeyDown(e: KeyboardEvent) {\n\t\tif (e.key == 'Enter') {\n\t\t\tthis._apply();\n\t\t\tthis.deactivate();\n\t\t}\n\t}\n\n\t// the calendar shows the days of the typed expression picked, when it is a single day or a range of days: when it\n\t// opens, and as the text is edited while it is open\n\t_onCalendarOpen = () => this._syncCalendar();\n\n\t_onInput = () => {\n\t\tif (this.calendarDropdown?.isOpen) this._syncCalendar();\n\t}\n\n\tprivate _syncCalendar() {\n\t\tconst calendar = this.calendar;\n\t\tif (!calendar) return;\n\t\tconst groups = parseDateExpression(this.input?.value ?? '', this.type);\n\t\tconst bounds = groups?.length === 1 ? groups[0] : null;\n\t\tconst from = bounds?.find(b => b.op === '>=')?.value ?? null;\n\t\tconst before = bounds?.find(b => b.op === '<')?.value ?? null;\n\t\tcalendar.rangeStart = from;\n\t\tcalendar.rangeEnd = from && before ? startOfDay(subMilliseconds(before, 1)) : null; // the last day of the range\n\t\t// the calendar shows the month of the start, of today without one\n\t\tcalendar.date = startOfDay(from ?? new Date());\n\t}\n\n\t// the second click completes the range: it is written into the input and applied\n\t_onRangeChange = (e: RangeChangeEvent) => {\n\t\tif (!e.to || !this.input) return;\n\t\tthis.input.value = isSameDay(e.from, e.to) ? this.formatDay(e.from) : `${this.formatDay(e.from)}..${this.formatDay(e.to)}`;\n\t\tthis.calendarDropdown?.close();\n\t\tthis._apply();\n\t\tthis.deactivate();\n\t}\n\n\tprivate get examples() {\n\t\tif (this.type === 'tm') return '9:00, 9:00..17:00, >= 12:00, < 8:00 or > 16:00';\n\t\tconst day = this.formatDay(new Date(2026, 10, 6));\n\t\tconst other = this.formatDay(new Date(2026, 10, 20));\n\t\tconst time = this.type === 'dt' ? `, ${day} 14:00` : '';\n\t\treturn `${day}, ${day}..${other}, > ${day}, 11.2026, 2026, != 2026${time}`;\n\t}\n\n\trender = () => html`\n\t\t<div class=\"filter-inner\">\n\t\t\t<input ${ref(this.inputRef)}\n\t\t\t\ttype=\"text\"\n\t\t\t\ttitle=\"${msg('Examples:')} ${this.examples}\"\n\t\t\t\t@keydown=\"${this._onInputKeyDown}\"\n\t\t\t\t@input=\"${this._onInput}\"\n\t\t\t\t.value=\"${this.termText(this.currentValue)}\">\n\t\t\t${this.hasCalendar ? html`\n\t\t\t\t<og-dropdown ${ref(this.dropdownRef)} icon=\"calendar-days\" color=\"accent\" alignment=\"right\" noCaret\n\t\t\t\t\ttitle=\"${msg('Pick a day or a range of days: the first click starts it, the second ends it')}\"\n\t\t\t\t\t@dropdown.open=\"${this._onCalendarOpen}\">\n\t\t\t\t\t<og-calendar ${ref(this.calendarRef)} slot=\"content\" range @rangechange=\"${this._onRangeChange}\"></og-calendar>\n\t\t\t\t</og-dropdown>\n\t\t\t` : ''}\n\t\t\t<og-button icon=\"xmark\" color=\"red\" ${ref(this.clearButtonRef)} @mousedown=\"${this._onClearClick}\"></og-button>\n\t\t</div>\n\t`;\n\n\tactivate() {\n\t\tsuper.activate();\n\t\tif (this.input) {\n\t\t\tthis.input.value = this.termText(this.currentValue);\n\t\t}\n\t\tsetTimeout(() => this.input?.select(), 100);\n\t}\n\n\tdeactivate() {\n\t\tthis.calendarDropdown?.close();\n\t\tsuper.deactivate();\n\t}\n\n}\n"]}
@@ -25,9 +25,9 @@ const createDropdownFilter = (column) => {
25
25
  const filterMap = new Map([
26
26
  ['t', () => dom.createElement('og-filter-text')],
27
27
  ['n', () => dom.createElement('og-filter-number')],
28
- ['d', () => dom.createElement('og-filter-range')],
29
- ['dt', () => dom.createElement('og-filter-range')],
30
- ['tm', () => dom.createElement('og-filter-range')],
28
+ ['d', () => dom.createElement('og-filter-date')],
29
+ ['dt', () => dom.createElement('og-filter-date')],
30
+ ['tm', () => dom.createElement('og-filter-date')],
31
31
  ['b', () => dom.createElement('og-filter-checkbox')],
32
32
  ['s', (column) => createDropdownFilter(column)],
33
33
  ['m', (column) => createDropdownFilter(column)]
@@ -1 +1 @@
1
- {"version":3,"file":"filterFactory.js","sourceRoot":"","sources":["../../src/filters/filterFactory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAItC,SAAS,oBAAoB,CAAC,MAAmB;IAChD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAe,EAAE,CAAC,IAAI,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AC,iBAAiB,CAAC,CAAC;IAClD,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;IACpD,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;CAC/C,CAAC,CAAC;AAEH,MAAM,UAAU,YAAY,CAAC,MAAmB,EAAE,UAAuB;IACxE,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAe,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC9F,SAAS,CAAC,WAAW,GAAG,MAAM,CAAC;IAC/B,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC;IACnC,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { CellType, ColumnModel, FilterModel } from \"@omegagrid/grid-core\";\nimport { BaseFilter } from \"./baseFilter\";\nimport { dom } from \"@omegagrid/core\";\nimport { DropdownFilter } from \"./dropdownFilter\";\nimport { TreeAdapter, TreeSource } from \"@omegagrid/tree\";\n\nfunction collectDropdownItems(column: ColumnModel) : TreeSource {\n\tconst values = new Map<string, string>();\n\t\n\tfor (let r = 0; r < column.model.rows.length; r++) {\n\t\tconst cell = column.cell(r);\n\t\tvalues.set(cell.value as string, (cell.displayValue ?? cell.value ?? \"\").toString());\n\t}\n\n\tconst items: TreeSource = [];\n\tvalues.forEach((v, k) => items.push({k, v}));\n\treturn items;\n}\n\nconst createDropdownFilter = (column: ColumnModel) => {\n\tconst component = dom.createElement<DropdownFilter>('og-filter-dropdown');\n\tif (column.adapter) {\n\t\tcomponent.adapter = column.adapter as TreeAdapter;\n\t} else if (column.editorContent) {\n\t\tcomponent.items = column.editorContent as TreeSource;\n\t} else {\n\t\tcomponent.items = collectDropdownItems(column);\n\t}\n\treturn component;\n}\n\nconst filterMap = new Map<CellType, (column: ColumnModel) => BaseFilter>([\n\t['t', () => dom.createElement('og-filter-text')],\n\t['n', () => dom.createElement('og-filter-number')],\n\t['d', () => dom.createElement('og-filter-range')],\n\t['dt', () => dom.createElement('og-filter-range')],\n\t['tm', () => dom.createElement('og-filter-range')],\n\t['b', () => dom.createElement('og-filter-checkbox')],\n\t['s', (column) => createDropdownFilter(column)],\n\t['m', (column) => createDropdownFilter(column)]\n]);\n\nexport function createFilter(column: ColumnModel, filteModel: FilterModel): BaseFilter {\n\tconst factory = filterMap.get(column.type);\n\tconst component: BaseFilter = factory ? factory(column) : dom.createElement('og-filter-text');\n\tcomponent.columnModel = column;\n\tcomponent.filterModel = filteModel;\n\treturn component;\n}\n"]}
1
+ {"version":3,"file":"filterFactory.js","sourceRoot":"","sources":["../../src/filters/filterFactory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAItC,SAAS,oBAAoB,CAAC,MAAmB;IAChD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAe,EAAE,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAA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CAAC,CAAC;IAC/C,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;CAC/C,CAAC,CAAC;AAEH,MAAM,UAAU,YAAY,CAAC,MAAmB,EAAE,UAAuB;IACxE,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAe,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC9F,SAAS,CAAC,WAAW,GAAG,MAAM,CAAC;IAC/B,SAAS,CAAC,WAAW,GAAG,UAAU,CAAC;IACnC,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import { CellType, ColumnModel, FilterModel } from \"@omegagrid/grid-core\";\nimport { BaseFilter } from \"./baseFilter\";\nimport { dom } from \"@omegagrid/core\";\nimport { DropdownFilter } from \"./dropdownFilter\";\nimport { TreeAdapter, TreeSource } from \"@omegagrid/tree\";\n\nfunction collectDropdownItems(column: ColumnModel) : TreeSource {\n\tconst values = new Map<string, string>();\n\t\n\tfor (let r = 0; r < column.model.rows.length; r++) {\n\t\tconst cell = column.cell(r);\n\t\tvalues.set(cell.value as string, (cell.displayValue ?? cell.value ?? \"\").toString());\n\t}\n\n\tconst items: TreeSource = [];\n\tvalues.forEach((v, k) => items.push({k, v}));\n\treturn items;\n}\n\nconst createDropdownFilter = (column: ColumnModel) => {\n\tconst component = dom.createElement<DropdownFilter>('og-filter-dropdown');\n\tif (column.adapter) {\n\t\tcomponent.adapter = column.adapter as TreeAdapter;\n\t} else if (column.editorContent) {\n\t\tcomponent.items = column.editorContent as TreeSource;\n\t} else {\n\t\tcomponent.items = collectDropdownItems(column);\n\t}\n\treturn component;\n}\n\nconst filterMap = new Map<CellType, (column: ColumnModel) => BaseFilter>([\n\t['t', () => dom.createElement('og-filter-text')],\n\t['n', () => dom.createElement('og-filter-number')],\n\t['d', () => dom.createElement('og-filter-date')],\n\t['dt', () => dom.createElement('og-filter-date')],\n\t['tm', () => dom.createElement('og-filter-date')],\n\t['b', () => dom.createElement('og-filter-checkbox')],\n\t['s', (column) => createDropdownFilter(column)],\n\t['m', (column) => createDropdownFilter(column)]\n]);\n\nexport function createFilter(column: ColumnModel, filteModel: FilterModel): BaseFilter {\n\tconst factory = filterMap.get(column.type);\n\tconst component: BaseFilter = factory ? factory(column) : dom.createElement('og-filter-text');\n\tcomponent.columnModel = column;\n\tcomponent.filterModel = filteModel;\n\treturn component;\n}\n"]}
@@ -2,7 +2,6 @@ export * from "./textFilter";
2
2
  export * from "./checkboxFilter";
3
3
  export * from "./dropdownFilter";
4
4
  export * from "./numberFilter";
5
- export * from "./rangeFilter";
6
- export * from "./rangeFilterPopup";
5
+ export * from "./dateFilter";
7
6
  export * from "./filterFactory";
8
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
@@ -2,7 +2,6 @@ export * from "./textFilter";
2
2
  export * from "./checkboxFilter";
3
3
  export * from "./dropdownFilter";
4
4
  export * from "./numberFilter";
5
- export * from "./rangeFilter";
6
- export * from "./rangeFilterPopup";
5
+ export * from "./dateFilter";
7
6
  export * from "./filterFactory";
8
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from \"./textFilter\";\nexport * from \"./checkboxFilter\";\nexport * from \"./dropdownFilter\";\nexport * from \"./numberFilter\";\nexport * from \"./rangeFilter\";\nexport * from \"./rangeFilterPopup\";\nexport * from \"./filterFactory\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC","sourcesContent":["export * from \"./textFilter\";\nexport * from \"./checkboxFilter\";\nexport * from \"./dropdownFilter\";\nexport * from \"./numberFilter\";\nexport * from \"./dateFilter\";\nexport * from \"./filterFactory\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeRenderer.d.ts","sourceRoot":"","sources":["../../src/renderers/DateTimeRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAI,cAAc,CAoBrH"}
1
+ {"version":3,"file":"DateTimeRenderer.d.ts","sourceRoot":"","sources":["../../src/renderers/DateTimeRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAK/C,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAI,cAAc,CAwBrH"}
@@ -1,16 +1,22 @@
1
1
  import { BaseRenderer } from "./BaseRenderer";
2
2
  import { dom } from "@omegagrid/core";
3
+ const INVALID_FORMAT = '!invalid format';
3
4
  export function DateTimeRenderer(div, cell, options) {
4
5
  const opts = cell.model.options;
5
- try {
6
- // a date and time cell (type dt) or a time cell (type tm) without a format of its own shows the format of its type
7
- const formatter = cell.type == 'dt' ? opts.dateTimeFormatter : (cell.type == 'tm' ? opts.timeFormatter : opts.dateFormatter);
8
- div.textContent = cell.value
9
- ? formatter(cell.value, cell.format)
10
- : '';
6
+ if (cell.isInvalidDate) {
7
+ div.textContent = INVALID_FORMAT; // a text the cell could not read as a date: marked, the editor opens with it
11
8
  }
12
- catch (_err) {
13
- div.textContent = '!invalid format';
9
+ else {
10
+ try {
11
+ // a date and time cell (type dt) or a time cell (type tm) without a format of its own shows the format of its type
12
+ const formatter = cell.type == 'dt' ? opts.dateTimeFormatter : (cell.type == 'tm' ? opts.timeFormatter : opts.dateFormatter);
13
+ div.textContent = cell.value
14
+ ? formatter(cell.value, cell.format)
15
+ : '';
16
+ }
17
+ catch (_err) {
18
+ div.textContent = INVALID_FORMAT;
19
+ }
14
20
  }
15
21
  if (cell.editable && opts.editing?.dateCalendarEditor) {
16
22
  const triangle = dom.createElement('div');
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeRenderer.js","sourceRoot":"","sources":["../../src/renderers/DateTimeRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,G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../types\";\nimport { dom } from \"@omegagrid/core\";\n\nexport function DateTimeRenderer(div: HTMLDivElement, cell: CellModel, options?: CellRendererOptions) : HTMLDivElement {\n\tconst opts = cell.model.options;\n\ttry {\n\t\t// a date and time cell (type dt) or a time cell (type tm) without a format of its own shows the format of its type\n\t\tconst formatter = cell.type == 'dt' ? opts.dateTimeFormatter : (cell.type == 'tm' ? opts.timeFormatter : opts.dateFormatter);\n\t\tdiv.textContent = cell.value\n\t\t\t? formatter(cell.value as Date|string, cell.format)\n\t\t\t: '';\n\t} catch (_err) {\n\t\tdiv.textContent = '!invalid format';\n\t}\n\t\n\tif (cell.editable && opts.editing?.dateCalendarEditor) {\n\t\tconst triangle = dom.createElement('div');\n\t\ttriangle.className = 'triangle-down';\n\t\tdom.setPosition(triangle, {t: 8, r: 8});\n\t\tdiv.appendChild(triangle);\n\t}\n\n\treturn BaseRenderer.call(this, div, cell, options);\n}"]}
1
+ {"version":3,"file":"DateTimeRenderer.js","sourceRoot":"","sources":["../../src/renderers/DateTimeRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC,MAAM,UAAU,gBAAgB,CAAC,GAAmB,EAAE,IAAe,EAAE,OAA6B;IACnG,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAChC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACxB,GAAG,CAAC,WAAW,GAAG,cAAc,CAAC,CAAC,6EAA6E;IAChH,CAAC;SAAM,CAAC;QACP,IAAI,CAAC;YACJ,mHAAmH;YACnH,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC7H,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK;gBAC3B,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,KAAoB,EAAE,IAAI,CAAC,MAAM,CAAC;gBACnD,CAAC,CAAC,EAAE,CAAC;QACP,CAAC;QAAC,OAAO,IAAI,EAAE,CAAC;YACf,GAAG,CAAC,WAAW,GAAG,cAAc,CAAC;QAClC,CAAC;IACF,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE,kBAAkB,EAAE,CAAC;QACvD,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1C,QAAQ,CAAC,SAAS,GAAG,eAAe,CAAC;QACrC,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAC,CAAC,CAAC;QACxC,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import { CellModel } from \"@omegagrid/grid-core\";\nimport { BaseRenderer } from \"./BaseRenderer\";\nimport { CellRendererOptions } from \"../types\";\nimport { dom } from \"@omegagrid/core\";\n\nconst INVALID_FORMAT = '!invalid format';\n\nexport function DateTimeRenderer(div: HTMLDivElement, cell: CellModel, options?: CellRendererOptions) : HTMLDivElement {\n\tconst opts = cell.model.options;\n\tif (cell.isInvalidDate) {\n\t\tdiv.textContent = INVALID_FORMAT; // a text the cell could not read as a date: marked, the editor opens with it\n\t} else {\n\t\ttry {\n\t\t\t// a date and time cell (type dt) or a time cell (type tm) without a format of its own shows the format of its type\n\t\t\tconst formatter = cell.type == 'dt' ? opts.dateTimeFormatter : (cell.type == 'tm' ? opts.timeFormatter : opts.dateFormatter);\n\t\t\tdiv.textContent = cell.value\n\t\t\t\t? formatter(cell.value as Date|string, cell.format)\n\t\t\t\t: '';\n\t\t} catch (_err) {\n\t\t\tdiv.textContent = INVALID_FORMAT;\n\t\t}\n\t}\n\n\tif (cell.editable && opts.editing?.dateCalendarEditor) {\n\t\tconst triangle = dom.createElement('div');\n\t\ttriangle.className = 'triangle-down';\n\t\tdom.setPosition(triangle, {t: 8, r: 8});\n\t\tdiv.appendChild(triangle);\n\t}\n\n\treturn BaseRenderer.call(this, div, cell, options);\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"filterLabel.d.ts","sourceRoot":"","sources":["../../src/ui/filterLabel.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AA2B5C,qBACa,WAAY,SAAQ,UAAU;IAE1C,MAAM,CAAC,MAAM,0BA4CX;IAGF,KAAK,EAAE,WAAW,CAAC;;IAMnB,iBAAiB;IAIjB,WAAW;IAUX,MAAM,6CAGJ;CAEF"}
1
+ {"version":3,"file":"filterLabel.d.ts","sourceRoot":"","sources":["../../src/ui/filterLabel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C,qBACa,WAAY,SAAQ,UAAU;IAE1C,MAAM,CAAC,MAAM,0BA4CX;IAGF,KAAK,EAAE,WAAW,CAAC;;IAMnB,iBAAiB;IAIjB,WAAW;IASX,MAAM,6CAGJ;CAEF"}
@@ -7,31 +7,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { utils } from '@omegagrid/core';
8
8
  import { LitElement, html, css } from 'lit';
9
9
  import { customElement, property } from 'lit/decorators.js';
10
- const isRangeTerm = (v) => !!v && typeof v === 'object' && !Array.isArray(v) && v.kind === 'range';
11
- const formatRangePart = (v) => {
12
- if (v == null || v === '')
13
- return '';
14
- if (v instanceof Date)
15
- return v.toLocaleDateString();
16
- if (typeof v === 'string') {
17
- const d = new Date(v);
18
- if (!Number.isNaN(d.getTime()))
19
- return d.toLocaleDateString();
20
- return v;
21
- }
22
- return String(v);
23
- };
24
- const formatRange = (r) => {
25
- const from = formatRangePart(r.from);
26
- const to = formatRangePart(r.to);
27
- if (from && to)
28
- return `${from} – ${to}`;
29
- if (from)
30
- return `≥ ${from}`;
31
- if (to)
32
- return `≤ ${to}`;
33
- return '';
34
- };
35
10
  let FilterLabel = class FilterLabel extends LitElement {
36
11
  constructor() {
37
12
  super();
@@ -49,8 +24,6 @@ let FilterLabel = class FilterLabel extends LitElement {
49
24
  if (utils.isBool(this.value)) {
50
25
  return html `<og-icon .icon="${this.value ? 'square-check' : 'square'}"></og-icon>`;
51
26
  }
52
- if (isRangeTerm(this.value))
53
- return formatRange(this.value);
54
27
  if (typeof this.value === 'object')
55
28
  return '';
56
29
  return this.value;
@@ -1 +1 @@
1
- {"version":3,"file":"filterLabel.js","sourceRoot":"","sources":["../../src/ui/filterLabel.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,GAAG,CAAC,CAAU,EAAoB,EAAE,CACpD,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAK,CAAiB,CAAC,IAAI,KAAK,OAAO,CAAC;AAE1F,MAAM,eAAe,GAAG,CAAC,CAAU,EAAU,EAAE;IAC9C,IAAI,CAAC,IAAI,IAAI,IAAI,C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K,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAA,mBAAmB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,cAAc,CAAC;QACpF,CAAC;QACD,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5D,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,KAAe,CAAC;IAC7B,CAAC;;AAjEM,kBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4ClB,AA5CY,CA4CX;AAGF;IADC,QAAQ,EAAE;0CACQ;AAjDP,WAAW;IADvB,aAAa,CAAC,iBAAiB,CAAC;GACpB,WAAW,CA0EvB","sourcesContent":["import { utils } from '@omegagrid/core';\nimport { FilterRange, FilterValue } from '@omegagrid/grid-core';\nimport { LitElement, html, css } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nconst isRangeTerm = (v: unknown): v is FilterRange =>\n\t!!v && typeof v === 'object' && !Array.isArray(v) && (v as FilterRange).kind === 'range';\n\nconst formatRangePart = (v: unknown): string => {\n\tif (v == null || v === '') return '';\n\tif (v instanceof Date) return v.toLocaleDateString();\n\tif (typeof v === 'string') {\n\t\tconst d = new Date(v);\n\t\tif (!Number.isNaN(d.getTime())) return d.toLocaleDateString();\n\t\treturn v;\n\t}\n\treturn String(v);\n};\n\nconst formatRange = (r: FilterRange): string => {\n\tconst from = formatRangePart(r.from);\n\tconst to = formatRangePart(r.to);\n\tif (from && to) return `${from} – ${to}`;\n\tif (from) return `≥ ${from}`;\n\tif (to) return `≤ ${to}`;\n\treturn '';\n};\n\n\n@customElement('og-filter-label')\nexport class FilterLabel extends LitElement {\n\n\tstatic styles = css`\n\t\t:host {\n\t\t\tpadding: 0;\n\t\t\tdisplay: block;\n\t\t\talign-items: center;\n\t\t\tcursor: pointer;\n\t\t\theight: 100%;\n\t\t\tline-height: 21px;\n\t\t}\n\n\t\t:host(:hover og-icon) {\n\t\t\tbackground-color: var(--og-accent-color-highlight);\n\t\t}\n\n\t\tinput {\n\t\t\tcolor: var(--og-text-color);\n\t\t}\n\n\t\tog-icon {\n\t\t\tcolor: var(--og-accent-color);\n\t\t\tflex: 0;\n\t\t\tmin-width: 20px;\n\t\t\tpadding-top: 1px;\n\t\t\tpadding-left: 0px;\n\t\t}\n\n\t\t#filterIcon {\n\t\t\tposition: absolute;\n\t\t\tleft: 0px;\n\t\t\ttop: 0px;\n\t\t}\n\n\t\t.text {\n\t\t\tflex: 1;\n\t\t\theight: 100%;\n\t\t\tfont-style: italic;\n\t\t\tfont-weight: normal;\n\t\t}\n\n\t\t.text:empty {\n\t\t\tbackground-image: repeating-linear-gradient(45deg, var(--og-accent-color-alpha) 0, var(--og-accent-color-alpha) 2px, transparent 0, transparent 50%);\n\t\t\tbackground-size: 10px 10px;\n\t\t\tbackground-color: transparent;\n\t\t}\n\t`;\n\n\t@property()\n\tvalue: FilterValue;\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t}\n\n\trenderValue() {\n\t\tif (this.value == null) return '';\n\t\tif (utils.isBool(this.value)) {\n\t\t\treturn html`<og-icon .icon=\"${this.value ? 'square-check' : 'square'}\"></og-icon>`;\n\t\t}\n\t\tif (isRangeTerm(this.value)) return formatRange(this.value);\n\t\tif (typeof this.value === 'object') return '';\n\t\treturn this.value as string;\n\t}\n\n\trender = () =>html`\n\t\t<og-icon id=\"filterIcon\" .icon=\"${{icon: \"filter\"}}\"></og-icon>\n\t\t<div class=\"text\">${this.renderValue()}</div>\n\t`;\n\t\n}"]}
1
+ {"version":3,"file":"filterLabel.js","sourceRoot":"","sources":["../../src/ui/filterLabel.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGrD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAmD1C;QACC,KAAK,EAAE,CAAC;QAgBT,WAAM,GAAG,GAAG,EAAE,CAAA,IAAI,CAAA;oCACiB,EAAC,IAAI,EAAE,QAAQ,EAAC;sBAC9B,IAAI,CAAC,WAAW,EAAE;EACtC,CAAC;IAlBF,CAAC;IAED,iBAAiB;QAChB,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAED,WAAW;QACV,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI;YAAE,OAAO,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAA,mBAAmB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,cAAc,CAAC;QACpF,CAAC;QACD,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,KAAe,CAAC;IAC7B,CAAC;;AAhEM,kBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4ClB,AA5CY,CA4CX;AAGF;IADC,QAAQ,EAAE;0CACQ;AAjDP,WAAW;IADvB,aAAa,CAAC,iBAAiB,CAAC;GACpB,WAAW,CAyEvB","sourcesContent":["import { utils } from '@omegagrid/core';\nimport { FilterValue } from '@omegagrid/grid-core';\nimport { LitElement, html, css } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\n@customElement('og-filter-label')\nexport class FilterLabel extends LitElement {\n\n\tstatic styles = css`\n\t\t:host {\n\t\t\tpadding: 0;\n\t\t\tdisplay: block;\n\t\t\talign-items: center;\n\t\t\tcursor: pointer;\n\t\t\theight: 100%;\n\t\t\tline-height: 21px;\n\t\t}\n\n\t\t:host(:hover og-icon) {\n\t\t\tbackground-color: var(--og-accent-color-highlight);\n\t\t}\n\n\t\tinput {\n\t\t\tcolor: var(--og-text-color);\n\t\t}\n\n\t\tog-icon {\n\t\t\tcolor: var(--og-accent-color);\n\t\t\tflex: 0;\n\t\t\tmin-width: 20px;\n\t\t\tpadding-top: 1px;\n\t\t\tpadding-left: 0px;\n\t\t}\n\n\t\t#filterIcon {\n\t\t\tposition: absolute;\n\t\t\tleft: 0px;\n\t\t\ttop: 0px;\n\t\t}\n\n\t\t.text {\n\t\t\tflex: 1;\n\t\t\theight: 100%;\n\t\t\tfont-style: italic;\n\t\t\tfont-weight: normal;\n\t\t}\n\n\t\t.text:empty {\n\t\t\tbackground-image: repeating-linear-gradient(45deg, var(--og-accent-color-alpha) 0, var(--og-accent-color-alpha) 2px, transparent 0, transparent 50%);\n\t\t\tbackground-size: 10px 10px;\n\t\t\tbackground-color: transparent;\n\t\t}\n\t`;\n\n\t@property()\n\tvalue: FilterValue;\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t}\n\n\trenderValue() {\n\t\tif (this.value == null) return '';\n\t\tif (utils.isBool(this.value)) {\n\t\t\treturn html`<og-icon .icon=\"${this.value ? 'square-check' : 'square'}\"></og-icon>`;\n\t\t}\n\t\tif (typeof this.value === 'object') return '';\n\t\treturn this.value as string;\n\t}\n\n\trender = () =>html`\n\t\t<og-icon id=\"filterIcon\" .icon=\"${{icon: \"filter\"}}\"></og-icon>\n\t\t<div class=\"text\">${this.renderValue()}</div>\n\t`;\n\t\n}"]}
package/dist/ui/grid.d.ts CHANGED
@@ -45,6 +45,12 @@ export declare class Grid extends LitElement implements Layout {
45
45
  model: GridModel;
46
46
  adapter: GridAdapter;
47
47
  selection: SelectionModel;
48
+ /**
49
+ * The options objects this grid made with initOptions(): a `.options` binding or an assignment from outside
50
+ * brings a partial object instead, which willUpdate() completes before the model gets it
51
+ * (a model holding partial options has no `selecting`, `scrolling`... and the rendering falls over).
52
+ */
53
+ private _initializedOptions;
48
54
  options: Options;
49
55
  logger: log.Logger;
50
56
  zoom: number;
@@ -76,6 +82,15 @@ export declare class Grid extends LitElement implements Layout {
76
82
  destroy(): void;
77
83
  initAdapter(): Promise<void>;
78
84
  updateOptions(options: Partial<Options>): void;
85
+ /**
86
+ * Options started over from the defaults: only the state the grid holds itself (the zoom) is carried over
87
+ * from the previous ones. Used when the adapter is replaced - the options of the previous adapter must not
88
+ * leak into the next one (a refresh of the same adapter merges its options over the current ones instead,
89
+ * see initAdapter()).
90
+ */
91
+ resetOptions(previous?: Options): Options;
92
+ /** initOptions() whose result the grid recognizes as complete (see `_initializedOptions`) */
93
+ private _initOptions;
79
94
  private _debounceVerticalSlide;
80
95
  private _debounceHorizontalSlide;
81
96
  render: () => import("lit-html").TemplateResult<1>;
@@ -1 +1 @@
1
- {"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/ui/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,EAAU,MAAM,iBAAiB,CAAC;AACzG,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAe,OAAO,EAAa,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACnI,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAA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K7B,OAAO;IAUb,WAAW,CAAC,MAAM,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC;IAK1G,iBAAiB,CAAC,MAAM,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC;IAIhH,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAI7B,aAAa;IAOb,QAAQ,CAAC,KAAK,EAAE,UAAU;CAM1B"}
package/dist/ui/grid.js CHANGED
@@ -37,7 +37,13 @@ let Grid = class Grid extends LitElement {
37
37
  this.tooltipRef = createRef();
38
38
  this.commentRef = createRef();
39
39
  this.selection = new SelectionModel(0, 0);
40
- this.options = initOptions();
40
+ /**
41
+ * The options objects this grid made with initOptions(): a `.options` binding or an assignment from outside
42
+ * brings a partial object instead, which willUpdate() completes before the model gets it
43
+ * (a model holding partial options has no `selecting`, `scrolling`... and the rendering falls over).
44
+ */
45
+ this._initializedOptions = new WeakSet();
46
+ this.options = this._initOptions();
41
47
  this.logger = new log.Logger('Ωgrid');
42
48
  this.zoom = 1;
43
49
  this.rendering = new GridRendering(this);
@@ -217,9 +223,24 @@ let Grid = class Grid extends LitElement {
217
223
  this.dispatchEvent(new GridEvent('afterLoad', { grid: this }));
218
224
  }
219
225
  updateOptions(options) {
220
- this.options = initOptions(options, this.options);
226
+ this.options = this._initOptions(options, this.options);
221
227
  this.requestUpdate();
222
228
  }
229
+ /**
230
+ * Options started over from the defaults: only the state the grid holds itself (the zoom) is carried over
231
+ * from the previous ones. Used when the adapter is replaced - the options of the previous adapter must not
232
+ * leak into the next one (a refresh of the same adapter merges its options over the current ones instead,
233
+ * see initAdapter()).
234
+ */
235
+ resetOptions(previous) {
236
+ return this._initOptions({ zoom: previous?.zoom });
237
+ }
238
+ /** initOptions() whose result the grid recognizes as complete (see `_initializedOptions`) */
239
+ _initOptions(options, origOptions) {
240
+ const result = initOptions(options, origOptions);
241
+ this._initializedOptions.add(result);
242
+ return result;
243
+ }
223
244
  openCommands() {
224
245
  this.commands.open();
225
246
  }
@@ -282,12 +303,26 @@ let Grid = class Grid extends LitElement {
282
303
  }
283
304
  setSourceData(data) {
284
305
  if (data.options)
285
- this.options = initOptions(data.options, this.options);
306
+ this.options = this._initOptions(data.options, this.options);
286
307
  this.model = new GridModel(data, this.options, this.logger);
287
308
  }
288
309
  willUpdate(changedProps) {
310
+ // options set from outside (`.options="${partial}"`) are completed over the previous ones before
311
+ // updated() hands them to the model; the grid's own options are complete already
312
+ const bound = changedProps.has('options') && !this._initializedOptions.has(this.options) ? this.options ?? {} : null;
313
+ const prev = bound ? changedProps.get('options') : this.options;
314
+ if (changedProps.has('adapter') && changedProps.get('adapter')) {
315
+ // a different adapter: its options start over; options bound in the same update still apply
316
+ // (done here, not in updated(): a property set there costs another update cycle and a Lit warning)
317
+ this.options = this.resetOptions(prev);
318
+ if (bound)
319
+ this.options = this._initOptions(bound, this.options);
320
+ }
321
+ else if (bound) {
322
+ this.options = this._initOptions(bound, prev);
323
+ }
289
324
  if (changedProps.has('model')) {
290
- this.options = initOptions(this.model.options, this.options);
325
+ this.options = this._initOptions(this.model.options, this.options);
291
326
  this.model.options = this.options;
292
327
  this.history = new History(this.model);
293
328
  this.filtering.init();
@@ -1 +1 @@
1
- {"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/ui/grid.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAuB,OAAO,EAAkB,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzG,OAAO,EAAE,SAAS,EAAc,cAAc,EAAW,WAAW,EAAE,OAAO,EAAE,SAAS,EAAc,MAAM,sBAAsB,CAAC;AAEnI,OAAO,EAAE,cAAc,EAAE,MAAM,qB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AED,gBAAgB,CAAC,IAAY;QAC5B,OAAO,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,aAAa;QACZ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,cAAc,CAAa,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ,CAAC,KAAiB;QACzB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;;AA1VM,WAAM,GAAG,CAAC,MAAM,CAAC,AAAX,CAAY;AAsCzB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;mCACR;AAGjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;qCACJ;AAGrB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;uCAC4B;AAGrD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;qCACQ;AAGjC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;oCACmB;AAG5C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kCAChB;AAvDG,IAAI;IADhB,aAAa,CAAC,SAAS,CAAC;GACZ,IAAI,CA8VhB","sourcesContent":["import { dom, log, Slider, Sizer, Layout, Menu, Plugins, AnyConstructor, events } from '@omegagrid/core';\nimport { GridModel, GridSource, SelectionModel, Options, initOptions, History, CellRange, TableTheme } from '@omegagrid/grid-core';\nimport { Selector } from './selector';\nimport { CommandManager } from '@omegagrid/commands';\nimport { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { createRef, ref } from 'lit/directives/ref.js';\nimport { Table } from './table';\nimport { GridTooltip as Tooltip } from './tooltip';\nimport { styles } from './grid.style';\nimport { GridRendering } from './grid.rendering';\nimport { GridSelecting } from './grid.selecting';\nimport { GridErrorEvent, GridEvent, GridEvents } from './grid.events';\nimport { GridEditing } from './grid.editing';\nimport { GridFiltering } from './grid.filtering';\nimport { GridObjects } from './grid.objects';\nimport { GridSorting } from './grid.sorting';\nimport { GridMenus } from './grid.menu';\nimport { GridGroup } from './group';\nimport { Comment } from './comment';\nimport { UserColumnWidths } from './userColumnWidths';\nimport { GridAdapter } from '../gridAdapter';\nimport { initGridCommands } from '../commands';\nimport { debounce } from 'ts-debounce';\n\n@customElement('og-grid')\nexport class Grid extends LitElement implements Layout {\n\n\tstatic styles = [styles];\n\n\tprivate tableRef = createRef<Table>();\n\tget table() : Table { return this.tableRef.value }\n\n\tprivate hSliderRef = createRef<Slider>();\n\tget hSlider() { return this.hSliderRef.value }\n\n\tprivate vSliderRef = createRef<Slider>();\n\tget vSlider() { return this.vSliderRef.value }\n\n\tprivate hSizerRef = createRef<Sizer>();\n\tget hSizer() { return this.hSizerRef.value }\n\n\tprivate vSizerRef = createRef<Sizer>();\n\tget vSizer() { return this.vSizerRef.value }\n\n\tprivate selectorRef = createRef<Selector>();\n\tget selector() { return this.selectorRef.value }\n\n\tprivate copySelectorRef = createRef<Selector>();\n\tget copySelector() { return this.copySelectorRef.value }\n\n\tprivate formulaSelectorRef = createRef<Selector>();\n\tget formulaSelector() { return this.formulaSelectorRef.value }\n\n\tprivate contextMenuRef = createRef<Menu>();\n\tget contextMenu() { return this.contextMenuRef.value }\n\n\tprivate tooltipRef = createRef<Tooltip>();\n\tget tooltip() { return this.tooltipRef.value }\n\n\tprivate commentRef = createRef<Comment>();\n\tget comment() { return this.commentRef.value }\n\n\tget designMode() { return this.group ? this.group.designMode : false }\n\n\t@property({type: Object})\n\tmodel: GridModel;\n\n\t@property({type: Object})\n\tadapter: GridAdapter;\n\n\t@property({type: Object})\n\tselection: SelectionModel = new SelectionModel(0, 0);\n\n\t@property({type: Object})\n\toptions: Options = initOptions();\n\n\t@property({type: Object})\n\tlogger: log.Logger = new log.Logger('Ωgrid')\n\n\t@property({type: Number})\n\tzoom = 1;\n\n\tgroup: GridGroup;\n\thistory: History;\n\trendering = new GridRendering(this);\n\tselecting = new GridSelecting(this);\n\tevents = new GridEvents(this);\n\tediting = new GridEditing(this);\n\tfiltering = new GridFiltering(this);\n\tsorting = new GridSorting(this);\n\tmenus = new GridMenus(this);\n\tobjects = new GridObjects(this);\n\tcommands = new CommandManager(this);\n\tplugins = new Plugins<Grid>(this);\n\treadonly userColumnWidths = new UserColumnWidths();\n\tloading = false;\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.logger.info('connected');\n\t\t// release an update deferred while the grid was disconnected\n\t\tthis._resumeUpdate?.();\n\t\tthis._resumeUpdate = null;\n\t\tthis.layout();\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.destroy();\n\t}\n\n\tprivate _resumeUpdate: () => void;\n\n\t/**\n\t * Defer updates while the grid is not connected. Rendering the template\n\t * of a disconnected element wipes the element refs (the lit ref directive\n\t * sets the ref value only when connected), so firstUpdated/updated would\n\t * crash on the missing table/menu. Deferring in scheduleUpdate keeps the\n\t * changed properties, the update runs on (re)connection.\n\t */\n\tprotected async scheduleUpdate() {\n\t\twhile (!this.isConnected) {\n\t\t\tawait new Promise<void>(resolve => this._resumeUpdate = resolve);\n\t\t}\n\t\tsuper.scheduleUpdate();\n\t}\n\n\tdestroy() {\n\t\t//dom.remove(this.mouseTooltip);\n\t\tif (this.contextMenu) dom.remove(this.contextMenu);\n\t\tif (this.comment) dom.remove(this.comment);\n\t}\n\n\tasync initAdapter() {\n\t\tthis.adapter.attach(this);\n\t\tif (this.table) this.table.rowOffset = 0;\n\t\tthis.dispatchEvent(new GridEvent('beforeLoad', {grid: this}));\n\t\tconst columns = await this.adapter.getColumns();\n\t\tconst options = initOptions(await this.adapter.getOptions(), this.options);\n\t\tconst prevFilter = this.model?.filter;\n\t\tconst prevSorting = this.model?.sorting;\n\t\tconst requestFilters = this.rendering.getAdapterRequestFilters();\n\t\t// on the first load the adapter has no model to resolve the column indexes of the filter and order by\n\t\tif (!this.model) requestFilters.columns = columns;\n\t\tif (!this.model && options.pageSize > 0) {\n\t\t\tconst defaultFilter = options.filters?.defaultSettings;\n\t\t\tconst defaultOrder = options.sorting?.defaultSettings;\n\t\t\tif (defaultFilter?.length) requestFilters.filter = defaultFilter.map(s => ({...s}));\n\t\t\tif (defaultOrder?.length) requestFilters.order = defaultOrder.map(s => ({...s}));\n\t\t}\n\t\tconst rows = await this.adapter.getRows(requestFilters);\n\t\trequestFilters.rows = rows;\n\t\tconst cells = await this.adapter.getCells(requestFilters);\n\t\tconst sparklines = await this.adapter.getSparklines();\n\t\tconst comments = await this.adapter.getComments();\n\t\tconst rules = await this.adapter.getRules();\n\t\tconst styles = await this.adapter.getStyles();\n\t\tthis.setSourceData({\n\t\t\tcolumns,\n\t\t\trows,\n\t\t\tcells,\n\t\t\toptions,\n\t\t\tsparklines,\n\t\t\tcomments,\n\t\t\trules,\n\t\t\tstyles\n\t\t});\n\t\tthis.userColumnWidths.apply(this.model.columns);\n\t\t// the previous model holds the state of the user, an empty one included: the default settings\n\t\t// the new model applied to itself in its constructor must not come back after a refresh\n\t\tif (prevFilter) {\n\t\t\tif (prevFilter.settings.length) {\n\t\t\t\tthis.model.filter.restore(prevFilter.settings, prevFilter.custom);\n\t\t\t} else if (this.model.filter.settings.length) {\n\t\t\t\tthis.model.filter.resetFilter(false);\n\t\t\t\tthis.model.filter.custom = prevFilter.custom;\n\t\t\t}\n\t\t} else if (this.model.filter.settings.length && this.filtering.isCustomFilter) {\n\t\t\tthis.model.filter.restore(this.model.filter.settings, true);\n\t\t}\n\t\tif (prevSorting) {\n\t\t\tif (prevSorting.settings.length) {\n\t\t\t\tthis.model.sorting.restore(prevSorting.settings, !this.sorting.isCustomSorting);\n\t\t\t} else if (this.model.sorting.settings.length) {\n\t\t\t\tthis.model.sorting.resetSort();\n\t\t\t}\n\t\t} else if (this.model.sorting.settings.length && this.sorting.isCustomSorting) {\n\t\t\tthis.model.sorting.restore(this.model.sorting.settings, false);\n\t\t}\n\t\tthis.dispatchEvent(new GridEvent('afterLoad', {grid: this}));\n\t}\n\n\tupdateOptions(options: Partial<Options>) {\n\t\tthis.options = initOptions(options, this.options);\n\t\tthis.requestUpdate();\n\t}\n\n\tprivate _debounceVerticalSlide = debounce(this.events._onVerticalSlide, Slider.SLIDE_DELAY, {isImmediate: true, maxWait: 50});\n\tprivate _debounceHorizontalSlide = debounce(this.events._onHorizontalSlide, Slider.SLIDE_DELAY, {isImmediate: true, maxWait: 50});\n\n\trender = () => html`\n\t\t<og-table ${ref(this.tableRef)}\n\t\t\t.zoom=\"${this.zoom}\"\n\t\t\t.hideOuterBorder=\"${this.options.hideOuterBorder}\">\n\t\t</og-table>\n\n\t\t<og-slider ${ref(this.vSliderRef)}\n\t\t\t?hidden=\"${true}\"\n\t\t\tdirection=\"vertical\"\n\t\t\t@slide=\"${this._debounceVerticalSlide}\"\n\t\t\t@slideStart=\"${this.events._onSlideStart}\"\n\t\t\t@slideEnd=\"${this.events._onSlideStop}\">\n\t\t</og-slider>\n\n\t\t<og-slider ${ref(this.hSliderRef)}\n\t\t\t?hidden=\"${true}\"\n\t\t\tdirection=\"horizontal\"\n\t\t\t@slide=\"${this._debounceHorizontalSlide}\"\n\t\t\t@slideStart=\"${this.events._onSlideStart}\"\n\t\t\t@slideEnd=\"${this.events._onSlideStop}\">\n\t\t</og-slider>\n\n\t\t<og-sizer ${ref(this.vSizerRef)} orientation=\"vertical\"></og-sizer>\n\n\t\t<og-sizer ${ref(this.hSizerRef)} orientation=\"horizontal\"></og-sizer>\n\n\t\t<og-selector ${ref(this.selectorRef)}\n\t\t\t?autofill=\"${this.options.autofill}\"\n\t\t\t?movable=\"${true}\"\n\t\t\t?subselector=\"${true}\">\n\t\t</og-selector>\n\n\t\t<og-selector ${ref(this.copySelectorRef)}\n\t\t\t?autofill=\"${false}\"\n\t\t\t?movable=\"${false}\"\n\t\t\t?animated=\"${true}\">\n\t\t</og-selector>\n\n\t\t<og-selector ${ref(this.formulaSelectorRef)}\n\t\t\t?autofill=\"${false}\"\n\t\t\t?movable=\"${false}\"\n\t\t\t?animated=\"${true}\"\n\t\t\tstyle=\"z-index: 110\">\n\t\t</og-selector>\n\n\t\t<og-menu ${ref(this.contextMenuRef)} style=\"display: none; z-index: 1000\"></og-menu>\n\n\t\t<og-grid-tooltip ${ref(this.tooltipRef)} style=\"display: none\"></og-grid-tooltip>\n\n\t\t<og-grid-comment ${ref(this.commentRef)} style=\"display: none\"></og-grid-comment>\n\t`;\n\n\topenCommands() {\n\t\tthis.commands.open();\n\t}\n\n\tcloseCommands() {\n\t\tthis.commands.close();\n\t}\n\n\tasync firstUpdated() {\n\t\tthis.tabIndex = 0;\n\t\tthis.events.init();\n\t\tthis.menus.init();\n\n\t\tawait this.table.updateComplete;\n\t\tthis.logger.info('init');\n\t\tthis.dispatchEvent(new GridEvent('init', {grid: this}));\n\t}\n\n\tasync updated(changedProps: Map<PropertyKey, unknown>) {\n\t\tdom.setSize(this.table, {w: this.clientWidth, h: this.clientHeight});\n\t\tif (changedProps.has('adapter')) {\n\t\t\tif (changedProps.get('adapter')) this.userColumnWidths.clear(); // a different adapter brings a different column set\n\t\t\ttry {\n\t\t\t\tawait this.initAdapter();\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error('Error initializing adapter:', error);\n\t\t\t\tthis.dispatchEvent(new GridErrorEvent(error as Error));\n\t\t\t}\n\t\t}\n\n\t\tif (this.model) {\n\t\t\tif (this.options) this.model.options = this.options;\n\t\t\tthis.rendering.requireVerticalUpdate = true;\n\t\t\tthis.rendering.requireHorizontalUpdate = true;\n\t\t\tthis.table.model = this.model;\n\t\t\tif (changedProps.has('model')) {\n\t\t\t\tthis.sorting.init();\n\n\t\t\t\tif (this.model.options.firstCell) { // TODO: move somewhere else\n\t\t\t\t\tconst cell = CellRange.fromA1(this.model.options.firstCell);\n\t\t\t\t\tthis.table.colOffset = cell.c1;\n\t\t\t\t\tthis.table.rowOffset = cell.r1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait this.table.updateComplete;\n\t\t\tthis.rendering.updateSliders();\n\t\t\tthis.rendering.debounceRenderCells();\n\t\t\tinitGridCommands(this);\n\t\t\tthis.dispatchEvent(new GridEvent('loadmodel', {grid: this}));\n\t\t}\n\n\t\tif (changedProps.has('zoom') && (changedProps.get('zoom') || 1) !== (this.zoom || 1)) {\n\t\t\tthis.options.zoom = this.zoom;\n\t\t\tthis.rendering.render(true);\n\t\t}\n\t}\n\n\tinnerLayout() {\n\t\tdom.setSize(this.table, {w: this.clientWidth, h: this.clientHeight});\n\t\tthis.table.requestUpdate();\n\t}\n\n\tdebounceInnerLayout = debounce(this.innerLayout, 100);\n\n\tlayout() {\n\t\tif (this.table) this.debounceInnerLayout();\n\t}\n\n\tsetSourceData(data: GridSource) {\n\t\tif (data.options) this.options = initOptions(data.options, this.options);\n\t\tthis.model = new GridModel(data, this.options, this.logger);\n\t}\n\n\twillUpdate(changedProps: Map<PropertyKey, unknown>) {\n\t\tif (changedProps.has('model')) {\n\t\t\tthis.options = initOptions(this.model.options, this.options);\n\t\t\tthis.model.options = this.options;\n\t\t\tthis.history = new History(this.model);\n\t\t\tthis.filtering.init();\n\t\t\tthis.zoom = this.options.zoom || 1;\n\t\t}\n\t}\n\n\tfocus(options?: FocusOptions): void {\n\t\tsuper.focus(options);\n\t\tthis.editing.activeEditor?.focus();\n\t}\n\n\tasync refresh() {\n\t\tif (this.adapter) {\n\t\t\tthis.table.clearHeaderCache();\n\t\t\tthis.table.clearBodyCache();\n\t\t\tawait this.initAdapter();\n\t\t} else {\n\t\t\tawait this.rendering.render(true);\n\t\t}\n\t}\n\n\tcreateEvent<TEvent extends GridEvent>(type: string, args?: Partial<TEvent>, event?: AnyConstructor<TEvent>) {\n\t\tconst EventConstructor = (event ?? GridEvent) as AnyConstructor<TEvent>;\n\t\treturn new EventConstructor(type, {grid: this, ...args});\n\t}\n\n\tdispatchGridEvent<TEvent extends GridEvent>(type: string, args?: Partial<TEvent>, event?: AnyConstructor<TEvent>) {\n\t\tthis.dispatchEvent(this.createEvent(type, args, event));\n\t}\n\n\tgetConnectedGrid(name: string) {\n\t\treturn this.group?.getGrid(name);\n\t}\n\n\tgetSourceData() {\n\t\tconst data = this.model?.getSourceData() ?? {};\n\t\tconst event = new events.SerialzieEvent<GridSource>(data);\n\t\tthis.dispatchEvent(event);\n\t\treturn event.data;\n\t}\n\n\tsetTheme(theme: TableTheme) {\n\t\tthis.model.theme = theme;\n\t\tthis.model.applyTheme(theme, true);\n\t\tthis.refresh();\n\t}\n\n}\n"]}
1
+ {"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/ui/grid.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAuB,OAAO,EAAkB,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzG,OAAO,EAAE,SAAS,EAAc,cAAc,EAAyB,WAAW,EAAE,OAAO,EAAE,SAAS,EAAc,MAAM,sBAAsB,CAAC;AAEjJ,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD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,CAAa,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ,CAAC,KAAiB;QACzB,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;;AA9XM,WAAM,GAAG,CAAC,MAAM,CAAC,AAAX,CAAY;AAsCzB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;mCACR;AAGjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;qCACJ;AAGrB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;uCAC4B;AAUrD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;qCACc;AAGvC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;oCACmB;AAG5C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kCAChB;AA9DG,IAAI;IADhB,aAAa,CAAC,SAAS,CAAC;GACZ,IAAI,CAkYhB","sourcesContent":["import { dom, log, Slider, Sizer, Layout, Menu, Plugins, AnyConstructor, events } from '@omegagrid/core';\nimport { GridModel, GridSource, SelectionModel, Options, OptionSource, initOptions, History, CellRange, TableTheme } from '@omegagrid/grid-core';\nimport { Selector } from './selector';\nimport { CommandManager } from '@omegagrid/commands';\nimport { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { createRef, ref } from 'lit/directives/ref.js';\nimport { Table } from './table';\nimport { GridTooltip as Tooltip } from './tooltip';\nimport { styles } from './grid.style';\nimport { GridRendering } from './grid.rendering';\nimport { GridSelecting } from './grid.selecting';\nimport { GridErrorEvent, GridEvent, GridEvents } from './grid.events';\nimport { GridEditing } from './grid.editing';\nimport { GridFiltering } from './grid.filtering';\nimport { GridObjects } from './grid.objects';\nimport { GridSorting } from './grid.sorting';\nimport { GridMenus } from './grid.menu';\nimport { GridGroup } from './group';\nimport { Comment } from './comment';\nimport { UserColumnWidths } from './userColumnWidths';\nimport { GridAdapter } from '../gridAdapter';\nimport { initGridCommands } from '../commands';\nimport { debounce } from 'ts-debounce';\n\n@customElement('og-grid')\nexport class Grid extends LitElement implements Layout {\n\n\tstatic styles = [styles];\n\n\tprivate tableRef = createRef<Table>();\n\tget table() : Table { return this.tableRef.value }\n\n\tprivate hSliderRef = createRef<Slider>();\n\tget hSlider() { return this.hSliderRef.value }\n\n\tprivate vSliderRef = createRef<Slider>();\n\tget vSlider() { return this.vSliderRef.value }\n\n\tprivate hSizerRef = createRef<Sizer>();\n\tget hSizer() { return this.hSizerRef.value }\n\n\tprivate vSizerRef = createRef<Sizer>();\n\tget vSizer() { return this.vSizerRef.value }\n\n\tprivate selectorRef = createRef<Selector>();\n\tget selector() { return this.selectorRef.value }\n\n\tprivate copySelectorRef = createRef<Selector>();\n\tget copySelector() { return this.copySelectorRef.value }\n\n\tprivate formulaSelectorRef = createRef<Selector>();\n\tget formulaSelector() { return this.formulaSelectorRef.value }\n\n\tprivate contextMenuRef = createRef<Menu>();\n\tget contextMenu() { return this.contextMenuRef.value }\n\n\tprivate tooltipRef = createRef<Tooltip>();\n\tget tooltip() { return this.tooltipRef.value }\n\n\tprivate commentRef = createRef<Comment>();\n\tget comment() { return this.commentRef.value }\n\n\tget designMode() { return this.group ? this.group.designMode : false }\n\n\t@property({type: Object})\n\tmodel: GridModel;\n\n\t@property({type: Object})\n\tadapter: GridAdapter;\n\n\t@property({type: Object})\n\tselection: SelectionModel = new SelectionModel(0, 0);\n\n\t/**\n\t * The options objects this grid made with initOptions(): a `.options` binding or an assignment from outside\n\t * brings a partial object instead, which willUpdate() completes before the model gets it\n\t * (a model holding partial options has no `selecting`, `scrolling`... and the rendering falls over).\n\t */\n\tprivate _initializedOptions = new WeakSet<Options>();\n\n\t@property({type: Object})\n\toptions: Options = this._initOptions();\n\n\t@property({type: Object})\n\tlogger: log.Logger = new log.Logger('Ωgrid')\n\n\t@property({type: Number})\n\tzoom = 1;\n\n\tgroup: GridGroup;\n\thistory: History;\n\trendering = new GridRendering(this);\n\tselecting = new GridSelecting(this);\n\tevents = new GridEvents(this);\n\tediting = new GridEditing(this);\n\tfiltering = new GridFiltering(this);\n\tsorting = new GridSorting(this);\n\tmenus = new GridMenus(this);\n\tobjects = new GridObjects(this);\n\tcommands = new CommandManager(this);\n\tplugins = new Plugins<Grid>(this);\n\treadonly userColumnWidths = new UserColumnWidths();\n\tloading = false;\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.logger.info('connected');\n\t\t// release an update deferred while the grid was disconnected\n\t\tthis._resumeUpdate?.();\n\t\tthis._resumeUpdate = null;\n\t\tthis.layout();\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.destroy();\n\t}\n\n\tprivate _resumeUpdate: () => void;\n\n\t/**\n\t * Defer updates while the grid is not connected. Rendering the template\n\t * of a disconnected element wipes the element refs (the lit ref directive\n\t * sets the ref value only when connected), so firstUpdated/updated would\n\t * crash on the missing table/menu. Deferring in scheduleUpdate keeps the\n\t * changed properties, the update runs on (re)connection.\n\t */\n\tprotected async scheduleUpdate() {\n\t\twhile (!this.isConnected) {\n\t\t\tawait new Promise<void>(resolve => this._resumeUpdate = resolve);\n\t\t}\n\t\tsuper.scheduleUpdate();\n\t}\n\n\tdestroy() {\n\t\t//dom.remove(this.mouseTooltip);\n\t\tif (this.contextMenu) dom.remove(this.contextMenu);\n\t\tif (this.comment) dom.remove(this.comment);\n\t}\n\n\tasync initAdapter() {\n\t\tthis.adapter.attach(this);\n\t\tif (this.table) this.table.rowOffset = 0;\n\t\tthis.dispatchEvent(new GridEvent('beforeLoad', {grid: this}));\n\t\tconst columns = await this.adapter.getColumns();\n\t\tconst options = initOptions(await this.adapter.getOptions(), this.options);\n\t\tconst prevFilter = this.model?.filter;\n\t\tconst prevSorting = this.model?.sorting;\n\t\tconst requestFilters = this.rendering.getAdapterRequestFilters();\n\t\t// on the first load the adapter has no model to resolve the column indexes of the filter and order by\n\t\tif (!this.model) requestFilters.columns = columns;\n\t\tif (!this.model && options.pageSize > 0) {\n\t\t\tconst defaultFilter = options.filters?.defaultSettings;\n\t\t\tconst defaultOrder = options.sorting?.defaultSettings;\n\t\t\tif (defaultFilter?.length) requestFilters.filter = defaultFilter.map(s => ({...s}));\n\t\t\tif (defaultOrder?.length) requestFilters.order = defaultOrder.map(s => ({...s}));\n\t\t}\n\t\tconst rows = await this.adapter.getRows(requestFilters);\n\t\trequestFilters.rows = rows;\n\t\tconst cells = await this.adapter.getCells(requestFilters);\n\t\tconst sparklines = await this.adapter.getSparklines();\n\t\tconst comments = await this.adapter.getComments();\n\t\tconst rules = await this.adapter.getRules();\n\t\tconst styles = await this.adapter.getStyles();\n\t\tthis.setSourceData({\n\t\t\tcolumns,\n\t\t\trows,\n\t\t\tcells,\n\t\t\toptions,\n\t\t\tsparklines,\n\t\t\tcomments,\n\t\t\trules,\n\t\t\tstyles\n\t\t});\n\t\tthis.userColumnWidths.apply(this.model.columns);\n\t\t// the previous model holds the state of the user, an empty one included: the default settings\n\t\t// the new model applied to itself in its constructor must not come back after a refresh\n\t\tif (prevFilter) {\n\t\t\tif (prevFilter.settings.length) {\n\t\t\t\tthis.model.filter.restore(prevFilter.settings, prevFilter.custom);\n\t\t\t} else if (this.model.filter.settings.length) {\n\t\t\t\tthis.model.filter.resetFilter(false);\n\t\t\t\tthis.model.filter.custom = prevFilter.custom;\n\t\t\t}\n\t\t} else if (this.model.filter.settings.length && this.filtering.isCustomFilter) {\n\t\t\tthis.model.filter.restore(this.model.filter.settings, true);\n\t\t}\n\t\tif (prevSorting) {\n\t\t\tif (prevSorting.settings.length) {\n\t\t\t\tthis.model.sorting.restore(prevSorting.settings, !this.sorting.isCustomSorting);\n\t\t\t} else if (this.model.sorting.settings.length) {\n\t\t\t\tthis.model.sorting.resetSort();\n\t\t\t}\n\t\t} else if (this.model.sorting.settings.length && this.sorting.isCustomSorting) {\n\t\t\tthis.model.sorting.restore(this.model.sorting.settings, false);\n\t\t}\n\t\tthis.dispatchEvent(new GridEvent('afterLoad', {grid: this}));\n\t}\n\n\tupdateOptions(options: Partial<Options>) {\n\t\tthis.options = this._initOptions(options, this.options);\n\t\tthis.requestUpdate();\n\t}\n\n\t/**\n\t * Options started over from the defaults: only the state the grid holds itself (the zoom) is carried over\n\t * from the previous ones. Used when the adapter is replaced - the options of the previous adapter must not\n\t * leak into the next one (a refresh of the same adapter merges its options over the current ones instead,\n\t * see initAdapter()).\n\t */\n\tresetOptions(previous?: Options): Options {\n\t\treturn this._initOptions({zoom: previous?.zoom});\n\t}\n\n\t/** initOptions() whose result the grid recognizes as complete (see `_initializedOptions`) */\n\tprivate _initOptions(options?: Partial<OptionSource>, origOptions?: Options): Options {\n\t\tconst result = initOptions(options, origOptions);\n\t\tthis._initializedOptions.add(result);\n\t\treturn result;\n\t}\n\n\tprivate _debounceVerticalSlide = debounce(this.events._onVerticalSlide, Slider.SLIDE_DELAY, {isImmediate: true, maxWait: 50});\n\tprivate _debounceHorizontalSlide = debounce(this.events._onHorizontalSlide, Slider.SLIDE_DELAY, {isImmediate: true, maxWait: 50});\n\n\trender = () => html`\n\t\t<og-table ${ref(this.tableRef)}\n\t\t\t.zoom=\"${this.zoom}\"\n\t\t\t.hideOuterBorder=\"${this.options.hideOuterBorder}\">\n\t\t</og-table>\n\n\t\t<og-slider ${ref(this.vSliderRef)}\n\t\t\t?hidden=\"${true}\"\n\t\t\tdirection=\"vertical\"\n\t\t\t@slide=\"${this._debounceVerticalSlide}\"\n\t\t\t@slideStart=\"${this.events._onSlideStart}\"\n\t\t\t@slideEnd=\"${this.events._onSlideStop}\">\n\t\t</og-slider>\n\n\t\t<og-slider ${ref(this.hSliderRef)}\n\t\t\t?hidden=\"${true}\"\n\t\t\tdirection=\"horizontal\"\n\t\t\t@slide=\"${this._debounceHorizontalSlide}\"\n\t\t\t@slideStart=\"${this.events._onSlideStart}\"\n\t\t\t@slideEnd=\"${this.events._onSlideStop}\">\n\t\t</og-slider>\n\n\t\t<og-sizer ${ref(this.vSizerRef)} orientation=\"vertical\"></og-sizer>\n\n\t\t<og-sizer ${ref(this.hSizerRef)} orientation=\"horizontal\"></og-sizer>\n\n\t\t<og-selector ${ref(this.selectorRef)}\n\t\t\t?autofill=\"${this.options.autofill}\"\n\t\t\t?movable=\"${true}\"\n\t\t\t?subselector=\"${true}\">\n\t\t</og-selector>\n\n\t\t<og-selector ${ref(this.copySelectorRef)}\n\t\t\t?autofill=\"${false}\"\n\t\t\t?movable=\"${false}\"\n\t\t\t?animated=\"${true}\">\n\t\t</og-selector>\n\n\t\t<og-selector ${ref(this.formulaSelectorRef)}\n\t\t\t?autofill=\"${false}\"\n\t\t\t?movable=\"${false}\"\n\t\t\t?animated=\"${true}\"\n\t\t\tstyle=\"z-index: 110\">\n\t\t</og-selector>\n\n\t\t<og-menu ${ref(this.contextMenuRef)} style=\"display: none; z-index: 1000\"></og-menu>\n\n\t\t<og-grid-tooltip ${ref(this.tooltipRef)} style=\"display: none\"></og-grid-tooltip>\n\n\t\t<og-grid-comment ${ref(this.commentRef)} style=\"display: none\"></og-grid-comment>\n\t`;\n\n\topenCommands() {\n\t\tthis.commands.open();\n\t}\n\n\tcloseCommands() {\n\t\tthis.commands.close();\n\t}\n\n\tasync firstUpdated() {\n\t\tthis.tabIndex = 0;\n\t\tthis.events.init();\n\t\tthis.menus.init();\n\n\t\tawait this.table.updateComplete;\n\t\tthis.logger.info('init');\n\t\tthis.dispatchEvent(new GridEvent('init', {grid: this}));\n\t}\n\n\tasync updated(changedProps: Map<PropertyKey, unknown>) {\n\t\tdom.setSize(this.table, {w: this.clientWidth, h: this.clientHeight});\n\t\tif (changedProps.has('adapter')) {\n\t\t\tif (changedProps.get('adapter')) this.userColumnWidths.clear(); // a different adapter brings a different column set\n\t\t\ttry {\n\t\t\t\tawait this.initAdapter();\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error('Error initializing adapter:', error);\n\t\t\t\tthis.dispatchEvent(new GridErrorEvent(error as Error));\n\t\t\t}\n\t\t}\n\n\t\tif (this.model) {\n\t\t\tif (this.options) this.model.options = this.options;\n\t\t\tthis.rendering.requireVerticalUpdate = true;\n\t\t\tthis.rendering.requireHorizontalUpdate = true;\n\t\t\tthis.table.model = this.model;\n\t\t\tif (changedProps.has('model')) {\n\t\t\t\tthis.sorting.init();\n\n\t\t\t\tif (this.model.options.firstCell) { // TODO: move somewhere else\n\t\t\t\t\tconst cell = CellRange.fromA1(this.model.options.firstCell);\n\t\t\t\t\tthis.table.colOffset = cell.c1;\n\t\t\t\t\tthis.table.rowOffset = cell.r1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait this.table.updateComplete;\n\t\t\tthis.rendering.updateSliders();\n\t\t\tthis.rendering.debounceRenderCells();\n\t\t\tinitGridCommands(this);\n\t\t\tthis.dispatchEvent(new GridEvent('loadmodel', {grid: this}));\n\t\t}\n\n\t\tif (changedProps.has('zoom') && (changedProps.get('zoom') || 1) !== (this.zoom || 1)) {\n\t\t\tthis.options.zoom = this.zoom;\n\t\t\tthis.rendering.render(true);\n\t\t}\n\t}\n\n\tinnerLayout() {\n\t\tdom.setSize(this.table, {w: this.clientWidth, h: this.clientHeight});\n\t\tthis.table.requestUpdate();\n\t}\n\n\tdebounceInnerLayout = debounce(this.innerLayout, 100);\n\n\tlayout() {\n\t\tif (this.table) this.debounceInnerLayout();\n\t}\n\n\tsetSourceData(data: GridSource) {\n\t\tif (data.options) this.options = this._initOptions(data.options, this.options);\n\t\tthis.model = new GridModel(data, this.options, this.logger);\n\t}\n\n\twillUpdate(changedProps: Map<PropertyKey, unknown>) {\n\t\t// options set from outside (`.options=\"${partial}\"`) are completed over the previous ones before\n\t\t// updated() hands them to the model; the grid's own options are complete already\n\t\tconst bound = changedProps.has('options') && !this._initializedOptions.has(this.options) ? this.options ?? {} : null;\n\t\tconst prev = bound ? changedProps.get('options') as Options : this.options;\n\t\tif (changedProps.has('adapter') && changedProps.get('adapter')) {\n\t\t\t// a different adapter: its options start over; options bound in the same update still apply\n\t\t\t// (done here, not in updated(): a property set there costs another update cycle and a Lit warning)\n\t\t\tthis.options = this.resetOptions(prev);\n\t\t\tif (bound) this.options = this._initOptions(bound, this.options);\n\t\t} else if (bound) {\n\t\t\tthis.options = this._initOptions(bound, prev);\n\t\t}\n\t\tif (changedProps.has('model')) {\n\t\t\tthis.options = this._initOptions(this.model.options, this.options);\n\t\t\tthis.model.options = this.options;\n\t\t\tthis.history = new History(this.model);\n\t\t\tthis.filtering.init();\n\t\t\tthis.zoom = this.options.zoom || 1;\n\t\t}\n\t}\n\n\tfocus(options?: FocusOptions): void {\n\t\tsuper.focus(options);\n\t\tthis.editing.activeEditor?.focus();\n\t}\n\n\tasync refresh() {\n\t\tif (this.adapter) {\n\t\t\tthis.table.clearHeaderCache();\n\t\t\tthis.table.clearBodyCache();\n\t\t\tawait this.initAdapter();\n\t\t} else {\n\t\t\tawait this.rendering.render(true);\n\t\t}\n\t}\n\n\tcreateEvent<TEvent extends GridEvent>(type: string, args?: Partial<TEvent>, event?: AnyConstructor<TEvent>) {\n\t\tconst EventConstructor = (event ?? GridEvent) as AnyConstructor<TEvent>;\n\t\treturn new EventConstructor(type, {grid: this, ...args});\n\t}\n\n\tdispatchGridEvent<TEvent extends GridEvent>(type: string, args?: Partial<TEvent>, event?: AnyConstructor<TEvent>) {\n\t\tthis.dispatchEvent(this.createEvent(type, args, event));\n\t}\n\n\tgetConnectedGrid(name: string) {\n\t\treturn this.group?.getGrid(name);\n\t}\n\n\tgetSourceData() {\n\t\tconst data = this.model?.getSourceData() ?? {};\n\t\tconst event = new events.SerialzieEvent<GridSource>(data);\n\t\tthis.dispatchEvent(event);\n\t\treturn event.data;\n\t}\n\n\tsetTheme(theme: TableTheme) {\n\t\tthis.model.theme = theme;\n\t\tthis.model.applyTheme(theme, true);\n\t\tthis.refresh();\n\t}\n\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/grid",
3
- "version": "0.11.33",
3
+ "version": "0.11.35",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Universal datagrid component",
6
6
  "main": "./dist/index.js",
@@ -35,12 +35,12 @@
35
35
  "_prepublish": "yarn test && yarn lint"
36
36
  },
37
37
  "dependencies": {
38
- "@omegagrid/commands": "^0.11.33",
39
- "@omegagrid/core": "^0.11.33",
40
- "@omegagrid/grid-core": "^0.11.33",
41
- "@omegagrid/localize": "^0.11.33",
42
- "@omegagrid/tabs": "^0.11.33",
43
- "@omegagrid/tree": "^0.11.33",
38
+ "@omegagrid/commands": "^0.11.35",
39
+ "@omegagrid/core": "^0.11.35",
40
+ "@omegagrid/grid-core": "^0.11.35",
41
+ "@omegagrid/localize": "^0.11.35",
42
+ "@omegagrid/tabs": "^0.11.35",
43
+ "@omegagrid/tree": "^0.11.35",
44
44
  "@stdlib/stats": "^0.0.13",
45
45
  "date-fns": "^3.2.0",
46
46
  "lit": "^3.1.1",
@@ -1,15 +0,0 @@
1
- import { BaseFilter } from "./baseFilter";
2
- export declare class RangeFilter extends BaseFilter {
3
- static styles: import("lit").CSSResult[];
4
- private dropdownEl;
5
- private popupEl;
6
- private get popupType();
7
- private _currentRange;
8
- private _formatLabel;
9
- private _onApply;
10
- private _onClear;
11
- render: () => import("lit-html").TemplateResult<1>;
12
- activate(): void;
13
- deactivate(): void;
14
- }
15
- //# sourceMappingURL=rangeFilter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rangeFilter.d.ts","sourceRoot":"","sources":["../../src/filters/rangeFilter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB1C,qBACa,WAAY,SAAQ,UAAU;IAE1C,MAAM,CAAC,MAAM,4BAaV;IAGH,OAAO,CAAC,UAAU,CAAW;IAG7B,OAAO,CAAC,OAAO,CAAmB;IAElC,OAAO,KAAK,SAAS,GAGpB;IAED,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,QAAQ,CAQf;IAED,OAAO,CAAC,QAAQ,CAIf;IAED,MAAM,6CASJ;IAEF,QAAQ;IAUR,UAAU;CAIV"}
@@ -1,130 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import constants from "../constants";
8
- import { customElement, query } from 'lit/decorators.js';
9
- import { BaseFilter } from "./baseFilter";
10
- import { html, css } from 'lit';
11
- const isRangeTerm = (v) => !!v && typeof v === 'object' && !Array.isArray(v) && v.kind === 'range';
12
- const toDate = (v) => {
13
- if (v == null || v === '')
14
- return null;
15
- if (v instanceof Date)
16
- return v;
17
- const d = new Date(v);
18
- return Number.isNaN(d.getTime()) ? null : d;
19
- };
20
- let RangeFilter = class RangeFilter extends BaseFilter {
21
- constructor() {
22
- super(...arguments);
23
- this._onApply = (e) => {
24
- if (e.from == null && e.to == null) {
25
- this.clearFilter();
26
- }
27
- else {
28
- this.filter({ kind: 'range', from: e.from, to: e.to });
29
- }
30
- this.dropdownEl?.close();
31
- this.deactivate();
32
- };
33
- this._onClear = () => {
34
- this.clearFilter();
35
- this.dropdownEl?.close();
36
- this.deactivate();
37
- };
38
- this.render = () => html `
39
- <og-dropdown color="transparent" alignment="left">
40
- <div slot="label">${this._formatLabel()}</div>
41
- <og-filter-range-popup slot="content"
42
- type="${this.popupType}"
43
- @apply="${this._onApply}"
44
- @clear="${this._onClear}">
45
- </og-filter-range-popup>
46
- </og-dropdown>
47
- `;
48
- }
49
- get popupType() {
50
- const t = this.columnModel?.type;
51
- return (t === 'dt' || t === 'tm') ? t : 'd';
52
- }
53
- _currentRange() {
54
- const r = isRangeTerm(this.currentValue) ? this.currentValue : null;
55
- if (!r)
56
- return { from: null, to: null };
57
- switch (this.popupType) {
58
- case 'd':
59
- case 'dt': return { from: toDate(r.from), to: toDate(r.to) };
60
- case 'tm': return {
61
- from: r.from == null ? null : String(r.from),
62
- to: r.to == null ? null : String(r.to),
63
- };
64
- }
65
- }
66
- _formatLabel() {
67
- const r = isRangeTerm(this.currentValue) ? this.currentValue : null;
68
- if (!r || (r.from == null && r.to == null))
69
- return '';
70
- const type = this.popupType;
71
- const fmt = (v) => {
72
- if (v == null)
73
- return '';
74
- if (v instanceof Date)
75
- return v.toLocaleDateString();
76
- if (type === 'd' || type === 'dt') {
77
- const d = toDate(v);
78
- if (d)
79
- return d.toLocaleDateString();
80
- }
81
- return String(v);
82
- };
83
- const from = fmt(r.from);
84
- const to = fmt(r.to);
85
- if (from && to)
86
- return `${from} – ${to}`;
87
- if (from)
88
- return `≥ ${from}`;
89
- return `≤ ${to}`;
90
- }
91
- activate() {
92
- super.activate();
93
- const { from, to } = this._currentRange();
94
- setTimeout(() => {
95
- if (!this.activated)
96
- return; // closed before the delay ran out, e.g. by a scroll
97
- this.popupEl?.setValues(from, to);
98
- this.dropdownEl?.open();
99
- }, 50);
100
- }
101
- deactivate() {
102
- this.dropdownEl?.close();
103
- super.deactivate();
104
- }
105
- };
106
- RangeFilter.styles = [...BaseFilter.styles, css `
107
- :host {
108
- display: block;
109
- box-sizing: border-box;
110
- height: 100%;
111
- width: 100%;
112
- }
113
-
114
- og-dropdown {
115
- display: flex;
116
- width: 100%;
117
- height: 100%;
118
- }
119
- `];
120
- __decorate([
121
- query('og-dropdown')
122
- ], RangeFilter.prototype, "dropdownEl", void 0);
123
- __decorate([
124
- query(`${constants.PREFIX}-filter-range-popup`)
125
- ], RangeFilter.prototype, "popupEl", void 0);
126
- RangeFilter = __decorate([
127
- customElement(`${constants.PREFIX}-filter-range`)
128
- ], RangeFilter);
129
- export { RangeFilter };
130
- //# sourceMappingURL=rangeFilter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rangeFilter.js","sourceRoot":"","sources":["../../src/filters/rangeFilter.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAKhC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAoB,EAAE,CACpD,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAK,CAAiB,CAAC,IAAI,KAAK,OAAO,CAAC;AAE1F,MAAM,MAAM,GAAG,CAAC,CAAU,EAAe,EAAE;IAC1C,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,CAAC,YAAY,IAAI;QAAE,OAAO,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,CAAW,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC;AAGK,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QA6DE,aAAQ,GAAG,CAAC,CAAwB,EAAE,E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port { BaseFilter } from \"./baseFilter\";\nimport { html, css } from 'lit';\nimport { FilterRange } from \"@omegagrid/grid-core\";\nimport { Dropdown } from \"@omegagrid/core\";\nimport { RangeFilterApplyEvent, RangeFilterPopup, RangeFilterType, RangeValue } from \"./rangeFilterPopup\";\n\nconst isRangeTerm = (v: unknown): v is FilterRange =>\n\t!!v && typeof v === 'object' && !Array.isArray(v) && (v as FilterRange).kind === 'range';\n\nconst toDate = (v: unknown): Date | null => {\n\tif (v == null || v === '') return null;\n\tif (v instanceof Date) return v;\n\tconst d = new Date(v as string);\n\treturn Number.isNaN(d.getTime()) ? null : d;\n};\n\n@customElement(`${constants.PREFIX}-filter-range`)\nexport class RangeFilter extends BaseFilter {\n\n\tstatic styles = [...BaseFilter.styles, css`\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t\tbox-sizing: border-box;\n\t\t\theight: 100%;\n\t\t\twidth: 100%;\n\t\t}\n\n\t\tog-dropdown {\n\t\t\tdisplay: flex;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t`];\n\n\t@query('og-dropdown')\n\tprivate dropdownEl: Dropdown;\n\n\t@query(`${constants.PREFIX}-filter-range-popup`)\n\tprivate popupEl: RangeFilterPopup;\n\n\tprivate get popupType(): RangeFilterType {\n\t\tconst t = this.columnModel?.type;\n\t\treturn (t === 'dt' || t === 'tm') ? t : 'd';\n\t}\n\n\tprivate _currentRange(): { from: RangeValue, to: RangeValue } {\n\t\tconst r = isRangeTerm(this.currentValue) ? this.currentValue : null;\n\t\tif (!r) return { from: null, to: null };\n\t\tswitch (this.popupType) {\n\t\t\tcase 'd':\n\t\t\tcase 'dt': return { from: toDate(r.from), to: toDate(r.to) };\n\t\t\tcase 'tm': return {\n\t\t\t\tfrom: r.from == null ? null : String(r.from),\n\t\t\t\tto: r.to == null ? null : String(r.to),\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate _formatLabel(): string {\n\t\tconst r = isRangeTerm(this.currentValue) ? this.currentValue : null;\n\t\tif (!r || (r.from == null && r.to == null)) return '';\n\t\tconst type = this.popupType;\n\t\tconst fmt = (v: unknown) => {\n\t\t\tif (v == null) return '';\n\t\t\tif (v instanceof Date) return v.toLocaleDateString();\n\t\t\tif (type === 'd' || type === 'dt') {\n\t\t\t\tconst d = toDate(v);\n\t\t\t\tif (d) return d.toLocaleDateString();\n\t\t\t}\n\t\t\treturn String(v);\n\t\t};\n\t\tconst from = fmt(r.from);\n\t\tconst to = fmt(r.to);\n\t\tif (from && to) return `${from} – ${to}`;\n\t\tif (from) return `≥ ${from}`;\n\t\treturn `≤ ${to}`;\n\t}\n\n\tprivate _onApply = (e: RangeFilterApplyEvent) => {\n\t\tif (e.from == null && e.to == null) {\n\t\t\tthis.clearFilter();\n\t\t} else {\n\t\t\tthis.filter({ kind: 'range', from: e.from, to: e.to } as FilterRange);\n\t\t}\n\t\tthis.dropdownEl?.close();\n\t\tthis.deactivate();\n\t}\n\n\tprivate _onClear = () => {\n\t\tthis.clearFilter();\n\t\tthis.dropdownEl?.close();\n\t\tthis.deactivate();\n\t}\n\n\trender = () => html`\n\t\t<og-dropdown color=\"transparent\" alignment=\"left\">\n\t\t\t<div slot=\"label\">${this._formatLabel()}</div>\n\t\t\t<og-filter-range-popup slot=\"content\"\n\t\t\t\ttype=\"${this.popupType}\"\n\t\t\t\t@apply=\"${this._onApply}\"\n\t\t\t\t@clear=\"${this._onClear}\">\n\t\t\t</og-filter-range-popup>\n\t\t</og-dropdown>\n\t`;\n\n\tactivate() {\n\t\tsuper.activate();\n\t\tconst { from, to } = this._currentRange();\n\t\tsetTimeout(() => {\n\t\t\tif (!this.activated) return; // closed before the delay ran out, e.g. by a scroll\n\t\t\tthis.popupEl?.setValues(from, to);\n\t\t\tthis.dropdownEl?.open();\n\t\t}, 50);\n\t}\n\n\tdeactivate() {\n\t\tthis.dropdownEl?.close();\n\t\tsuper.deactivate();\n\t}\n}\n"]}
@@ -1,30 +0,0 @@
1
- import { LitElement } from 'lit';
2
- export type RangeFilterType = 'd' | 'dt' | 'tm';
3
- export type RangeValue = Date | string | null;
4
- export declare class RangeFilterApplyEvent extends Event {
5
- from: RangeValue;
6
- to: RangeValue;
7
- constructor(from: RangeValue, to: RangeValue);
8
- }
9
- export declare class RangeFilterClearEvent extends Event {
10
- constructor();
11
- }
12
- export declare class RangeFilterPopup extends LitElement {
13
- static styles: import("lit").CSSResult;
14
- type: RangeFilterType;
15
- private _from;
16
- private _to;
17
- constructor();
18
- private _onPopupMouseDown;
19
- setValues(from: RangeValue, to: RangeValue): void;
20
- private _onFromDate;
21
- private _onToDate;
22
- private _onFromText;
23
- private _onToText;
24
- private _apply;
25
- private _clear;
26
- private _onKeyDown;
27
- private _renderRow;
28
- render(): import("lit-html").TemplateResult<1>;
29
- }
30
- //# sourceMappingURL=rangeFilterPopup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rangeFilterPopup.d.ts","sourceRoot":"","sources":["../../src/filters/rangeFilterPopup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAM5C,MAAM,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;AAE9C,qBAAa,qBAAsB,SAAQ,KAAK;IAC5B,IAAI,EAAE,UAAU;IAAS,EAAE,EAAE,UAAU;gBAAvC,IAAI,EAAE,UAAU,EAAS,EAAE,EAAE,UAAU;CAG1D;AAED,qBAAa,qBAAsB,SAAQ,KAAK;;CAI/C;AAED,qBACa,gBAAiB,SAAQ,UAAU;IAE/C,MAAM,CAAC,MAAM,0BAiCX;IAGF,IAAI,EAAE,eAAe,CAAO;IAEnB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,GAAG,CAAoB;;IAWxC,OAAO,CAAC,iBAAiB,CAKxB;IAED,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU;IAK1C,OAAO,CAAC,WAAW,CAAqE;IACxF,OAAO,CAAC,SAAS,CAAmE;IAEpF,OAAO,CAAC,WAAW,CAAuE;IAC1F,OAAO,CAAC,SAAS,CAAqE;IAEtF,OAAO,CAAC,MAAM,CAEb;IAED,OAAO,CAAC,MAAM,CAIb;IAED,OAAO,CAAC,UAAU,CAKjB;IAED,OAAO,CAAC,UAAU;IAalB,MAAM;CAYN"}
@@ -1,137 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { LitElement, html, css } from 'lit';
8
- import { customElement, property, state } from 'lit/decorators.js';
9
- import { msg } from '@omegagrid/localize';
10
- import constants from '../constants';
11
- export class RangeFilterApplyEvent extends Event {
12
- constructor(from, to) {
13
- super('apply', { bubbles: false, composed: true });
14
- this.from = from;
15
- this.to = to;
16
- }
17
- }
18
- export class RangeFilterClearEvent extends Event {
19
- constructor() {
20
- super('clear', { bubbles: false, composed: true });
21
- }
22
- }
23
- let RangeFilterPopup = class RangeFilterPopup extends LitElement {
24
- constructor() {
25
- super();
26
- this.type = 'd';
27
- this._from = null;
28
- this._to = null;
29
- this._onPopupMouseDown = (e) => {
30
- const path = e.composedPath();
31
- this.renderRoot.querySelectorAll('og-calendar-dropdown').forEach(dd => {
32
- if (dd.isOpen && !path.includes(dd) && !path.includes(dd.dropdown))
33
- dd.close();
34
- });
35
- };
36
- this._onFromDate = (e) => { this._from = e.value ?? null; };
37
- this._onToDate = (e) => { this._to = e.value ?? null; };
38
- this._onFromText = (e) => { this._from = e.value || null; };
39
- this._onToText = (e) => { this._to = e.value || null; };
40
- this._apply = () => {
41
- this.dispatchEvent(new RangeFilterApplyEvent(this._from, this._to));
42
- };
43
- this._clear = () => {
44
- this._from = null;
45
- this._to = null;
46
- this.dispatchEvent(new RangeFilterClearEvent());
47
- };
48
- this._onKeyDown = (e) => {
49
- if (e.key === 'Enter') {
50
- e.stopPropagation();
51
- this._apply();
52
- }
53
- };
54
- // Close an open calendar dropdown when clicking elsewhere in the popup. The popup
55
- // content lives inside the outer dropdown container, which stops mousedown before it
56
- // reaches document.body — so the calendar's own outside-click handler never fires for
57
- // in-popup clicks. Handle it here, scoped to this popup, so the popup itself stays open.
58
- this.addEventListener('mousedown', this._onPopupMouseDown);
59
- }
60
- setValues(from, to) {
61
- this._from = from;
62
- this._to = to;
63
- }
64
- _renderRow(label, value, which) {
65
- let control;
66
- if (this.type === 'tm') {
67
- // TODO: change to time picker when available
68
- const onChange = which === 'from' ? this._onFromText : this._onToText;
69
- control = html `<og-input .value="${(value ?? '')}" @change="${onChange}"></og-input>`;
70
- }
71
- else {
72
- const onChange = which === 'from' ? this._onFromDate : this._onToDate;
73
- control = html `<og-calendar-dropdown cross buttonInput .value="${value}" @change="${onChange}"></og-calendar-dropdown>`;
74
- }
75
- return html `<div class="row"><label>${label}</label>${control}</div>`;
76
- }
77
- render() {
78
- return html `
79
- <div @keydown="${this._onKeyDown}" style="display: contents;">
80
- ${this._renderRow(msg('From'), this._from, 'from')}
81
- ${this._renderRow(msg('To'), this._to, 'to')}
82
- <div class="actions">
83
- <og-button icon="check" color="accent" text="${msg('Apply')}" @click="${this._apply}"></og-button>
84
- <og-button icon="xmark" color="red" text="${msg('Clear')}" @click="${this._clear}"></og-button>
85
- </div>
86
- </div>
87
- `;
88
- }
89
- };
90
- RangeFilterPopup.styles = css `
91
- :host {
92
- display: flex;
93
- flex-direction: column;
94
- gap: 5px;
95
- padding: 6px;
96
- min-width: 200px;
97
- }
98
-
99
- .row {
100
- display: flex;
101
- flex-direction: row;
102
- align-items: center;
103
- gap: 6px;
104
- }
105
-
106
- .row > label {
107
- flex: 0 0 28px;
108
- }
109
-
110
- .row > og-calendar-dropdown,
111
- .row > og-input {
112
- flex: 1;
113
- min-width: 0;
114
- box-sizing: border-box;
115
- }
116
-
117
- .actions {
118
- display: flex;
119
- justify-content: flex-end;
120
- gap: 4px;
121
- margin-top: 4px;
122
- }
123
- `;
124
- __decorate([
125
- property({ type: String })
126
- ], RangeFilterPopup.prototype, "type", void 0);
127
- __decorate([
128
- state()
129
- ], RangeFilterPopup.prototype, "_from", void 0);
130
- __decorate([
131
- state()
132
- ], RangeFilterPopup.prototype, "_to", void 0);
133
- RangeFilterPopup = __decorate([
134
- customElement(`${constants.PREFIX}-filter-range-popup`)
135
- ], RangeFilterPopup);
136
- export { RangeFilterPopup };
137
- //# sourceMappingURL=rangeFilterPopup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rangeFilterPopup.js","sourceRoot":"","sources":["../../src/filters/rangeFilterPopup.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,SAAS,MAAM,cAAc,CAAC;AAKrC,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC/C,YAAmB,IAAgB,EAAS,EAAc;QACzD,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QADjC,SAAI,GAAJ,IAAI,CAAY;QAAS,OAAE,GAAF,EAAE,CAAY;IAE1D,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC/C;QACC,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,E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AAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACtE,OAAO,GAAG,IAAI,CAAA,mDAAmD,KAAoB,cAAc,QAAQ,2BAA2B,CAAC;QACxI,CAAC;QACD,OAAO,IAAI,CAAA,2BAA2B,KAAK,WAAW,OAAO,QAAQ,CAAC;IACvE,CAAC;IAED,MAAM;QACL,OAAO,IAAI,CAAA;oBACO,IAAI,CAAC,UAAU;MAC7B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC;MAChD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC;;oDAEI,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,MAAM;iDACvC,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,CAAC,MAAM;;;GAGlF,CAAC;IACH,CAAC;;AA7GM,uBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiClB,AAjCY,CAiCX;AAGF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACC;AAEX;IAAhB,KAAK,EAAE;+CAAkC;AACzB;IAAhB,KAAK,EAAE;6CAAgC;AAzC5B,gBAAgB;IAD5B,aAAa,CAAC,GAAG,SAAS,CAAC,MAAM,qBAAqB,CAAC;GAC3C,gBAAgB,CAgH5B","sourcesContent":["import { LitElement, html, css } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { Dropdown, events } from '@omegagrid/core';\nimport { msg } from '@omegagrid/localize';\nimport constants from '../constants';\n\nexport type RangeFilterType = 'd' | 'dt' | 'tm';\nexport type RangeValue = Date | string | null;\n\nexport class RangeFilterApplyEvent extends Event {\n\tconstructor(public from: RangeValue, public to: RangeValue) {\n\t\tsuper('apply', { bubbles: false, composed: true });\n\t}\n}\n\nexport class RangeFilterClearEvent extends Event {\n\tconstructor() {\n\t\tsuper('clear', { bubbles: false, composed: true });\n\t}\n}\n\n@customElement(`${constants.PREFIX}-filter-range-popup`)\nexport class RangeFilterPopup extends LitElement {\n\n\tstatic styles = css`\n\t\t:host {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\tgap: 5px;\n\t\t\tpadding: 6px;\n\t\t\tmin-width: 200px;\n\t\t}\n\n\t\t.row {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: row;\n\t\t\talign-items: center;\n\t\t\tgap: 6px;\n\t\t}\n\n\t\t.row > label {\n\t\t\tflex: 0 0 28px;\n\t\t}\n\n\t\t.row > og-calendar-dropdown,\n\t\t.row > og-input {\n\t\t\tflex: 1;\n\t\t\tmin-width: 0;\n\t\t\tbox-sizing: border-box;\n\t\t}\n\n\t\t.actions {\n\t\t\tdisplay: flex;\n\t\t\tjustify-content: flex-end;\n\t\t\tgap: 4px;\n\t\t\tmargin-top: 4px;\n\t\t}\n\t`;\n\n\t@property({ type: String })\n\ttype: RangeFilterType = 'd';\n\n\t@state() private _from: RangeValue = null;\n\t@state() private _to: RangeValue = null;\n\n\tconstructor() {\n\t\tsuper();\n\t\t// Close an open calendar dropdown when clicking elsewhere in the popup. The popup\n\t\t// content lives inside the outer dropdown container, which stops mousedown before it\n\t\t// reaches document.body — so the calendar's own outside-click handler never fires for\n\t\t// in-popup clicks. Handle it here, scoped to this popup, so the popup itself stays open.\n\t\tthis.addEventListener('mousedown', this._onPopupMouseDown);\n\t}\n\n\tprivate _onPopupMouseDown = (e: MouseEvent) => {\n\t\tconst path = e.composedPath();\n\t\tthis.renderRoot.querySelectorAll<Dropdown>('og-calendar-dropdown').forEach(dd => {\n\t\t\tif (dd.isOpen && !path.includes(dd) && !path.includes(dd.dropdown)) dd.close();\n\t\t});\n\t}\n\n\tsetValues(from: RangeValue, to: RangeValue) {\n\t\tthis._from = from;\n\t\tthis._to = to;\n\t}\n\n\tprivate _onFromDate = (e: events.ChangeEvent<Date>) => { this._from = e.value ?? null; }\n\tprivate _onToDate = (e: events.ChangeEvent<Date>) => { this._to = e.value ?? null; }\n\n\tprivate _onFromText = (e: events.ChangeEvent<string>) => { this._from = e.value || null; }\n\tprivate _onToText = (e: events.ChangeEvent<string>) => { this._to = e.value || null; }\n\n\tprivate _apply = () => {\n\t\tthis.dispatchEvent(new RangeFilterApplyEvent(this._from, this._to));\n\t}\n\n\tprivate _clear = () => {\n\t\tthis._from = null;\n\t\tthis._to = null;\n\t\tthis.dispatchEvent(new RangeFilterClearEvent());\n\t}\n\n\tprivate _onKeyDown = (e: KeyboardEvent) => {\n\t\tif (e.key === 'Enter') {\n\t\t\te.stopPropagation();\n\t\t\tthis._apply();\n\t\t}\n\t}\n\n\tprivate _renderRow(label: string, value: RangeValue, which: 'from' | 'to') {\n\t\tlet control;\n\t\tif (this.type === 'tm') {\n\t\t\t// TODO: change to time picker when available\n\t\t\tconst onChange = which === 'from' ? this._onFromText : this._onToText;\n\t\t\tcontrol = html`<og-input .value=\"${(value ?? '') as string}\" @change=\"${onChange}\"></og-input>`;\n\t\t} else {\n\t\t\tconst onChange = which === 'from' ? this._onFromDate : this._onToDate;\n\t\t\tcontrol = html`<og-calendar-dropdown cross buttonInput .value=\"${value as Date | null}\" @change=\"${onChange}\"></og-calendar-dropdown>`;\n\t\t}\n\t\treturn html`<div class=\"row\"><label>${label}</label>${control}</div>`;\n\t}\n\n\trender() {\n\t\treturn html`\n\t\t\t<div @keydown=\"${this._onKeyDown}\" style=\"display: contents;\">\n\t\t\t\t${this._renderRow(msg('From'), this._from, 'from')}\n\t\t\t\t${this._renderRow(msg('To'), this._to, 'to')}\n\t\t\t\t<div class=\"actions\">\n\t\t\t\t\t<og-button icon=\"check\" color=\"accent\" text=\"${msg('Apply')}\" @click=\"${this._apply}\"></og-button>\n\t\t\t\t\t<og-button icon=\"xmark\" color=\"red\" text=\"${msg('Clear')}\" @click=\"${this._clear}\"></og-button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t`;\n\t}\n}\n"]}