@operato/process 1.1.27 → 1.1.29

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 (25) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/src/modeller/property-sidebar/data-binding/data-binding-mapper.d.ts +54 -0
  3. package/dist/src/modeller/property-sidebar/data-binding/data-binding-mapper.js +389 -0
  4. package/dist/src/modeller/property-sidebar/data-binding/data-binding-mapper.js.map +1 -0
  5. package/dist/src/modeller/property-sidebar/data-binding/data-binding.d.ts +44 -0
  6. package/dist/src/modeller/property-sidebar/data-binding/data-binding.js +455 -0
  7. package/dist/src/modeller/property-sidebar/data-binding/data-binding.js.map +1 -0
  8. package/dist/src/modeller/property-sidebar/effects/property-event-hover.js +6 -1
  9. package/dist/src/modeller/property-sidebar/effects/property-event-hover.js.map +1 -1
  10. package/dist/src/modeller/property-sidebar/effects/property-event-tap.js +18 -9
  11. package/dist/src/modeller/property-sidebar/effects/property-event-tap.js.map +1 -1
  12. package/dist/src/modeller/property-sidebar/property-sidebar.d.ts +2 -0
  13. package/dist/src/modeller/property-sidebar/property-sidebar.js +11 -0
  14. package/dist/src/modeller/property-sidebar/property-sidebar.js.map +1 -1
  15. package/dist/src/ox-process-viewer.d.ts +1 -0
  16. package/dist/src/ox-process-viewer.js +5 -0
  17. package/dist/src/ox-process-viewer.js.map +1 -1
  18. package/dist/tsconfig.tsbuildinfo +1 -1
  19. package/package.json +11 -11
  20. package/src/modeller/property-sidebar/data-binding/data-binding-mapper.ts +419 -0
  21. package/src/modeller/property-sidebar/data-binding/data-binding.ts +476 -0
  22. package/src/modeller/property-sidebar/effects/property-event-hover.ts +6 -1
  23. package/src/modeller/property-sidebar/effects/property-event-tap.ts +16 -7
  24. package/src/modeller/property-sidebar/property-sidebar.ts +11 -0
  25. package/src/ox-process-viewer.ts +6 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/process",
3
- "version": "1.1.27",
3
+ "version": "1.1.29",
4
4
  "description": "Webcomponent for business process modeling following open-wc recommendations",
5
5
  "author": "heartyoh",
6
6
  "main": "dist/src/index.js",
@@ -51,17 +51,17 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@open-wc/scoped-elements": "^2.1.3",
54
- "@operato/app": "^1.1.27",
55
- "@operato/board": "^1.1.27",
56
- "@operato/data-grist": "^1.1.27",
57
- "@operato/font": "^1.1.27",
54
+ "@operato/app": "^1.1.28",
55
+ "@operato/board": "^1.1.29",
56
+ "@operato/data-grist": "^1.1.28",
57
+ "@operato/font": "^1.1.28",
58
58
  "@operato/graphql": "^1.1.13",
59
59
  "@operato/i18n": "^1.1.13",
60
- "@operato/input": "^1.1.27",
61
- "@operato/markdown": "^1.1.13",
62
- "@operato/popup": "^1.1.23",
63
- "@operato/property-editor": "^1.1.27",
64
- "@operato/styles": "^1.1.13",
60
+ "@operato/input": "^1.1.28",
61
+ "@operato/markdown": "^1.1.28",
62
+ "@operato/popup": "^1.1.28",
63
+ "@operato/property-editor": "^1.1.28",
64
+ "@operato/styles": "^1.1.28",
65
65
  "@operato/utils": "^1.1.15",
66
66
  "@polymer/paper-dropdown-menu": "^3.2.0",
67
67
  "@types/file-saver": "^2.0.4",
@@ -111,5 +111,5 @@
111
111
  "prettier --write"
112
112
  ]
113
113
  },
114
- "gitHead": "5605397be78c3f388251d275cd7d0f41c6ba53ff"
114
+ "gitHead": "73c9f4d35069d5644cfeb227c1b42ce0de71dc3e"
115
115
  }
