@operato/dataset 1.0.0-alpha.4 → 1.0.0-alpha.40

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +330 -0
  2. package/demo/index.html +11 -95
  3. package/demo/ox-data-entry-form.html +118 -0
  4. package/demo/ox-data-item-spec.html +152 -0
  5. package/demo/ox-data-ooc-view.html +185 -0
  6. package/demo/ox-data-sample-view.html +150 -0
  7. package/demo/ox-grist-editor-data-item-spec.html +473 -0
  8. package/dist/src/grist-editor/index.d.ts +1 -0
  9. package/dist/src/grist-editor/index.js +7 -0
  10. package/dist/src/grist-editor/index.js.map +1 -0
  11. package/dist/src/grist-editor/ox-grist-editor-data-item-spec.d.ts +11 -0
  12. package/dist/src/grist-editor/ox-grist-editor-data-item-spec.js +77 -0
  13. package/dist/src/grist-editor/ox-grist-editor-data-item-spec.js.map +1 -0
  14. package/dist/src/grist-editor/ox-popup-data-item-spec.d.ts +13 -0
  15. package/dist/src/grist-editor/ox-popup-data-item-spec.js +90 -0
  16. package/dist/src/grist-editor/ox-popup-data-item-spec.js.map +1 -0
  17. package/dist/src/index.d.ts +6 -1
  18. package/dist/src/index.js +6 -1
  19. package/dist/src/index.js.map +1 -1
  20. package/dist/src/ox-data-entry-form.d.ts +1 -24
  21. package/dist/src/ox-data-entry-form.js +58 -17
  22. package/dist/src/ox-data-entry-form.js.map +1 -1
  23. package/dist/src/ox-data-item-spec.d.ts +18 -0
  24. package/dist/src/ox-data-item-spec.js +77 -0
  25. package/dist/src/ox-data-item-spec.js.map +1 -0
  26. package/dist/src/ox-data-ooc-view.d.ts +10 -0
  27. package/dist/src/ox-data-ooc-view.js +69 -0
  28. package/dist/src/ox-data-ooc-view.js.map +1 -0
  29. package/dist/src/ox-data-sample-view copy.d.ts +13 -0
  30. package/dist/src/ox-data-sample-view copy.js +214 -0
  31. package/dist/src/ox-data-sample-view copy.js.map +1 -0
  32. package/dist/src/ox-data-sample-view.d.ts +13 -0
  33. package/dist/src/ox-data-sample-view.js +165 -0
  34. package/dist/src/ox-data-sample-view.js.map +1 -0
  35. package/dist/src/ox-data-use-case.d.ts +16 -0
  36. package/dist/src/ox-data-use-case.js +111 -0
  37. package/dist/src/ox-data-use-case.js.map +1 -0
  38. package/dist/src/types.d.ts +76 -0
  39. package/dist/src/types.js +2 -0
  40. package/dist/src/types.js.map +1 -0
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +19 -11
  43. package/src/grist-editor/index.ts +10 -0
  44. package/src/grist-editor/ox-grist-editor-data-item-spec.ts +92 -0
  45. package/src/grist-editor/ox-popup-data-item-spec.ts +90 -0
  46. package/src/index.ts +6 -1
  47. package/src/ox-data-entry-form.ts +59 -38
  48. package/src/ox-data-item-spec.ts +74 -0
  49. package/src/ox-data-ooc-view.ts +67 -0
  50. package/src/ox-data-sample-view.ts +171 -0
  51. package/src/ox-data-use-case.ts +147 -0
  52. package/src/types.ts +70 -0
  53. package/themes/app-theme.css +142 -0
  54. package/themes/form-theme.css +75 -0
  55. package/themes/grist-theme.css +194 -0
  56. package/themes/oops-theme.css +26 -0
  57. package/themes/report-theme.css +47 -0
  58. package/translations/en.json +1 -0
  59. package/translations/ko.json +1 -0
  60. package/translations/ms.json +1 -0
  61. package/translations/zh.json +1 -0
