@omegagrid/grid 0.10.64 → 0.10.66

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.
@@ -1 +1 @@
1
- {"version":3,"file":"rangeFilter.d.ts","sourceRoot":"","sources":["../../src/filters/rangeFilter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAsB1C,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;IAcrB,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,QAAQ,CAQf;IAED,OAAO,CAAC,QAAQ,CAIf;IAED,MAAM,6CASJ;IAEF,QAAQ;IASR,UAAU;CAIV"}
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;IASR,UAAU;CAIV"}
@@ -17,12 +17,6 @@ const toDate = (v) => {
17
17
  const d = new Date(v);
18
18
  return Number.isNaN(d.getTime()) ? null : d;
19
19
  };
20
- const toNum = (v) => {
21
- if (v == null || v === '')
22
- return null;
23
- const n = typeof v === 'number' ? v : Number(v);
24
- return Number.isNaN(n) ? null : n;
25
- };
26
20
  let RangeFilter = class RangeFilter extends BaseFilter {
27
21
  constructor() {
28
22
  super(...arguments);
@@ -54,14 +48,13 @@ let RangeFilter = class RangeFilter extends BaseFilter {
54
48
  }
55
49
  get popupType() {
56
50
  const t = this.columnModel?.type;
57
- return (t === 'd' || t === 'dt' || t === 'tm') ? t : 'n';
51
+ return (t === 'dt' || t === 'tm') ? t : 'd';
58
52
  }
59
53
  _currentRange() {
60
54
  const r = isRangeTerm(this.currentValue) ? this.currentValue : null;
61
55
  if (!r)
62
56
  return { from: null, to: null };
63
57
  switch (this.popupType) {
64
- case 'n': return { from: toNum(r.from), to: toNum(r.to) };
65
58
  case 'd':
66
59
  case 'dt': return { from: toDate(r.from), to: toDate(r.to) };
67
60
  case 'tm': return {
@@ -1 +1 @@
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,K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GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1C,UAAU,CAAC,GAAG,EAAE;YACf,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC,EAAE,EAAE,CAAC,CAAC;IACR,CAAC;IAED,UAAU;QACT,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;;AAnGM,kBAAM,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,GAAG,CAAA;;;;;;;;;;;;;EAazC,CAAC,AAbW,CAaV;AAGK;IADP,KAAK,CAAC,aAAa,CAAC;+CACQ;AAGrB;IADP,KAAK,CAAC,GAAG,SAAS,CAAC,MAAM,qBAAqB,CAAC;4CACd;AArBtB,WAAW;IADvB,aAAa,CAAC,GAAG,SAAS,CAAC,MAAM,eAAe,CAAC;GACrC,WAAW,CAsGvB","sourcesContent":["import constants from \"../constants\";\nimport { customElement, query } from 'lit/decorators.js';\nimport { 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\nconst toNum = (v: unknown): number | null => {\n\tif (v == null || v === '') return null;\n\tconst n = typeof v === 'number' ? v : Number(v);\n\treturn Number.isNaN(n) ? null : n;\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 === 'd' || t === 'dt' || t === 'tm') ? t : 'n';\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 'n': return { from: toNum(r.from), to: toNum(r.to) };\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\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
+ {"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,CA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AAC,UAAU,EAAE,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;;AAlGM,kBAAM,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,GAAG,CAAA;;;;;;;;;;;;;EAazC,CAAC,AAbW,CAaV;AAGK;IADP,KAAK,CAAC,aAAa,CAAC;+CACQ;AAGrB;IADP,KAAK,CAAC,GAAG,SAAS,CAAC,MAAM,qBAAqB,CAAC;4CACd;AArBtB,WAAW;IADvB,aAAa,CAAC,GAAG,SAAS,CAAC,MAAM,eAAe,CAAC;GACrC,WAAW,CAqGvB","sourcesContent":["import constants from \"../constants\";\nimport { customElement, query } from 'lit/decorators.js';\nimport { 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\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,6 +1,6 @@
1
1
  import { LitElement } from 'lit';
2
- export type RangeFilterType = 'n' | 'd' | 'dt' | 'tm';
3
- export type RangeValue = Date | number | string | null;
2
+ export type RangeFilterType = 'd' | 'dt' | 'tm';
3
+ export type RangeValue = Date | string | null;
4
4
  export declare class RangeFilterApplyEvent extends Event {
5
5
  from: RangeValue;
6
6
  to: RangeValue;
@@ -19,8 +19,6 @@ export declare class RangeFilterPopup extends LitElement {
19
19
  setValues(from: RangeValue, to: RangeValue): void;
20
20
  private _onFromDate;
21
21
  private _onToDate;
22
- private _onFromNum;
23
- private _onToNum;
24
22
  private _onFromText;
25
23
  private _onToText;
26
24
  private _apply;
@@ -1 +1 @@
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,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AACtD,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAEvD,qBAAa,qBAAsB,SAAQ,KAAK;IAC5B,IAAI,EAAE,UAAU;IAAS,EAAE,EAAE,UAAU;gBAAvC,IAAI,EAAE,UAAU,EAAS,EAAE,EAAE,UAAU;CAG1D;AAED,qBAA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WxC,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"}
@@ -23,7 +23,7 @@ export class RangeFilterClearEvent extends Event {
23
23
  let RangeFilterPopup = class RangeFilterPopup extends LitElement {
24
24
  constructor() {
25
25
  super();
26
- this.type = 'n';
26
+ this.type = 'd';
27
27
  this._from = null;
28
28
  this._to = null;
29
29
  this._onPopupMouseDown = (e) => {
@@ -35,14 +35,6 @@ let RangeFilterPopup = class RangeFilterPopup extends LitElement {
35
35
  };
36
36
  this._onFromDate = (e) => { this._from = e.value ?? null; };
37
37
  this._onToDate = (e) => { this._to = e.value ?? null; };
38
- this._onFromNum = (e) => {
39
- const v = e.target.value;
40
- this._from = v == null || Number.isNaN(v) ? null : v;
41
- };
42
- this._onToNum = (e) => {
43
- const v = e.target.value;
44
- this._to = v == null || Number.isNaN(v) ? null : v;
45
- };
46
38
  this._onFromText = (e) => { this._from = e.value || null; };
47
39
  this._onToText = (e) => { this._to = e.value || null; };
48
40
  this._apply = () => {
@@ -71,18 +63,14 @@ let RangeFilterPopup = class RangeFilterPopup extends LitElement {
71
63
  }
72
64
  _renderRow(label, value, which) {
73
65
  let control;
74
- if (this.type === 'd' || this.type === 'dt') {
75
- const onChange = which === 'from' ? this._onFromDate : this._onToDate;
76
- control = html `<og-calendar-dropdown cross buttonInput .value="${value}" @change="${onChange}"></og-calendar-dropdown>`;
77
- }
78
- else if (this.type === 'tm') {
66
+ if (this.type === 'tm') {
79
67
  // TODO: change to time picker when available
80
68
  const onChange = which === 'from' ? this._onFromText : this._onToText;
81
69
  control = html `<og-input .value="${(value ?? '')}" @change="${onChange}"></og-input>`;
82
70
  }
83
71
  else {
84
- const onChange = which === 'from' ? this._onFromNum : this._onToNum;
85
- control = html `<og-numericinput buttons .value="${value}" @change="${onChange}"></og-numericinput>`;
72
+ const onChange = which === 'from' ? this._onFromDate : this._onToDate;
73
+ control = html `<og-calendar-dropdown cross buttonInput .value="${value}" @change="${onChange}"></og-calendar-dropdown>`;
86
74
  }
87
75
  return html `<div class="row"><label>${label}</label>${control}</div>`;
88
76
  }
@@ -120,7 +108,6 @@ RangeFilterPopup.styles = css `
120
108
  }
121
109
 
122
110
  .row > og-calendar-dropdown,
123
- .row > og-numericinput,
124
111
  .row > og-input {
125
112
  flex: 1;
126
113
  min-width: 0;
@@ -1 +1 @@
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,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC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G,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;;AA1HM,uBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkClB,AAlCY,CAkCX;AAGF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACC;AAEX;IAAhB,KAAK,EAAE;+CAAkC;AACzB;IAAhB,KAAK,EAAE;6CAAgC;AA1C5B,gBAAgB;IAD5B,aAAa,CAAC,GAAG,SAAS,CAAC,MAAM,qBAAqB,CAAC;GAC3C,gBAAgB,CA6H5B","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 = 'n' | 'd' | 'dt' | 'tm';\nexport type RangeValue = Date | number | 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-numericinput,\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 = 'n';\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 _onFromNum = (e: Event) => {\n\t\tconst v = (e.target as unknown as { value: number }).value;\n\t\tthis._from = v == null || Number.isNaN(v) ? null : v;\n\t}\n\tprivate _onToNum = (e: Event) => {\n\t\tconst v = (e.target as unknown as { value: number }).value;\n\t\tthis._to = v == null || Number.isNaN(v) ? null : v;\n\t}\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 === 'd' || this.type === 'dt') {\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} else if (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._onFromNum : this._onToNum;\n\t\t\tcontrol = html`<og-numericinput buttons .value=\"${value as number | null}\" @change=\"${onChange}\"></og-numericinput>`;\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"]}
1
+ {"version":3,"file":"range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;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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/grid",
3
- "version": "0.10.64",
3
+ "version": "0.10.66",
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.10.64",
39
- "@omegagrid/core": "^0.10.64",
40
- "@omegagrid/grid-core": "^0.10.64",
41
- "@omegagrid/localize": "^0.10.64",
42
- "@omegagrid/tabs": "^0.10.64",
43
- "@omegagrid/tree": "^0.10.64",
38
+ "@omegagrid/commands": "^0.10.66",
39
+ "@omegagrid/core": "^0.10.66",
40
+ "@omegagrid/grid-core": "^0.10.66",
41
+ "@omegagrid/localize": "^0.10.66",
42
+ "@omegagrid/tabs": "^0.10.66",
43
+ "@omegagrid/tree": "^0.10.66",
44
44
  "@stdlib/stats": "^0.0.13",
45
45
  "date-fns": "^3.2.0",
46
46
  "lit": "^3.1.1",