@omegagrid/grid 0.11.32 → 0.11.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editors/baseEditor.d.ts.map +1 -1
- package/dist/editors/baseEditor.js +6 -3
- package/dist/editors/baseEditor.js.map +1 -1
- package/dist/editors/calendarEditor.d.ts +10 -1
- package/dist/editors/calendarEditor.d.ts.map +1 -1
- package/dist/editors/calendarEditor.js +113 -19
- package/dist/editors/calendarEditor.js.map +1 -1
- package/dist/editors/dateEditor.d.ts +3 -1
- package/dist/editors/dateEditor.d.ts.map +1 -1
- package/dist/editors/dateEditor.js +22 -3
- package/dist/editors/dateEditor.js.map +1 -1
- package/dist/editors/index.d.ts.map +1 -1
- package/dist/editors/index.js +2 -0
- package/dist/editors/index.js.map +1 -1
- package/dist/filters/dateFilter.d.ts +54 -0
- package/dist/filters/dateFilter.d.ts.map +1 -0
- package/dist/filters/dateFilter.js +179 -0
- package/dist/filters/dateFilter.js.map +1 -0
- package/dist/filters/filterFactory.js +3 -3
- package/dist/filters/filterFactory.js.map +1 -1
- package/dist/filters/index.d.ts +1 -2
- package/dist/filters/index.d.ts.map +1 -1
- package/dist/filters/index.js +1 -2
- package/dist/filters/index.js.map +1 -1
- package/dist/renderers/DateTimeRenderer.d.ts.map +1 -1
- package/dist/renderers/DateTimeRenderer.js +3 -1
- package/dist/renderers/DateTimeRenderer.js.map +1 -1
- package/dist/ui/filterLabel.d.ts.map +1 -1
- package/dist/ui/filterLabel.js +0 -27
- package/dist/ui/filterLabel.js.map +1 -1
- package/dist/ui/grid.d.ts +15 -0
- package/dist/ui/grid.d.ts.map +1 -1
- package/dist/ui/grid.editing.d.ts.map +1 -1
- package/dist/ui/grid.editing.js +5 -4
- package/dist/ui/grid.editing.js.map +1 -1
- package/dist/ui/grid.js +39 -4
- package/dist/ui/grid.js.map +1 -1
- package/package.json +7 -7
- package/dist/filters/rangeFilter.d.ts +0 -15
- package/dist/filters/rangeFilter.d.ts.map +0 -1
- package/dist/filters/rangeFilter.js +0 -130
- package/dist/filters/rangeFilter.js.map +0 -1
- package/dist/filters/rangeFilterPopup.d.ts +0 -30
- package/dist/filters/rangeFilterPopup.d.ts.map +0 -1
- package/dist/filters/rangeFilterPopup.js +0 -137
- package/dist/filters/rangeFilterPopup.js.map +0 -1
|
@@ -1,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,EA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;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"]}
|