@operato/data-grist 8.0.3 → 8.1.0
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@operato/data-grist",
|
3
|
-
"version": "8.0
|
3
|
+
"version": "8.1.0",
|
4
4
|
"description": "User interface for grid (desktop) and list (mobile)",
|
5
5
|
"author": "heartyoh",
|
6
6
|
"main": "dist/index.js",
|
@@ -63,13 +63,13 @@
|
|
63
63
|
"dependencies": {
|
64
64
|
"@material/web": "^2.0.0",
|
65
65
|
"@operato/headroom": "^8.0.0",
|
66
|
-
"@operato/input": "^8.0
|
67
|
-
"@operato/p13n": "^8.0
|
68
|
-
"@operato/popup": "^8.0
|
66
|
+
"@operato/input": "^8.1.0",
|
67
|
+
"@operato/p13n": "^8.1.0",
|
68
|
+
"@operato/popup": "^8.1.0",
|
69
69
|
"@operato/pull-to-refresh": "^8.0.0",
|
70
70
|
"@operato/styles": "^8.0.0",
|
71
71
|
"@operato/time-calculator": "^8.0.0",
|
72
|
-
"@operato/utils": "^8.
|
72
|
+
"@operato/utils": "^8.1.0",
|
73
73
|
"i18next": "^23.11.5",
|
74
74
|
"json5": "^2.2.0",
|
75
75
|
"lit": "^3.1.2",
|
@@ -108,5 +108,5 @@
|
|
108
108
|
"prettier --write"
|
109
109
|
]
|
110
110
|
},
|
111
|
-
"gitHead": "
|
111
|
+
"gitHead": "5f8d40b06fbc80dc848bfa91796933761b90a3f8"
|
112
112
|
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import '@material/web/icon/icon.js';
|
2
|
-
import './record-view';
|
3
|
-
import { LitElement } from 'lit';
|
4
|
-
import { DataGrist } from '../data-grist';
|
5
|
-
export declare class RecordCreator extends LitElement {
|
6
|
-
grist?: DataGrist;
|
7
|
-
callback?: (operation: {
|
8
|
-
[key: string]: any;
|
9
|
-
}) => boolean;
|
10
|
-
lightPopup: boolean;
|
11
|
-
preventCloseOnBlur: boolean;
|
12
|
-
constructor();
|
13
|
-
connectedCallback(): void;
|
14
|
-
render(): import("lit-html").TemplateResult<1>;
|
15
|
-
lightPopupRecordView(): void;
|
16
|
-
popupRecordView(): void;
|
17
|
-
}
|
@@ -1,148 +0,0 @@
|
|
1
|
-
import { __decorate } from "tslib";
|
2
|
-
import '@material/web/icon/icon.js';
|
3
|
-
import './record-view';
|
4
|
-
import { html, LitElement } from 'lit';
|
5
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
6
|
-
import { OxPopup } from '@operato/popup';
|
7
|
-
let RecordCreator = class RecordCreator extends LitElement {
|
8
|
-
constructor() {
|
9
|
-
super();
|
10
|
-
this.lightPopup = false;
|
11
|
-
this.preventCloseOnBlur = false;
|
12
|
-
this.addEventListener('click', (e) => {
|
13
|
-
e.preventDefault();
|
14
|
-
e.stopPropagation();
|
15
|
-
if (this.lightPopup) {
|
16
|
-
this.lightPopupRecordView();
|
17
|
-
}
|
18
|
-
else {
|
19
|
-
this.popupRecordView();
|
20
|
-
}
|
21
|
-
});
|
22
|
-
}
|
23
|
-
connectedCallback() {
|
24
|
-
super.connectedCallback();
|
25
|
-
this.grist = this.closest('ox-grist');
|
26
|
-
}
|
27
|
-
render() {
|
28
|
-
return html `<slot></slot>`;
|
29
|
-
}
|
30
|
-
lightPopupRecordView() {
|
31
|
-
const config = this.grist.compiledConfig;
|
32
|
-
var title = 'create';
|
33
|
-
const rowIndex = -1;
|
34
|
-
var record = {};
|
35
|
-
const columns = config.columns;
|
36
|
-
var popup = OxPopup.open({
|
37
|
-
template: html `
|
38
|
-
<div title>${title}</div>
|
39
|
-
<ox-record-view
|
40
|
-
@field-change=${(e) => {
|
41
|
-
const view = e.currentTarget;
|
42
|
-
var { after, before, column, record, row } = e.detail;
|
43
|
-
var validation = column.validation;
|
44
|
-
if (validation && typeof validation == 'function') {
|
45
|
-
if (!validation.call(this, after, before, record, column)) {
|
46
|
-
return;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
view.record = {
|
50
|
-
...record,
|
51
|
-
[column.name]: after
|
52
|
-
};
|
53
|
-
}}
|
54
|
-
.columns=${columns}
|
55
|
-
.record=${record}
|
56
|
-
.rowIndex=${rowIndex}
|
57
|
-
@reset=${(e) => {
|
58
|
-
const view = e.currentTarget;
|
59
|
-
view.record = {};
|
60
|
-
}}
|
61
|
-
@cancel=${(e) => {
|
62
|
-
popup.close();
|
63
|
-
}}
|
64
|
-
@ok=${(e) => {
|
65
|
-
popup.close();
|
66
|
-
const view = e.currentTarget;
|
67
|
-
this.dispatchEvent(new CustomEvent('ok', {
|
68
|
-
bubbles: true,
|
69
|
-
composed: true,
|
70
|
-
detail: view.record
|
71
|
-
}));
|
72
|
-
}}
|
73
|
-
></ox-record-view>
|
74
|
-
`,
|
75
|
-
parent: document.body,
|
76
|
-
preventCloseOnBlur: this.preventCloseOnBlur
|
77
|
-
});
|
78
|
-
}
|
79
|
-
popupRecordView() {
|
80
|
-
const config = this.grist.compiledConfig;
|
81
|
-
const rowIndex = -1;
|
82
|
-
var record = {};
|
83
|
-
const columns = config.columns;
|
84
|
-
var title = 'create';
|
85
|
-
var recordView = document.createElement('ox-record-view');
|
86
|
-
recordView.columns = columns;
|
87
|
-
recordView.record = record;
|
88
|
-
recordView.rowIndex = rowIndex;
|
89
|
-
document.dispatchEvent(new CustomEvent('open-popup', {
|
90
|
-
detail: {
|
91
|
-
template: recordView,
|
92
|
-
options: {
|
93
|
-
backdrop: true,
|
94
|
-
size: 'large',
|
95
|
-
title
|
96
|
-
},
|
97
|
-
callback: (popup) => {
|
98
|
-
recordView.addEventListener('reset', (e) => {
|
99
|
-
const view = e.currentTarget;
|
100
|
-
view.record = {};
|
101
|
-
});
|
102
|
-
recordView.addEventListener('cancel', (e) => {
|
103
|
-
popup.close();
|
104
|
-
});
|
105
|
-
recordView.addEventListener('ok', async (e) => {
|
106
|
-
var _a;
|
107
|
-
const view = e.currentTarget;
|
108
|
-
if (await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.call(this, view.record))) {
|
109
|
-
popup.close();
|
110
|
-
}
|
111
|
-
});
|
112
|
-
recordView.addEventListener('field-change', async (e) => {
|
113
|
-
const view = e.currentTarget;
|
114
|
-
var { after, before, column, record, row } = e.detail;
|
115
|
-
var validation = column.validation;
|
116
|
-
if (validation && typeof validation == 'function') {
|
117
|
-
if (!(await validation.call(this, after, before, record, column))) {
|
118
|
-
return;
|
119
|
-
}
|
120
|
-
}
|
121
|
-
view.record = {
|
122
|
-
...record,
|
123
|
-
[column.name]: after
|
124
|
-
};
|
125
|
-
});
|
126
|
-
popup.onclosed = () => { };
|
127
|
-
}
|
128
|
-
}
|
129
|
-
}));
|
130
|
-
}
|
131
|
-
};
|
132
|
-
__decorate([
|
133
|
-
state()
|
134
|
-
], RecordCreator.prototype, "grist", void 0);
|
135
|
-
__decorate([
|
136
|
-
property({ type: Object })
|
137
|
-
], RecordCreator.prototype, "callback", void 0);
|
138
|
-
__decorate([
|
139
|
-
property({ type: Boolean, attribute: 'light-popup' })
|
140
|
-
], RecordCreator.prototype, "lightPopup", void 0);
|
141
|
-
__decorate([
|
142
|
-
property({ type: Boolean, attribute: 'prevent-close-on-blur' })
|
143
|
-
], RecordCreator.prototype, "preventCloseOnBlur", void 0);
|
144
|
-
RecordCreator = __decorate([
|
145
|
-
customElement('ox-record-creator')
|
146
|
-
], RecordCreator);
|
147
|
-
export { RecordCreator };
|
148
|
-
//# sourceMappingURL=record-creator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"record-creator.js","sourceRoot":"","sources":["../../../src/record-view/record-creator.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,eAAe,CAAA;AAEtB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,O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AM,IAAI,GAAG,CAAC,CAAC,aAA2B,CAAA;wBAE1C,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAI,CAAiB,CAAC,MAM/D,CAAA;wBAED,IAAI,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;wBAClC,IAAI,UAAU,IAAI,OAAO,UAAU,IAAI,UAAU,EAAE,CAAC;4BAClD,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;gCAClE,OAAM;4BACR,CAAC;wBACH,CAAC;wBAED,IAAI,CAAC,MAAM,GAAG;4BACZ,GAAG,MAAM;4BACT,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK;yBACrB,CAAA;oBACH,CAAC,CAAC,CAAA;oBAEF,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;gBAC3B,CAAC;aACF;SACF,CAAC,CACH,CAAA;IACH,CAAC;CACF,CAAA;AArKU;IAAR,KAAK,EAAE;4CAAkB;AAEE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAA0D;AAC9B;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;iDAA4B;AACjB;IAAhE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;yDAA2B;AALhF,aAAa;IADzB,aAAa,CAAC,mBAAmB,CAAC;GACtB,aAAa,CAsKzB","sourcesContent":["import '@material/web/icon/icon.js'\nimport './record-view'\n\nimport { html, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { OxPopup } from '@operato/popup'\n\nimport { DataGrist } from '../data-grist'\nimport { ColumnConfig, GristRecord } from '../types'\nimport { RecordView } from './record-view'\n\n@customElement('ox-record-creator')\nexport class RecordCreator extends LitElement {\n @state() grist?: DataGrist\n\n @property({ type: Object }) callback?: (operation: { [key: string]: any }) => boolean\n @property({ type: Boolean, attribute: 'light-popup' }) lightPopup: boolean = false\n @property({ type: Boolean, attribute: 'prevent-close-on-blur' }) preventCloseOnBlur = false\n\n constructor() {\n super()\n\n this.addEventListener('click', (e: Event) => {\n e.preventDefault()\n e.stopPropagation()\n\n if (this.lightPopup) {\n this.lightPopupRecordView()\n } else {\n this.popupRecordView()\n }\n })\n }\n\n connectedCallback(): void {\n super.connectedCallback()\n\n this.grist = this.closest('ox-grist') as DataGrist\n }\n\n render() {\n return html`<slot></slot>`\n }\n\n lightPopupRecordView() {\n const config = this.grist!.compiledConfig\n var title = 'create'\n const rowIndex = -1\n var record: GristRecord = {}\n const columns = config.columns\n\n var popup = OxPopup.open({\n template: html`\n <div title>${title}</div>\n <ox-record-view\n @field-change=${(e: CustomEvent) => {\n const view = e.currentTarget as RecordView\n\n var { after, before, column, record, row } = (e as CustomEvent).detail as {\n after: any\n before: any\n column: ColumnConfig\n record: GristRecord\n row: number\n }\n\n var validation = column.validation\n if (validation && typeof validation == 'function') {\n if (!validation.call(this, after, before, record, column)) {\n return\n }\n }\n\n view.record = {\n ...record,\n [column.name]: after\n }\n }}\n .columns=${columns}\n .record=${record}\n .rowIndex=${rowIndex}\n @reset=${(e: Event) => {\n const view = e.currentTarget as RecordView\n view.record = {}\n }}\n @cancel=${(e: Event) => {\n popup.close()\n }}\n @ok=${(e: Event) => {\n popup.close()\n\n const view = e.currentTarget as RecordView\n\n this.dispatchEvent(\n new CustomEvent('ok', {\n bubbles: true,\n composed: true,\n detail: view.record\n })\n )\n }}\n ></ox-record-view>\n `,\n parent: document.body,\n preventCloseOnBlur: this.preventCloseOnBlur\n })\n }\n\n popupRecordView() {\n const config = this.grist!.compiledConfig\n const rowIndex = -1\n var record: GristRecord = {}\n const columns = config.columns\n\n var title = 'create'\n\n var recordView = document.createElement('ox-record-view') as RecordView\n\n recordView.columns = columns\n recordView.record = record\n recordView.rowIndex = rowIndex\n\n document.dispatchEvent(\n new CustomEvent('open-popup', {\n detail: {\n template: recordView,\n options: {\n backdrop: true,\n size: 'large',\n title\n },\n callback: (popup: any) => {\n recordView.addEventListener('reset', (e: Event) => {\n const view = e.currentTarget as RecordView\n view.record = {}\n })\n\n recordView.addEventListener('cancel', (e: Event) => {\n popup.close()\n })\n\n recordView.addEventListener('ok', async (e: Event) => {\n const view = e.currentTarget as RecordView\n if (await this.callback?.(view.record)) {\n popup.close()\n }\n })\n\n recordView.addEventListener('field-change', async (e: Event) => {\n const view = e.currentTarget as RecordView\n\n var { after, before, column, record, row } = (e as CustomEvent).detail as {\n after: any\n before: any\n column: ColumnConfig\n record: GristRecord\n row: number\n }\n\n var validation = column.validation\n if (validation && typeof validation == 'function') {\n if (!(await validation.call(this, after, before, record, column))) {\n return\n }\n }\n\n view.record = {\n ...record,\n [column.name]: after\n }\n })\n\n popup.onclosed = () => {}\n }\n }\n })\n )\n }\n}\n"]}
|