@omegagrid/grid 0.11.34 → 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.
- package/dist/editors/dateEditor.d.ts +1 -1
- package/dist/editors/dateEditor.d.ts.map +1 -1
- package/dist/editors/dateEditor.js +8 -4
- package/dist/editors/dateEditor.js.map +1 -1
- package/dist/renderers/DateTimeRenderer.d.ts.map +1 -1
- package/dist/renderers/DateTimeRenderer.js +14 -8
- package/dist/renderers/DateTimeRenderer.js.map +1 -1
- package/package.json +7 -7
|
@@ -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;
|
|
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(
|
|
43
|
+
return dates.parseTime(text, getLocale()) ?? text;
|
|
40
44
|
if (this.withTime)
|
|
41
|
-
return dates.parseDateTime(
|
|
42
|
-
const date = dates.parse(
|
|
43
|
-
return date ? dates.dateToSerialDate(date) :
|
|
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,yEA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AAK,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrC,CAAC;IACF,CAAC;IAED,yIAAyI;IACzI,QAAQ;QACP,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;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"]}
|
|
@@ -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;
|
|
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
|
-
|
|
6
|
-
// a
|
|
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
|
-
|
|
13
|
-
|
|
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,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,MAAM,UAAU,gBAAgB,CAAC,GAAmB,EAAE,IAAe,EAAE,OAA6B;IACnG,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAChC,IAAI,CAAC;
|
|
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}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/grid",
|
|
3
|
-
"version": "0.11.
|
|
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.
|
|
39
|
-
"@omegagrid/core": "^0.11.
|
|
40
|
-
"@omegagrid/grid-core": "^0.11.
|
|
41
|
-
"@omegagrid/localize": "^0.11.
|
|
42
|
-
"@omegagrid/tabs": "^0.11.
|
|
43
|
-
"@omegagrid/tree": "^0.11.
|
|
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",
|