@operato/property-panel 9.0.0-beta.14

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 (156) hide show
  1. package/.editorconfig +29 -0
  2. package/.storybook/main.js +5 -0
  3. package/.storybook/preview.js +52 -0
  4. package/.storybook/server.mjs +8 -0
  5. package/CHANGELOG.md +11 -0
  6. package/LICENSE +21 -0
  7. package/README.md +76 -0
  8. package/demo/index.html +30 -0
  9. package/dist/src/graphql/board.d.ts +6 -0
  10. package/dist/src/graphql/board.js +130 -0
  11. package/dist/src/graphql/board.js.map +1 -0
  12. package/dist/src/graphql/data-subscription.d.ts +5 -0
  13. package/dist/src/graphql/data-subscription.js +24 -0
  14. package/dist/src/graphql/data-subscription.js.map +1 -0
  15. package/dist/src/graphql/favorite-board.d.ts +1 -0
  16. package/dist/src/graphql/favorite-board.js +23 -0
  17. package/dist/src/graphql/favorite-board.js.map +1 -0
  18. package/dist/src/graphql/group.d.ts +7 -0
  19. package/dist/src/graphql/group.js +125 -0
  20. package/dist/src/graphql/group.js.map +1 -0
  21. package/dist/src/graphql/index.d.ts +4 -0
  22. package/dist/src/graphql/index.js +5 -0
  23. package/dist/src/graphql/index.js.map +1 -0
  24. package/dist/src/graphql/play-group.d.ts +13 -0
  25. package/dist/src/graphql/play-group.js +205 -0
  26. package/dist/src/graphql/play-group.js.map +1 -0
  27. package/dist/src/graphql/scenario.d.ts +6 -0
  28. package/dist/src/graphql/scenario.js +69 -0
  29. package/dist/src/graphql/scenario.js.map +1 -0
  30. package/dist/src/index.d.ts +7 -0
  31. package/dist/src/index.js +8 -0
  32. package/dist/src/index.js.map +1 -0
  33. package/dist/src/ox-property-panel.d.ts +46 -0
  34. package/dist/src/ox-property-panel.js +346 -0
  35. package/dist/src/ox-property-panel.js.map +1 -0
  36. package/dist/src/property-panel/abstract-property.d.ts +10 -0
  37. package/dist/src/property-panel/abstract-property.js +53 -0
  38. package/dist/src/property-panel/abstract-property.js.map +1 -0
  39. package/dist/src/property-panel/data-binding/data-binding-mapper.d.ts +58 -0
  40. package/dist/src/property-panel/data-binding/data-binding-mapper.js +380 -0
  41. package/dist/src/property-panel/data-binding/data-binding-mapper.js.map +1 -0
  42. package/dist/src/property-panel/data-binding/data-binding-value-map.d.ts +6 -0
  43. package/dist/src/property-panel/data-binding/data-binding-value-map.js +20 -0
  44. package/dist/src/property-panel/data-binding/data-binding-value-map.js.map +1 -0
  45. package/dist/src/property-panel/data-binding/data-binding-value-range.d.ts +6 -0
  46. package/dist/src/property-panel/data-binding/data-binding-value-range.js +20 -0
  47. package/dist/src/property-panel/data-binding/data-binding-value-range.js.map +1 -0
  48. package/dist/src/property-panel/data-binding/data-binding.d.ts +44 -0
  49. package/dist/src/property-panel/data-binding/data-binding.js +442 -0
  50. package/dist/src/property-panel/data-binding/data-binding.js.map +1 -0
  51. package/dist/src/property-panel/effects/effects.d.ts +24 -0
  52. package/dist/src/property-panel/effects/effects.js +72 -0
  53. package/dist/src/property-panel/effects/effects.js.map +1 -0
  54. package/dist/src/property-panel/effects/property-animation.d.ts +23 -0
  55. package/dist/src/property-panel/effects/property-animation.js +147 -0
  56. package/dist/src/property-panel/effects/property-animation.js.map +1 -0
  57. package/dist/src/property-panel/effects/property-animations.d.ts +22 -0
  58. package/dist/src/property-panel/effects/property-animations.js +70 -0
  59. package/dist/src/property-panel/effects/property-animations.js.map +1 -0
  60. package/dist/src/property-panel/effects/property-event-hover.d.ts +21 -0
  61. package/dist/src/property-panel/effects/property-event-hover.js +193 -0
  62. package/dist/src/property-panel/effects/property-event-hover.js.map +1 -0
  63. package/dist/src/property-panel/effects/property-event-tap.d.ts +36 -0
  64. package/dist/src/property-panel/effects/property-event-tap.js +262 -0
  65. package/dist/src/property-panel/effects/property-event-tap.js.map +1 -0
  66. package/dist/src/property-panel/effects/property-event.d.ts +22 -0
  67. package/dist/src/property-panel/effects/property-event.js +64 -0
  68. package/dist/src/property-panel/effects/property-event.js.map +1 -0
  69. package/dist/src/property-panel/effects/property-shadow.d.ts +23 -0
  70. package/dist/src/property-panel/effects/property-shadow.js +66 -0
  71. package/dist/src/property-panel/effects/property-shadow.js.map +1 -0
  72. package/dist/src/property-panel/effects/value-converter.d.ts +1 -0
  73. package/dist/src/property-panel/effects/value-converter.js +17 -0
  74. package/dist/src/property-panel/effects/value-converter.js.map +1 -0
  75. package/dist/src/property-panel/inspector/inspector.d.ts +27 -0
  76. package/dist/src/property-panel/inspector/inspector.js +357 -0
  77. package/dist/src/property-panel/inspector/inspector.js.map +1 -0
  78. package/dist/src/property-panel/shapes/shapes.d.ts +26 -0
  79. package/dist/src/property-panel/shapes/shapes.js +312 -0
  80. package/dist/src/property-panel/shapes/shapes.js.map +1 -0
  81. package/dist/src/property-panel/specifics/specific-properties-builder.d.ts +16 -0
  82. package/dist/src/property-panel/specifics/specific-properties-builder.js +138 -0
  83. package/dist/src/property-panel/specifics/specific-properties-builder.js.map +1 -0
  84. package/dist/src/property-panel/specifics/specifics.d.ts +25 -0
  85. package/dist/src/property-panel/specifics/specifics.js +84 -0
  86. package/dist/src/property-panel/specifics/specifics.js.map +1 -0
  87. package/dist/src/property-panel/styles/styles.d.ts +23 -0
  88. package/dist/src/property-panel/styles/styles.js +269 -0
  89. package/dist/src/property-panel/styles/styles.js.map +1 -0
  90. package/dist/src/types.d.ts +43 -0
  91. package/dist/src/types.js +2 -0
  92. package/dist/src/types.js.map +1 -0
  93. package/dist/stories/index.stories.d.ts +22 -0
  94. package/dist/stories/index.stories.js +121 -0
  95. package/dist/stories/index.stories.js.map +1 -0
  96. package/dist/stories/input-table-property.stories.d.ts +21 -0
  97. package/dist/stories/input-table-property.stories.js +84 -0
  98. package/dist/stories/input-table-property.stories.js.map +1 -0
  99. package/dist/test/ox-property-panel.test.d.ts +1 -0
  100. package/dist/test/ox-property-panel.test.js +24 -0
  101. package/dist/test/ox-property-panel.test.js.map +1 -0
  102. package/dist/tsconfig.tsbuildinfo +1 -0
  103. package/package.json +108 -0
  104. package/src/graphql/board.ts +144 -0
  105. package/src/graphql/data-subscription.ts +30 -0
  106. package/src/graphql/favorite-board.ts +25 -0
  107. package/src/graphql/group.ts +138 -0
  108. package/src/graphql/index.ts +4 -0
  109. package/src/graphql/play-group.ts +225 -0
  110. package/src/graphql/scenario.ts +79 -0
  111. package/src/index.ts +8 -0
  112. package/src/ox-property-panel.ts +347 -0
  113. package/src/property-panel/abstract-property.ts +67 -0
  114. package/src/property-panel/data-binding/data-binding-mapper.ts +412 -0
  115. package/src/property-panel/data-binding/data-binding-value-map.ts +19 -0
  116. package/src/property-panel/data-binding/data-binding-value-range.ts +19 -0
  117. package/src/property-panel/data-binding/data-binding.ts +464 -0
  118. package/src/property-panel/effects/effects.ts +77 -0
  119. package/src/property-panel/effects/property-animation.ts +155 -0
  120. package/src/property-panel/effects/property-animations.ts +74 -0
  121. package/src/property-panel/effects/property-event-hover.ts +212 -0
  122. package/src/property-panel/effects/property-event-tap.ts +269 -0
  123. package/src/property-panel/effects/property-event.ts +73 -0
  124. package/src/property-panel/effects/property-shadow.ts +77 -0
  125. package/src/property-panel/effects/value-converter.ts +17 -0
  126. package/src/property-panel/inspector/inspector.ts +407 -0
  127. package/src/property-panel/shapes/shapes.ts +321 -0
  128. package/src/property-panel/specifics/specific-properties-builder.ts +152 -0
  129. package/src/property-panel/specifics/specifics.ts +81 -0
  130. package/src/property-panel/styles/styles.ts +287 -0
  131. package/src/types.ts +63 -0
  132. package/stories/index.stories.ts +134 -0
  133. package/stories/input-table-property.stories.ts +96 -0
  134. package/test/ox-property-panel.test.ts +32 -0
  135. package/themes/app-theme.css +138 -0
  136. package/themes/calendar-theme.css +61 -0
  137. package/themes/dark.css +51 -0
  138. package/themes/grist-theme.css +175 -0
  139. package/themes/help-theme.css +57 -0
  140. package/themes/layout-theme.css +94 -0
  141. package/themes/light.css +51 -0
  142. package/themes/material-theme.css +23 -0
  143. package/themes/md-typescale-styles.css +100 -0
  144. package/themes/oops-theme.css +22 -0
  145. package/themes/report-theme.css +47 -0
  146. package/themes/spacing.css +23 -0
  147. package/themes/state-color.css +6 -0
  148. package/themes/tooltip-theme.css +11 -0
  149. package/translations/en.json +723 -0
  150. package/translations/ja.json +727 -0
  151. package/translations/ko.json +727 -0
  152. package/translations/ms.json +609 -0
  153. package/translations/zh.json +726 -0
  154. package/tsconfig.json +25 -0
  155. package/web-dev-server.config.mjs +27 -0
  156. package/web-test-runner.config.mjs +41 -0
