@operato/app 1.0.0-alpha.2 → 1.0.0-alpha.22
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/@types/global/index.d.ts +2 -0
- package/CHANGELOG.md +176 -0
- package/demo/data-grist-test.html +456 -0
- package/dist/src/grist/code-editor.js +8 -3
- package/dist/src/grist/code-editor.js.map +1 -1
- package/dist/src/grist/index.js +2 -0
- package/dist/src/grist/index.js.map +1 -1
- package/dist/src/grist/object-editor.d.ts +1 -1
- package/dist/src/grist/object-editor.js +1 -1
- package/dist/src/grist/object-editor.js.map +1 -1
- package/dist/src/grist/parameters-editor-builder.d.ts +4 -0
- package/dist/src/grist/parameters-editor-builder.js +118 -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/src/input/ox-input-background-pattern.d.ts +31 -0
- package/dist/src/input/ox-input-background-pattern.js +150 -0
- package/dist/src/input/ox-input-background-pattern.js.map +1 -0
- package/dist/src/input/ox-input-fill-style.d.ts +41 -0
- package/dist/src/input/ox-input-fill-style.js +325 -0
- package/dist/src/input/ox-input-fill-style.js.map +1 -0
- package/dist/src/input/ox-input-graphql.d.ts +36 -0
- package/dist/src/input/ox-input-graphql.js +161 -0
- package/dist/src/input/ox-input-graphql.js.map +1 -0
- package/dist/src/property-editor/index.d.ts +24 -0
- package/dist/src/property-editor/index.js +58 -0
- package/dist/src/property-editor/index.js.map +1 -0
- package/dist/src/property-editor/ox-property-editor-graphql.d.ts +5 -0
- package/dist/src/property-editor/ox-property-editor-graphql.js +15 -0
- package/dist/src/property-editor/ox-property-editor-graphql.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -12
- package/src/grist/code-editor.ts +2 -3
- package/src/grist/index.ts +2 -0
- package/src/grist/object-editor.ts +1 -1
- package/src/grist/parameters-editor-builder.ts +128 -0
- package/src/grist/parameters-editor-popup.ts +106 -0
- package/src/grist/parameters-editor.ts +112 -0
- package/src/input/ox-input-background-pattern.ts +166 -0
- package/src/input/ox-input-fill-style.ts +359 -0
- package/src/input/ox-input-graphql.ts +169 -0
- package/src/property-editor/index.ts +59 -0
- package/src/property-editor/ox-property-editor-graphql.ts +12 -0
- package/yarn-error.log +17112 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import '@operato/i18n/ox-i18n.js'
|
|
6
|
+
import '@operato/input/ox-input-color.js'
|
|
7
|
+
import '@operato/input/ox-input-color-stops.js'
|
|
8
|
+
import '@operato/input/ox-input-color-gradient.js'
|
|
9
|
+
import './ox-input-background-pattern.js'
|
|
10
|
+
|
|
11
|
+
import { BackgroundPatternOption, OxInputBackgroundPattern } from './ox-input-background-pattern.js'
|
|
12
|
+
import { ColorStop, GradientOption, OxFormField, OxInputColorGradient } from '@operato/input'
|
|
13
|
+
import { PropertyValues, css, html } from 'lit'
|
|
14
|
+
import { customElement, property, query } from 'lit/decorators.js'
|
|
15
|
+
|
|
16
|
+
export type FillStyle =
|
|
17
|
+
| {
|
|
18
|
+
type?: 'no' | 'solid' | 'gradient' | 'pattern'
|
|
19
|
+
gradientType?: 'linear' | 'radial'
|
|
20
|
+
colorStops?: ColorStop[]
|
|
21
|
+
rotation?: number
|
|
22
|
+
center?: 'center' | 'left-top' | 'right-top' | 'right-bottom' | 'left-bottom'
|
|
23
|
+
image?: HTMLImageElement | string
|
|
24
|
+
offsetX?: number
|
|
25
|
+
offsetY?: number
|
|
26
|
+
width?: number
|
|
27
|
+
height?: number
|
|
28
|
+
align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom'
|
|
29
|
+
fitPattern?: boolean
|
|
30
|
+
}
|
|
31
|
+
| 'no'
|
|
32
|
+
| string
|
|
33
|
+
|
|
34
|
+
@customElement('ox-input-fill-style')
|
|
35
|
+
export class OxInputColorStyle extends OxFormField {
|
|
36
|
+
static styles = css`
|
|
37
|
+
:host {
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[fill-type] {
|
|
43
|
+
display: flex;
|
|
44
|
+
margin: 0 0 14px 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[fill-type] * {
|
|
48
|
+
flex: auto;
|
|
49
|
+
margin: 0;
|
|
50
|
+
text-align: left;
|
|
51
|
+
align-self: center;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.grid-10 {
|
|
55
|
+
display: grid;
|
|
56
|
+
|
|
57
|
+
grid-template-columns: repeat(10, 1fr);
|
|
58
|
+
grid-gap: 5px;
|
|
59
|
+
grid-auto-rows: minmax(24px, auto);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.grid-10 > ox-input-color {
|
|
63
|
+
grid-column: span 4;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.grid-10 > .icon-only-label {
|
|
67
|
+
grid-column: span 1;
|
|
68
|
+
|
|
69
|
+
background: url(/assets/images/icon-properties-label.png) no-repeat;
|
|
70
|
+
float: left;
|
|
71
|
+
margin: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.icon-only-label.color {
|
|
75
|
+
background-position: 70% -498px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[editors] > :not([active]) {
|
|
79
|
+
display: none;
|
|
80
|
+
}
|
|
81
|
+
`
|
|
82
|
+
|
|
83
|
+
@property({ type: Object }) value?: FillStyle
|
|
84
|
+
@property({ type: String }) fillType?: string
|
|
85
|
+
@property({ type: String }) solid?: string
|
|
86
|
+
@property({ type: Object }) gradient?: GradientOption
|
|
87
|
+
@property({ type: Object }) pattern?: BackgroundPatternOption
|
|
88
|
+
|
|
89
|
+
private _block_reset: boolean = false
|
|
90
|
+
|
|
91
|
+
updated(changes: PropertyValues<this>) {
|
|
92
|
+
changes.has('value') && this._onChangedValue(this.value || {})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
render() {
|
|
96
|
+
return html`
|
|
97
|
+
<div @change=${(e: Event) => this._onChangedFillType(e)} fill-type>
|
|
98
|
+
<input
|
|
99
|
+
type="radio"
|
|
100
|
+
id="fill-type-no"
|
|
101
|
+
name="fill-type"
|
|
102
|
+
value="no"
|
|
103
|
+
.checked=${!this.fillType || this.fillType == 'no'}
|
|
104
|
+
/>
|
|
105
|
+
<label for="fill-type-no"><ox-i18n msgid="label.no-fill">no fill</ox-i18n></label>
|
|
106
|
+
<input type="radio" id="fill-type-solid" name="fill-type" value="solid" .checked=${this.fillType == 'solid'} />
|
|
107
|
+
<label for="fill-type-solid"><ox-i18n msgid="label.solid">solid</ox-i18n></label>
|
|
108
|
+
<input
|
|
109
|
+
type="radio"
|
|
110
|
+
id="fill-type-gradient"
|
|
111
|
+
name="fill-type"
|
|
112
|
+
value="gradient"
|
|
113
|
+
.checked=${this.fillType == 'gradient'}
|
|
114
|
+
/>
|
|
115
|
+
<label for="fill-type-gradient"><ox-i18n msgid="label.gradient">gradient</ox-i18n></label>
|
|
116
|
+
<input
|
|
117
|
+
type="radio"
|
|
118
|
+
id="fill-type-pattern"
|
|
119
|
+
name="fill-type"
|
|
120
|
+
value="pattern"
|
|
121
|
+
.checked=${this.fillType == 'pattern'}
|
|
122
|
+
/>
|
|
123
|
+
<label for="fill-type-pattern"><ox-i18n msgid="label.pattern">pattern</ox-i18n></label>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<div editors>
|
|
127
|
+
<div ?active=${this.fillType == 'no'}></div>
|
|
128
|
+
|
|
129
|
+
<div class="grid-10" ?active=${this.fillType == 'solid'}>
|
|
130
|
+
<label class="icon-only-label color"></label>
|
|
131
|
+
<ox-input-color @change=${(e: Event) => this._onChangedSolid(e)} .value=${this.solid}> </ox-input-color>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<div ?active=${this.fillType == 'gradient'}>
|
|
135
|
+
<ox-input-color-gradient @change=${(e: Event) => this._onChandedGradient(e)} .value=${this.gradient}>
|
|
136
|
+
</ox-input-color-gradient>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<div ?active=${this.fillType == 'pattern'}>
|
|
140
|
+
<ox-input-background-pattern @change=${(e: Event) => this._onChangedPattern(e)} .value=${this.pattern}>
|
|
141
|
+
</ox-input-background-pattern>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
`
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async _onChangedValue(value: FillStyle) {
|
|
148
|
+
/*
|
|
149
|
+
* this._block_reset의 역할은 내부 사용자 인터렉션에 의한 value의 변경시에는 각 type별 이전값을 유지하기 위함이다.
|
|
150
|
+
*/
|
|
151
|
+
await this.requestUpdate()
|
|
152
|
+
|
|
153
|
+
/* 설정 값에 따라서, 멤버 속성을 설정한다. */
|
|
154
|
+
if (!value) {
|
|
155
|
+
this.fillType = 'no'
|
|
156
|
+
|
|
157
|
+
if (!this._block_reset) {
|
|
158
|
+
this.solid = undefined
|
|
159
|
+
this.gradient = undefined
|
|
160
|
+
this.pattern = undefined
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this._block_reset = false
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
switch (typeof value) {
|
|
168
|
+
case 'string':
|
|
169
|
+
this.fillType = 'solid'
|
|
170
|
+
this.solid = value
|
|
171
|
+
|
|
172
|
+
if (!this._block_reset) {
|
|
173
|
+
this.gradient = undefined
|
|
174
|
+
this.pattern = undefined
|
|
175
|
+
}
|
|
176
|
+
break
|
|
177
|
+
case 'object':
|
|
178
|
+
this.fillType = value.type
|
|
179
|
+
|
|
180
|
+
if (value.type === 'gradient') {
|
|
181
|
+
this.gradient = {
|
|
182
|
+
type: value.gradientType || 'linear',
|
|
183
|
+
colorStops: value.colorStops || [
|
|
184
|
+
{
|
|
185
|
+
position: 0,
|
|
186
|
+
color: this.solid || '#000000'
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
position: 1,
|
|
190
|
+
color: this.solid || '#FFFFFF'
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
rotation: Number(value.rotation) || 0,
|
|
194
|
+
center: value.center
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (!this._block_reset) {
|
|
198
|
+
this.pattern = undefined
|
|
199
|
+
this.solid = undefined
|
|
200
|
+
}
|
|
201
|
+
} else if (value.type === 'pattern') {
|
|
202
|
+
this.pattern = {
|
|
203
|
+
image: value.image,
|
|
204
|
+
offsetX: Number(value.offsetX) || 0,
|
|
205
|
+
offsetY: Number(value.offsetY) || 0,
|
|
206
|
+
width: Number(value.width),
|
|
207
|
+
height: Number(value.height),
|
|
208
|
+
align: value.align,
|
|
209
|
+
fitPattern: value.fitPattern
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (!this._block_reset) {
|
|
213
|
+
this.gradient = undefined
|
|
214
|
+
this.solid = undefined
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
break
|
|
219
|
+
default:
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
this._block_reset = false
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
_onChangedFillType(e: Event) {
|
|
226
|
+
const element = e.target as HTMLInputElement
|
|
227
|
+
this.fillType = element.value
|
|
228
|
+
|
|
229
|
+
switch (this.fillType) {
|
|
230
|
+
case 'gradient':
|
|
231
|
+
if (!this.gradient) {
|
|
232
|
+
this.gradient = {
|
|
233
|
+
type: 'linear',
|
|
234
|
+
colorStops: [
|
|
235
|
+
{
|
|
236
|
+
position: 0,
|
|
237
|
+
color: this.solid || '#000000'
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
position: 1,
|
|
241
|
+
color: this.solid || '#FFFFFF'
|
|
242
|
+
}
|
|
243
|
+
],
|
|
244
|
+
rotation: 0,
|
|
245
|
+
center: 'center'
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
this.value = {
|
|
250
|
+
type: 'gradient',
|
|
251
|
+
gradientType: this.gradient.type || 'linear',
|
|
252
|
+
colorStops: this.gradient.colorStops || [
|
|
253
|
+
{
|
|
254
|
+
position: 0,
|
|
255
|
+
color: this.solid || '#000000'
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
position: 1,
|
|
259
|
+
color: this.solid || '#FFFFFF'
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
rotation: Number(this.gradient.rotation) || 0,
|
|
263
|
+
center: this.gradient.center
|
|
264
|
+
}
|
|
265
|
+
break
|
|
266
|
+
|
|
267
|
+
case 'pattern':
|
|
268
|
+
if (!this.pattern) this.pattern = {}
|
|
269
|
+
|
|
270
|
+
this.value = {
|
|
271
|
+
type: 'pattern',
|
|
272
|
+
image: this.pattern.image,
|
|
273
|
+
offsetX: Number(this.pattern.offsetX) || 0,
|
|
274
|
+
offsetY: Number(this.pattern.offsetY) || 0,
|
|
275
|
+
width: Number(this.pattern.width),
|
|
276
|
+
height: Number(this.pattern.height),
|
|
277
|
+
align: this.pattern.align,
|
|
278
|
+
fitPattern: this.pattern.fitPattern
|
|
279
|
+
}
|
|
280
|
+
break
|
|
281
|
+
|
|
282
|
+
case 'solid':
|
|
283
|
+
if (!this.solid) this.solid = '#fff'
|
|
284
|
+
this.value = this.solid
|
|
285
|
+
break
|
|
286
|
+
|
|
287
|
+
case 'no':
|
|
288
|
+
this.value = ''
|
|
289
|
+
break
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
this._block_reset = true
|
|
293
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
_onChangedSolid(e: Event) {
|
|
297
|
+
if (this.fillType !== 'solid') return
|
|
298
|
+
|
|
299
|
+
this.solid = (e.target as HTMLInputElement).value
|
|
300
|
+
|
|
301
|
+
this.value = this.solid
|
|
302
|
+
|
|
303
|
+
this._block_reset = true
|
|
304
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
_onChandedGradient(e: Event) {
|
|
308
|
+
/*
|
|
309
|
+
* TODO Gradient의 rotation은 symmetry 기능 등으로 외부에서 변경될 수도 있다.
|
|
310
|
+
* 이 점을 감안해서, 외부 변경에 대한 대응을 해야 한다.
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
if (this.fillType !== 'gradient') {
|
|
314
|
+
return
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
this.gradient = (e.target as OxInputColorGradient).value
|
|
318
|
+
|
|
319
|
+
this.value = {
|
|
320
|
+
type: 'gradient',
|
|
321
|
+
gradientType: this.gradient.type || 'linear',
|
|
322
|
+
colorStops: this.gradient.colorStops || [
|
|
323
|
+
{
|
|
324
|
+
position: 0,
|
|
325
|
+
color: this.solid || '#000000'
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
position: 1,
|
|
329
|
+
color: this.solid || '#FFFFFF'
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
rotation: Number(this.gradient.rotation) || 0,
|
|
333
|
+
center: this.gradient.center
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
this._block_reset = true
|
|
337
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
_onChangedPattern(e: Event) {
|
|
341
|
+
if (this.fillType !== 'pattern') return
|
|
342
|
+
|
|
343
|
+
this.pattern = (e.target as OxInputBackgroundPattern).value
|
|
344
|
+
|
|
345
|
+
this.value = {
|
|
346
|
+
type: 'pattern',
|
|
347
|
+
image: this.pattern?.image,
|
|
348
|
+
offsetX: Number(this.pattern?.offsetX) || 0,
|
|
349
|
+
offsetY: Number(this.pattern?.offsetY) || 0,
|
|
350
|
+
width: Number(this.pattern?.width),
|
|
351
|
+
height: Number(this.pattern?.height),
|
|
352
|
+
align: this.pattern?.align,
|
|
353
|
+
fitPattern: this.pattern?.fitPattern
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
this._block_reset = true
|
|
357
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
|
358
|
+
}
|
|
359
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import 'codemirror/addon/display/fullscreen'
|
|
6
|
+
import 'codemirror/addon/display/autorefresh'
|
|
7
|
+
import 'codemirror/addon/hint/show-hint'
|
|
8
|
+
import 'codemirror/addon/lint/lint'
|
|
9
|
+
import 'codemirror-graphql/hint'
|
|
10
|
+
import 'codemirror-graphql/lint'
|
|
11
|
+
import 'codemirror-graphql/mode'
|
|
12
|
+
|
|
13
|
+
import { GRAPHQL_URI, client } from '@operato/graphql'
|
|
14
|
+
import { LitElement, PropertyValues, css, html, unsafeCSS } from 'lit'
|
|
15
|
+
import { customElement, property, query } from 'lit/decorators.js'
|
|
16
|
+
import { introspectSchema, wrapSchema } from '@graphql-tools/wrap'
|
|
17
|
+
|
|
18
|
+
import CodeMirror from 'codemirror'
|
|
19
|
+
import CodeMirrorStyle from '!!text-loader!codemirror/lib/codemirror.css'
|
|
20
|
+
import FullScreenStyle from '!!text-loader!codemirror/addon/display/fullscreen.css'
|
|
21
|
+
import LintStyle from '!!text-loader!codemirror/addon/lint/lint.css'
|
|
22
|
+
import NightThemeStyle from '!!text-loader!codemirror/theme/night.css'
|
|
23
|
+
import ShowHintStyle from '!!text-loader!codemirror/addon/hint/show-hint.css'
|
|
24
|
+
import { fetch } from 'cross-fetch'
|
|
25
|
+
import { print } from 'graphql'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
WEB Component for code-mirror graphql editor.
|
|
29
|
+
|
|
30
|
+
Example:
|
|
31
|
+
|
|
32
|
+
<ox-input-graphql value=${text} link=${link}>
|
|
33
|
+
</ox-input-graphql>
|
|
34
|
+
*/
|
|
35
|
+
@customElement('ox-input-graphql')
|
|
36
|
+
export default class OxInputGraphql extends LitElement {
|
|
37
|
+
static styles = [
|
|
38
|
+
css`
|
|
39
|
+
${unsafeCSS(CodeMirrorStyle)}
|
|
40
|
+
${unsafeCSS(FullScreenStyle)}
|
|
41
|
+
${unsafeCSS(NightThemeStyle)}
|
|
42
|
+
${unsafeCSS(LintStyle)}
|
|
43
|
+
${unsafeCSS(ShowHintStyle)}
|
|
44
|
+
`,
|
|
45
|
+
css`
|
|
46
|
+
:host {
|
|
47
|
+
display: block;
|
|
48
|
+
position: relative;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
textarea {
|
|
52
|
+
display: block;
|
|
53
|
+
height: 100%;
|
|
54
|
+
width: 100%;
|
|
55
|
+
resize: none;
|
|
56
|
+
font-size: 16px;
|
|
57
|
+
line-height: 20px;
|
|
58
|
+
border: 0px;
|
|
59
|
+
padding: 0px;
|
|
60
|
+
}
|
|
61
|
+
`
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `value`는 에디터에서 작성중인 contents이다.
|
|
66
|
+
*/
|
|
67
|
+
@property({ type: String }) value?: string
|
|
68
|
+
@property({ type: String }) link?: string
|
|
69
|
+
|
|
70
|
+
@query('textarea') textarea!: HTMLTextAreaElement
|
|
71
|
+
|
|
72
|
+
private _self_changing: boolean = false
|
|
73
|
+
private _changed: boolean = false
|
|
74
|
+
private _editor?: CodeMirror.EditorFromTextArea
|
|
75
|
+
|
|
76
|
+
async updated(changes: PropertyValues<this>) {
|
|
77
|
+
if ((!this._editor || changes.has('value') || changes.has('link')) && !this._self_changing) {
|
|
78
|
+
if (changes.has('link')) {
|
|
79
|
+
this._editor = undefined
|
|
80
|
+
}
|
|
81
|
+
;(await this.getEditor())!.setValue(this.value === undefined ? '' : String(this.value))
|
|
82
|
+
// ;(await this.getEditor()).refresh()
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
render() {
|
|
87
|
+
return html` <textarea></textarea> `
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async getSchema() {
|
|
91
|
+
const executor = async ({ document, variables }: any) => {
|
|
92
|
+
const query = print(document)
|
|
93
|
+
const uri = this.link || GRAPHQL_URI
|
|
94
|
+
|
|
95
|
+
const fetchResult = await fetch(uri, {
|
|
96
|
+
method: 'POST',
|
|
97
|
+
headers: {
|
|
98
|
+
'Content-Type': 'application/json'
|
|
99
|
+
},
|
|
100
|
+
body: JSON.stringify({ query, variables })
|
|
101
|
+
})
|
|
102
|
+
return fetchResult.json()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return await wrapSchema({
|
|
106
|
+
schema: await introspectSchema(executor),
|
|
107
|
+
executor
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async getEditor() {
|
|
112
|
+
if (!this._editor) {
|
|
113
|
+
try {
|
|
114
|
+
var schema = await this.getSchema()
|
|
115
|
+
} catch (err) {
|
|
116
|
+
console.error(err)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (this.textarea) {
|
|
120
|
+
this._editor = CodeMirror.fromTextArea(this.textarea, {
|
|
121
|
+
value: this.value,
|
|
122
|
+
mode: 'graphql',
|
|
123
|
+
lint: {
|
|
124
|
+
//@ts-ignore
|
|
125
|
+
schema
|
|
126
|
+
},
|
|
127
|
+
hintOptions: {
|
|
128
|
+
//@ts-ignore
|
|
129
|
+
schema
|
|
130
|
+
},
|
|
131
|
+
tabSize: 2,
|
|
132
|
+
lineNumbers: false,
|
|
133
|
+
showCursorWhenSelecting: true,
|
|
134
|
+
theme: 'night',
|
|
135
|
+
extraKeys: {
|
|
136
|
+
F11: function (cm) {
|
|
137
|
+
cm.setOption('fullScreen', !cm.getOption('fullScreen'))
|
|
138
|
+
},
|
|
139
|
+
Esc: function (cm) {
|
|
140
|
+
cm.setOption('fullScreen', !cm.getOption('fullScreen'))
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
autoRefresh: {
|
|
144
|
+
delay: 500
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
this._editor.on('blur', (editor: CodeMirror.Editor, e: FocusEvent) => {
|
|
149
|
+
if (!this._changed) return
|
|
150
|
+
|
|
151
|
+
this.value = editor.getValue()
|
|
152
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
this._editor.on('change', async (editor: CodeMirror.Editor, changeObj: CodeMirror.EditorChange) => {
|
|
156
|
+
this._self_changing = true
|
|
157
|
+
|
|
158
|
+
this._changed = true
|
|
159
|
+
|
|
160
|
+
await this.requestUpdate()
|
|
161
|
+
|
|
162
|
+
this._self_changing = false
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return this._editor
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import '@operato/property-editor/ox-property-editor-legend.js'
|
|
2
|
+
import '@operato/property-editor/ox-property-editor-number.js'
|
|
3
|
+
import '@operato/property-editor/ox-property-editor-password.js'
|
|
4
|
+
import '@operato/property-editor/ox-property-editor-angle.js'
|
|
5
|
+
import '@operato/property-editor/ox-property-editor-string.js'
|
|
6
|
+
import '@operato/property-editor/ox-property-editor-data.js'
|
|
7
|
+
import '@operato/property-editor/ox-property-editor-date.js'
|
|
8
|
+
import '@operato/property-editor/ox-property-editor-checkbox.js'
|
|
9
|
+
import '@operato/property-editor/ox-property-editor-options.js'
|
|
10
|
+
import '@operato/property-editor/ox-property-editor-select.js'
|
|
11
|
+
import '@operato/property-editor/ox-property-editor-scene-component-id.js'
|
|
12
|
+
import '@operato/property-editor/ox-property-editor-color.js'
|
|
13
|
+
import '@operato/property-editor/ox-property-editor-multiple-colors.js'
|
|
14
|
+
import '@operato/property-editor/ox-property-editor-solid-colorstops.js'
|
|
15
|
+
import '@operato/property-editor/ox-property-editor-gradient-colorstops.js'
|
|
16
|
+
import '@operato/property-editor/ox-property-editor-gradient-colorstops.js'
|
|
17
|
+
import '@operato/property-editor/ox-property-editor-textarea.js'
|
|
18
|
+
import '@operato/property-editor/ox-property-editor-table.js'
|
|
19
|
+
import '@operato/property-editor/ox-property-editor-value-map.js'
|
|
20
|
+
import '@operato/property-editor/ox-property-editor-value-ranges.js'
|
|
21
|
+
import '@operato/attachment/ox-property-editor-attachment-selector.js'
|
|
22
|
+
import '@operato/attachment/ox-property-editor-image-selector.js'
|
|
23
|
+
import '@operato/font/ox-property-editor-font-selector.js'
|
|
24
|
+
import './ox-property-editor-graphql.js'
|
|
25
|
+
|
|
26
|
+
import { OxPropertyEditor } from '@operato/property-editor'
|
|
27
|
+
|
|
28
|
+
OxPropertyEditor.register({
|
|
29
|
+
legend: 'ox-property-editor-legend',
|
|
30
|
+
number: 'ox-property-editor-number',
|
|
31
|
+
slider: 'ox-property-editor-range',
|
|
32
|
+
password: 'ox-property-editor-password',
|
|
33
|
+
angle: 'ox-property-editor-angle',
|
|
34
|
+
string: 'ox-property-editor-string',
|
|
35
|
+
textarea: 'ox-property-editor-textarea',
|
|
36
|
+
javascript: 'ox-property-editor-textarea',
|
|
37
|
+
checkbox: 'ox-property-editor-checkbox',
|
|
38
|
+
boolean: 'ox-property-editor-checkbox',
|
|
39
|
+
select: 'ox-property-editor-select',
|
|
40
|
+
date: 'ox-property-editor-date',
|
|
41
|
+
options: 'ox-property-editor-options',
|
|
42
|
+
data: 'ox-property-editor-data',
|
|
43
|
+
file: 'ox-property-editor-file',
|
|
44
|
+
image: 'ox-property-editor-image',
|
|
45
|
+
'range-input': 'ox-property-editor-range',
|
|
46
|
+
'attachment-selector': 'ox-property-editor-attachment-selector',
|
|
47
|
+
'gltf-selector': 'ox-property-editor-attachment-selector',
|
|
48
|
+
'image-selector': 'ox-property-editor-image-selector',
|
|
49
|
+
color: 'ox-property-editor-color',
|
|
50
|
+
'solid-color-stops': 'ox-property-editor-solid-colorstops',
|
|
51
|
+
'gradient-color-stops': 'ox-property-editor-gradient-colorstops',
|
|
52
|
+
'multiple-color': 'ox-property-editor-multiple-colors',
|
|
53
|
+
map: 'ox-property-editor-value-map',
|
|
54
|
+
range: 'ox-property-editor-value-ranges',
|
|
55
|
+
graphql: 'ox-property-editor-graphql',
|
|
56
|
+
'editor-table': 'ox-property-editor-table',
|
|
57
|
+
'id-input': 'ox-property-editor-scene-component-id',
|
|
58
|
+
'font-selector': 'ox-property-editor-font-selector'
|
|
59
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '../input/ox-input-graphql.js'
|
|
2
|
+
|
|
3
|
+
import { OxPropertyEditor } from '@operato/property-editor'
|
|
4
|
+
import { customElement } from 'lit/decorators.js'
|
|
5
|
+
import { html } from 'lit'
|
|
6
|
+
|
|
7
|
+
@customElement('ox-property-editor-graphql')
|
|
8
|
+
export class OxPropertyEditorGraphQL extends OxPropertyEditor {
|
|
9
|
+
editorTemplate() {
|
|
10
|
+
return html` <ox-input-graphql id="editor" .value=${this.value} fullwidth> </ox-input-graphql> `
|
|
11
|
+
}
|
|
12
|
+
}
|