@operato/app 1.0.0-alpha.3 → 1.0.0-alpha.32

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 (127) hide show
  1. package/@types/global/index.d.ts +2 -0
  2. package/CHANGELOG.md +178 -8
  3. package/demo/data-grist-test.html +456 -0
  4. package/dist/src/{grist → grist-editor}/index.d.ts +0 -0
  5. package/dist/src/grist-editor/index.js +26 -0
  6. package/dist/src/grist-editor/index.js.map +1 -0
  7. package/dist/src/grist-editor/ox-grist-editor-code.d.ts +7 -0
  8. package/dist/src/grist-editor/ox-grist-editor-code.js +56 -0
  9. package/dist/src/grist-editor/ox-grist-editor-code.js.map +1 -0
  10. package/dist/src/grist-editor/ox-grist-editor-crontab.d.ts +8 -0
  11. package/dist/src/grist-editor/ox-grist-editor-crontab.js +50 -0
  12. package/dist/src/grist-editor/ox-grist-editor-crontab.js.map +1 -0
  13. package/dist/src/grist-editor/ox-grist-editor-json.d.ts +7 -0
  14. package/dist/src/grist-editor/ox-grist-editor-json.js +54 -0
  15. package/dist/src/grist-editor/ox-grist-editor-json.js.map +1 -0
  16. package/dist/src/grist-editor/ox-grist-editor-parameters.d.ts +12 -0
  17. package/dist/src/grist-editor/ox-grist-editor-parameters.js +84 -0
  18. package/dist/src/grist-editor/ox-grist-editor-parameters.js.map +1 -0
  19. package/dist/src/grist-editor/ox-grist-editor-partition-keys.d.ts +11 -0
  20. package/dist/src/grist-editor/ox-grist-editor-partition-keys.js +74 -0
  21. package/dist/src/grist-editor/ox-grist-editor-partition-keys.js.map +1 -0
  22. package/dist/src/{grist/code-editor.d.ts → grist-editor/ox-grist-editor-resource-code.d.ts} +2 -2
  23. package/dist/src/{grist/code-editor.js → grist-editor/ox-grist-editor-resource-code.js} +10 -5
  24. package/dist/src/grist-editor/ox-grist-editor-resource-code.js.map +1 -0
  25. package/dist/src/grist-editor/ox-grist-editor-resource-id.d.ts +10 -0
  26. package/dist/src/{grist/id-input.js → grist-editor/ox-grist-editor-resource-id.js} +18 -67
  27. package/dist/src/grist-editor/ox-grist-editor-resource-id.js.map +1 -0
  28. package/dist/src/grist-editor/ox-grist-editor-resource-object.d.ts +11 -0
  29. package/dist/src/{grist/object-editor.js → grist-editor/ox-grist-editor-resource-object.js} +14 -64
  30. package/dist/src/grist-editor/ox-grist-editor-resource-object.js.map +1 -0
  31. package/dist/src/grist-editor/ox-grist-editor-value-map.d.ts +11 -0
  32. package/dist/src/grist-editor/ox-grist-editor-value-map.js +74 -0
  33. package/dist/src/grist-editor/ox-grist-editor-value-map.js.map +1 -0
  34. package/dist/src/grist-editor/ox-grist-renderer-resource-id.d.ts +2 -0
  35. package/dist/src/{grist/id-renderer.js → grist-editor/ox-grist-renderer-resource-id.js} +2 -2
  36. package/dist/src/grist-editor/ox-grist-renderer-resource-id.js.map +1 -0
  37. package/dist/src/grist-editor/ox-grist-renderer-resource-object.d.ts +2 -0
  38. package/dist/src/grist-editor/ox-grist-renderer-resource-object.js +22 -0
  39. package/dist/src/grist-editor/ox-grist-renderer-resource-object.js.map +1 -0
  40. package/dist/src/grist-editor/ox-parameters-builder.d.ts +4 -0
  41. package/dist/src/grist-editor/ox-parameters-builder.js +118 -0
  42. package/dist/src/grist-editor/ox-parameters-builder.js.map +1 -0
  43. package/dist/src/grist-editor/ox-popup-code-input.d.ts +12 -0
  44. package/dist/src/grist-editor/ox-popup-code-input.js +71 -0
  45. package/dist/src/grist-editor/ox-popup-code-input.js.map +1 -0
  46. package/dist/src/grist-editor/ox-popup-crontab-input.d.ts +11 -0
  47. package/dist/src/grist-editor/ox-popup-crontab-input.js +74 -0
  48. package/dist/src/grist-editor/ox-popup-crontab-input.js.map +1 -0
  49. package/dist/src/grist-editor/ox-popup-parameters-builder.d.ts +13 -0
  50. package/dist/src/grist-editor/ox-popup-parameters-builder.js +111 -0
  51. package/dist/src/grist-editor/ox-popup-parameters-builder.js.map +1 -0
  52. package/dist/src/grist-editor/ox-popup-partition-keys-input.d.ts +12 -0
  53. package/dist/src/grist-editor/ox-popup-partition-keys-input.js +98 -0
  54. package/dist/src/grist-editor/ox-popup-partition-keys-input.js.map +1 -0
  55. package/dist/src/grist-editor/ox-popup-value-map-input.d.ts +12 -0
  56. package/dist/src/grist-editor/ox-popup-value-map-input.js +104 -0
  57. package/dist/src/grist-editor/ox-popup-value-map-input.js.map +1 -0
  58. package/dist/src/{grist/id-selector.d.ts → grist-editor/ox-selector-resource-id.d.ts} +1 -1
  59. package/dist/src/{grist/id-selector.js → grist-editor/ox-selector-resource-id.js} +15 -15
  60. package/dist/src/grist-editor/ox-selector-resource-id.js.map +1 -0
  61. package/dist/src/{grist/object-selector.d.ts → grist-editor/ox-selector-resource-object.d.ts} +1 -1
  62. package/dist/src/{grist/object-selector.js → grist-editor/ox-selector-resource-object.js} +21 -21
  63. package/dist/src/grist-editor/ox-selector-resource-object.js.map +1 -0
  64. package/dist/src/index.d.ts +3 -1
  65. package/dist/src/index.js +3 -1
  66. package/dist/src/index.js.map +1 -1
  67. package/dist/src/input/index.d.ts +3 -0
  68. package/dist/src/input/index.js +4 -0
  69. package/dist/src/input/index.js.map +1 -0
  70. package/dist/src/input/ox-input-background-pattern.d.ts +31 -0
  71. package/dist/src/input/ox-input-background-pattern.js +150 -0
  72. package/dist/src/input/ox-input-background-pattern.js.map +1 -0
  73. package/dist/src/input/ox-input-fill-style.d.ts +41 -0
  74. package/dist/src/input/ox-input-fill-style.js +325 -0
  75. package/dist/src/input/ox-input-fill-style.js.map +1 -0
  76. package/dist/src/input/ox-input-graphql.d.ts +36 -0
  77. package/dist/src/input/ox-input-graphql.js +161 -0
  78. package/dist/src/input/ox-input-graphql.js.map +1 -0
  79. package/dist/src/property-editor/index.d.ts +24 -0
  80. package/dist/src/property-editor/index.js +58 -0
  81. package/dist/src/property-editor/index.js.map +1 -0
  82. package/dist/src/property-editor/ox-property-editor-graphql.d.ts +5 -0
  83. package/dist/src/property-editor/ox-property-editor-graphql.js +15 -0
  84. package/dist/src/property-editor/ox-property-editor-graphql.js.map +1 -0
  85. package/dist/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +42 -16
  87. package/src/grist-editor/index.ts +28 -0
  88. package/src/grist-editor/ox-grist-editor-code.ts +64 -0
  89. package/src/grist-editor/ox-grist-editor-crontab.ts +62 -0
  90. package/src/grist-editor/ox-grist-editor-json.ts +62 -0
  91. package/src/grist-editor/ox-grist-editor-parameters.ts +99 -0
  92. package/src/grist-editor/ox-grist-editor-partition-keys.ts +86 -0
  93. package/src/{grist/code-editor.ts → grist-editor/ox-grist-editor-resource-code.ts} +4 -5
  94. package/src/grist-editor/ox-grist-editor-resource-id.ts +83 -0
  95. package/src/{grist/object-editor.ts → grist-editor/ox-grist-editor-resource-object.ts} +11 -48
  96. package/src/grist-editor/ox-grist-editor-value-map.ts +86 -0
  97. package/src/{grist/id-renderer.ts → grist-editor/ox-grist-renderer-resource-id.ts} +1 -1
  98. package/src/grist-editor/ox-grist-renderer-resource-object.ts +25 -0
  99. package/src/grist-editor/ox-parameters-builder.ts +128 -0
  100. package/src/grist-editor/ox-popup-code-input.ts +65 -0
  101. package/src/grist-editor/ox-popup-crontab-input.ts +74 -0
  102. package/src/grist-editor/ox-popup-parameters-builder.ts +106 -0
  103. package/src/grist-editor/ox-popup-partition-keys-input.ts +95 -0
  104. package/src/grist-editor/ox-popup-value-map-input.ts +101 -0
  105. package/src/{grist/id-selector.ts → grist-editor/ox-selector-resource-id.ts} +2 -2
  106. package/src/{grist/object-selector.ts → grist-editor/ox-selector-resource-object.ts} +3 -3
  107. package/src/index.ts +3 -1
  108. package/src/input/index.ts +3 -0
  109. package/src/input/ox-input-background-pattern.ts +166 -0
  110. package/src/input/ox-input-fill-style.ts +359 -0
  111. package/src/input/ox-input-graphql.ts +169 -0
  112. package/src/property-editor/index.ts +59 -0
  113. package/src/property-editor/ox-property-editor-graphql.ts +12 -0
  114. package/yarn-error.log +17112 -0
  115. package/dist/src/grist/code-editor.js.map +0 -1
  116. package/dist/src/grist/id-input.d.ts +0 -19
  117. package/dist/src/grist/id-input.js.map +0 -1
  118. package/dist/src/grist/id-renderer.d.ts +0 -2
  119. package/dist/src/grist/id-renderer.js.map +0 -1
  120. package/dist/src/grist/id-selector.js.map +0 -1
  121. package/dist/src/grist/index.js +0 -9
  122. package/dist/src/grist/index.js.map +0 -1
  123. package/dist/src/grist/object-editor.d.ts +0 -18
  124. package/dist/src/grist/object-editor.js.map +0 -1
  125. package/dist/src/grist/object-selector.js.map +0 -1
  126. package/src/grist/id-input.ts +0 -135
  127. package/src/grist/index.ts +0 -11
@@ -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
+ }