@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,74 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@material/web/icon/icon.js'
6
+ import '@operato/help/ox-title-with-help.js'
7
+
8
+ import { css, html, LitElement } from 'lit'
9
+ import { property, state } from 'lit/decorators.js'
10
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements'
11
+
12
+ import { Properties, Scene } from '@hatiolab/things-scene'
13
+ import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js'
14
+
15
+ import { PropertyAnimation } from './property-animation.js'
16
+ import { convert } from './value-converter.js'
17
+
18
+ export class PropertyAnimations extends ScopedElementsMixin(LitElement) {
19
+ static styles = [PropertyGridStyles]
20
+
21
+ @property({ type: Object }) value?: Properties
22
+ @property({ type: Object }) scene!: Scene
23
+
24
+ @state() _expanded: boolean = false
25
+
26
+ firstUpdated() {
27
+ this.renderRoot.addEventListener('change', this.onValueChange.bind(this))
28
+ }
29
+
30
+ static get scopedElements() {
31
+ return {
32
+ 'property-animation': PropertyAnimation
33
+ }
34
+ }
35
+
36
+ render() {
37
+ const value = this.value || {}
38
+
39
+ return html`
40
+ <fieldset collapsable ?collapsed=${!this._expanded}>
41
+ <legend>
42
+ <ox-title-with-help topic="board-modeller/effects/animation" msgid="label.animation"
43
+ >animation</ox-title-with-help
44
+ >
45
+ <md-icon
46
+ @click=${() => {
47
+ this._expanded = !this._expanded
48
+ }}
49
+ >${this._expanded ? 'expand_less' : 'expand_more'}</md-icon
50
+ >
51
+ </legend>
52
+
53
+ <property-animation value-key="oncreate" .scene=${this.scene} .value=${value.oncreate || {}}>
54
+ </property-animation>
55
+ </fieldset>
56
+ `
57
+ }
58
+
59
+ onValueChange(e: Event) {
60
+ var element = e.target as HTMLElement
61
+ var key = element.getAttribute('value-key')
62
+
63
+ if (!key) {
64
+ return
65
+ }
66
+
67
+ this.value = {
68
+ ...this.value,
69
+ [key]: convert(element)
70
+ }
71
+
72
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
73
+ }
74
+ }
@@ -0,0 +1,212 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@operato/input/ox-input-data.js'
6
+ import '@operato/i18n/ox-i18n.js'
7
+
8
+ import { css, html, LitElement } from 'lit'
9
+ import { property } from 'lit/decorators.js'
10
+ import { ifDefined } from 'lit/directives/if-defined.js'
11
+
12
+ import { Properties, Scene } from '@hatiolab/things-scene'
13
+ import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js'
14
+
15
+ import { convert } from './value-converter.js'
16
+
17
+ const SETS_ACTION = ['data-set', 'partial-data-set', 'value-set', 'partial-value-set']
18
+
19
+ export class PropertyEventHover extends LitElement {
20
+ static styles = [
21
+ PropertyGridStyles,
22
+ css`
23
+ datalist option.cursor-auto {
24
+ cursor: auto;
25
+ }
26
+
27
+ datalist option.cursor-pointer {
28
+ cursor: pointer;
29
+ }
30
+
31
+ datalist option.cursor-default {
32
+ cursor: default;
33
+ }
34
+
35
+ datalist option.cursor-move {
36
+ cursor: move;
37
+ }
38
+
39
+ datalist option.cursor-text {
40
+ cursor: text;
41
+ }
42
+
43
+ datalist option.cursor-wait {
44
+ cursor: wait;
45
+ }
46
+
47
+ datalist option.cursor-help {
48
+ cursor: help;
49
+ }
50
+
51
+ datalist option.cursor-crosshair {
52
+ cursor: crosshair;
53
+ }
54
+
55
+ datalist option.cursor-not-allowed {
56
+ cursor: not-allowed;
57
+ }
58
+
59
+ datalist option.cursor-grab {
60
+ cursor: grab;
61
+ }
62
+ `
63
+ ]
64
+
65
+ @property({ type: Object }) value?: Properties
66
+ @property({ type: Object }) scene?: Scene
67
+
68
+ firstUpdated() {
69
+ this.renderRoot.addEventListener('change', this.onValueChange.bind(this))
70
+ }
71
+
72
+ render() {
73
+ var { action, value = '', target = '', emphasize, restore } = this.value || {}
74
+
75
+ return html`
76
+ <div class="property-grid">
77
+ <input id="checkbox-emphasize" type="checkbox" value-key="emphasize" .checked=${emphasize} />
78
+ <label for="checkbox-emphasize" class="checkbox-label">
79
+ <ox-i18n msgid="label.emphasize">emphasize</ox-i18n>
80
+ </label>
81
+
82
+ <label> <ox-i18n msgid="label.action">action</ox-i18n> </label>
83
+ <select id="tap-select" value-key="action" .value=${action || ''}>
84
+ <option value=""></option>
85
+ <option value="popup">popup target board</option>
86
+ <option value="info-window">open infowindow</option>
87
+ <option value="data-toggle">toggle(true/false) target component data</option>
88
+ <option value="data-tristate">tristate(0/1/2) target component data</option>
89
+ <option value="data-set">set value to target component data</option>
90
+ <option value="value-set">set value to target component value</option>
91
+ <option value="mouse-cursor">change mouse cursor to target style</option>
92
+ </select>
93
+
94
+ <label> <ox-i18n msgid="label.target">target</ox-i18n> </label>
95
+
96
+ ${action == 'popup'
97
+ ? html`
98
+ <ox-editor-board-selector
99
+ class="custom-editor"
100
+ value-key="target"
101
+ .value=${target}
102
+ ></ox-editor-board-selector>
103
+ `
104
+ : html`
105
+ <input
106
+ value-key="target"
107
+ .value=${target || ''}
108
+ list="target-list"
109
+ .placeholder="${this._getPlaceHoder(action)}"
110
+ />
111
+
112
+ <datalist id="target-list">
113
+ ${this._getTargetList(action).map(
114
+ ({ value, description, class: clazz }) => html`
115
+ <option .value=${value} class=${ifDefined(clazz)}>${description}</option>
116
+ `
117
+ )}
118
+ </datalist>
119
+ `}
120
+ ${SETS_ACTION.indexOf(action) != -1
121
+ ? html`
122
+ <label> <ox-i18n msgid="label.value">value</ox-i18n> </label>
123
+ <ox-input-data
124
+ class="custom-editor property-full-bleed"
125
+ value-key="value"
126
+ .value=${value}
127
+ fullwidth
128
+ ></ox-input-data>
129
+ `
130
+ : html``}
131
+
132
+ <input id="checkbox-restore" type="checkbox" value-key="restore" .checked=${restore} />
133
+ <label for="checkbox-restore" class="checkbox-label">
134
+ <ox-i18n msgid="label.restore-on-leave">restore on leave</ox-i18n>
135
+ </label>
136
+ </div>
137
+ `
138
+ }
139
+
140
+ _getPlaceHoder(action: string) {
141
+ switch (action) {
142
+ case 'popup':
143
+ case 'goto':
144
+ return 'SCENE-100'
145
+ case 'link-open':
146
+ case 'link-move':
147
+ return 'http://www.hatiolab.com/'
148
+ default:
149
+ return ''
150
+ }
151
+ }
152
+
153
+ _getTargetList(action: string): { value: string; description?: string; class?: string }[] {
154
+ switch (action) {
155
+ case 'data-toggle':
156
+ case 'data-tristate':
157
+ case 'data-set':
158
+ case 'value-set':
159
+ case 'partial-data-set':
160
+ case 'partial-value-set':
161
+ let ids =
162
+ (this.scene &&
163
+ this.scene.ids.map(i => {
164
+ const id = i.key
165
+ return { value: `#${id}`, description: this.scene!.findById(id)?.get('type') }
166
+ })) ||
167
+ []
168
+ ids.unshift({ value: '(self)', description: 'self component' })
169
+ return ids
170
+
171
+ case 'info-window':
172
+ return (
173
+ (this.scene &&
174
+ this.scene.ids
175
+ .filter(i => {
176
+ return this.scene!.findById(i.key).get('type') == 'info-window'
177
+ })
178
+ .map(i => {
179
+ const id = i.key
180
+ return { value: `#${id}`, description: this.scene!.findById(id)?.get('type') }
181
+ })) ||
182
+ []
183
+ )
184
+
185
+ case 'mouse-cursor':
186
+ return ['auto', 'pointer', 'default', 'move', 'text', 'wait', 'help', 'crosshair', 'not-allowed', 'grab'].map(
187
+ style => {
188
+ return { value: style, class: `cursor-${style}` }
189
+ }
190
+ )
191
+
192
+ default:
193
+ return []
194
+ }
195
+ }
196
+
197
+ onValueChange(e: Event) {
198
+ var element = e.target as HTMLElement
199
+ var key = element.getAttribute('value-key')
200
+
201
+ if (!key) {
202
+ return
203
+ }
204
+
205
+ this.value = {
206
+ ...this.value,
207
+ [key]: convert(element)
208
+ }
209
+
210
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
211
+ }
212
+ }
@@ -0,0 +1,269 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@operato/input/ox-input-data.js'
6
+ import '@operato/i18n/ox-i18n.js'
7
+
8
+ import { css, html, LitElement } from 'lit'
9
+ import { property, state } from 'lit/decorators.js'
10
+
11
+ import { Properties, Scene } from '@hatiolab/things-scene'
12
+ import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js'
13
+
14
+ import { scenarios } from '../../graphql/scenario.js'
15
+ import { playlists } from '../../graphql/play-group.js'
16
+ import { convert } from './value-converter.js'
17
+
18
+ const SETS_ACTION = ['data-set', 'partial-data-set', 'value-set', 'partial-value-set', 'start-scenario', 'run-scenario']
19
+
20
+ export class PropertyEventTap extends LitElement {
21
+ static styles = [
22
+ PropertyGridStyles,
23
+ css`
24
+ :host {
25
+ display: flex;
26
+ }
27
+ `
28
+ ]
29
+
30
+ @property({ type: Object }) value?: Properties
31
+ @property({ type: Object }) scene?: Scene
32
+
33
+ @state() scenarios: { value: string; description: string }[] = []
34
+ @state() playlists: { value: string; description: string }[] = []
35
+ @state() targetList: { value: string; description: string }[] = []
36
+
37
+ async firstUpdated() {
38
+ this.renderRoot.addEventListener('change', this.onValueChange.bind(this))
39
+ }
40
+
41
+ render() {
42
+ var { action, value = '', target = '', pressed, options } = this.value || {}
43
+ var { input = '(self)', output = true } = options || {}
44
+
45
+ return html`
46
+ <div class="property-grid">
47
+ <input id="checkbox-pressed" type="checkbox" value-key="pressed" .checked=${pressed} />
48
+ <label for="checkbox-pressed" class="checkbox-label"> <ox-i18n msgid="label.pressed">pressed</ox-i18n> </label>
49
+
50
+ <label> <ox-i18n msgid="label.action">action</ox-i18n> </label>
51
+ <select
52
+ id="tap-select"
53
+ value-key="action"
54
+ .value=${action || ''}
55
+ @change=${async (e: Event) => {
56
+ if ((e.target as HTMLSelectElement).value.includes('scenario')) {
57
+ this.scenarios = (await scenarios()).map(({ name, description }) => {
58
+ return { value: name, description }
59
+ })
60
+ } else if ((e.target as HTMLSelectElement).value == 'goto-playlist') {
61
+ this.playlists = (await playlists()).map(({ name, description }) => {
62
+ return { value: name, description }
63
+ })
64
+ }
65
+ }}
66
+ >
67
+ <option value=""></option>
68
+ <option value="goto">go to target board</option>
69
+ <option value="goto-playlist">go to target playlist</option>
70
+ <option value="link-open">open new window for target link</option>
71
+ <option value="link-move">move to target link</option>
72
+ <option value="route-page">route to page</option>
73
+ <option value="popup">popup target board</option>
74
+ <option value="modal-popup">modal popup target board</option>
75
+ <option value="close-scene">close current board</option>
76
+ <option value="infoWindow">open infowindow</option>
77
+ <option value="toggle-info-window">toggle infowindow</option>
78
+ <option value="data-toggle">toggle(true/false) target component data</option>
79
+ <option value="data-tristate">tristate(0/1/2) target component data</option>
80
+ <option value="data-spreading">forcely execute data spreading of target component</option>
81
+ <option value="data-set">set value to target component data</option>
82
+ <option value="partial-data-set">set partial value to target component data</option>
83
+ <option value="value-set">set value to target component value</option>
84
+ <option value="partial-value-set">set partial value to target component value</option>
85
+ <option value="start-scenario">start the given scenario</option>
86
+ <option value="run-scenario">run the given scenario</option>
87
+ <option value="export-data">export data</option>
88
+ <option value="import-data">import data</option>
89
+ </select>
90
+
91
+ <label> <ox-i18n msgid="label.target">target</ox-i18n> </label>
92
+
93
+ ${action === 'goto' || action?.includes('popup')
94
+ ? html`
95
+ <ox-editor-board-selector
96
+ class="custom-editor"
97
+ value-key="target"
98
+ .value=${target}
99
+ ></ox-editor-board-selector>
100
+ `
101
+ : html`
102
+ <input
103
+ value-key="target"
104
+ .value=${target}
105
+ list="target-list"
106
+ .placeholder=${this._getPlaceHoder(action)}
107
+ @focusin=${() => {
108
+ this.targetList = this._getTargetList(action)
109
+ }}
110
+ />
111
+
112
+ <datalist id="target-list">
113
+ ${this.targetList.map(
114
+ ({ value, description }) => html` <option .value=${value}>${description}</option> `
115
+ )}
116
+ </datalist>
117
+ `}
118
+ ${action === 'goto' || action === 'goto-playlist' || action?.includes('popup')
119
+ ? html`
120
+ <label for="input"> <ox-i18n msgid="label.input-data">input</ox-i18n> </label>
121
+ <input
122
+ id="input"
123
+ value-key="input"
124
+ .value=${input}
125
+ list="input-list"
126
+ @focusin=${() => {
127
+ this.targetList = this._getInputList(action)
128
+ }}
129
+ />
130
+ <datalist id="input-list">
131
+ ${this.targetList.map(
132
+ ({ value, description }) => html` <option .value=${value}>${description}</option> `
133
+ )}
134
+ </datalist>
135
+ ${
136
+ /* currently 'goto' does not support returning result */
137
+ action?.includes('popup')
138
+ ? html` <input id="checkbox-output" type="checkbox" value-key="output" .checked=${output} />
139
+ <label for="checkbox-output" class="checkbox-label">
140
+ <ox-i18n msgid="label.will-get-return">will-get-return</ox-i18n>
141
+ </label>`
142
+ : html``
143
+ }
144
+ `
145
+ : SETS_ACTION.indexOf(action) != -1
146
+ ? html`
147
+ <label> <ox-i18n msgid="label.value">value</ox-i18n> </label>
148
+ <ox-input-data
149
+ class="custom-editor property-full-bleed"
150
+ value-key="value"
151
+ .value=${value}
152
+ fullwidth
153
+ ></ox-input-data>
154
+ `
155
+ : html``}
156
+ </div>
157
+ `
158
+ }
159
+
160
+ _getPlaceHoder(action: string) {
161
+ switch (action) {
162
+ case 'link-open':
163
+ case 'link-move':
164
+ return 'http://www.hatiolab.com/'
165
+ case 'export-data':
166
+ return 'abc.xlsx'
167
+ default:
168
+ return ''
169
+ }
170
+ }
171
+
172
+ _getTargetList(action: string): { value: string; description: string }[] {
173
+ switch (action) {
174
+ case 'data-toggle':
175
+ case 'data-tristate':
176
+ case 'data-set':
177
+ case 'value-set':
178
+ case 'popup':
179
+ case 'modal-popup':
180
+ case 'data-spreading':
181
+ let ids =
182
+ (this.scene &&
183
+ this.scene.ids.map(i => {
184
+ const id = i.key
185
+ return { value: `#${id}`, description: this.scene!.findById(id)?.get('type') }
186
+ })) ||
187
+ []
188
+ ids.unshift({ value: '(self)', description: 'self component' })
189
+ return ids
190
+ case 'infoWindow':
191
+ case 'toggle-info-window':
192
+ return (
193
+ (this.scene &&
194
+ this.scene.ids
195
+ .filter(i => {
196
+ return this.scene!.findById(i.key).get('type') == 'info-window'
197
+ })
198
+ .map(i => {
199
+ const id = i.key
200
+ return { value: `#${id}`, description: this.scene!.findById(id)?.get('type') }
201
+ })) ||
202
+ []
203
+ )
204
+ case 'start-scenario':
205
+ case 'run-scenario':
206
+ return this.scenarios
207
+ case 'goto-playlist':
208
+ return this.playlists
209
+ case 'export-data':
210
+ default:
211
+ return []
212
+ }
213
+ }
214
+
215
+ _getInputList(action: string): { value: string; description: string }[] {
216
+ switch (action) {
217
+ case 'popup':
218
+ case 'modal-popup':
219
+ case 'data-spreading':
220
+ case 'goto':
221
+ case 'goto-playlist':
222
+ let ids =
223
+ (this.scene &&
224
+ this.scene.ids.map(i => {
225
+ const id = i.key
226
+ return { value: `#${id}`, description: this.scene!.findById(id)?.get('type') }
227
+ })) ||
228
+ []
229
+ ids.unshift({ value: '(self)', description: 'self component' })
230
+ return ids
231
+ default:
232
+ return []
233
+ }
234
+ }
235
+
236
+ onValueChange(e: Event) {
237
+ var element = e.target as HTMLElement
238
+ var key = element.getAttribute('value-key')
239
+
240
+ if (!key) {
241
+ return
242
+ }
243
+
244
+ if (key === 'input' || key === 'output') {
245
+ var { options = {} } = this.value || {}
246
+
247
+ this.value = {
248
+ ...this.value,
249
+ options: {
250
+ ...options,
251
+ [key]: convert(element)
252
+ }
253
+ }
254
+ } else {
255
+ this.value = {
256
+ ...this.value,
257
+ [key]: convert(element)
258
+ }
259
+ }
260
+
261
+ var { action } = this.value
262
+ if (action !== 'goto' && action !== 'goto-playlist' && !action?.includes('popup')) {
263
+ /* clear unused options */
264
+ delete this.value.options
265
+ }
266
+
267
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
268
+ }
269
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@operato/help/ox-title-with-help.js'
6
+
7
+ import { html, LitElement } from 'lit'
8
+ import { property } from 'lit/decorators.js'
9
+
10
+ import { Properties, Scene } from '@hatiolab/things-scene'
11
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements'
12
+ import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js'
13
+
14
+ import { PropertyEventHover } from './property-event-hover.js'
15
+ import { PropertyEventTap } from './property-event-tap.js'
16
+ import { convert } from './value-converter.js'
17
+
18
+ export class PropertyEvent extends ScopedElementsMixin(LitElement) {
19
+ static styles = [PropertyGridStyles]
20
+
21
+ @property({ type: Object }) value?: Properties
22
+ @property({ type: Object }) scene?: Scene
23
+
24
+ firstUpdated() {
25
+ this.renderRoot.addEventListener('change', this.onValueChange.bind(this))
26
+ }
27
+
28
+ static get scopedElements() {
29
+ return {
30
+ 'property-event-hover': PropertyEventHover,
31
+ 'property-event-tap': PropertyEventTap
32
+ }
33
+ }
34
+
35
+ render() {
36
+ const value = this.value || {}
37
+
38
+ return html`
39
+ <fieldset>
40
+ <legend>
41
+ <ox-title-with-help msgid="label.hover-event" topic="board-modeller/effects/hover-event"></ox-title-with-help>
42
+ </legend>
43
+
44
+ <property-event-hover value-key="hover" .scene=${this.scene} .value=${value.hover || {}}>
45
+ </property-event-hover>
46
+ </fieldset>
47
+
48
+ <fieldset>
49
+ <legend>
50
+ <ox-title-with-help msgid="label.tap-event" topic="board-modeller/effects/tap-event"></ox-title-with-help>
51
+ </legend>
52
+
53
+ <property-event-tap value-key="tap" .scene=${this.scene} .value=${value.tap || {}}> </property-event-tap>
54
+ </fieldset>
55
+ `
56
+ }
57
+
58
+ onValueChange(e: Event) {
59
+ var element = e.target as HTMLElement
60
+ var key = element.getAttribute('value-key')
61
+
62
+ if (!key) {
63
+ return
64
+ }
65
+
66
+ this.value = {
67
+ ...this.value,
68
+ [key]: convert(element)
69
+ }
70
+
71
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
72
+ }
73
+ }