@operato/property-panel 9.2.1 → 10.0.0-beta.2

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 (77) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/src/index.d.ts +1 -0
  3. package/dist/src/index.js +1 -0
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/src/ox-property-panel.d.ts +8 -0
  6. package/dist/src/ox-property-panel.js +44 -3
  7. package/dist/src/ox-property-panel.js.map +1 -1
  8. package/dist/src/property-panel/abstract-property.js +1 -0
  9. package/dist/src/property-panel/abstract-property.js.map +1 -1
  10. package/dist/src/property-panel/data-binding/data-binding-mapper.js +1 -1
  11. package/dist/src/property-panel/data-binding/data-binding-mapper.js.map +1 -1
  12. package/dist/src/property-panel/data-binding/data-binding.js.map +1 -1
  13. package/dist/src/property-panel/effects/property-animation.js +1 -1
  14. package/dist/src/property-panel/effects/property-animation.js.map +1 -1
  15. package/dist/src/property-panel/effects/property-event-hover.js +3 -3
  16. package/dist/src/property-panel/effects/property-event-hover.js.map +1 -1
  17. package/dist/src/property-panel/effects/property-event-tap.js +4 -4
  18. package/dist/src/property-panel/effects/property-event-tap.js.map +1 -1
  19. package/dist/src/property-panel/inspector/inspector.js +6 -6
  20. package/dist/src/property-panel/inspector/inspector.js.map +1 -1
  21. package/dist/src/property-panel/shapes/shapes.d.ts +0 -2
  22. package/dist/src/property-panel/shapes/shapes.js +5 -44
  23. package/dist/src/property-panel/shapes/shapes.js.map +1 -1
  24. package/dist/src/property-panel/threed/property-material3d.d.ts +27 -0
  25. package/dist/src/property-panel/threed/property-material3d.js +189 -0
  26. package/dist/src/property-panel/threed/property-material3d.js.map +1 -0
  27. package/dist/src/property-panel/threed/property-scene3d.d.ts +26 -0
  28. package/dist/src/property-panel/threed/property-scene3d.js +314 -0
  29. package/dist/src/property-panel/threed/property-scene3d.js.map +1 -0
  30. package/dist/src/property-panel/threed/threed.d.ts +17 -0
  31. package/dist/src/property-panel/threed/threed.js +98 -0
  32. package/dist/src/property-panel/threed/threed.js.map +1 -0
  33. package/dist/src/types.d.ts +1 -1
  34. package/dist/src/types.js.map +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +13 -9
  37. package/.editorconfig +0 -29
  38. package/.storybook/main.js +0 -5
  39. package/.storybook/preview.js +0 -52
  40. package/.storybook/server.mjs +0 -8
  41. package/demo/index.html +0 -30
  42. package/dist/stories/index.stories.d.ts +0 -22
  43. package/dist/stories/index.stories.js +0 -121
  44. package/dist/stories/index.stories.js.map +0 -1
  45. package/src/graphql/board.ts +0 -144
  46. package/src/graphql/data-subscription.ts +0 -30
  47. package/src/graphql/favorite-board.ts +0 -25
  48. package/src/graphql/group.ts +0 -138
  49. package/src/graphql/index.ts +0 -4
  50. package/src/graphql/play-group.ts +0 -225
  51. package/src/graphql/scenario.ts +0 -79
  52. package/src/index.ts +0 -8
  53. package/src/ox-property-panel.ts +0 -347
  54. package/src/property-panel/abstract-property.ts +0 -65
  55. package/src/property-panel/data-binding/data-binding-mapper.ts +0 -408
  56. package/src/property-panel/data-binding/data-binding-value-map.ts +0 -19
  57. package/src/property-panel/data-binding/data-binding-value-range.ts +0 -19
  58. package/src/property-panel/data-binding/data-binding.ts +0 -470
  59. package/src/property-panel/effects/effects.ts +0 -77
  60. package/src/property-panel/effects/property-animation.ts +0 -155
  61. package/src/property-panel/effects/property-animations.ts +0 -73
  62. package/src/property-panel/effects/property-event-hover-emphasize.ts +0 -74
  63. package/src/property-panel/effects/property-event-hover.ts +0 -255
  64. package/src/property-panel/effects/property-event-tap.ts +0 -269
  65. package/src/property-panel/effects/property-event.ts +0 -73
  66. package/src/property-panel/effects/property-shadow.ts +0 -77
  67. package/src/property-panel/effects/value-converter.ts +0 -17
  68. package/src/property-panel/inspector/inspector.ts +0 -376
  69. package/src/property-panel/shapes/shapes.ts +0 -379
  70. package/src/property-panel/specifics/specific-properties-builder.ts +0 -160
  71. package/src/property-panel/specifics/specifics.ts +0 -81
  72. package/src/property-panel/styles/styles.ts +0 -285
  73. package/src/types.ts +0 -63
  74. package/stories/index.stories.ts +0 -134
  75. package/tsconfig.json +0 -26
  76. package/web-dev-server.config.mjs +0 -27
  77. package/web-test-runner.config.mjs +0 -41
