@operato/app 1.0.0-alpha.2 → 1.0.0-alpha.20
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 +159 -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-color-gradient.d.ts +25 -0
- package/dist/src/input/ox-input-color-gradient.js +318 -0
- package/dist/src/input/ox-input-color-gradient.js.map +1 -0
- package/dist/src/input/ox-input-fill-style.d.ts +42 -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 +31 -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-color-gradient.ts +341 -0
- package/src/input/ox-input-fill-style.ts +360 -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
|
@@ -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
|
+
}
|