@@ -0,0 +1,473 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" />
6
+ <style>
7
+ body {
8
+ /* box-sizing: border-box; */
9
+ margin: 0;
10
+ padding: 0;
11
+ overflow: hidden;
12
+
13
+ /* This is a font-stack that tries to use the system-default sans-serifs first */
14
+ font-family: Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
15
+ line-height: 1.5;
16
+ -webkit-font-smoothing: antialiased;
17
+ }
18
+
19
+ #app {
20
+ width: 100vw;
21
+ height: 100vh;
22
+
23
+ display: flex;
24
+ flex-direction: column;
25
+ }
26
+
27
+ #demo {
28
+ flex: 1;
29
+
30
+ display: flex;
31
+ flex-direction: column;
32
+ overflow: hidden;
33
+ }
34
+
35
+ grist-demo {
36
+ flex: 1;
37
+ overflow: auto;
38
+ }
39
+ </style>
40
+ <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
41
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
42
+
43
+ <link href="/themes/app-theme.css" rel="stylesheet" />
44
+ <link href="/themes/oops-theme.css" rel="stylesheet" />
45
+ <link href="/themes/grist-theme.css" rel="stylesheet" />
46
+
47
+ <script>
48
+ // HACK(keanulee): The Redux package assumes `process` exists - mock it here before
49
+ // the module is loaded.
50
+ window.process = {
51
+ env: {
52
+ NODE_ENV: 'production'
53
+ }
54
+ }
55
+
56
+ window.operato = 1 /* to debug popuped grist-editors */
57
+ </script>
58
+ </head>
59
+
60
+ <body>
61
+ <script type="module">
62
+ import { LitElement, html, css, render } from 'lit'
63
+
64
+ import '@operato/property-editor/ox-property-editor-checkbox.js'
65
+ import '@operato/property-editor/ox-property-editor-number.js'
66
+ import '@operato/property-editor/ox-property-editor-string.js'
67
+ import '@operato/property-editor/ox-property-editor-options.js'
68
+
69
+ import '@operato/property-editor/ox-properties-dynamic-view.js'
70
+
71
+ import { OxPropertyEditor } from '@operato/property-editor'
72
+
73
+ OxPropertyEditor.register({
74
+ number: 'ox-property-editor-number',
75
+ string: 'ox-property-editor-string',
76
+ boolean: 'ox-property-editor-checkbox',
77
+ options: 'ox-property-editor-options'
78
+ })
79
+
80
+ import '@operato/data-grist'
81
+ import '@operato/data-grist/ox-filters-form.js'
82
+ import '@operato/data-grist/ox-sorters-control.js'
83
+ import '@material/mwc-icon'
84
+ import { CommonGristStyles } from '@operato/styles'
85
+ import { i18next } from '@operato/i18n'
86
+ import { OxGristEditorParameters } from '@operato/app/grist-editor/ox-grist-editor-parameters.js'
87
+ import { OxGristEditorCrontab } from '@operato/app/grist-editor/ox-grist-editor-crontab.js'
88
+ import { OxGristEditorValueMap } from '@operato/app/grist-editor/ox-grist-editor-value-map.js'
89
+ import { OxGristEditorPartitionKeys } from '@operato/app/grist-editor/ox-grist-editor-partition-keys.js'
90
+
91
+ import { registerEditor } from '@operato/data-grist'
92
+
93
+ registerEditor('parameters', OxGristEditorParameters)
94
+ registerEditor('crontab', OxGristEditorCrontab)
95
+ registerEditor('value-map', OxGristEditorValueMap)
96
+ registerEditor('partition-keys', OxGristEditorPartitionKeys)
97
+
98
+ /* set grist-editors */
99
+ import '../dist/src/grist-editor/index.js'
100
+
101
+ import { OxDataUseCase } from '../dist/src/ox-data-use-case.js'
102
+
103
+ const ccpUseCase = {
104
+ getSpecification: dataItem => {
105
+ return {
106
+ name: 'ccp',
107
+ description: 'ccp specs',
108
+ specs: [
109
+ {
110
+ type: 'number',
111
+ label: 'critical limits',
112
+ name: 'criticalLimits',
113
+ property: dataItem
114
+ },
115
+ {
116
+ type: 'string',
117
+ label: 'target limits',
118
+ name: 'targetLimits',
119
+ property: dataItem
120
+ }
121
+ ]
122
+ }
123
+ }
124
+ }
125
+
126
+ const qcUseCase = {
127
+ getSpecification: dataItem => {
128
+ return {
129
+ name: 'qc',
130
+ description: 'qc specs',
131
+ specs: [
132
+ {
133
+ type: 'number',
134
+ label: 'critical limits',
135
+ name: 'criticalLimits',
136
+ property: dataItem
137
+ },
138
+ {
139
+ type: 'boolean',
140
+ label: 'target limits',
141
+ name: 'targetLimits',
142
+ property: dataItem
143
+ }
144
+ ]
145
+ }
146
+ }
147
+ }
148
+
149
+ OxDataUseCase.registerUseCase('ccp', ccpUseCase)
150
+ OxDataUseCase.registerUseCase('qc', qcUseCase)
151
+
152
+ const fetchHandler = async ({ page, limit, sorters = [] }) => {
153
+ var total = 10
154
+ var start = (page - 1) * limit
155
+
156
+ return {
157
+ total,
158
+ records: Array(limit * page > total ? total % limit : limit)
159
+ .fill()
160
+ .map((item, idx) => {
161
+ return {
162
+ id: idx,
163
+ name: `name-${start + idx + 1}`,
164
+ description: `description-${start + idx + 1}`,
165
+ sequence: idx + 1,
166
+ active: true,
167
+ tag: `tag-${idx + 1}`,
168
+ type: idx % 3 === 0 ? 'select' : idx % 3 === 1 ? 'number' : 'string',
169
+ spec: {
170
+ ccp: {
171
+ criticalLimits: 100,
172
+ targetLimits: 200
173
+ },
174
+ qc: {
175
+ criticalLimits: 300,
176
+ targetLimits: true
177
+ }
178
+ },
179
+ options:
180
+ idx % 2 === 0
181
+ ? {
182
+ options: [
183
+ {
184
+ text: 'A',
185
+ value: 'a'
186
+ },
187
+ {
188
+ text: 'B',
189
+ value: 'b'
190
+ }
191
+ ]
192
+ }
193
+ : undefined,
194
+ schedule: '* * * * * *',
195
+ keyvalue: {},
196
+ createdAt: Date.now(),
197
+ updatedAt: Date.now()
198
+ }
199
+ })
200
+ }
201
+ }
202
+
203
+ class GristDemo extends LitElement {
204
+ static styles = [
205
+ CommonGristStyles,
206
+ css`
207
+ :host {
208
+ display: flex;
209
+ flex-direction: column;
210
+ }
211
+
212
+ #tailer {
213
+ display: flex;
214
+ flex-direction: row;
215
+ margin: 0 var(--margin-default);
216
+ }
217
+
218
+ #tailer a {
219
+ padding: 0 var(--padding-default) 0 var(--padding-default);
220
+ margin: 0 var(--margin-narrow);
221
+ border-right: 1px solid rgba(0, 0, 0, 0.1);
222
+ font-size: var(--fontsize-default);
223
+ color: var(--primary-color);
224
+ }
225
+ `
226
+ ]
227
+
228
+ static get properties() {
229
+ return {
230
+ mode: String
231
+ }
232
+ }
233
+
234
+ get grist() {
235
+ return this.renderRoot.querySelector('ox-grist')
236
+ }
237
+
238
+ config = {
239
+ list: { fields: ['name', 'description', 'active'] },
240
+ columns: [
241
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
242
+ {
243
+ type: 'gutter',
244
+ gutterName: 'button',
245
+ icon: 'add',
246
+ handlers: {
247
+ click: 'record-copy'
248
+ }
249
+ },
250
+ { type: 'gutter', gutterName: 'sequence' },
251
+ {
252
+ type: 'gutter',
253
+ gutterName: 'button',
254
+ icon: 'arrow_upward',
255
+ handlers: {
256
+ click: 'move-up'
257
+ }
258
+ },
259
+ {
260
+ type: 'gutter',
261
+ gutterName: 'button',
262
+ icon: 'arrow_downward',
263
+ handlers: {
264
+ click: 'move-down'
265
+ }
266
+ },
267
+ {
268
+ type: 'number',
269
+ name: 'sequence',
270
+ hidden: true
271
+ },
272
+ {
273
+ type: 'string',
274
+ name: 'id',
275
+ hidden: true
276
+ },
277
+ {
278
+ type: 'string',
279
+ name: 'name',
280
+ header: i18next.t('field.name'),
281
+ record: {
282
+ editable: true
283
+ },
284
+ width: 140
285
+ },
286
+ {
287
+ type: 'string',
288
+ name: 'description',
289
+ header: i18next.t('field.description'),
290
+ record: {
291
+ editable: true
292
+ },
293
+ width: 180
294
+ },
295
+ {
296
+ type: 'checkbox',
297
+ name: 'active',
298
+ label: true,
299
+ header: i18next.t('field.active'),
300
+ record: {
301
+ editable: true
302
+ },
303
+ sortable: true,
304
+ width: 60
305
+ },
306
+ {
307
+ type: 'string',
308
+ name: 'tag',
309
+ header: i18next.t('field.tag'),
310
+ record: {
311
+ editable: true
312
+ },
313
+ width: 180
314
+ },
315
+ {
316
+ type: 'select',
317
+ name: 'type',
318
+ header: i18next.t('field.type'),
319
+ record: {
320
+ options: ['', 'number', 'text', 'select', 'boolean', 'file'],
321
+ editable: true
322
+ },
323
+ width: 120
324
+ },
325
+ {
326
+ type: 'crontab',
327
+ name: 'schedule',
328
+ header: i18next.t('field.schedule'),
329
+ record: {
330
+ editable: true
331
+ },
332
+ width: 120
333
+ },
334
+ {
335
+ type: 'partition-keys',
336
+ name: 'keyvalue',
337
+ header: i18next.t('field.keyvalue'),
338
+ record: {
339
+ editable: true,
340
+ options: {
341
+ objectified: true,
342
+ valuetype: 'string'
343
+ }
344
+ },
345
+ width: 120
346
+ },
347
+ {
348
+ type: 'parameters',
349
+ name: 'options',
350
+ header: i18next.t('field.options'),
351
+ record: {
352
+ editable: true,
353
+ renderer: (value, column, record, rowIndex, field) => {
354
+ return typeof value === 'string' ? value : typeof value === 'object' ? JSON.stringify(value) : ''
355
+ },
356
+ options: async (value, column, record, row, field) => {
357
+ return {
358
+ name: record.type,
359
+ help: '',
360
+ spec:
361
+ record.type === 'select'
362
+ ? [
363
+ {
364
+ type: 'options',
365
+ name: 'options',
366
+ label: 'options'
367
+ }
368
+ ]
369
+ : [],
370
+ context: this.grist,
371
+ objectified: true /* tell parameters editor not to need to parse */
372
+ }
373
+ }
374
+ },
375
+ width: 120
376
+ },
377
+ {
378
+ type: 'string',
379
+ name: 'unit',
380
+ header: i18next.t('field.unit'),
381
+ record: {
382
+ editable: true
383
+ },
384
+ width: 120
385
+ },
386
+ {
387
+ type: 'number',
388
+ name: 'quota',
389
+ header: i18next.t('field.quota'),
390
+ record: {
391
+ editable: true
392
+ },
393
+ width: 60
394
+ },
395
+ {
396
+ type: 'data-item-spec',
397
+ name: 'spec',
398
+ header: i18next.t('field.spec'),
399
+ record: {
400
+ editable: true,
401
+ options: {
402
+ name,
403
+ objectified: true
404
+ }
405
+ },
406
+ width: 200
407
+ }
408
+ ],
409
+ rows: {
410
+ selectable: {
411
+ multiple: true
412
+ }
413
+ },
414
+ pagination: {
415
+ infinite: true
416
+ },
417
+ sorters: [
418
+ {
419
+ name: 'sequence'
420
+ }
421
+ ]
422
+ }
423
+
424
+ render() {
425
+ const mode = this.mode || 'CARD'
426
+
427
+ return html`
428
+ <ox-grist .config=${this.config} .mode=${mode} auto-fetch .fetchHandler=${fetchHandler}>
429
+ <div id="filters" slot="headroom">
430
+ <ox-filters-form @filters-change=${e => console.log('changed', e.detail)}></ox-filters-form>
431
+ </div>
432
+
433
+ <div slot="headroom" id="headroom">
434
+ <div id="sorters">
435
+ Sort
436
+ <mwc-icon
437
+ @click=${e => {
438
+ const target = e.currentTarget
439
+ this.renderRoot.querySelector('#sorter-control').open({
440
+ right: 0,
441
+ top: target.offsetTop + target.offsetHeight
442
+ })
443
+ }}
444
+ >expand_more</mwc-icon
445
+ >
446
+ <ox-popup id="sorter-control">
447
+ <ox-sorters-control> </ox-sorters-control>
448
+ </ox-popup>
449
+ </div>
450
+
451
+ <div id="modes">
452
+ <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>view_list</mwc-icon>
453
+ <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>menu</mwc-icon>
454
+ <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
455
+ </div>
456
+ </div>
457
+ </ox-grist>
458
+ `
459
+ }
460
+ }
461
+
462
+ customElements.define('ox-data-items', GristDemo)
463
+
464
+ setTimeout(() => {
465
+ render(html` <ox-data-items mode="LIST"></ox-data-items> `, document.querySelector('#demo'))
466
+ })
467
+ </script>
468
+
469
+ <div id="app">
470
+ <div id="demo"></div>
471
+ </div>
472
+ </body>
473
+ </html>
@@ -0,0 +1 @@
1
+ export * from './ox-grist-editor-data-item-spec';
@@ -0,0 +1,7 @@
1
+ import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist';
2
+ import { OxGristEditorDataItemSpec } from './ox-grist-editor-data-item-spec';
3
+ /* register grist renderer/editor for id */
4
+ registerEditor('data-item-spec', OxGristEditorDataItemSpec);
5
+ registerRenderer('data-item-spec', OxGristRendererJson5);
6
+ export * from './ox-grist-editor-data-item-spec';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grist-editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAE5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAE5E,2CAA2C;AAC3C,cAAc,CAAC,gBAAgB,EAAE,yBAAyB,CAAC,CAAA;AAE3D,gBAAgB,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;AAExD,cAAc,kCAAkC,CAAA","sourcesContent":["import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist'\n\nimport { OxGristEditorDataItemSpec } from './ox-grist-editor-data-item-spec'\n\n/* register grist renderer/editor for id */\nregisterEditor('data-item-spec', OxGristEditorDataItemSpec)\n\nregisterRenderer('data-item-spec', OxGristRendererJson5)\n\nexport * from './ox-grist-editor-data-item-spec'\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import './ox-popup-data-item-spec.js';
5
+ import { OxGristEditor } from '@operato/data-grist';
6
+ export declare class OxGristEditorDataItemSpec extends OxGristEditor {
7
+ private popup?;
8
+ get editorTemplate(): import("lit-html").TemplateResult<1>;
9
+ firstUpdated(): Promise<void>;
10
+ openSelector(): Promise<void>;
11
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import './ox-popup-data-item-spec.js';
6
+ import { html } from 'lit';
7
+ import { customElement } from 'lit/decorators.js';
8
+ import { cloneDeep } from 'lodash-es';
9
+ import { OxGristEditor } from '@operato/data-grist';
10
+ import { i18next } from '@operato/i18n';
11
+ import { openPopup } from '@operato/layout';
12
+ let OxGristEditorDataItemSpec = class OxGristEditorDataItemSpec extends OxGristEditor {
13
+ get editorTemplate() {
14
+ const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value;
15
+ return html ` ${value || ''} `;
16
+ }
17
+ async firstUpdated() {
18
+ await this.updateComplete;
19
+ this.renderRoot.addEventListener('click', (e) => {
20
+ e.stopPropagation();
21
+ this.openSelector();
22
+ });
23
+ this.openSelector();
24
+ }
25
+ async openSelector() {
26
+ if (this.popup) {
27
+ delete this.popup;
28
+ }
29
+ var { options } = this.column.record;
30
+ if (typeof options === 'function') {
31
+ options = await options.call(this, this.value, this.column, this.record, this.row, this.field);
32
+ }
33
+ const { name, help, objectified = false } = options;
34
+ const confirmCallback = (newval) => {
35
+ this.dispatchEvent(new CustomEvent('field-change', {
36
+ bubbles: true,
37
+ composed: true,
38
+ detail: {
39
+ before: this.value,
40
+ after: !objectified ? JSON.stringify(newval) : newval,
41
+ record: this.record,
42
+ column: this.column,
43
+ row: this.row
44
+ }
45
+ }));
46
+ };
47
+ try {
48
+ var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {});
49
+ }
50
+ catch (e) {
51
+ var value = {};
52
+ }
53
+ /*
54
+ 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
55
+ layout의 구성에 변화가 발생하면, 다시 render된다.
56
+ 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
57
+ 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
58
+ 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
59
+ 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
60
+ */
61
+ var template = html `
62
+ <ox-popup-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>
63
+ </ox-popup-data-item-spec>
64
+ `;
65
+ this.popup = openPopup(template, {
66
+ backdrop: true,
67
+ size: 'large',
68
+ title: `${(name === null || name === void 0 ? void 0 : name.toUpperCase()) || ''} ${i18next.t('field.spec')}`,
69
+ help
70
+ });
71
+ }
72
+ };
73
+ OxGristEditorDataItemSpec = __decorate([
74
+ customElement('ox-grist-editor-data-item-spec')
75
+ ], OxGristEditorDataItemSpec);
76
+ export { OxGristEditorDataItemSpec };
77
+ //# sourceMappingURL=ox-grist-editor-data-item-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-grist-editor-data-item-spec.js","sourceRoot":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E,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,EAAE,KAAI,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE;YAChE,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA5EY,yBAAyB;IADrC,aAAa,CAAC,gCAAgC,CAAC;GACnC,yBAAyB,CA4ErC;SA5EY,yBAAyB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-popup-data-item-spec.js'\n\nimport { html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport { cloneDeep } from 'lodash-es'\n\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup, PopupHandle } from '@operato/layout'\n\n@customElement('ox-grist-editor-data-item-spec')\nexport class OxGristEditorDataItemSpec extends OxGristEditor {\n private popup?: PopupHandle\n\n get editorTemplate() {\n const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value\n return html` ${value || ''} `\n }\n\n async firstUpdated() {\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', (e: Event) => {\n e.stopPropagation()\n\n this.openSelector()\n })\n\n this.openSelector()\n }\n\n async openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n var { options } = this.column.record\n\n if (typeof options === 'function') {\n options = await options.call(this, this.value, this.column, this.record, this.row, this.field)\n }\n\n const { name, help, objectified = false } = options\n\n const confirmCallback = (newval: any) => {\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: !objectified ? JSON.stringify(newval) : newval,\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n try {\n var value: any =\n !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {})\n } catch (e) {\n var value: any = {}\n }\n\n /* \n 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로, \n layout의 구성에 변화가 발생하면, 다시 render된다.\n 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)\n 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,\n 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.\n 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.\n */\n var template = html`\n <ox-popup-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>\n </ox-popup-data-item-spec>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || ''} ${i18next.t('field.spec')}`,\n help\n })\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import '../ox-data-item-spec.js';
2
+ import { LitElement } from 'lit';
3
+ import { DataItem } from '../types.js';
4
+ export declare class OxPopupDataItemSpec extends LitElement {
5
+ static styles: import("lit").CSSResult[];
6
+ value: any;
7
+ dataItem?: DataItem;
8
+ confirmCallback: (newval: any) => void;
9
+ render(): import("lit-html").TemplateResult<1>;
10
+ private onChange;
11
+ private onCancel;
12
+ private onConfirm;
13
+ }