@operato/dataset 1.0.0-alpha.22 → 1.0.0-alpha.25

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 (25) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/demo/index.html +1 -1
  3. package/demo/ox-grist-editor-data-item-spec.html +467 -0
  4. package/dist/src/grist-editor/index.d.ts +1 -1
  5. package/dist/src/grist-editor/index.js +3 -3
  6. package/dist/src/grist-editor/index.js.map +1 -1
  7. package/dist/src/grist-editor/ox-grist-editor-data-item-spec.d.ts +11 -0
  8. package/dist/src/grist-editor/{ox-data-item-spec-editor.js → ox-grist-editor-data-item-spec.js} +15 -36
  9. package/dist/src/grist-editor/ox-grist-editor-data-item-spec.js.map +1 -0
  10. package/dist/src/grist-editor/{ox-data-item-spec-editor-popup.d.ts → ox-popup-data-item-spec.d.ts} +3 -2
  11. package/dist/src/grist-editor/{ox-data-item-spec-editor-popup.js → ox-popup-data-item-spec.js} +13 -17
  12. package/dist/src/grist-editor/ox-popup-data-item-spec.js.map +1 -0
  13. package/dist/src/ox-data-item-spec.d.ts +1 -1
  14. package/dist/src/ox-data-item-spec.js +17 -3
  15. package/dist/src/ox-data-item-spec.js.map +1 -1
  16. package/dist/tsconfig.tsbuildinfo +1 -1
  17. package/package.json +12 -12
  18. package/src/grist-editor/index.ts +3 -3
  19. package/src/grist-editor/{ox-data-item-spec-editor.ts → ox-grist-editor-data-item-spec.ts} +12 -25
  20. package/src/grist-editor/{ox-data-item-spec-editor-popup.ts → ox-popup-data-item-spec.ts} +7 -10
  21. package/src/ox-data-item-spec.ts +19 -4
  22. package/demo/data-item-grist.html +0 -343
  23. package/dist/src/grist-editor/ox-data-item-spec-editor-popup.js.map +0 -1
  24. package/dist/src/grist-editor/ox-data-item-spec-editor.d.ts +0 -18
  25. package/dist/src/grist-editor/ox-data-item-spec-editor.js.map +0 -1
@@ -2,35 +2,21 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import './ox-data-item-spec-editor-popup.js'
5
+ import './ox-popup-data-item-spec.js'
6
6
 
7
- import { ColumnConfig, GristRecord } from '@operato/data-grist'
8
- import { LitElement, css, html } from 'lit'
9
7
  import { PopupHandle, openPopup } from '@operato/layout'
10
- import { customElement, property } from 'lit/decorators.js'
11
8
 
9
+ import { InputEditor } from '@operato/data-grist'
10
+ import { cloneDeep } from 'lodash-es'
11
+ import { customElement } from 'lit/decorators.js'
12
+ import { html } from 'lit'
12
13
  import { i18next } from '@operato/i18n'
13
14
 