@@ -0,0 +1,419 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@operato/input/ox-input-value-map.js'
6
+ import '@operato/input/ox-input-value-ranges.js'
7
+ import '@operato/input/ox-buttons-radio.js'
8
+ import '@operato/input/ox-input-code.js'
9
+ import '@operato/i18n/ox-i18n.js'
10
+ import '@operato/help/ox-help-icon.js'
11
+
12
+ import { css, html, LitElement, PropertyValues } from 'lit'
13
+ import { property, query, state } from 'lit/decorators.js'
14
+
15
+ import { Properties, Scene } from '@hatiolab/things-scene'
16
+
17
+ export type Rule =
18
+ | {
19
+ map?: Properties
20
+ range?: Properties[]
21
+ eval?: string
22
+ }
23
+ | any
24
+
25
+ export type Mapping = {
26
+ rule: 'map' | 'range' | 'eval' | 'value'
27
+ accessor?: string
28
+ target?: string
29
+ property?: string
30
+ param?: Rule
31
+ ndnsp?: boolean
32
+ }
33
+
34
+ /**
35
+ element for mapping data value editing
36
+
37
+ Example:
38
+
39
+ <data-binding-mapper mapping=${mapping}>
40
+ </data-binding-mapper>
41
+ */
42
+
43
+ export class DataBindingMapper extends LitElement {
44
+ static styles = [
45
+ css`
46
+ :host {
47
+ background-color: rgba(255, 255, 255, 0.5);
48
+ overflow: hidden;
49
+ padding: 7px 0 0 0;
50
+ border: 1px solid rgba(0, 0, 0, 0.2);
51
+ border-width: 0 1px 1px 1px;
52
+ padding: 4px;
53
+ line-height: 2;
54
+
55
+ display: grid;
56
+ grid-template-columns: repeat(10, 1fr);
57
+ grid-gap: 4px;
58
+ grid-auto-rows: minmax(24px, auto);
59
+
60
+ align-items: center;
61
+ }
62
+
63
+ :host > * {
64
+ align-self: stretch;
65
+ }
66
+
67
+ label {
68
+ grid-column: span 3;
69
+ text-align: right;
70
+ text-transform: capitalize;
71
+ }
72
+
73
+ input,
74
+ select,
75
+ ox-buttons-radio,
76
+ [mapping-rule] {
77
+ grid-column: span 7;
78
+ }
79
+ input,
80
+ select {
81
+ border: var(--property-sidebar-fieldset-border);
82
+ }
83
+
84
+ ox-buttons-radio {
85
+ display: flex;
86
+ padding: 0 4px;
87
+ }
88
+
89
+ ox-buttons-radio > * {
90
+ text-align: center;
91
+ flex: 1;
92
+ margin: 2px;
93
+ border-bottom: 2px solid #fff;
94
+ }
95
+
96
+ ox-buttons-radio div[active] {
97
+ border-color: #f2471c;
98
+ }
99
+
100
+ select {
101
+ height: 22px;
102
+ }
103
+
104
+ [mapping-rule] {
105
+ display: flex;
106
+ }
107
+
108
+ [mapping-rule] * {
109
+ flex: auto;
110
+ margin: 0;
111
+ text-align: left;
112
+ align-self: center;
113
+ }
114
+
115
+ [rule-editors] {
116
+ grid-column: span 10;
117
+
118
+ display: 'flex';
119
+ align-content: auto;
120
+ }
121
+
122
+ [rule-editors] :not([active]) {
123
+ display: none;
124
+ }
125
+
126
+ ox-input-code {
127
+ height: 300px;
128
+ overflow: auto;
129
+ }
130
+
131
+ /* checkbox-row */
132
+ .checkbox-row {
133
+ grid-column: span 10;
134
+
135
+ display: grid;
136
+ grid-template-columns: repeat(10, 1fr);
137
+ grid-gap: 5px;
138
+ grid-auto-rows: minmax(24px, auto);
139
+ align-items: center;
140
+ }
141
+
142
+ .checkbox-row > input {
143
+ grid-column: 4 / 5;
144
+ }
145
+
146
+ .checkbox-row > label {
147
+ grid-column: span 6;
148
+ text-align: left;
149
+ }
150
+ `
151
+ ]
152
+
153
+ @property({ type: Object }) mapping: Mapping = {
154
+ rule: 'value'
155
+ }
156
+ @property({ type: Object }) rule: Rule = {}
157
+ @property({ type: Array }) properties: Properties[] = []
158
+ @property({ type: Object }) scene?: Scene
159
+
160
+ @state() _valueTypes: any = {
161
+ play: 'boolean',
162
+ hidden: 'boolean',
163
+ started: 'boolean',
164
+
165
+ rotation: 'number',
166
+ value: 'number',
167
+
168
+ fillStyle: 'color',
169
+ strokeStyle: 'color',
170
+ fontColor: 'color',
171
+
172
+ data: 'object',
173
+ source: 'object',
174
+ location: 'object',
175
+ dimension: 'object',
176
+
177
+ text: 'string',
178
+ ref: 'string'
179
+ }
180
+ @state() _componentIds: { value: string; description: string }[] = []
181
+
182
+ @query('#eval-editor') editor!: HTMLInputElement
183
+ @query('#target-input') target!: HTMLInputElement
184
+
185
+ firstUpdated() {
186
+ this.renderRoot.addEventListener('change', e => this._onChange(e))
187
+ }
188
+
189
+ updated(changes: PropertyValues<this>) {
190
+ changes.has('mapping') && this._onChangedMapping()
191
+ }
192
+
193
+ render() {
194
+ const mapping = this.mapping || {
195
+ rule: 'value'
196
+ }
197
+
198
+ return html`
199
+ <label for="accessor-input"> <ox-i18n msgid="label.accessor">accessor</ox-i18n><ox-help-icon topic="board-modeller/accessor"> </label>
200
+ <input
201
+ id="accessor-input"
202
+ value-key="accessor"
203
+ type="text"
204
+ data-mapping-accessor
205
+ .value=${mapping.accessor || ''}
206
+ />
207
+
208
+ <label for="target-input"> <ox-i18n msgid="label.target">target</ox-i18n> </label>
209
+ <input
210
+ id="target-input"
211
+ type="text"
212
+ value-key="target"
213
+ list="target-list"
214
+ .value=${mapping.target || ''}
215
+ @focusin=${() => {
216
+ this._componentIds =
217
+ (this.scene &&
218
+ this.scene.ids.map(i => {
219
+ const id = i.key
220
+ return { value: `#${id}`, description: this.scene!.findById(id)?.get('type') }
221
+ })) ||
222
+ []
223
+ }}
224
+ />
225
+ <datalist id="target-list">
226
+ <option value="(self)"></option>
227
+ <option value="(key)"></option>
228
+ <option value="[propkey]"></option>
229
+ ${
230
+ this._componentIds.length
231
+ ? html`
232
+ ${this._componentIds.map(
233
+ ({ value, description }) => html` <option value=${value}>${description}</option> `
234
+ )}
235
+ `
236
+ : html``
237
+ }
238
+ </datalist>
239
+
240
+ <label for="property-input"> <ox-i18n msgid="label.property">property</ox-i18n> </label>
241
+ <select id="property-input" value-key="property" .value=${mapping.property}>
242
+ ${this.properties.map(
243
+ item => html` <option .value=${item.name} ?selected=${item.name == mapping.property}>${item.label}</option> `
244
+ )}
245
+ </select>
246
+
247
+ <label> <ox-i18n msgid="label.rule-type">rule type</ox-i18n> </label>
248
+ <ox-buttons-radio .value=${mapping.rule} @change=${(e: Event) => this._onChangeRule(e)}>
249
+ <div data-value="value"><ox-i18n msgid="label.value"></ox-i18n></div>
250
+ <div data-value="map"><ox-i18n msgid="label.map"></ox-i18n></div>
251
+ <div data-value="range"><ox-i18n msgid="label.range"></ox-i18n></div>
252
+ <div data-value="eval"><ox-i18n msgid="label.eval"></ox-i18n></div>
253
+ </ox-buttons-radio>
254
+
255
+ <div rule-editors ?hidden=${mapping.rule == 'value'}>
256
+ <ox-input-value-map
257
+ value-key="map"
258
+ .value=${this.rule.map || {}}
259
+ .valuetype=${this._valuetype(mapping.property!)}
260
+ ?active=${mapping.rule == 'map'}
261
+ >
262
+ </ox-input-value-map>
263
+
264
+ <ox-input-value-ranges
265
+ value-key="range"
266
+ .value=${this.rule.range || []}
267
+ .valuetype=${this._valuetype(mapping.property!)}
268
+ ?active=${mapping.rule == 'range'}
269
+ >
270
+ </ox-input-value-ranges>
271
+
272
+ <ox-input-code
273
+ value-key="eval"
274
+ id="eval-editor"
275
+ .value=${this.rule.eval || ''}
276
+ ?active=${mapping.rule == 'eval'}
277
+ >
278
+ </ox-input-code>
279
+ </div>
280
+
281
+ <div class="checkbox-row">
282
+ <input id="checkbox-ndnsp" type="checkbox" value-key="ndnsp" .checked=${mapping.ndnsp === true} />
283
+ <label for="checkbox-ndnsp"> <ox-i18n msgid="label.ndnsp">No Data No Spreading</ox-i18n> </label>
284
+ </div>
285
+ `
286
+ }
287
+
288
+ _valuetype(property: string) {
289
+ return this._valueTypes[property] || 'string'
290
+ }
291
+
292
+ private _keep_saved_rule_params: boolean = false
293
+
294
+ async _onChangedMapping() {
295
+ if (this._keep_saved_rule_params) {
296
+ this._keep_saved_rule_params = false
297
+ } else {
298
+ await this.updateComplete
299
+
300
+ var rule: Rule = {}
301
+
302
+ if (this.mapping) {
303
+ switch (this.mapping.rule) {
304
+ case 'map':
305
+ rule.map = this.mapping.param || {}
306
+ break
307
+ case 'range':
308
+ rule.range = this.mapping.param || []
309
+ break
310
+ case 'eval':
311
+ rule.eval = this.mapping.param || ''
312
+ break
313
+ default:
314
+ this.mapping.rule = 'value'
315
+ break
316
+ }
317
+ }
318
+
319
+ this.rule = rule
320
+ this.requestUpdate()
321
+ }
322
+ }
323
+
324
+ _onChangeRule(e: Event) {
325
+ var element = e.target as HTMLInputElement
326
+ var value = element.value
327
+
328
+ let param
329
+
330
+ switch (value) {
331
+ case 'map':
332
+ param = this.rule.map
333
+ break
334
+ case 'range':
335
+ param = this.rule.range
336
+ break
337
+ case 'eval':
338
+ param = this.rule.eval || ''
339
+
340
+ // rule.eval에 값이 없을 때, ace-editor 내용이 초기화되지 않는 문제때문에 처리함.
341
+ if (!param) {
342
+ this.editor.value = 'return'
343
+ }
344
+ break
345
+ default:
346
+ }
347
+
348
+ this.mapping = {
349
+ ...this.mapping,
350
+ rule: value as 'value' | 'map' | 'range' | 'eval',
351
+ param
352
+ }
353
+
354
+ this._keep_saved_rule_params = true
355
+ this.dispatchEvent(new CustomEvent('value-change', { bubbles: true, composed: true }))
356
+ }
357
+
358
+ _onChange(e: Event) {
359
+ var element = e.target as HTMLInputElement
360
+ var key = element.getAttribute('value-key')
361
+
362
+ if (!key) return
363
+
364
+ var value: string | boolean = element.value
365
+
366
+ if (key === 'target') {
367
+ if (value.length > 0 && !/^[.#(\[]/.test(value)) {
368
+ value = '#' + value.trim()
369
+
370
+ this.target.value = value
371
+ }
372
+
373
+ this.mapping = {
374
+ ...this.mapping,
375
+ target: value
376
+ }
377
+ } else if (key === 'accessor') {
378
+ this.mapping = {
379
+ ...this.mapping,
380
+ accessor: (value || '').trim()
381
+ }
382
+ } else if (key === 'property') {
383
+ this.mapping = {
384
+ ...this.mapping,
385
+ property: (value || '').trim()
386
+ }
387
+ } else if (key === 'map' || key === 'range' || key === 'eval') {
388
+ this.rule[key] = value
389
+ this.mapping = {
390
+ ...this.mapping,
391
+ param: value
392
+ }
393
+ } else if (key === 'ndnsp' /* no data no spreading */) {
394
+ value = element.checked
395
+
396
+ this.mapping = {
397
+ ...this.mapping,
398
+ ndnsp: value
399
+ }
400
+ }
401
+
402
+ if (!this.mapping.rule) {
403
+ this.mapping.rule = 'value'
404
+ }
405
+
406
+ this._keep_saved_rule_params = true
407
+ this.dispatchEvent(
408
+ new CustomEvent('value-change', {
409
+ bubbles: true,
410
+ composed: true,
411
+ detail: {
412
+ changed: {
413
+ [key]: value
414
+ }
415
+ }
416
+ })
417
+ )
418
+ }
419
+ }