@@ -0,0 +1,347 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@material/web/icon/icon.js'
6
+
7
+ import { css, html, LitElement, PropertyValues } from 'lit'
8
+ import { customElement, property } from 'lit/decorators.js'
9
+ import deepClone from 'lodash-es/cloneDeep.js'
10
+
11
+ import { BOUNDS, Component, Model, Scene } from '@hatiolab/things-scene'
12
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements'
13
+ import { ScrollbarStyles } from '@operato/styles'
14
+
15
+ import { PropertyDataBinding } from './property-panel/data-binding/data-binding.js'
16
+ import { PropertyEffects } from './property-panel/effects/effects.js'
17
+ import { SceneInspector } from './property-panel/inspector/inspector.js'
18
+ import { PropertyShapes } from './property-panel/shapes/shapes.js'
19
+ // import { PropertySpecific } from './property-panel/specifics/specifics.js'
20
+ import { PropertyStyles } from './property-panel/styles/styles.js'
21
+
22
+ @customElement('ox-property-panel')
23
+ export class OxPropertyPanel extends ScopedElementsMixin(LitElement) {
24
+ static styles = [
25
+ ScrollbarStyles,
26
+ css`
27
+ :host {
28
+ border-left: 1px solid var(--md-sys-color-border, #ccc);
29
+ width: 270px;
30
+ display: flex;
31
+ flex-direction: column;
32
+ background-color: var(--property-sidebar-background-color, var(--md-sys-color-secondary-container));
33
+ color: var(--property-sidebar-color, var(--md-sys-color-on-secondary-container));
34
+ user-select: none;
35
+
36
+ --input-padding: var(--spacing-small);
37
+ --label-font: var(--property-sidebar-fieldset-label, roboto);
38
+ }
39
+
40
+ [tab] {
41
+ display: flex;
42
+ background-color: rgba(0, 0, 0, 0.08);
43
+ opacity: 0.85;
44
+ }
45
+
46
+ [tab] md-icon {
47
+ flex: 1;
48
+
49
+ display: flex;
50
+ align-items: center;
51
+ justify-content: center;
52
+
53
+ color: var(--property-sidebar-tab-icon-color);
54
+ height: 40px;
55
+ }
56
+
57
+ [tab] [selected] {
58
+ background-color: var(--property-sidebar-background-color, var(--md-sys-color-secondary-container));
59
+ border-left: 1px solid rgba(255, 255, 255, 0.5);
60
+ border-right: 1px solid rgba(0, 0, 0, 0.15);
61
+ opacity: 1;
62
+ }
63
+
64
+ [content] {
65
+ flex: 1;
66
+
67
+ overflow: hidden;
68
+ overflow-y: auto;
69
+
70
+ --md-icon-size: 22px;
71
+ }
72
+
73
+ [content] > :not([active]) {
74
+ display: none;
75
+ }
76
+ `
77
+ ]
78
+
79
+ @property({ type: Object }) scene: Scene | null = null
80
+ @property({ type: Object }) bounds: any = {}
81
+ @property({ type: Object }) model: Model | null = {}
82
+ @property({ type: Array }) selected: Component[] = []
83
+ @property({ type: Array }) specificProps: any
84
+ @property({ type: String }) tabName: string | null = 'shape'
85
+ @property({ type: Boolean }) collapsed: boolean = false
86
+ @property({ type: Array }) fonts: any[] = []
87
+ @property({ type: Array }) propertyEditor: any[] = []
88
+
89
+ propertyTarget: Component | null = null
90
+
91
+ firstUpdated() {
92
+ this.renderRoot.addEventListener('property-change', this.onPropertyChanged.bind(this) as EventListener)
93
+ this.renderRoot.addEventListener('bounds-change', this.onBoundsChanged.bind(this) as EventListener)
94
+ }
95
+
96
+ updated(change: PropertyValues<this>) {
97
+ change.has('scene') && this.onSceneChanged()
98
+ change.has('selected') && this.onSelectedChanged(this.selected)
99
+ change.has('collapsed') && this.onCollapsed(this.collapsed)
100
+ }
101
+
102
+ static get scopedElements() {
103
+ return {
104
+ 'property-shape': PropertyShapes,
105
+ 'property-style': PropertyStyles,
106
+ 'property-effect': PropertyEffects,
107
+ // 'property-specific': PropertySpecific,
108
+ 'property-data-binding': PropertyDataBinding,
109
+ 'scene-inspector': SceneInspector
110
+ }
111
+ }
112
+
113
+ render() {
114
+ var tabName = this.tabName ? this.tabName : 'shape'
115
+
116
+ return html`
117
+ <div
118
+ tab
119
+ @click=${(e: MouseEvent) => {
120
+ this.tabName = (e.target as HTMLElement).getAttribute('name')
121
+ }}
122
+ >
123
+ <md-icon name="shape" ?selected=${tabName == 'shape'}>format_shapes</md-icon>
124
+ <md-icon name="style" ?selected=${tabName == 'style'}>palette</md-icon>
125
+ <md-icon name="effect" ?selected=${tabName == 'effect'}>movie_filter</md-icon>
126
+ <md-icon name="specific" ?selected=${tabName == 'specific'}>tune</md-icon>
127
+ <md-icon name="data-binding" ?selected=${tabName == 'data-binding'}>share</md-icon>
128
+ <md-icon name="inspector" ?selected=${tabName == 'inspector'}>visibility</md-icon>
129
+ </div>
130
+
131
+ <div content>
132
+ ${html`
133
+ ${{
134
+ shape: html`
135
+ <property-shape
136
+ .value=${this.model}
137
+ .bounds=${this.bounds}
138
+ .selected=${this.selected}
139
+ ?active=${tabName == 'shape'}
140
+ ?is-line=${this.isLine(this.selected)}
141
+ >
142
+ </property-shape>
143
+ `,
144
+ style: html`
145
+ <property-style
146
+ .value=${this.model}
147
+ .selected=${this.selected}
148
+ .fonts=${this.fonts}
149
+ ?active=${tabName == 'style'}
150
+ >
151
+ </property-style>
152
+ `,
153
+ effect: html`
154
+ <property-effect .value=${this.model} .scene=${this.scene} ?active=${tabName == 'effect'}>
155
+ </property-effect>
156
+ `,
157
+ specific: html`
158
+ <property-specific
159
+ .value=${this.model}
160
+ .scene=${this.scene}
161
+ .selected=${this.selected}
162
+ .props=${this.specificProps}
163
+ .propertyEditor=${this.propertyEditor}
164
+ ?active=${tabName == 'specific'}
165
+ >
166
+ </property-specific>
167
+ `,
168
+ 'data-binding': html`
169
+ <property-data-binding .scene=${this.scene} .value=${this.model} ?active=${tabName == 'data-binding'}>
170
+ </property-data-binding>
171
+ `,
172
+ inspector: html`
173
+ <scene-inspector .scene=${this.scene} ?active=${tabName == 'inspector'}></scene-inspector>
174
+ `
175
+ }[this.tabName!]}
176
+ `}
177
+ </div>
178
+ `
179
+ }
180
+
181
+ private onPropertyChanged(e: CustomEvent) {
182
+ var detail = e.detail
183
+
184
+ if (this.propertyTarget) {
185
+ /* 단일 컴포넌트의 경우에 적용 */
186
+ this.scene && this.scene.undoableChange(() => this.propertyTarget!.set(detail))
187
+ } else {
188
+ /* 여러 컴포넌트의 경우에 적용 */
189
+ this.scene && this.scene.undoableChange(() => this.selected.forEach(component => component.set(detail)))
190
+ }
191
+ }
192
+
193
+ private onBoundsChanged(e: CustomEvent) {
194
+ var detail = e.detail
195
+
196
+ if (!this.scene) {
197
+ return
198
+ }
199
+
200
+ if (this.propertyTarget) {
201
+ /* 단일 컴포넌트의 경우에 적용 */
202
+ this.scene.undoableChange(() => {
203
+ this.propertyTarget!.bounds = {
204
+ ...this.propertyTarget!.bounds,
205
+ ...detail
206
+ }
207
+ })
208
+ } else {
209
+ /* 여러 컴포넌트의 경우에 적용 */
210
+ this.scene.undoableChange(() => {
211
+ this.selected.forEach(component => {
212
+ component.bounds = {
213
+ ...component.bounds,
214
+ ...detail
215
+ }
216
+ })
217
+ })
218
+ }
219
+ }
220
+
221
+ private onChangedByScene() {
222
+ if (this.propertyTarget) {
223
+ this.model = {
224
+ ...this.propertyTarget.model
225
+ }
226
+ this.setBounds(this.propertyTarget.bounds)
227
+ }
228
+ }
229
+
230
+ private setPropertyTargetAsDefault() {
231
+ if (!this.scene) {
232
+ this.setPropertyTarget(null)
233
+ this.specificProps = []
234
+ this.model = null
235
+ this.bounds = {}
236
+ } else {
237
+ this.scene.select('model-layer')
238
+ }
239
+ }
240
+
241
+ private onCollapsed(collapsed: boolean) {
242
+ !collapsed && (this.style.display = '')
243
+
244
+ this.animate(
245
+ collapsed
246
+ ? [
247
+ { transform: 'translateX(0)', opacity: 1, easing: 'ease-in' },
248
+ { transform: 'translateX(100%)', opacity: 1 }
249
+ ]
250
+ : [
251
+ { transform: 'translateX(100%)', opacity: 1 },
252
+ { transform: 'translateX(0)', opacity: 1, easing: 'ease-out' }
253
+ ],
254
+ {
255
+ duration: 500
256
+ }
257
+ ).onfinish = () => {
258
+ collapsed && (this.style.display = 'none')
259
+ dispatchEvent(new Event('resize'))
260
+ }
261
+ }
262
+
263
+ private async onSceneChanged() {
264
+ await this.updateComplete
265
+
266
+ if (this.scene) this.selected = this.scene.select('model-layer')
267
+ }
268
+
269
+ private async onSelectedChanged(after: Component[]) {
270
+ await this.updateComplete
271
+
272
+ if (after.length == 1) {
273
+ this.setPropertyTarget(after[0])
274
+ // 컴포넌트 특성 속성(specific properties)을 먼저 바꾸고, 모델을 바꾸어준다.
275
+ // 컴포넌트 속성에 따라 UI 컴포넌트가 준비되고, 이후에 모델값을 보여주도록 하기 위해서이다.
276
+ this.specificProps = deepClone(this.propertyTarget!.nature.properties)
277
+ this.model = {
278
+ ...this.propertyTarget!.model
279
+ }
280
+ this.setBounds(this.propertyTarget!.bounds)
281
+ } else if (after.length == 0) {
282
+ // 선택이 안된 경우
283
+
284
+ this.setPropertyTargetAsDefault()
285
+ } else {
286
+ // 다중 선택된 경우
287
+
288
+ var type = after[0].model.type
289
+ for (let i = 1; i < after.length; i++) {
290
+ if (after[i].model.type != type) {
291
+ type = undefined
292
+ break
293
+ }
294
+ }
295
+
296
+ this.setPropertyTarget(null)
297
+
298
+ if (type) this.specificProps = deepClone(after[0].nature.properties)
299
+ else this.specificProps = null
300
+
301
+ this.model = {
302
+ type: type,
303
+ alpha: 1
304
+ }
305
+ this.bounds = {}
306
+ }
307
+ }
308
+
309
+ private setPropertyTarget(newTarget: Component | null) {
310
+ var oldTarget = this.propertyTarget
311
+
312
+ if (oldTarget) {
313
+ oldTarget.off('change', this.onChangedByScene, this)
314
+ }
315
+ if (newTarget) {
316
+ newTarget.on('change', this.onChangedByScene, this)
317
+ }
318
+
319
+ this.propertyTarget = newTarget
320
+ }
321
+
322
+ private setBounds(bounds: BOUNDS) {
323
+ this.bounds = {
324
+ left: bounds.left,
325
+ top: bounds.top,
326
+ width: Math.round(bounds.width),
327
+ height: Math.round(bounds.height)
328
+ }
329
+ }
330
+
331
+ private isLine(selected: Component[]) {
332
+ var isLine = false
333
+
334
+ for (var i = 0; i < selected.length; i++) {
335
+ var comp = selected[i]
336
+
337
+ if (!comp.isLine || !comp.isLine()) {
338
+ isLine = false
339
+ return isLine
340
+ }
341
+
342
+ isLine = true
343
+ }
344
+
345
+ return isLine
346
+ }
347
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { LitElement } from 'lit'
6
+
7
+ export class AbstractProperty extends LitElement {
8
+ firstUpdated() {
9
+ this.renderRoot.addEventListener('change', this.onValueChange.bind(this))
10
+ }
11
+
12
+ protected onValueChange(e: Event) {
13
+ var element = e.target as HTMLElement
14
+ var key = element.getAttribute('value-key')
15
+
16
+ if (!key) {
17
+ return
18
+ }
19
+
20
+ var value = this.getValueFromEventTarget(element)
21
+
22
+ this.onAfterValueChange(key, value)
23
+ }
24
+
25
+ protected getValueFromEventTarget(element: HTMLElement) {
26
+ var value
27
+
28
+ switch (element.tagName) {
29
+ case 'INPUT':
30
+ switch ((element as any).type) {
31
+ case 'checkbox':
32
+ value = (element as any).checked
33
+ break
34
+ case 'number':
35
+ value = Number((element as any).valueAsNumber)
36
+ break
37
+ case 'text':
38
+ value = String((element as any).value)
39
+ }
40
+ break
41
+
42
+ case 'MD-ICON':
43
+ value = (element as any).hasAttribute('active')
44
+ break
45
+
46
+ default:
47
+ value = (element as any).value
48
+ break
49
+ }
50
+
51
+ return value
52
+ }
53
+
54
+ protected onAfterValueChange(key: string, value: any) {
55
+ console.log('property change', key, value)
56
+
57
+ this.dispatchEvent(
58
+ new CustomEvent('property-change', {
59
+ bubbles: true,
60
+ composed: true,
61
+ detail: {
62
+ [key]: value
63
+ }
64
+ })
65
+ )
66
+ }
67
+ }