14
- @customElement('ox-data-item-spec-editor')
15
- export class OxDataItemSpecEditor extends LitElement {
16
- static styles = css`
17
- :host {
18
- color: black;
19
-
20
- overflow: hidden;
21
- text-overflow: ellipsis;
22
- }
23
- `
24
-
25
- @property({ type: Object }) value: any
26
- @property({ type: Object }) column!: ColumnConfig
27
- @property({ type: Object }) record!: GristRecord
28
- @property({ type: Number }) row!: number
29
- @property({ type: Object }) field!: any
30
-
15
+ @customElement('ox-grist-editor-data-item-spec')
16
+ export class OxGristEditorDataItemSpec extends InputEditor {
31
17
  private popup?: PopupHandle
32
18
 
33
- render() {
19
+ get editorTemplate() {
34
20
  const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value
35
21
  return html` ${value || ''} `
36
22
  }
@@ -77,7 +63,8 @@ export class OxDataItemSpecEditor extends LitElement {
77
63
  }
78
64
 
79
65
  try {
80
- var value: any = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : this.value
66
+ var value: any =
67
+ !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {})
81
68
  } catch (e) {
82
69
  var value: any = {}
83
70
  }
@@ -91,8 +78,8 @@ export class OxDataItemSpecEditor extends LitElement {
91
78
  따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
92
79
  */
93
80
  var template = html`
94
- <ox-data-item-spec-editor-popup .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>
95
- </ox-data-item-spec-editor-popup>
81
+ <ox-popup-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>
82
+ </ox-popup-data-item-spec>
96
83
  `
97
84
 
98
85
  this.popup = openPopup(template, {
@@ -3,11 +3,12 @@ import '../ox-data-item-spec.js'
3
3
  import { LitElement, css, html } from 'lit'
4
4
  import { customElement, property } from 'lit/decorators.js'
5
5
 
6
+ import { DataItem } from '../types.js'
6
7
  import { ScrollbarStyles } from '@operato/styles'
7
8
  import { i18next } from '@operato/i18n'
8
9
 
9
- @customElement('ox-data-item-spec-editor-popup')
10
- export class OxDataItemSpecEditorPopup extends LitElement {
10
+ @customElement('ox-popup-data-item-spec')
11
+ export class OxPopupDataItemSpec extends LitElement {
11
12
  static styles = [
12
13
  ScrollbarStyles,
13
14
  css`
@@ -44,19 +45,15 @@ export class OxDataItemSpecEditorPopup extends LitElement {
44
45
  ]
45
46
 
46
47
  @property({ type: Object }) value: any
47
- @property({ type: Object }) dataItem: any
48
+ @property({ type: Object }) dataItem?: DataItem
48
49
  @property({ type: Object }) confirmCallback!: (newval: any) => void
49
50
 
50
51
  render() {
51
- var dataItem = this.dataItem instanceof Array ? this.dataItem : []
52
+ var dataItem = this.dataItem || {}
52
53
 
53
54
  return html`
54
- ${dataItem.length > 0
55
- ? html`
56
- <ox-data-item-spec .value=${this.value} .dataItem=${dataItem} @change=${this.onChange.bind(this)}>
57
- </ox-data-item-spec>
58
- `
59
- : html` <span><i18n-msg msgid="text.no properties to set"></i18n-msg></span> `}
55
+ <ox-data-item-spec .value=${this.value} .dataItem=${dataItem} @change=${this.onChange.bind(this)}>
56
+ </ox-data-item-spec>
60
57
 
61
58
  <div class="button-container">
62
59
  <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
@@ -1,9 +1,10 @@
1
1
  import '@operato/property-editor/ox-properties-dynamic-view.js'
2
2
 
3
- import { DataItem, DataItemSpecSet, DataItemSpecSetProvider } from './types.js'
4
- import { LitElement, PropertyValues, css, html } from 'lit'
3
+ import { css, html, LitElement, PropertyValues } from 'lit'
5
4
  import { customElement, property, queryAll, state } from 'lit/decorators.js'
6
5
 
6
+ import { DataItem, DataItemSpecSet, DataItemSpecSetProvider } from './types.js'
7
+
7
8
  @customElement('ox-data-item-spec')
8
9
  export class OxDataItemSpec extends LitElement {
9
10
  static registry: { [name: string]: DataItemSpecSetProvider } = {}
@@ -16,6 +17,20 @@ export class OxDataItemSpec extends LitElement {
16
17
  :host {
17
18
  display: flex;
18
19
  flex-direction: row;
20
+ border-bottom: var(--border-dark-color);
21
+ padding: var(--margin-default) 0;
22
+ }
23
+ [specName] {
24
+ font: var(--legend-font);
25
+ color: var(--legend-text-color);
26
+ }
27
+ [description] {
28
+ font: var(--form-sublabel-font);
29
+ opacity: 0.8;
30
+ }
31
+
32
+ form {
33
+ flex: 1;
19
34
  }
20
35
  `
21
36
 
@@ -29,8 +44,8 @@ export class OxDataItemSpec extends LitElement {
29
44
  render() {
30
45
  return html`<form @property-change=${(e: Event) => this.onChange(e)}>
31
46
  ${this.dataItemSpecSets.map(
32
- ({ name, description, specs }) => html` <div>${name}</div>
33
- <div>${description}</div>
47
+ ({ name, description, specs }) => html` <div specName>${name}</div>
48
+ <div description>${description}</div>
34
49
  <ox-properties-dynamic-view data-name=${name} .props=${specs} .value=${this.value?.[name]}>
35
50
  </ox-properties-dynamic-view>`
36
51
  )}
@@ -1,343 +0,0 @@
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
- </script>
56
- </head>
57
-
58
- <body>
59
- <script type="module">
60
- import { LitElement, html, css, render } from 'lit'
61
- import '@operato/data-grist'
62
- import '@operato/data-grist/ox-filters-form.js'
63
- import '@operato/data-grist/ox-sorters-control.js'
64
- import '@material/mwc-icon'
65
- import { CommonGristStyles } from '@operato/styles'
66
- import { i18next } from '@operato/i18n'
67
-
68
- /* set grist-editors */
69
- import '../dist/src/grist-editor/index.js'
70
-
71
- const fetchHandler = async ({ page, limit, sorters = [] }) => {
72
- var total = 10
73
- var start = (page - 1) * limit
74
-
75
- return {
76
- total,
77
- records: Array(limit * page > total ? total % limit : limit)
78
- .fill()
79
- .map((item, idx) => {
80
- return {
81
- id: idx,
82
- name: `name-${start + idx + 1}`,
83
- description: `description-${start + idx + 1}`,
84
- sequence: idx + 1,
85
- active: true,
86
- tag: `tag-${idx + 1}`,
87
- type: idx % 3 === 0 ? 'select' : idx % 3 === 1 ? 'number' : 'string',
88
- createdAt: Date.now(),
89
- updatedAt: Date.now()
90
- }
91
- })
92
- }
93
- }
94
-
95
- var config = {
96
- list: { fields: ['name', 'description', 'active'] },
97
- columns: [
98
- { type: 'gutter', gutterName: 'row-selector', multiple: true },
99
- {
100
- type: 'gutter',
101
- gutterName: 'button',
102
- icon: 'add',
103
- handlers: {
104
- click: 'record-copy'
105
- }
106
- },
107
- { type: 'gutter', gutterName: 'sequence' },
108
- {
109
- type: 'gutter',
110
- gutterName: 'button',
111
- icon: 'arrow_upward',
112
- handlers: {
113
- click: 'move-up'
114
- }
115
- },
116
- {
117
- type: 'gutter',
118
- gutterName: 'button',
119
- icon: 'arrow_downward',
120
- handlers: {
121
- click: 'move-down'
122
- }
123
- },
124
- {
125
- type: 'number',
126
- name: 'sequence',
127
- hidden: true
128
- },
129
- {
130
- type: 'string',
131
- name: 'id',
132
- hidden: true
133
- },
134
- {
135
- type: 'string',
136
- name: 'name',
137
- header: i18next.t('field.name'),
138
- record: {
139
- editable: true
140
- },
141
- width: 140
142
- },
143
- {
144
- type: 'string',
145
- name: 'description',
146
- header: i18next.t('field.description'),
147
- record: {
148
- editable: true
149
- },
150
- width: 180
151
- },
152
- {
153
- type: 'checkbox',
154
- name: 'active',
155
- label: true,
156
- header: i18next.t('field.active'),
157
- record: {
158
- editable: true
159
- },
160
- sortable: true,
161
- width: 60
162
- },
163
- {
164
- type: 'string',
165
- name: 'tag',
166
- header: i18next.t('field.tag'),
167
- record: {
168
- editable: true
169
- },
170
- width: 180
171
- },
172
- {
173
- type: 'select',
174
- name: 'type',
175
- header: i18next.t('field.type'),
176
- record: {
177
- options: ['', 'number', 'text', 'select', 'boolean', 'file'],
178
- editable: true
179
- },
180
- width: 120
181
- },
182
- {
183
- type: 'parameters',
184
- name: 'options',
185
- header: i18next.t('field.options'),
186
- record: {
187
- editable: true,
188
- renderer: (value, column, record, rowIndex, field) => {
189
- return typeof value === 'string' ? value : typeof value === 'object' ? JSON.stringify(value) : ''
190
- },
191
- options: async (value, column, record, row, field) => {
192
- return {
193
- name: record.type,
194
- help: '',
195
- spec:
196
- record.type === 'select'
197
- ? [
198
- {
199
- type: 'options',
200
- name: 'options',
201
- label: 'options'
202
- }
203
- ]
204
- : [],
205
- context: this.grist,
206
- objectified: true
207
- }
208
- }
209
- },
210
- width: 120
211
- },
212
- {
213
- type: 'string',
214
- name: 'unit',
215
- header: i18next.t('field.unit'),
216
- record: {
217
- editable: true
218
- },
219
- width: 120
220
- },
221
- {
222
- type: 'number',
223
- name: 'quota',
224
- header: i18next.t('field.quota'),
225
- record: {
226
- editable: true
227
- },
228
- width: 60
229
- },
230
- {
231
- type: 'data-item-spec',
232
- name: 'spec',
233
- header: i18next.t('field.spec'),
234
- record: {
235
- editable: true,
236
- options: {
237
- name,
238
- objectified: true
239
- }
240
- },
241
- width: 200
242
- }
243
- ],
244
- rows: {
245
- selectable: {
246
- multiple: true
247
- }
248
- },
249
- pagination: {
250
- infinite: true
251
- },
252
- sorters: [
253
- {
254
- name: 'sequence'
255
- }
256
- ]
257
- }
258
-
259
- class GristDemo extends LitElement {
260
- static styles = [
261
- CommonGristStyles,
262
- css`
263
- :host {
264
- display: flex;
265
- flex-direction: column;
266
- }
267
-
268
- #tailer {
269
- display: flex;
270
- flex-direction: row;
271
- margin: 0 var(--margin-default);
272
- }
273
-
274
- #tailer a {
275
- padding: 0 var(--padding-default) 0 var(--padding-default);
276
- margin: 0 var(--margin-narrow);
277
- border-right: 1px solid rgba(0, 0, 0, 0.1);
278
- font-size: var(--fontsize-default);
279
- color: var(--primary-color);
280
- }
281
- `
282
- ]
283
-
284
- static get properties() {
285
- return {
286
- mode: String
287
- }
288
- }
289
-
290
- get grist() {
291
- return this.renderRoot.querySelector('ox-grist')
292
- }
293
-
294
- render() {
295
- const mode = this.mode || 'CARD'
296
-
297
- return html`
298
- <ox-grist .config=${config} .mode=${mode} auto-fetch .fetchHandler=${fetchHandler}>
299
- <div id="filters" slot="headroom">
300
- <ox-filters-form @filters-change=${e => console.log('changed', e.detail)}></ox-filters-form>
301
- </div>
302
-
303
- <div slot="headroom" id="headroom">
304
- <div id="sorters">
305
- Sort
306
- <mwc-icon
307
- @click=${e => {
308
- const target = e.currentTarget
309
- this.renderRoot.querySelector('#sorter-control').open({
310
- right: 0,
311
- top: target.offsetTop + target.offsetHeight
312
- })
313
- }}
314
- >expand_more</mwc-icon
315
- >
316
- <ox-popup id="sorter-control">
317
- <ox-sorters-control> </ox-sorters-control>
318
- </ox-popup>
319
- </div>
320
-
321
- <div id="modes">
322
- <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>view_list</mwc-icon>
323
- <mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>menu</mwc-icon>
324
- <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
325
- </div>
326
- </div>
327
- </ox-grist>
328
- `
329
- }
330
- }
331
-
332
- customElements.define('ox-data-items', GristDemo)
333
-
334
- setTimeout(() => {
335
- render(html` <ox-data-items mode="LIST"></ox-data-items> `, document.querySelector('#demo'))
336
- })
337
- </script>
338
-
339
- <div id="app">
340
- <div id="demo"></div>
341
- </div>
342
- </body>
343
- </html>
@@ -1 +0,0 @@
1
- {"version":3,"file":"ox-data-item-spec-editor-popup.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-data-item-spec-editor-popup.ts"],"names":[],"mappings":";AAAA,OAAO,yBAAyB,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAa,yBAAyB,GAAtC,MAAa,yBAA0B,SAAQ,UAAU;IAwCvD,MAAM;QACJ,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;QAElE,OA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FY,yBAAyB","sourcesContent":["import '../ox-data-item-spec.js'\n\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-data-item-spec-editor-popup')\nexport class OxDataItemSpecEditorPopup extends LitElement {\n static styles = [\n ScrollbarStyles,\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-data-item-spec {\n flex: 1;\n overflow-y: auto;\n }\n\n span {\n flex: 1;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n color: var(--primary-color);\n }\n\n .button-container {\n display: flex;\n margin-left: auto;\n }\n `\n ]\n\n @property({ type: Object }) value: any\n @property({ type: Object }) dataItem: any\n @property({ type: Object }) confirmCallback!: (newval: any) => void\n\n render() {\n var dataItem = this.dataItem instanceof Array ? this.dataItem : []\n\n return html`\n ${dataItem.length > 0\n ? html`\n <ox-data-item-spec .value=${this.value} .dataItem=${dataItem} @change=${this.onChange.bind(this)}>\n </ox-data-item-spec>\n `\n : html` <span><i18n-msg msgid=\"text.no properties to set\"></i18n-msg></span> `}\n\n <div class=\"button-container\">\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 private onChange(e: CustomEvent) {\n e.stopPropagation()\n\n /* \n 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로, \n layout의 구성에 변화가 발생하면, 다시 render된다.\n 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)\n 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,\n 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.\n 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.\n (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)\n => \n 이런 이유로, Object.assign(...)을 사용하였다.\n */\n this.value = e.detail\n }\n\n private onCancel(e: Event) {\n history.back()\n }\n\n private onConfirm(e: Event) {\n this.confirmCallback && this.confirmCallback(this.value)\n history.back()\n }\n}\n"]}
@@ -1,18 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import './ox-data-item-spec-editor-popup.js';
5
- import { ColumnConfig, GristRecord } from '@operato/data-grist';
6
- import { LitElement } from 'lit';
7
- export declare class OxDataItemSpecEditor extends LitElement {
8
- static styles: import("lit").CSSResult;
9
- value: any;
10
- column: ColumnConfig;
11
- record: GristRecord;
12
- row: number;
13
- field: any;
14
- private popup?;
15
- render(): import("lit-html").TemplateResult<1>;
16
- firstUpdated(): Promise<void>;
17
- openSelector(): Promise<void>;
18
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ox-data-item-spec-editor.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-data-item-spec-editor.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,qCAAqC,CAAA;AAG5C,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,UAAU;IAkBlD,MAAM;QACJ,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CA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CAAC;mDAAY;AAd5B,oBAAoB;IADhC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,oBAAoB,CA0FhC;SA1FY,oBAAoB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-data-item-spec-editor-popup.js'\n\nimport { ColumnConfig, GristRecord } from '@operato/data-grist'\nimport { LitElement, css, html } from 'lit'\nimport { PopupHandle, openPopup } from '@operato/layout'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-data-item-spec-editor')\nexport class OxDataItemSpecEditor extends LitElement {\n static styles = css`\n :host {\n color: black;\n\n overflow: hidden;\n text-overflow: ellipsis;\n }\n `\n\n @property({ type: Object }) value: any\n @property({ type: Object }) column!: ColumnConfig\n @property({ type: Object }) record!: GristRecord\n @property({ type: Number }) row!: number\n @property({ type: Object }) field!: any\n\n private popup?: PopupHandle\n\n render() {\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 => {\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 = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : 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-data-item-spec-editor-popup .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>\n </ox-data-item-spec-editor-popup>\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"]}