@operato/app 1.0.2 → 1.0.8

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
@@ -3,7 +3,7 @@
3
3
  "description": "WebApplication production supporting components following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "heartyoh",
6
- "version": "1.0.2",
6
+ "version": "1.0.8",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
9
9
  "exports": {
@@ -28,6 +28,67 @@
28
28
  "./grist-editor/ox-grist-editor-resource-code.js": "./dist/src/grist-editor/ox-grist-editor-resource-code.js",
29
29
  "./filter-renderer.js": "./dist/src/filter-renderer/index.js"
30
30
  },
31
+ "typesVersions": {
32
+ "*": {
33
+ "input.js": [
34
+ "dist/src/input/index.d.ts"
35
+ ],
36
+ "input/ox-input-graphql.js": [
37
+ "dist/src/input/ox-input-graphql.d.ts"
38
+ ],
39
+ "input/ox-input-background-pattern.js": [
40
+ "dist/src/input/ox-input-background-pattern.d.ts"
41
+ ],
42
+ "input/ox-input-fill-style.js": [
43
+ "dist/src/input/ox-input-fill-style.d.ts"
44
+ ],
45
+ "property-editor.js": [
46
+ "dist/src/property-editor/index.d.ts"
47
+ ],
48
+ "property-editor/ox-property-editor-graphql.js": [
49
+ "dist/src/property-editor/ox-property-editor-graphql.d.ts"
50
+ ],
51
+ "grist-editor.js": [
52
+ "dist/src/grist-editor/index.d.ts"
53
+ ],
54
+ "grist-editor/ox-grist-editor-resource-id.js": [
55
+ "dist/src/grist-editor/ox-grist-editor-resource-id.d.ts"
56
+ ],
57
+ "grist-editor/ox-selector-resource-id.js": [
58
+ "dist/src/grist-editor/ox-selector-resource-id.d.ts"
59
+ ],
60
+ "grist-editor/ox-grist-renderer-resource-id.js": [
61
+ "dist/src/grist-editor/ox-grist-renderer-resource-id.d.ts"
62
+ ],
63
+ "grist-editor/ox-selector-resource-object.js": [
64
+ "dist/src/grist-editor/ox-selector-resource-object.d.ts"
65
+ ],
66
+ "grist-editor/ox-grist-renderer-resource-object.js": [
67
+ "dist/src/grist-editor/ox-grist-renderer-resource-object.d.ts"
68
+ ],
69
+ "grist-editor/ox-grist-renderer-crontab.js": [
70
+ "dist/src/grist-editor/ox-grist-renderer-crontab.d.ts"
71
+ ],
72
+ "grist-editor/ox-grist-editor-json.js": [
73
+ "dist/src/grist-editor/ox-grist-editor-json.d.ts"
74
+ ],
75
+ "grist-editor/ox-grist-editor-code.js": [
76
+ "dist/src/grist-editor/ox-grist-editor-code.d.ts"
77
+ ],
78
+ "grist-editor/ox-grist-editor-resource-object.js": [
79
+ "dist/src/grist-editor/ox-grist-editor-resource-object.d.ts"
80
+ ],
81
+ "grist-editor/ox-grist-editor-resource-object-legacy.js": [
82
+ "dist/src/grist-editor/ox-grist-editor-resource-object-legacy.d.ts"
83
+ ],
84
+ "grist-editor/ox-grist-editor-resource-code.js": [
85
+ "dist/src/grist-editor/ox-grist-editor-resource-code.d.ts"
86
+ ],
87
+ "filter-renderer.js": [
88
+ "dist/src/filter-renderer/index.d.ts"
89
+ ]
90
+ }
91
+ },
31
92
  "publishConfig": {
32
93
  "access": "public",
33
94
  "@operato:registry": "https://registry.npmjs.org"
@@ -54,18 +115,18 @@
54
115
  "@material/mwc-button": "^0.26.1",
55
116
  "@material/mwc-icon": "^0.26.1",
56
117
  "@material/mwc-icon-button": "^0.26.1",
57
- "@operato/attachment": "^1.0.1",
58
- "@operato/data-grist": "^1.0.1",
59
- "@operato/font": "^1.0.1",
60
- "@operato/form": "^1.0.1",
61
- "@operato/graphql": "^1.0.0",
62
- "@operato/i18n": "^1.0.0",
63
- "@operato/input": "^1.0.1",
64
- "@operato/layout": "^1.0.1",
65
- "@operato/property-editor": "^1.0.1",
66
- "@operato/shell": "^1.0.1",
67
- "@operato/styles": "^1.0.0",
68
- "@operato/utils": "^1.0.1",
118
+ "@operato/attachment": "^1.0.8",
119
+ "@operato/data-grist": "^1.0.8",
120
+ "@operato/font": "^1.0.8",
121
+ "@operato/form": "^1.0.6",
122
+ "@operato/graphql": "^1.0.6",
123
+ "@operato/i18n": "^1.0.6",
124
+ "@operato/input": "^1.0.6",
125
+ "@operato/layout": "^1.0.7",
126
+ "@operato/property-editor": "^1.0.8",
127
+ "@operato/shell": "^1.0.7",
128
+ "@operato/styles": "^1.0.6",
129
+ "@operato/utils": "^1.0.6",
69
130
  "codemirror": "^5.64.0",
70
131
  "codemirror-graphql": "^1.3.2",
71
132
  "cronstrue": "^2.2.0",
@@ -102,9 +163,9 @@
102
163
  },
