@operato/scene-grist 7.3.11 → 7.3.19
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/grist-action.d.ts +2 -2
- package/dist/grist-action.js.map +1 -1
- package/dist/grist.js +17 -2
- package/dist/grist.js.map +1 -1
- package/package.json +2 -2
- package/translations/en.json +6 -5
- package/translations/ja.json +10 -9
- package/translations/ko.json +2 -1
- package/translations/ms.json +14 -13
- package/translations/zh.json +10 -9
- package/CHANGELOG.md +0 -867
- package/schema.graphql +0 -4452
- package/src/grist-action.ts +0 -417
- package/src/grist.ts +0 -354
- package/src/index.ts +0 -4
- package/src/templates/grist-action.ts +0 -20
- package/src/templates/grist.ts +0 -98
- package/src/templates/index.ts +0 -4
- package/tsconfig.json +0 -23
- package/tsconfig.tsbuildinfo +0 -1
package/src/grist.ts
DELETED
@@ -1,354 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
import 'ses'
|
6
|
-
import '@operato/data-grist/ox-grist.js'
|
7
|
-
import '@operato/data-grist/ox-filters-form.js'
|
8
|
-
|
9
|
-
import { Component, ComponentNature, error, HTMLOverlayElement, Properties } from '@hatiolab/things-scene'
|
10
|
-
import { DataGrist, FetchResult } from '@operato/data-grist'
|
11
|
-
import { i18next as _i18next } from '@operato/i18n'
|
12
|
-
import { FetchOption } from '@operato/data-grist/dist/src/types'
|
13
|
-
|
14
|
-
const NATURE: ComponentNature = {
|
15
|
-
mutable: false,
|
16
|
-
resizable: true,
|
17
|
-
rotatable: true,
|
18
|
-
properties: [
|
19
|
-
{
|
20
|
-
type: 'select',
|
21
|
-
label: 'grist-mode',
|
22
|
-
name: 'mode',
|
23
|
-
property: {
|
24
|
-
options: [
|
25
|
-
{
|
26
|
-
display: 'Grid',
|
27
|
-
value: 'GRID'
|
28
|
-
},
|
29
|
-
{
|
30
|
-
display: 'List',
|
31
|
-
value: 'LIST'
|
32
|
-
},
|
33
|
-
{
|
34
|
-
display: 'Card',
|
35
|
-
value: 'CARD'
|
36
|
-
},
|
37
|
-
{
|
38
|
-
display: 'Depends on device',
|
39
|
-
value: 'DEVICE'
|
40
|
-
}
|
41
|
-
]
|
42
|
-
}
|
43
|
-
},
|
44
|
-
{
|
45
|
-
type: 'textarea',
|
46
|
-
label: 'config',
|
47
|
-
name: 'config'
|
48
|
-
},
|
49
|
-
{
|
50
|
-
type: 'checkbox',
|
51
|
-
label: 'filterable',
|
52
|
-
name: 'filterable'
|
53
|
-
},
|
54
|
-
{
|
55
|
-
type: 'checkbox',
|
56
|
-
label: 'appendable',
|
57
|
-
name: 'appendable'
|
58
|
-
},
|
59
|
-
{
|
60
|
-
type: 'checkbox',
|
61
|
-
label: 'paginatable',
|
62
|
-
name: 'paginatable'
|
63
|
-
},
|
64
|
-
{
|
65
|
-
type: 'number',
|
66
|
-
label: 'content-scale',
|
67
|
-
name: 'contentScale',
|
68
|
-
property: {
|
69
|
-
step: 0.1,
|
70
|
-
min: 0.1
|
71
|
-
}
|
72
|
-
},
|
73
|
-
{
|
74
|
-
type: 'select',
|
75
|
-
label: 'bound-data',
|
76
|
-
name: 'boundData',
|
77
|
-
property: {
|
78
|
-
options: [
|
79
|
-
{
|
80
|
-
display: '',
|
81
|
-
value: ''
|
82
|
-
},
|
83
|
-
{
|
84
|
-
display: 'Focused Row',
|
85
|
-
value: 'focused-row'
|
86
|
-
},
|
87
|
-
{
|
88
|
-
display: 'Selected Rows',
|
89
|
-
value: 'selected-rows'
|
90
|
-
}
|
91
|
-
]
|
92
|
-
}
|
93
|
-
}
|
94
|
-
],
|
95
|
-
help: 'scene/component/grist'
|
96
|
-
}
|
97
|
-
|
98
|
-
const isMobileDevice = () => false
|
99
|
-
|
100
|
-
export default class SceneGrist extends HTMLOverlayElement {
|
101
|
-
public beforeFetchFuncs: any = {}
|
102
|
-
|
103
|
-
private __value: any = {}
|
104
|
-
private _listenTo?: any
|
105
|
-
private _listener?: any
|
106
|
-
|
107
|
-
public grist?: DataGrist
|
108
|
-
|
109
|
-
get nature() {
|
110
|
-
return NATURE
|
111
|
-
}
|
112
|
-
|
113
|
-
ready() {
|
114
|
-
super.ready()
|
115
|
-
|
116
|
-
if (this.rootModel) {
|
117
|
-
this._listenTo = this.rootModel
|
118
|
-
this._listener = function (this: SceneGrist, after: Properties) {
|
119
|
-
after.scale && this.rescale()
|
120
|
-
}.bind(this)
|
121
|
-
this.rootModel.on('change', this._listener)
|
122
|
-
}
|
123
|
-
}
|
124
|
-
|
125
|
-
removed() {
|
126
|
-
if (this._listenTo) {
|
127
|
-
this._listenTo.off('change', this._listener)
|
128
|
-
|
129
|
-
delete this._listenTo
|
130
|
-
delete this._listener
|
131
|
-
}
|
132
|
-
}
|
133
|
-
|
134
|
-
createElement() {
|
135
|
-
super.createElement()
|
136
|
-
|
137
|
-
this.grist = document.createElement('ox-grist') as DataGrist
|
138
|
-
this.element.appendChild(this.grist)
|
139
|
-
|
140
|
-
this.rescale()
|
141
|
-
|
142
|
-
const grist = this.grist
|
143
|
-
|
144
|
-
this.setGristConfig(grist)
|
145
|
-
|
146
|
-
grist.fetchHandler = async ({
|
147
|
-
page,
|
148
|
-
limit,
|
149
|
-
sorters,
|
150
|
-
sortings,
|
151
|
-
filters,
|
152
|
-
inherited,
|
153
|
-
options
|
154
|
-
}: FetchOption): Promise<FetchResult> => {
|
155
|
-
Object.values(this.beforeFetchFuncs).forEach((func: any) =>
|
156
|
-
func({ page, limit, sorters, sortings, filters, inherited, options })
|
157
|
-
)
|
158
|
-
var { total = 0, records = [] } = grist.data || {}
|
159
|
-
|
160
|
-
return {
|
161
|
-
page,
|
162
|
-
limit,
|
163
|
-
total,
|
164
|
-
records
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
|
-
grist.addEventListener('select-record-change', e => {
|
169
|
-
if (this.state.boundData === 'selected-rows') {
|
170
|
-
this.data = (e.target as DataGrist)?.selected || []
|
171
|
-
}
|
172
|
-
})
|
173
|
-
|
174
|
-
grist.addEventListener('select-all-change', e => {
|
175
|
-
if (this.state.boundData === 'selected-rows') {
|
176
|
-
this.data = (e.target as DataGrist)?.selected || []
|
177
|
-
}
|
178
|
-
})
|
179
|
-
|
180
|
-
grist.addEventListener('focus-change', (e: Event) => {
|
181
|
-
if (this.state.boundData === 'focused-row') {
|
182
|
-
this.data = ((e.target as DataGrist)?.data?.records || [])[(e as CustomEvent).detail.row]
|
183
|
-
}
|
184
|
-
})
|
185
|
-
}
|
186
|
-
|
187
|
-
get value() {
|
188
|
-
return this.__value
|
189
|
-
}
|
190
|
-
|
191
|
-
set value(value) {
|
192
|
-
this.__value = value
|
193
|
-
if (!this.grist || typeof value !== 'object') return
|
194
|
-
|
195
|
-
var { page, limit } = this.config.pagination || {}
|
196
|
-
|
197
|
-
this.grist.data =
|
198
|
-
value instanceof Array
|
199
|
-
? {
|
200
|
-
page,
|
201
|
-
limit,
|
202
|
-
...this.grist._data,
|
203
|
-
total: value.length,
|
204
|
-
records: Array.from(value)
|
205
|
-
}
|
206
|
-
: {
|
207
|
-
page,
|
208
|
-
limit,
|
209
|
-
...this.grist._data,
|
210
|
-
...value
|
211
|
-
}
|
212
|
-
}
|
213
|
-
|
214
|
-
onchange(after: Properties, before: Properties) {
|
215
|
-
super.onchange(after, before)
|
216
|
-
|
217
|
-
if (
|
218
|
-
'mode' in after ||
|
219
|
-
'filterable' in after ||
|
220
|
-
'appendable' in after ||
|
221
|
-
'paginatable' in after ||
|
222
|
-
'config' in after
|
223
|
-
) {
|
224
|
-
this.setGristConfig(this.grist)
|
225
|
-
}
|
226
|
-
|
227
|
-
this.rescale()
|
228
|
-
}
|
229
|
-
|
230
|
-
dispose() {
|
231
|
-
super.dispose()
|
232
|
-
|
233
|
-
delete this.grist
|
234
|
-
}
|
235
|
-
|
236
|
-
/*
|
237
|
-
* 컴포넌트의 생성 또는 속성 변화 시에 호출되며,
|
238
|
-
* 그에 따른 html element의 반영이 필요한 부분을 구현한다.
|
239
|
-
*
|
240
|
-
* ThingsComponent state => HTML element properties
|
241
|
-
*/
|
242
|
-
setElementProperties(grist: DataGrist) {
|
243
|
-
this.rescale()
|
244
|
-
}
|
245
|
-
|
246
|
-
setGristConfig(grist: DataGrist | undefined) {
|
247
|
-
if (!grist) {
|
248
|
-
return
|
249
|
-
}
|
250
|
-
|
251
|
-
var { mode, filterable } = this.state
|
252
|
-
|
253
|
-
if (mode != 'DEVICE') {
|
254
|
-
grist.mode = mode
|
255
|
-
} else {
|
256
|
-
grist.mode = isMobileDevice() ? 'LIST' : 'GRID'
|
257
|
-
}
|
258
|
-
|
259
|
-
grist.config = this.config
|
260
|
-
|
261
|
-
grist.innerHTML = filterable
|
262
|
-
? `
|
263
|
-
<div slot="headroom">
|
264
|
-
<div style="padding: 9px 9px 0px 9px;">
|
265
|
-
<ox-filters-form autofocus></ox-filters-form>
|
266
|
-
</div>
|
267
|
-
</div>
|
268
|
-
`
|
269
|
-
: ''
|
270
|
-
}
|
271
|
-
|
272
|
-
/*
|
273
|
-
* 컴포넌트가 ready 상태가 되거나, 컴포넌트의 속성이 변화될 시 setElementProperties 뒤에 호출된다.
|
274
|
-
* 변화에 따른 기본적인 html 속성이 super.reposition()에서 진행되고, 그 밖의 작업이 필요할 때, 오버라이드 한다.
|
275
|
-
*/
|
276
|
-
reposition() {
|
277
|
-
const { fillStyle } = this.state
|
278
|
-
|
279
|
-
if (!fillStyle) {
|
280
|
-
this.grist?.style.setProperty('--grist-background-color', 'var(--md-sys-color-surface, #f7f6f4)')
|
281
|
-
} else {
|
282
|
-
this.grist?.style.removeProperty('--grist-background-color')
|
283
|
-
}
|
284
|
-
|
285
|
-
super.reposition()
|
286
|
-
}
|
287
|
-
|
288
|
-
/*
|
289
|
-
* grist는 부모의 스케일의 역으로 transform해서, scale을 1로 맞춘다.
|
290
|
-
*/
|
291
|
-
rescale() {
|
292
|
-
var grist = this.grist
|
293
|
-
if (!grist) {
|
294
|
-
return
|
295
|
-
}
|
296
|
-
|
297
|
-
const scale = this.getState('contentScale') || 1
|
298
|
-
|
299
|
-
const sx = scale
|
300
|
-
const sy = scale
|
301
|
-
|
302
|
-
const transform = `scale(${sx}, ${sy})`
|
303
|
-
|
304
|
-
;['-webkit-', '-moz-', '-ms-', '-o-', ''].forEach((prefix: string) => {
|
305
|
-
grist!.style.setProperty(prefix + 'transform', transform)
|
306
|
-
grist!.style.setProperty(prefix + 'transform-origin', '0px 0px')
|
307
|
-
})
|
308
|
-
|
309
|
-
const { width, height } = this.state
|
310
|
-
grist.style.width = Math.round(width / scale) + 'px'
|
311
|
-
grist.style.height = Math.round(height / scale) + 'px'
|
312
|
-
}
|
313
|
-
|
314
|
-
get config() {
|
315
|
-
var { config, appendable, paginatable } = this.state
|
316
|
-
|
317
|
-
if (typeof config !== 'object') {
|
318
|
-
try {
|
319
|
-
const c = new Compartment({
|
320
|
-
t: _i18next.t,
|
321
|
-
i18next: _i18next
|
322
|
-
})
|
323
|
-
|
324
|
-
config = c.evaluate(`(${config})`)
|
325
|
-
} catch (e) {
|
326
|
-
error(e)
|
327
|
-
}
|
328
|
-
}
|
329
|
-
|
330
|
-
if (paginatable) {
|
331
|
-
if (config.pagination && !config.pagination.limit && config.pagination.pages && config.pagination.pages.length) {
|
332
|
-
config.pagination.limit = config.pagination.pages[0]
|
333
|
-
}
|
334
|
-
}
|
335
|
-
|
336
|
-
config.pagination = {
|
337
|
-
...config.pagination,
|
338
|
-
infinite: !paginatable
|
339
|
-
}
|
340
|
-
|
341
|
-
config.rows = {
|
342
|
-
...config.rows,
|
343
|
-
appendable: !!appendable
|
344
|
-
}
|
345
|
-
|
346
|
-
return config
|
347
|
-
}
|
348
|
-
|
349
|
-
get tagName() {
|
350
|
-
return 'div'
|
351
|
-
}
|
352
|
-
}
|
353
|
-
|
354
|
-
Component.register('grist', SceneGrist)
|
package/src/index.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
import { ACTIONS } from '../grist-action'
|
2
|
-
|
3
|
-
const icon = new URL('../../icons/grist-action.png', import.meta.url).href
|
4
|
-
|
5
|
-
export default {
|
6
|
-
type: 'grist-action',
|
7
|
-
description: 'grist-action',
|
8
|
-
group: 'table',
|
9
|
-
/* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */
|
10
|
-
icon,
|
11
|
-
model: {
|
12
|
-
type: 'grist-action',
|
13
|
-
left: 10,
|
14
|
-
top: 10,
|
15
|
-
width: 100,
|
16
|
-
height: 100,
|
17
|
-
strokeStyle: 'darkgray',
|
18
|
-
action: ACTIONS.GET_SELECTED
|
19
|
-
}
|
20
|
-
}
|
package/src/templates/grist.ts
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
const icon = new URL('../../icons/grist.png', import.meta.url).href
|
2
|
-
|
3
|
-
export default {
|
4
|
-
type: 'grist',
|
5
|
-
description: 'grist',
|
6
|
-
group: 'table',
|
7
|
-
/* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */
|
8
|
-
icon,
|
9
|
-
model: {
|
10
|
-
type: 'grist',
|
11
|
-
left: 10,
|
12
|
-
top: 10,
|
13
|
-
width: 400,
|
14
|
-
height: 300,
|
15
|
-
mode: 'GRID',
|
16
|
-
config: `{
|
17
|
-
columns: [
|
18
|
-
{
|
19
|
-
type: 'gutter',
|
20
|
-
gutterName: 'dirty'
|
21
|
-
},
|
22
|
-
{
|
23
|
-
type: 'gutter',
|
24
|
-
gutterName: 'sequence'
|
25
|
-
},
|
26
|
-
{
|
27
|
-
type: 'gutter',
|
28
|
-
gutterName: 'row-selector',
|
29
|
-
multiple: true
|
30
|
-
},
|
31
|
-
{
|
32
|
-
type: 'string',
|
33
|
-
name: 'id',
|
34
|
-
hidden: true
|
35
|
-
},
|
36
|
-
{
|
37
|
-
type: 'string',
|
38
|
-
name: 'name',
|
39
|
-
header: 'name',
|
40
|
-
record: {
|
41
|
-
editable: true
|
42
|
-
},
|
43
|
-
sortable: true,
|
44
|
-
width: 120
|
45
|
-
},
|
46
|
-
{
|
47
|
-
type: 'string',
|
48
|
-
name: 'description',
|
49
|
-
header: 'description',
|
50
|
-
record: {
|
51
|
-
align: 'left',
|
52
|
-
editable: true
|
53
|
-
},
|
54
|
-
width: 200
|
55
|
-
},
|
56
|
-
{
|
57
|
-
type: 'boolean',
|
58
|
-
name: 'active',
|
59
|
-
header: 'active',
|
60
|
-
record: {
|
61
|
-
editable: true
|
62
|
-
},
|
63
|
-
sortable: true,
|
64
|
-
width: 60
|
65
|
-
},
|
66
|
-
{
|
67
|
-
type: 'datetime',
|
68
|
-
name: 'updatedAt',
|
69
|
-
header: 'updated at',
|
70
|
-
width: 180
|
71
|
-
},
|
72
|
-
{
|
73
|
-
type: 'datetime',
|
74
|
-
name: 'createdAt',
|
75
|
-
header: 'created at',
|
76
|
-
width: 180
|
77
|
-
}
|
78
|
-
],
|
79
|
-
rows: {
|
80
|
-
selectable: {
|
81
|
-
multiple: true
|
82
|
-
},
|
83
|
-
handlers: {
|
84
|
-
click: 'select-row-toggle'
|
85
|
-
}
|
86
|
-
},
|
87
|
-
sorters: [
|
88
|
-
{
|
89
|
-
name: 'name',
|
90
|
-
desc: true
|
91
|
-
}
|
92
|
-
],
|
93
|
-
pagination: {
|
94
|
-
pages: [20, 30, 50, 100, 200]
|
95
|
-
}
|
96
|
-
}`
|
97
|
-
}
|
98
|
-
}
|
package/src/templates/index.ts
DELETED
package/tsconfig.json
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "es2018",
|
4
|
-
"module": "esnext",
|
5
|
-
"moduleResolution": "node",
|
6
|
-
"noEmitOnError": true,
|
7
|
-
"lib": ["es2019", "dom"],
|
8
|
-
"strict": true,
|
9
|
-
"esModuleInterop": false,
|
10
|
-
"allowJs": true,
|
11
|
-
"allowSyntheticDefaultImports": true,
|
12
|
-
"experimentalDecorators": true,
|
13
|
-
"importHelpers": true,
|
14
|
-
"outDir": "dist",
|
15
|
-
"sourceMap": true,
|
16
|
-
"inlineSources": true,
|
17
|
-
"rootDir": "src",
|
18
|
-
"declaration": true,
|
19
|
-
"incremental": true,
|
20
|
-
"skipLibCheck": true
|
21
|
-
},
|
22
|
-
"include": ["**/*.ts", "*.d.ts", "**/data-grist.d.ts"]
|
23
|
-
}
|