@operato/app 1.0.0-alpha.3 → 1.0.0-alpha.6
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/CHANGELOG.md +30 -0
- package/demo/data-grist-test.html +456 -0
- package/dist/src/grist/index.js +2 -0
- package/dist/src/grist/index.js.map +1 -1
- package/dist/src/grist/parameters-editor-builder.d.ts +4 -0
- package/dist/src/grist/parameters-editor-builder.js +119 -0
- package/dist/src/grist/parameters-editor-builder.js.map +1 -0
- package/dist/src/grist/parameters-editor-popup.d.ts +13 -0
- package/dist/src/grist/parameters-editor-popup.js +111 -0
- package/dist/src/grist/parameters-editor-popup.js.map +1 -0
- package/dist/src/grist/parameters-editor.d.ts +19 -0
- package/dist/src/grist/parameters-editor.js +105 -0
- package/dist/src/grist/parameters-editor.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -10
- package/src/grist/index.ts +2 -0
- package/src/grist/parameters-editor-builder.ts +130 -0
- package/src/grist/parameters-editor-popup.ts +106 -0
- package/src/grist/parameters-editor.ts +112 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.0-alpha.6](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2022-03-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @operato/app
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.0.0-alpha.5](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2022-03-11)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### :rocket: New Features
|
|
18
|
+
|
|
19
|
+
* start migration grist editors from things-factory ([8b31c7f](https://github.com/hatiolab/operato/commit/8b31c7f00ae9b32e68f6860c559a768c3d456704))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### :bug: Bug Fix
|
|
23
|
+
|
|
24
|
+
* migrate parameter-editor from things-factory ([019a30d](https://github.com/hatiolab/operato/commit/019a30df6fd4c8a273d4194d13f5784ed6f8d956))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [1.0.0-alpha.4](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2022-03-11)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @operato/app
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
## [1.0.0-alpha.3](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2022-03-10)
|
|
7
37
|
|
|
8
38
|
**Note:** Version bump only for package @operato/app
|
|
@@ -0,0 +1,456 @@
|
|
|
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
|
+
</head>
|
|
47
|
+
|
|
48
|
+
<body>
|
|
49
|
+
<script type="module">
|
|
50
|
+
import { LitElement, html, css, render } from 'lit'
|
|
51
|
+
import '../dist/index.js'
|
|
52
|
+
import '../dist/src/filters/filters-form.js'
|
|
53
|
+
import '../dist/src/sorters/sorters-control.js'
|
|
54
|
+
import '../dist/src/record-view/record-creator.js'
|
|
55
|
+
import '@operato/popup/ox-popup-list.js'
|
|
56
|
+
import '@material/mwc-icon'
|
|
57
|
+
import { CommonGristStyles } from '@operato/styles'
|
|
58
|
+
|
|
59
|
+
const fetchHandler = async ({ page, limit, sorters = [] }) => {
|
|
60
|
+
var total = 120993
|
|
61
|
+
var start = (page - 1) * limit
|
|
62
|
+
|
|
63
|
+
await new Promise(resolve => setTimeout(resolve, 500))
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
total,
|
|
67
|
+
records: Array(limit * page > total ? total % limit : limit)
|
|
68
|
+
.fill()
|
|
69
|
+
.map((item, idx) => {
|
|
70
|
+
return {
|
|
71
|
+
id: idx,
|
|
72
|
+
name: idx % 2 ? `shnam-${start + idx + 1}` : `heartyoh-${start + idx + 1}`,
|
|
73
|
+
description:
|
|
74
|
+
idx % 2 ? `hatiolabmanager${start + idx + 1}1234567890` : `hatiosea manager-${start + idx + 1}`,
|
|
75
|
+
email: idx % 2 ? `shnam-${start + idx + 1}@gmail.com` : `heartyoh-${start + idx + 1}@gmail.com`,
|
|
76
|
+
active: Math.round(Math.random() * 2) % 2 ? true : false,
|
|
77
|
+
barcode: idx % 2 ? `1234567890${start + idx + 1}` : `0987654321${start + idx + 1}`,
|
|
78
|
+
company:
|
|
79
|
+
idx % 2
|
|
80
|
+
? {
|
|
81
|
+
id: '2',
|
|
82
|
+
name: 'HatioLAB',
|
|
83
|
+
description: `경기도 성남시-${start + idx + 1}`
|
|
84
|
+
}
|
|
85
|
+
: {
|
|
86
|
+
id: '3',
|
|
87
|
+
name: 'HatioSEA',
|
|
88
|
+
description: `말레이시아 세티아알람-${start + idx + 1}`
|
|
89
|
+
},
|
|
90
|
+
thumbnail:
|
|
91
|
+
idx % 4 === 0
|
|
92
|
+
? '' /* no source */
|
|
93
|
+
: idx % 4 === 1
|
|
94
|
+
? `http://www.hatiolab.com/assets/img/operato-biz3.png`
|
|
95
|
+
: idx % 4 === 2
|
|
96
|
+
? `http://www.hatiolab.com/assets/img/thingsboard-30.png`
|
|
97
|
+
: `http://www.hatiolab.com/wrong-url.png` /* wrong source */,
|
|
98
|
+
role: ['admin', 'worker', 'tester'][idx % 3],
|
|
99
|
+
color: idx % 2 ? `#87f018` : `#180f87`,
|
|
100
|
+
rate: Math.round(Math.random() * 100),
|
|
101
|
+
dynamicType: ['text', 'email', 'checkbox', 'color', 'progress', 'barcode'][idx % 5],
|
|
102
|
+
dynamicValue: ['abcdefghijkl', 'heartyoh@hatiolab.com', 'true', 'orange', '50', '1234567890'][idx % 5],
|
|
103
|
+
homepage:
|
|
104
|
+
idx % 2
|
|
105
|
+
? `http://hatiolab.com/${start + idx + 1}`
|
|
106
|
+
: `http://deadpool.hatiolab.com/${start + idx + 1}`,
|
|
107
|
+
json5: {
|
|
108
|
+
abc: 'abc',
|
|
109
|
+
value: 123
|
|
110
|
+
},
|
|
111
|
+
createdAt: Date.now(),
|
|
112
|
+
updatedAt: Date.now()
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const config = {
|
|
119
|
+
list: {
|
|
120
|
+
thumbnail: 'thumbnail',
|
|
121
|
+
fields: ['name', 'description'],
|
|
122
|
+
details: ['role', 'email']
|
|
123
|
+
},
|
|
124
|
+
columns: [
|
|
125
|
+
{
|
|
126
|
+
type: 'gutter',
|
|
127
|
+
gutterName: 'dirty'
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: 'gutter',
|
|
131
|
+
gutterName: 'sequence'
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: 'gutter',
|
|
135
|
+
gutterName: 'row-selector',
|
|
136
|
+
multiple: true
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: 'gutter',
|
|
140
|
+
gutterName: 'button',
|
|
141
|
+
icon: 'edit',
|
|
142
|
+
handlers: {
|
|
143
|
+
click: function () {
|
|
144
|
+
console.log('clicked')
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: 'gutter',
|
|
150
|
+
gutterName: 'button',
|
|
151
|
+
icon: 'add',
|
|
152
|
+
handlers: {
|
|
153
|
+
click: 'record-copy'
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'gutter',
|
|
158
|
+
gutterName: 'button',
|
|
159
|
+
icon: 'arrow_downward',
|
|
160
|
+
handlers: {
|
|
161
|
+
click: 'move-down'
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: 'string',
|
|
166
|
+
name: 'id',
|
|
167
|
+
hidden: true
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type: 'link',
|
|
171
|
+
name: 'name',
|
|
172
|
+
label: true,
|
|
173
|
+
header: 'name',
|
|
174
|
+
record: {
|
|
175
|
+
editable: true,
|
|
176
|
+
options: {
|
|
177
|
+
// href: 'http://hatiolab.com',
|
|
178
|
+
href: function (column, record, rowIndex) {
|
|
179
|
+
return record['homepage']
|
|
180
|
+
},
|
|
181
|
+
target: '_blank'
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
filter: 'search',
|
|
185
|
+
sortable: true,
|
|
186
|
+
width: 120
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
type: 'string',
|
|
190
|
+
name: 'description',
|
|
191
|
+
header: 'description',
|
|
192
|
+
filter: 'search',
|
|
193
|
+
record: {
|
|
194
|
+
editable: true,
|
|
195
|
+
align: 'left'
|
|
196
|
+
},
|
|
197
|
+
width: 200,
|
|
198
|
+
handlers: {
|
|
199
|
+
click: (columns, data, column, record, rowIndex, target) => {
|
|
200
|
+
alert(`${column.name} ${record[column.name]}, row : ${rowIndex}`)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
type: 'email',
|
|
206
|
+
name: 'email',
|
|
207
|
+
label: true,
|
|
208
|
+
header: 'email',
|
|
209
|
+
record: {
|
|
210
|
+
editable: true
|
|
211
|
+
},
|
|
212
|
+
filter: 'search',
|
|
213
|
+
sortable: true,
|
|
214
|
+
width: 130,
|
|
215
|
+
validation: function (after, before, record, column) {
|
|
216
|
+
if (after.indexOf('@') == -1) {
|
|
217
|
+
document.dispatchEvent(
|
|
218
|
+
new CustomEvent('notify', {
|
|
219
|
+
detail: {
|
|
220
|
+
type: 'error',
|
|
221
|
+
message: `invalid value - ${after}`
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
)
|
|
225
|
+
return false
|
|
226
|
+
}
|
|
227
|
+
return true
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
type: 'boolean',
|
|
232
|
+
name: 'active',
|
|
233
|
+
header: 'active',
|
|
234
|
+
record: {
|
|
235
|
+
editable: true
|
|
236
|
+
},
|
|
237
|
+
filter: true,
|
|
238
|
+
handlers: {
|
|
239
|
+
dblclick: () => {
|
|
240
|
+
const grist = document.querySelector('ox-grist')
|
|
241
|
+
console.log(grist.dirtyRecords)
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
sortable: true,
|
|
245
|
+
width: 60
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
type: 'select',
|
|
249
|
+
name: 'role',
|
|
250
|
+
label: true,
|
|
251
|
+
header: 'role',
|
|
252
|
+
record: {
|
|
253
|
+
options: ['', 'admin', 'worker', 'tester'],
|
|
254
|
+
editable: true
|
|
255
|
+
},
|
|
256
|
+
filter: true,
|
|
257
|
+
sortable: true,
|
|
258
|
+
width: 120
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
type: 'color',
|
|
262
|
+
name: 'color',
|
|
263
|
+
header: 'color',
|
|
264
|
+
record: {
|
|
265
|
+
editable: true
|
|
266
|
+
},
|
|
267
|
+
sortable: true,
|
|
268
|
+
width: 50
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
type: 'float',
|
|
272
|
+
name: 'rate',
|
|
273
|
+
header: 'rate',
|
|
274
|
+
record: {
|
|
275
|
+
align: 'right',
|
|
276
|
+
editable: true
|
|
277
|
+
},
|
|
278
|
+
filter: 'between',
|
|
279
|
+
sortable: true,
|
|
280
|
+
width: 50
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
type: 'json5',
|
|
284
|
+
name: 'json5',
|
|
285
|
+
header: 'JSON5',
|
|
286
|
+
width: 200
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: 'image',
|
|
290
|
+
name: 'thumbnail',
|
|
291
|
+
header: 'thumbnail',
|
|
292
|
+
record: {
|
|
293
|
+
editable: true
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
type: 'datetime',
|
|
298
|
+
name: 'updatedAt',
|
|
299
|
+
header: 'updated at',
|
|
300
|
+
record: {
|
|
301
|
+
editable: true
|
|
302
|
+
},
|
|
303
|
+
filter: 'between',
|
|
304
|
+
sortable: true,
|
|
305
|
+
width: 180
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
type: 'datetime',
|
|
309
|
+
name: 'createdAt',
|
|
310
|
+
header: 'created at',
|
|
311
|
+
record: {
|
|
312
|
+
editable: false
|
|
313
|
+
},
|
|
314
|
+
sortable: true,
|
|
315
|
+
width: 180
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
rows: {
|
|
319
|
+
selectable: {
|
|
320
|
+
multiple: true
|
|
321
|
+
},
|
|
322
|
+
handlers: {
|
|
323
|
+
click: 'select-row-toggle'
|
|
324
|
+
},
|
|
325
|
+
classifier: function (record, rowIndex) {
|
|
326
|
+
const rate = record['rate']
|
|
327
|
+
const emphasized =
|
|
328
|
+
rate < 10 ? ['black', 'white'] : rate < 25 ? ['yellow', 'blue'] : rate < 40 ? ['cyan', 'red'] : undefined
|
|
329
|
+
return {
|
|
330
|
+
emphasized
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
sorters: [
|
|
335
|
+
{
|
|
336
|
+
name: 'name',
|
|
337
|
+
desc: true
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: 'email'
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
pagination: {
|
|
344
|
+
pages: [20, 30, 50, 100, 200]
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
class GristDemo extends LitElement {
|
|
349
|
+
static styles = [
|
|
350
|
+
CommonGristStyles,
|
|
351
|
+
css`
|
|
352
|
+
:host {
|
|
353
|
+
display: flex;
|
|
354
|
+
flex-direction: column;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#tailer {
|
|
358
|
+
display: flex;
|
|
359
|
+
flex-direction: row;
|
|
360
|
+
margin: 0 var(--margin-default);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
#tailer a {
|
|
364
|
+
padding: 0 var(--padding-default) 0 var(--padding-default);
|
|
365
|
+
margin: 0 var(--margin-narrow);
|
|
366
|
+
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
|
367
|
+
font-size: var(--fontsize-default);
|
|
368
|
+
color: var(--primary-color);
|
|
369
|
+
}
|
|
370
|
+
`
|
|
371
|
+
]
|
|
372
|
+
|
|
373
|
+
static get properties() {
|
|
374
|
+
return {
|
|
375
|
+
mode: String
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
get grist() {
|
|
380
|
+
return this.renderRoot.querySelector('ox-grist')
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
render() {
|
|
384
|
+
const mode = this.mode || 'CARD'
|
|
385
|
+
|
|
386
|
+
return html`
|
|
387
|
+
<ox-grist .config=${config} .mode=${mode} auto-fetch .fetchHandler=${fetchHandler}>
|
|
388
|
+
<div id="filters" slot="headroom">
|
|
389
|
+
<ox-filters-form @filters-change=${e => console.log('changed', e.detail)}></ox-filters-form>
|
|
390
|
+
</div>
|
|
391
|
+
|
|
392
|
+
<div slot="headroom" id="headroom">
|
|
393
|
+
<div id="tailer">
|
|
394
|
+
<a href="./report-test.html">Report Test</a>
|
|
395
|
+
<a
|
|
396
|
+
href="#"
|
|
397
|
+
@click=${() => {
|
|
398
|
+
this.renderRoot.querySelector('ox-grist').reset()
|
|
399
|
+
}}
|
|
400
|
+
>Reset</a
|
|
401
|
+
>
|
|
402
|
+
<a
|
|
403
|
+
href="#"
|
|
404
|
+
@click=${() => {
|
|
405
|
+
this.renderRoot.querySelector('ox-grist').fetch(true)
|
|
406
|
+
}}
|
|
407
|
+
>Fetch</a
|
|
408
|
+
>
|
|
409
|
+
</div>
|
|
410
|
+
|
|
411
|
+
<div id="sorters">
|
|
412
|
+
Sort
|
|
413
|
+
<mwc-icon
|
|
414
|
+
@click=${e => {
|
|
415
|
+
const target = e.currentTarget
|
|
416
|
+
this.renderRoot.querySelector('#sorter-control').open({
|
|
417
|
+
right: 0,
|
|
418
|
+
top: target.offsetTop + target.offsetHeight
|
|
419
|
+
})
|
|
420
|
+
}}
|
|
421
|
+
>expand_more</mwc-icon
|
|
422
|
+
>
|
|
423
|
+
<ox-popup id="sorter-control">
|
|
424
|
+
<ox-sorters-control> </ox-sorters-control>
|
|
425
|
+
</ox-popup>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
<div id="modes">
|
|
429
|
+
<mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>view_list</mwc-icon>
|
|
430
|
+
<mwc-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>menu</mwc-icon>
|
|
431
|
+
<mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
|
|
432
|
+
</div>
|
|
433
|
+
|
|
434
|
+
<ox-record-creator id="add" light-popup>
|
|
435
|
+
<button><mwc-icon>add</mwc-icon></button>
|
|
436
|
+
</ox-record-creator>
|
|
437
|
+
|
|
438
|
+
<button @click=${e => this.grist.cloneSelectedRecords()}><mwc-icon>add</mwc-icon></button>
|
|
439
|
+
</div>
|
|
440
|
+
</ox-grist>
|
|
441
|
+
`
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
customElements.define('grist-demo', GristDemo)
|
|
446
|
+
|
|
447
|
+
setTimeout(() => {
|
|
448
|
+
render(html` <grist-demo mode="LIST"></grist-demo> `, document.querySelector('#demo'))
|
|
449
|
+
})
|
|
450
|
+
</script>
|
|
451
|
+
|
|
452
|
+
<div id="app">
|
|
453
|
+
<div id="demo"></div>
|
|
454
|
+
</div>
|
|
455
|
+
</body>
|
|
456
|
+
</html>
|
package/dist/src/grist/index.js
CHANGED
|
@@ -2,8 +2,10 @@ import { registerEditor, registerRenderer } from '@operato/data-grist';
|
|
|
2
2
|
import { CodeEditor } from './code-editor';
|
|
3
3
|
import { IdInput } from './id-input.js';
|
|
4
4
|
import { IdRenderer } from './id-renderer.js';
|
|
5
|
+
import { ObjectEditor } from './object-editor';
|
|
5
6
|
/* register grist renderer/editor for id */
|
|
6
7
|
registerEditor('id', IdInput);
|
|
8
|
+
registerEditor('object', ObjectEditor);
|
|
7
9
|
registerEditor('code', CodeEditor);
|
|
8
10
|
registerRenderer('id', IdRenderer);
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grist/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grist/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,2CAA2C;AAC3C,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AAC7B,cAAc,CAAC,QAAQ,EAAE,YAAmB,CAAC,CAAA;AAC7C,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAElC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA","sourcesContent":["import { registerEditor, registerRenderer } from '@operato/data-grist'\n\nimport { CodeEditor } from './code-editor'\nimport { IdInput } from './id-input.js'\nimport { IdRenderer } from './id-renderer.js'\nimport { ObjectEditor } from './object-editor'\n\n/* register grist renderer/editor for id */\nregisterEditor('id', IdInput)\nregisterEditor('object', ObjectEditor as any)\nregisterEditor('code', CodeEditor)\n\nregisterRenderer('id', IdRenderer)\n"]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import '@things-factory/modeller-ui';
|
|
6
|
+
import { LitElement, html } from 'lit';
|
|
7
|
+
import { OxPropertyEditor } from '@operato/property-editor';
|
|
8
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
9
|
+
import { connect } from 'pwa-helpers/connect-mixin';
|
|
10
|
+
import { store } from '@operato/shell';
|
|
11
|
+
/**
|
|
12
|
+
모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
<ox-parameters-editor-builder value="{{value}}">
|
|
17
|
+
<label>Center X</label>
|
|
18
|
+
<input type="number" .value="${value.cx}">
|
|
19
|
+
<label>Width</label>
|
|
20
|
+
<input type="number" .value="${value.width}">
|
|
21
|
+
</ox-parameters-editor-builder>
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_VALUE = {
|
|
24
|
+
legend: '',
|
|
25
|
+
number: 0,
|
|
26
|
+
angle: 0,
|
|
27
|
+
string: '',
|
|
28
|
+
text: '',
|
|
29
|
+
textarea: '',
|
|
30
|
+
checkbox: false,
|
|
31
|
+
select: '',
|
|
32
|
+
color: '#000000',
|
|
33
|
+
'solidcolor-stops': null,
|
|
34
|
+
'gradientcolor-stops': null,
|
|
35
|
+
'gltf-selector': '',
|
|
36
|
+
'image-selector': '',
|
|
37
|
+
multiplecolor: null,
|
|
38
|
+
editortable: null,
|
|
39
|
+
imageselector: '',
|
|
40
|
+
options: null,
|
|
41
|
+
date: null
|
|
42
|
+
};
|
|
43
|
+
let ParametersEditorBuilder = class ParametersEditorBuilder extends connect(store)(LitElement) {
|
|
44
|
+
render() {
|
|
45
|
+
return html `<slot></slot>`;
|
|
46
|
+
}
|
|
47
|
+
firstUpdated() {
|
|
48
|
+
this.addEventListener('change', this._onValueChanged.bind(this));
|
|
49
|
+
}
|
|
50
|
+
updated(changes) {
|
|
51
|
+
changes.has('props') && this._onPropsChanged(this.props);
|
|
52
|
+
changes.has('value') && this._setValues();
|
|
53
|
+
}
|
|
54
|
+
_onPropsChanged(props) {
|
|
55
|
+
this.textContent = '';
|
|
56
|
+
(props || []).forEach(prop => {
|
|
57
|
+
let elementType = OxPropertyEditor.getEditor(prop.type);
|
|
58
|
+
if (!elementType) {
|
|
59
|
+
console.warn('Property Editor not defined', prop.type);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let element = document.createElement(elementType);
|
|
63
|
+
element.label = prop.label;
|
|
64
|
+
element.type = prop.type;
|
|
65
|
+
element.placeholder = prop.placeholder;
|
|
66
|
+
element.host = this.host;
|
|
67
|
+
// element.context = this.context
|
|
68
|
+
element.setAttribute('name', prop.name);
|
|
69
|
+
if (prop.observe) {
|
|
70
|
+
element.observe = prop.observe;
|
|
71
|
+
}
|
|
72
|
+
element.property = prop.property;
|
|
73
|
+
element.setAttribute('property-editor', '');
|
|
74
|
+
this.appendChild(element);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
_setValues() {
|
|
78
|
+
var value = this.value || {};
|
|
79
|
+
Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
|
|
80
|
+
const editor = propertyEditor;
|
|
81
|
+
let name = editor.getAttribute('name');
|
|
82
|
+
editor.value = value[name] === undefined ? DEFAULT_VALUE[editor.type] : value[name];
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
_getValues() {
|
|
86
|
+
var value = {};
|
|
87
|
+
Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
|
|
88
|
+
const editor = propertyEditor;
|
|
89
|
+
let name = editor.getAttribute('name');
|
|
90
|
+
value[name] = editor.value === undefined ? DEFAULT_VALUE[editor.type] : editor.value;
|
|
91
|
+
});
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
_onValueChanged(e) {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
var prop = e.target;
|
|
97
|
+
if (!prop || !prop.hasAttribute('property-editor')) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.dispatchEvent(new CustomEvent('property-change', {
|
|
101
|
+
bubbles: true,
|
|
102
|
+
composed: true,
|
|
103
|
+
detail: this._getValues()
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
__decorate([
|
|
108
|
+
property({ type: Object })
|
|
109
|
+
], ParametersEditorBuilder.prototype, "value", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
property({ type: Array })
|
|
112
|
+
], ParametersEditorBuilder.prototype, "props", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
property({ type: Object })
|
|
115
|
+
], ParametersEditorBuilder.prototype, "host", void 0);
|
|
116
|
+
ParametersEditorBuilder = __decorate([
|
|
117
|
+
customElement('ox-parameters-editor-builder')
|
|
118
|
+
], ParametersEditorBuilder);
|
|
119
|
+
//# sourceMappingURL=parameters-editor-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters-editor-builder.js","sourceRoot":"","sources":["../../../src/grist/parameters-editor-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,6BAA6B,CAAA;AAEpC,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,MAAM,KAAK,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,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C;GACxC,uBAAuB,CAiF5B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@things-factory/modeller-ui'\n\nimport { LitElement, PropertyValues, html } from 'lit'\nimport { OxPropertyEditor, PropertySpec } from '@operato/property-editor'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport { store } from '@operato/shell'\n\n/**\n모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.\n\nExample:\n\n <ox-parameters-editor-builder value=\"{{value}}\">\n <label>Center X</label>\n <input type=\"number\" .value=\"${value.cx}\">\n <label>Width</label>\n <input type=\"number\" .value=\"${value.width}\">\n </ox-parameters-editor-builder>\n*/\n\nconst DEFAULT_VALUE = {\n legend: '',\n number: 0,\n angle: 0,\n string: '',\n text: '',\n textarea: '',\n checkbox: false,\n select: '',\n color: '#000000',\n 'solidcolor-stops': null,\n 'gradientcolor-stops': null,\n 'gltf-selector': '',\n 'image-selector': '',\n multiplecolor: null,\n editortable: null,\n imageselector: '',\n options: null,\n date: null\n} as any\n\n@customElement('ox-parameters-editor-builder')\nclass ParametersEditorBuilder extends connect(store)(LitElement) {\n @property({ type: Object }) value: any\n @property({ type: Array }) props?: PropertySpec[]\n @property({ type: Object }) host: any\n\n render() {\n return html`<slot></slot>`\n }\n\n firstUpdated() {\n this.addEventListener('change', this._onValueChanged.bind(this))\n }\n\n updated(changes: PropertyValues<this>) {\n changes.has('props') && this._onPropsChanged(this.props)\n changes.has('value') && this._setValues()\n }\n\n _onPropsChanged(props: PropertySpec[] | undefined) {\n this.textContent = ''\n ;(props || []).forEach(prop => {\n let elementType = OxPropertyEditor.getEditor(prop.type)\n if (!elementType) {\n console.warn('Property Editor not defined', prop.type)\n return\n }\n let element = document.createElement(elementType) as OxPropertyEditor\n\n element.label = prop.label\n element.type = prop.type\n element.placeholder = prop.placeholder\n element.host = this.host\n // element.context = this.context\n element.setAttribute('name', prop.name)\n\n if (prop.observe) {\n element.observe = prop.observe\n }\n element.property = prop.property\n element.setAttribute('property-editor', '')\n\n this.appendChild(element)\n })\n }\n\n _setValues() {\n var value = this.value || {}\n Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {\n const editor = propertyEditor as OxPropertyEditor\n let name = editor.getAttribute('name')\n editor.value = value[name!] === undefined ? DEFAULT_VALUE[editor.type] : value[name!]\n })\n }\n\n _getValues() {\n var value = {} as any\n Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {\n const editor = propertyEditor as OxPropertyEditor\n let name = editor.getAttribute('name')\n value[name!] = editor.value === undefined ? DEFAULT_VALUE[editor.type] : editor.value\n })\n\n return value\n }\n\n _onValueChanged(e: Event) {\n e.stopPropagation()\n var prop = e.target as HTMLElement\n\n if (!prop || !prop.hasAttribute('property-editor')) {\n return\n }\n\n this.dispatchEvent(\n new CustomEvent('property-change', {\n bubbles: true,\n composed: true,\n detail: this._getValues()\n })\n )\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class ParametersEditorPopup extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult[];
|
|
4
|
+
value: any;
|
|
5
|
+
props: any;
|
|
6
|
+
host: any;
|
|
7
|
+
context: any;
|
|
8
|
+
confirmCallback: (newval: any) => void;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
private onChange;
|
|
11
|
+
private onCancel;
|
|
12
|
+
private onConfirm;
|
|
13
|
+
}
|