@@ -1,225 +0,0 @@
1
- import { PlayGroup } from '../types.js'
2
- import { client } from '@operato/graphql'
3
- import gql from 'graphql-tag'
4
-
5
- export async function playlists(): Promise<{ name: string; description: string }[]> {
6
- const response = await client.query({
7
- query: gql`
8
- {
9
- playGroups {
10
- items {
11
- id
12
- name
13
- description
14
- }
15
- total
16
- }
17
- }
18
- `
19
- })
20
-
21
- return response.data.playGroups.items
22
- }
23
-
24
- export async function fetchPlayGroupList() {
25
- const response = await client.query({
26
- query: gql`
27
- {
28
- playGroups {
29
- items {
30
- id
31
- name
32
- description
33
- }
34
- total
35
- }
36
- }
37
- `
38
- })
39
-
40
- return response.data
41
- }
42
-
43
- export async function fetchPlayGroup(groupId: string) {
44
- const response = await client.query({
45
- query: gql`
46
- query FetchPlayGroup($id: String!) {
47
- playGroup(id: $id) {
48
- id
49
- name
50
- description
51
- boards {
52
- id
53
- name
54
- description
55
- model
56
- thumbnail
57
- createdAt
58
- creator {
59
- id
60
- name
61
- }
62
- updatedAt
63
- updater {
64
- id
65
- name
66
- }
67
- }
68
- createdAt
69
- creator {
70
- id
71
- name
72
- }
73
- updatedAt
74
- updater {
75
- id
76
- name
77
- }
78
- }
79
- }
80
- `,
81
- variables: {
82
- id: groupId
83
- }
84
- })
85
-
86
- return response.data
87
- }
88
-
89
- export async function fetchPlayGroupByName(name: string) {
90
- const response = await client.query({
91
- query: gql`
92
- query FetchPlayGroupByName($name: String!) {
93
- playGroupByName(name: $name) {
94
- id
95
- }
96
- }
97
- `,
98
- variables: {
99
- name
100
- }
101
- })
102
-
103
- return response.data.playGroupByName
104
- }
105
-
106
- export async function createPlayGroup(group: PlayGroup) {
107
- var { name, description } = group
108
-
109
- const response = await client.mutate({
110
- mutation: gql`
111
- mutation CreatePlayGroup($playGroup: NewPlayGroup!) {
112
- createPlayGroup(playGroup: $playGroup) {
113
- id
114
- name
115
- description
116
- createdAt
117
- updatedAt
118
- }
119
- }
120
- `,
121
- variables: {
122
- playGroup: { name, description }
123
- }
124
- })
125
-
126
- return response.data
127
- }
128
-
129
- export async function updatePlayGroup(group: PlayGroup) {
130
- var { id, name, description } = group
131
-
132
- const response = await client.mutate({
133
- mutation: gql`
134
- mutation UpdatePlayGroup($id: String!, $patch: PlayGroupPatch!) {
135
- updatePlayGroup(id: $id, patch: $patch) {
136
- id
137
- name
138
- description
139
- createdAt
140
- updatedAt
141
- }
142
- }
143
- `,
144
- variables: {
145
- id,
146
- patch: { name, description }
147
- }
148
- })
149
-
150
- return response.data
151
- }
152
-
153
- export async function deletePlayGroup(id: string) {
154
- const response = await client.mutate({
155
- mutation: gql`
156
- mutation ($id: String!) {
157
- deletePlayGroup(id: $id)
158
- }
159
- `,
160
- variables: {
161
- id
162
- }
163
- })
164
- return response.data
165
- }
166
-
167
- export async function joinPlayGroup(boardId: string, group: PlayGroup) {
168
- var { id, name, description } = group
169
-
170
- const response = await client.mutate({
171
- mutation: gql`
172
- mutation JoinPlayGroup($id: String!, $boardIds: [String!]!) {
173
- joinPlayGroup(id: $id, boardIds: $boardIds) {
174
- id
175
- name
176
- description
177
- boards {
178
- id
179
- name
180
- description
181
- createdAt
182
- updatedAt
183
- }
184
- createdAt
185
- updatedAt
186
- }
187
- }
188
- `,
189
- variables: {
190
- id,
191
- boardIds: [boardId]
192
- }
193
- })
194
-
195
- return response.data
196
- }
197
-
198
- export async function leavePlayGroup(boardId: string, groupId: string) {
199
- const response = await client.mutate({
200
- mutation: gql`
201
- mutation ($id: String!, $boardIds: [String]!) {
202
- leavePlayGroup(id: $id, boardIds: $boardIds) {
203
- id
204
- name
205
- description
206
- boards {
207
- id
208
- name
209
- description
210
- createdAt
211
- updatedAt
212
- }
213
- createdAt
214
- updatedAt
215
- }
216
- }
217
- `,
218
- variables: {
219
- id: groupId,
220
- boardIds: [boardId]
221
- }
222
- })
223
-
224
- return response.data
225
- }
@@ -1,79 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- import { client } from '@operato/graphql'
4
-
5
- export const scenarios = async (): Promise<{ name: string; description: string }[]> => {
6
- var response = await client.query({
7
- query: gql`
8
- query {
9
- scenarios {
10
- items {
11
- name
12
- description
13
- }
14
- }
15
- }
16
- `
17
- })
18
-
19
- if (response.errors) {
20
- return []
21
- }
22
-
23
- return response.data.scenarios.items
24
- }
25
-
26
- export const startScenario = async (
27
- scenarioName: string,
28
- instanceName: string,
29
- variables: string | number | object
30
- ) => {
31
- if (!scenarioName) {
32
- return
33
- }
34
-
35
- if (client) {
36
- var response = await client.query({
37
- query: gql`
38
- mutation ($instanceName: String, $scenarioName: String!, $variables: Object) {
39
- startScenario(instanceName: $instanceName, scenarioName: $scenarioName, variables: $variables) {
40
- state
41
- message
42
- data
43
- }
44
- }
45
- `,
46
- variables: {
47
- instanceName: instanceName,
48
- scenarioName: scenarioName,
49
- variables
50
- }
51
- })
52
-
53
- return response?.data?.startScenario?.data
54
- }
55
- }
56
-
57
- export const runScenario = async (scenarioName: string, variables: string | number | object) => {
58
- if (!scenarioName) return
59
-
60
- if (client) {
61
- var response = await client.query({
62
- query: gql`
63
- mutation ($scenarioName: String!, $variables: Object) {
64
- runScenario(scenarioName: $scenarioName, variables: $variables) {
65
- state
66
- message
67
- data
68
- }
69
- }
70
- `,
71
- variables: {
72
- scenarioName: scenarioName,
73
- variables
74
- }
75
- })
76
-
77
- return response?.data?.runScenario?.data
78
- }
79
- }
package/src/index.ts DELETED
@@ -1,8 +0,0 @@
1
- export { OxPropertyPanel } from './ox-property-panel.js'
2
-
3
- export * from './property-panel/data-binding/data-binding.js'
4
- export * from './property-panel/effects/effects.js'
5
- export * from './property-panel/inspector/inspector.js'
6
- export * from './property-panel/shapes/shapes.js'
7
- export * from './property-panel/specifics/specifics.js'
8
- export * from './property-panel/styles/styles.js'
@@ -1,347 +0,0 @@
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
- }