103
164
  "lint-staged": {
104
165
  "*.ts": [
105
- "eslint --fix",
166
+ "eslint --fid.t",
106
167
  "prettier --write"
107
168
  ]
108
169
  },
109
- "gitHead": "dcd7b17f0019192e7c052bcf524acc2902e16367"
170
+ "gitHead": "21e1f15f77957ad9121075758fc5be9513baa945"
110
171
  }
@@ -1,36 +0,0 @@
1
- import '@operato/data-grist';
2
- import '@operato/form/ox-search-form.js';
3
- import { LitElement } from 'lit';
4
- import { DataGrist, FetchHandler, GristData, GristRecord } from '@operato/data-grist';
5
- export declare class OxSelectorResourceObjectAdv extends LitElement {
6
- static styles: import("lit").CSSResult[];
7
- value?: string;
8
- config: any;
9
- data: GristData;
10
- queryName: string;
11
- basicArgs: any;
12
- confirmCallback?: (record?: GristRecord | null) => void;
13
- selectedRecords: GristRecord[];
14
- searchFields: any;
15
- select: {
16
- type: string;
17
- name: string;
18
- header: string;
19
- subFields?: string[];
20
- hidden: boolean;
21
- ignoreCondition: boolean;
22
- queryName: string;
23
- width: number;
24
- }[];
25
- list: any;
26
- valueField: string | ((item: any) => any);
27
- grist: DataGrist;
28
- render(): import("lit-html").TemplateResult<1>;
29
- onempty(): void;
30
- oncancel(): void;
31
- onconfirm(): void;
32
- fetchHandler: FetchHandler;
33
- firstUpdated(): Promise<void>;
34
- getSelectFields(): string;
35
- get selected(): GristRecord | undefined;
36
- }
@@ -1,270 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import '@operato/data-grist';
3
- import '@operato/form/ox-search-form.js';
4
- import gql from 'graphql-tag';
5
- import { css, html, LitElement } from 'lit';
6
- import { customElement, property, query } from 'lit/decorators.js';
7
- import { ZERO_DATA } from '@operato/data-grist';
8
- import { MultiColumnFormStyles } from '@operato/form';
9
- import { client, gqlContext } from '@operato/graphql';
10
- import { i18next } from '@operato/i18n';
11
- import { closePopup } from '@operato/popup';
12
- import { adjustFilters, isMobileDevice } from '@operato/utils';
13
- let OxSelectorResourceObjectAdv = class OxSelectorResourceObjectAdv extends LitElement {
14
- constructor() {
15
- super(...arguments);
16
- this.data = ZERO_DATA;
17
- this.selectedRecords = [];
18
- this.select = [];
19
- this.valueField = 'id';
20
- this.fetchHandler = async ({ filters = [], page, limit, sortings = [] }) => {
21
- if (this.basicArgs) {
22
- filters = adjustFilters(filters, this.basicArgs);
23
- }
24
- const pagination = { page, limit };
25
- const response = await client.query({
26
- query: gql `
27
- query($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
28
- fetch: ${this.queryName} (filters: $filters, pagination: $pagination, sortings: $sortings) {
29
- ${this.getSelectFields()}
30
- }
31
- }
32
- `,
33
- variables: { filters, pagination, sortings },
34
- context: gqlContext()
35
- });
36
- if (!response.errors) {
37
- const records = response.data.fetch.items.map((item) => {
38
- let rowValue;
39
- if (this.valueField && typeof this.valueField === 'function') {
40
- rowValue = this.valueField(item);
41
- }
42
- else if (this.valueField) {
43
- rowValue = item[this.valueField];
44
- }
45
- else {
46
- rowValue = item.id;
47
- }
48
- if (this.value && this.value === rowValue) {
49
- this.selectedRecords = [item];
50
- item['__selected__'] = true;
51
- }
52
- return item;
53
- });
54
- const total = response.data.fetch.total;
55
- return {
56
- records,
57
- total,
58
- limit,
59
- page
60
- };
61
- }
62
- };
63
- }
64
- render() {
65
- return html `
66
- <ox-grist
67
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
68
- .config=${this.config}
69
- .data=${this.data}
70
- .fetchHandler=${this.fetchHandler.bind(this)}
71
- .selectedRecords=${this.selectedRecords}
72
- >
73
- <div id="filters" slot="headroom">
74
- <ox-filters-form autofocus></ox-filters-form>
75
- </div>
76
- </ox-grist>
77
-
78
- <div class="button-container">
79
- <mwc-button @click=${this.onempty.bind(this)}>${i18next.t('button.empty')}</mwc-button>
80
- <mwc-button @click=${this.oncancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
81
- <mwc-button @click=${this.onconfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
82
- </div>
83
- `;
84
- }
85
- onempty() {
86
- this.confirmCallback && this.confirmCallback();
87
- closePopup(this);
88
- }
89
- oncancel() {
90
- closePopup(this);
91
- }
92
- onconfirm() {
93
- this.confirmCallback && this.confirmCallback(this.selected);
94
- closePopup(this);
95
- }
96
- async firstUpdated() {
97
- this.config = {
98
- columns: [
99
- {
100
- type: 'gutter',
101
- gutterName: 'sequence'
102
- },
103
- {
104
- type: 'gutter',
105
- gutterName: 'row-selector',
106
- multiple: false
107
- }
108
- ],
109
- rows: {
110
- selectable: {
111
- multiple: false
112
- },
113
- handlers: {
114
- click: 'select-row',
115
- dblclick: ((columns, data, column, record, rowIndex, field) => {
116
- this.onconfirm();
117
- })
118
- },
119
- appendable: false
120
- }
121
- };
122
- const select = this.select || [
123
- {
124
- type: 'string',
125
- name: 'id',
126
- header: i18next.t('field.id'),
127
- hidden: true
128
- },
129
- {
130
- type: 'string',
131
- name: 'name',
132
- header: i18next.t('field.name'),
133
- record: {
134
- align: 'left'
135
- },
136
- sortable: true,
137
- filter: 'search',
138
- width: 160
139
- },
140
- {
141
- type: 'string',
142
- name: 'description',
143
- header: i18next.t('field.description'),
144
- record: {
145
- align: 'left'
146
- },
147
- sortable: true,
148
- filter: 'search',
149
- width: 300
150
- }
151
- ];
152
- this.config = {
153
- ...this.config,
154
- columns: [
155
- ...this.config.columns,
156
- ...select.map(selectField => {
157
- return {
158
- ...selectField,
159
- type: selectField.type || 'string',
160
- width: selectField.width || 160,
161
- header: selectField.header || i18next.t(`field.${selectField.name}`)
162
- };
163
- })
164
- ]
165
- };
166
- }
167
- getSelectFields() {
168
- if (this.select && this.select.length > 0) {
169
- return `items {
170
- ${this.select.map(selectField => {
171
- return selectField.type === 'object'
172
- ? `${selectField.name} { ${selectField.subFields && selectField.subFields.length > 0
173
- ? selectField.subFields.join(' ')
174
- : `id name description`} }`
175
- : `${selectField.name}`;
176
- })}
177
- }
178
- total`;
179
- }
180
- else {
181
- return `
182
- items {
183
- id
184
- name
185
- description
186
- }
187
- total
188
- `;
189
- }
190
- }
191
- get selected() {
192
- var grist = this.renderRoot.querySelector('ox-grist');
193
- var selected = grist.selected;
194
- return selected && selected.length > 0 ? selected[0] : undefined;
195
- }
196
- };
197
- OxSelectorResourceObjectAdv.styles = [
198
- MultiColumnFormStyles,
199
- css `
200
- :host {
201
- display: flex;
202
- flex-direction: column;
203
-
204
- background-color: #fff;
205
-
206
- width: var(--overlay-center-normal-width, 50%);
207
- height: var(--overlay-center-normal-height, 50%);
208
- }
209
-
210
- ox-grist {
211
- flex: 1;
212
- }
213
-
214
- #filters {
215
- display: flex;
216
- flex-direction: row;
217
- justify-content: space-between;
218
- }
219
-
220
- #filters > * {
221
- padding: var(--padding-default) var(--padding-wide);
222
- }
223
-
224
- .button-container {
225
- display: flex;
226
- margin-left: auto;
227
- }
228
- `
229
- ];
230
- __decorate([
231
- property({ type: String })
232
- ], OxSelectorResourceObjectAdv.prototype, "value", void 0);
233
- __decorate([
234
- property({ type: Object })
235
- ], OxSelectorResourceObjectAdv.prototype, "config", void 0);
236
- __decorate([
237
- property({ type: Object })
238
- ], OxSelectorResourceObjectAdv.prototype, "data", void 0);
239
- __decorate([
240
- property({ type: String })
241
- ], OxSelectorResourceObjectAdv.prototype, "queryName", void 0);
242
- __decorate([
243
- property({ type: Object })
244
- ], OxSelectorResourceObjectAdv.prototype, "basicArgs", void 0);
245
- __decorate([
246
- property({ type: Object })
247
- ], OxSelectorResourceObjectAdv.prototype, "confirmCallback", void 0);
248
- __decorate([
249
- property({ type: Array })
250
- ], OxSelectorResourceObjectAdv.prototype, "selectedRecords", void 0);
251
- __decorate([
252
- property({ type: Array })
253
- ], OxSelectorResourceObjectAdv.prototype, "searchFields", void 0);
254
- __decorate([
255
- property({ type: Array })
256
- ], OxSelectorResourceObjectAdv.prototype, "select", void 0);
257
- __decorate([
258
- property({ type: Object })
259
- ], OxSelectorResourceObjectAdv.prototype, "list", void 0);
260
- __decorate([
261
- property({ type: String })
262
- ], OxSelectorResourceObjectAdv.prototype, "valueField", void 0);
263
- __decorate([
264
- query('ox-grist')
265
- ], OxSelectorResourceObjectAdv.prototype, "grist", void 0);
266
- OxSelectorResourceObjectAdv = __decorate([
267
- customElement('ox-selector-resource-object-adv')
268
- ], OxSelectorResourceObjectAdv);
269
- export { OxSelectorResourceObjectAdv };
270
- //# sourceMappingURL=ox-selector-resource-object-adv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ox-selector-resource-object-adv.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-selector-resource-object-adv.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,iCAAiC,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAsE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACnH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAG9D,IA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@operato/data-grist'\nimport '@operato/form/ox-search-form.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { DataGrist, FetchHandler, GristData, GristEventHandler, GristRecord, ZERO_DATA } from '@operato/data-grist'\nimport { MultiColumnFormStyles } from '@operato/form'\nimport { client, gqlContext } from '@operato/graphql'\nimport { i18next } from '@operato/i18n'\nimport { closePopup } from '@operato/popup'\nimport { adjustFilters, isMobileDevice } from '@operato/utils'\n\n@customElement('ox-selector-resource-object-adv')\nexport class OxSelectorResourceObjectAdv extends LitElement {\n static styles = [\n MultiColumnFormStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n\n width: var(--overlay-center-normal-width, 50%);\n height: var(--overlay-center-normal-height, 50%);\n }\n\n ox-grist {\n flex: 1;\n }\n\n #filters {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n }\n\n #filters > * {\n padding: var(--padding-default) var(--padding-wide);\n }\n\n .button-container {\n display: flex;\n margin-left: auto;\n }\n `\n ]\n\n @property({ type: String }) value?: string\n @property({ type: Object }) config: any\n @property({ type: Object }) data: GristData = ZERO_DATA\n @property({ type: String }) queryName!: string\n @property({ type: Object }) basicArgs: any\n @property({ type: Object }) confirmCallback?: (record?: GristRecord | null) => void\n @property({ type: Array }) selectedRecords: GristRecord[] = []\n\n @property({ type: Array }) searchFields: any\n @property({ type: Array }) select: {\n type: string\n name: string\n header: string\n subFields?: string[]\n hidden: boolean\n ignoreCondition: boolean\n queryName: string\n width: number\n }[] = []\n @property({ type: Object }) list: any\n @property({ type: String }) valueField: string | ((item: any) => any) = 'id'\n\n @query('ox-grist') grist!: DataGrist\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.config}\n .data=${this.data}\n .fetchHandler=${this.fetchHandler.bind(this)}\n .selectedRecords=${this.selectedRecords}\n >\n <div id=\"filters\" slot=\"headroom\">\n <ox-filters-form autofocus></ox-filters-form>\n </div>\n </ox-grist>\n\n <div class=\"button-container\">\n <mwc-button @click=${this.onempty.bind(this)}>${i18next.t('button.empty')}</mwc-button>\n <mwc-button @click=${this.oncancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>\n <mwc-button @click=${this.onconfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>\n </div>\n `\n }\n\n onempty() {\n this.confirmCallback && this.confirmCallback()\n closePopup(this)\n }\n\n oncancel() {\n closePopup(this)\n }\n\n onconfirm() {\n this.confirmCallback && this.confirmCallback(this.selected)\n closePopup(this)\n }\n\n fetchHandler: FetchHandler = async ({ filters = [], page, limit, sortings = [] }) => {\n if (this.basicArgs) {\n filters = adjustFilters(filters, this.basicArgs)\n }\n const pagination = { page, limit }\n\n const response = await client.query({\n query: gql`\n query($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n fetch: ${this.queryName} (filters: $filters, pagination: $pagination, sortings: $sortings) {\n ${this.getSelectFields()}\n }\n }\n `,\n variables: { filters, pagination, sortings },\n context: gqlContext()\n })\n\n if (!response.errors) {\n const records = response.data.fetch.items.map((item: any) => {\n let rowValue\n\n if (this.valueField && typeof this.valueField === 'function') {\n rowValue = this.valueField(item)\n } else if (this.valueField) {\n rowValue = item[this.valueField]\n } else {\n rowValue = item.id\n }\n\n if (this.value && this.value === rowValue) {\n this.selectedRecords = [item]\n item['__selected__'] = true\n }\n\n return item\n })\n const total = response.data.fetch.total\n\n return {\n records,\n total,\n limit,\n page\n }\n }\n }\n\n async firstUpdated() {\n this.config = {\n columns: [\n {\n type: 'gutter',\n gutterName: 'sequence'\n },\n {\n type: 'gutter',\n gutterName: 'row-selector',\n multiple: false\n }\n ],\n rows: {\n selectable: {\n multiple: false\n },\n handlers: {\n click: 'select-row',\n dblclick: ((columns, data, column, record, rowIndex, field) => {\n this.onconfirm()\n }) as GristEventHandler\n },\n appendable: false\n }\n }\n\n const select = this.select || [\n {\n type: 'string',\n name: 'id',\n header: i18next.t('field.id'),\n hidden: true\n },\n {\n type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: {\n align: 'left'\n },\n sortable: true,\n filter: 'search',\n width: 160\n },\n {\n type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: {\n align: 'left'\n },\n sortable: true,\n filter: 'search',\n width: 300\n }\n ]\n\n this.config = {\n ...this.config,\n columns: [\n ...this.config.columns,\n ...select.map(selectField => {\n return {\n ...selectField,\n type: selectField.type || 'string',\n width: selectField.width || 160,\n header: selectField.header || i18next.t(`field.${selectField.name}`)\n }\n })\n ]\n }\n }\n\n getSelectFields() {\n if (this.select && this.select.length > 0) {\n return `items {\n ${this.select.map(selectField => {\n return selectField.type === 'object'\n ? `${selectField.name} { ${\n selectField.subFields && selectField.subFields.length > 0\n ? selectField.subFields.join(' ')\n : `id name description`\n } }`\n : `${selectField.name}`\n })}\n }\n total`\n } else {\n return `\n items {\n id\n name\n description\n }\n total\n `\n }\n }\n\n get selected() {\n var grist = this.renderRoot.querySelector('ox-grist') as DataGrist\n\n var selected = grist.selected\n\n return selected && selected.length > 0 ? selected[0] : undefined\n }\n}\n"]}