@operato/property-panel 10.0.0-beta.57 → 10.0.0-beta.59
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.
- package/CHANGELOG.md +29 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/property-panel/data-binding/data-binding.js +4 -3
- package/dist/src/property-panel/data-binding/data-binding.js.map +1 -1
- package/dist/src/property-panel/effects/effects.js +1 -1
- package/dist/src/property-panel/effects/effects.js.map +1 -1
- package/dist/src/property-panel/effects/property-event-hover.d.ts +1 -1
- package/dist/src/property-panel/effects/property-event.d.ts +15 -7
- package/dist/src/property-panel/effects/property-event.js +17 -38
- package/dist/src/property-panel/effects/property-event.js.map +1 -1
- package/dist/src/property-panel/event-handlers/event-handlers-help.d.ts +23 -0
- package/dist/src/property-panel/event-handlers/event-handlers-help.js +356 -0
- package/dist/src/property-panel/event-handlers/event-handlers-help.js.map +1 -0
- package/dist/src/property-panel/event-handlers/event-handlers-mapper.d.ts +31 -0
- package/dist/src/property-panel/event-handlers/event-handlers-mapper.js +238 -0
- package/dist/src/property-panel/event-handlers/event-handlers-mapper.js.map +1 -0
- package/dist/src/property-panel/event-handlers/event-handlers-popup.d.ts +42 -0
- package/dist/src/property-panel/event-handlers/event-handlers-popup.js +375 -0
- package/dist/src/property-panel/event-handlers/event-handlers-popup.js.map +1 -0
- package/dist/src/property-panel/event-handlers/event-handlers.d.ts +54 -0
- package/dist/src/property-panel/event-handlers/event-handlers.js +410 -0
- package/dist/src/property-panel/event-handlers/event-handlers.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/translations/en.json +7 -0
- package/translations/ja.json +7 -0
- package/translations/ko.json +7 -0
- package/translations/ms.json +7 -0
- package/translations/zh.json +7 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* EventHandlers panel — 컴포넌트의 `state.eventHandlers[]` 편집기.
|
|
5
|
+
*
|
|
6
|
+
* 데이터바인딩 panel 의 형제로 *완전 분리*. 데이터바인딩은 데이터 흐름 전용,
|
|
7
|
+
* eventHandlers 는 사용자 액션 (tap / hover / 등) 의 first-class 핸들러 등록.
|
|
8
|
+
*
|
|
9
|
+
* data-binding 패턴 그대로 — tabs (N handlers) + handler mapper + add/delete/copy/paste.
|
|
10
|
+
*/
|
|
11
|
+
import { __decorate } from "tslib";
|
|
12
|
+
import '@material/web/icon/icon.js';
|
|
13
|
+
import '@operato/help/ox-title-with-help.js';
|
|
14
|
+
import '@operato/input/ox-buttons-radio.js';
|
|
15
|
+
import '@operato/i18n/ox-i18n.js';
|
|
16
|
+
import { css, html } from 'lit';
|
|
17
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
18
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
19
|
+
import { PropertyGridStyles } from '@operato/styles/property-grid-styles.js';
|
|
20
|
+
import { openPopup } from '@operato/layout';
|
|
21
|
+
import { i18next } from '@operato/i18n';
|
|
22
|
+
import { AbstractProperty } from '../abstract-property.js';
|
|
23
|
+
import { EventHandlersMapper } from './event-handlers-mapper.js';
|
|
24
|
+
var clipboard = '{"trigger":"click","action":""}';
|
|
25
|
+
export class PropertyEventHandlers extends ScopedElementsMixin(AbstractProperty) {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.handlerIndex = 0;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 두 속성 통합 — 신규 `eventHandlers` 우선, 없으면 legacy `event` 객체를
|
|
32
|
+
* *read-only* 변환해 표시. 사용자가 수정 시 `eventHandlers` 에만 저장 — legacy
|
|
33
|
+
* 는 손대지 않음 (옛 코드 호환 / rollback 안전망).
|
|
34
|
+
*/
|
|
35
|
+
get handlers() {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
const v = this.value;
|
|
38
|
+
if (!v)
|
|
39
|
+
return [];
|
|
40
|
+
// 1. 신규
|
|
41
|
+
if (Array.isArray(v.eventHandlers))
|
|
42
|
+
return v.eventHandlers;
|
|
43
|
+
// 2. legacy 객체 → 변환 (표시만, 저장 시점이 아님)
|
|
44
|
+
const ev = v.event;
|
|
45
|
+
if (!ev || typeof ev !== 'object' || Array.isArray(ev))
|
|
46
|
+
return [];
|
|
47
|
+
const trigMap = {
|
|
48
|
+
tap: 'click',
|
|
49
|
+
hover: 'mouseenter',
|
|
50
|
+
dblclick: 'dblclick',
|
|
51
|
+
longpress: 'longpress'
|
|
52
|
+
};
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const key of Object.keys(ev)) {
|
|
55
|
+
const trig = trigMap[key];
|
|
56
|
+
const e = ev[key];
|
|
57
|
+
if (!trig || !e || typeof e !== 'object')
|
|
58
|
+
continue;
|
|
59
|
+
if (e.action === 'script') {
|
|
60
|
+
const code = typeof e.value === 'string' ? e.value : ((_b = (_a = e.value) === null || _a === void 0 ? void 0 : _a.script) !== null && _b !== void 0 ? _b : '');
|
|
61
|
+
out.push({ trigger: trig, action: 'script', code, target: e.target });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
out.push({
|
|
65
|
+
trigger: trig,
|
|
66
|
+
action: e.action,
|
|
67
|
+
target: e.target,
|
|
68
|
+
value: e.value,
|
|
69
|
+
options: { emphasize: e.emphasize, restore: e.restore, pressed: e.pressed, ...((_c = e.options) !== null && _c !== void 0 ? _c : {}) }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
firstUpdated() {
|
|
76
|
+
this.tabContainer.addEventListener('scroll', () => this._onTabScroll());
|
|
77
|
+
}
|
|
78
|
+
updated(changes) {
|
|
79
|
+
if (changes.has('value')) {
|
|
80
|
+
this.onValueChanged();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
static get scopedElements() {
|
|
84
|
+
return {
|
|
85
|
+
'event-handlers-mapper': EventHandlersMapper
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
render() {
|
|
89
|
+
const handlers = this.handlers;
|
|
90
|
+
const current = handlers[this.handlerIndex] || { trigger: 'click', action: '' };
|
|
91
|
+
return html `
|
|
92
|
+
<fieldset>
|
|
93
|
+
<legend style="box-sizing:border-box;width:100%">
|
|
94
|
+
<ox-title-with-help topic="board-modeller/effects/event-handlers" msgid="label.event-handlers"
|
|
95
|
+
>Event Handlers</ox-title-with-help
|
|
96
|
+
>
|
|
97
|
+
<span style="font-size:11px;opacity:0.65;margin-left:6px">(${handlers.length})</span>
|
|
98
|
+
<md-icon
|
|
99
|
+
style="float:right;font-size:medium;margin:0;cursor:pointer"
|
|
100
|
+
@click=${() => this._openHandlersPopup()}
|
|
101
|
+
title="open in popup"
|
|
102
|
+
>open_in_new</md-icon
|
|
103
|
+
>
|
|
104
|
+
</legend>
|
|
105
|
+
|
|
106
|
+
<div id="tab-header">
|
|
107
|
+
<md-icon id="tab-nav-left-button" @click=${() => this._onTabScrollNavLeft()} disabled
|
|
108
|
+
>chevron_left</md-icon
|
|
109
|
+
>
|
|
110
|
+
|
|
111
|
+
<ox-buttons-radio
|
|
112
|
+
id="tabs"
|
|
113
|
+
.value=${String(this.handlerIndex)}
|
|
114
|
+
@change=${(e) => {
|
|
115
|
+
e.stopPropagation();
|
|
116
|
+
this._setHandlerIndex(e.target.value);
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
${handlers.map((h, i) => html `
|
|
120
|
+
<div data-value=${i} title="${h.trigger} · ${h.action || '(none)'}${h.disabled ? ' (disabled)' : ''}">
|
|
121
|
+
${h.trigger}
|
|
122
|
+
</div>
|
|
123
|
+
`)}
|
|
124
|
+
<div data-value=${handlers.length} disabled title="add new">+</div>
|
|
125
|
+
</ox-buttons-radio>
|
|
126
|
+
|
|
127
|
+
<md-icon id="tab-nav-right-button" @click=${() => this._onTabScrollNavRight()} disabled
|
|
128
|
+
>chevron_right</md-icon
|
|
129
|
+
>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<div handler-toolbar>
|
|
133
|
+
<md-icon style="font-size:19px" @click=${() => this._clearHandler()} title="delete current"
|
|
134
|
+
>delete_forever</md-icon
|
|
135
|
+
>
|
|
136
|
+
<md-icon @click=${() => this._pasteHandler()} title="paste">content_paste</md-icon>
|
|
137
|
+
<md-icon style="font-size:17px" @click=${() => this._copyHandler()} title="copy"
|
|
138
|
+
>content_copy</md-icon
|
|
139
|
+
>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<event-handlers-mapper
|
|
143
|
+
@value-change=${(e) => this._onHandlerChanged(e)}
|
|
144
|
+
.scene=${this.scene}
|
|
145
|
+
.handler=${current}
|
|
146
|
+
></event-handlers-mapper>
|
|
147
|
+
</fieldset>
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
_setHandlerIndex(idx) {
|
|
151
|
+
this.handlerIndex = isNaN(Number(idx)) ? 0 : Number(idx);
|
|
152
|
+
this._onTabScroll();
|
|
153
|
+
}
|
|
154
|
+
_clearHandler() {
|
|
155
|
+
const next = [...this.handlers];
|
|
156
|
+
next.splice(this.handlerIndex, 1);
|
|
157
|
+
this._dispatchHandlersChange(next);
|
|
158
|
+
}
|
|
159
|
+
_copyHandler() {
|
|
160
|
+
var _a;
|
|
161
|
+
clipboard = JSON.stringify((_a = this.handlers[this.handlerIndex]) !== null && _a !== void 0 ? _a : {});
|
|
162
|
+
}
|
|
163
|
+
_pasteHandler() {
|
|
164
|
+
try {
|
|
165
|
+
const parsed = JSON.parse(clipboard);
|
|
166
|
+
const next = [...this.handlers];
|
|
167
|
+
next[this.handlerIndex] = parsed;
|
|
168
|
+
this._dispatchHandlersChange(next);
|
|
169
|
+
}
|
|
170
|
+
catch (_) {
|
|
171
|
+
/* invalid clipboard */
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
_onHandlerChanged(e) {
|
|
175
|
+
var _a;
|
|
176
|
+
const handler = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.handler;
|
|
177
|
+
if (!handler)
|
|
178
|
+
return;
|
|
179
|
+
const next = [...this.handlers];
|
|
180
|
+
// 신규 — last+1 위치 추가
|
|
181
|
+
if (this.handlerIndex >= next.length) {
|
|
182
|
+
next.push(handler);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
next[this.handlerIndex] = handler;
|
|
186
|
+
}
|
|
187
|
+
const currentIdx = this.handlerIndex;
|
|
188
|
+
this._afterRender = () => {
|
|
189
|
+
this._setHandlerIndex(currentIdx);
|
|
190
|
+
this.tabContainer.scrollLeft = this.tabContainer.scrollWidth;
|
|
191
|
+
};
|
|
192
|
+
this._dispatchHandlersChange(next);
|
|
193
|
+
}
|
|
194
|
+
_dispatchHandlersChange(handlers) {
|
|
195
|
+
// action 이 비어있는 handler 는 외부 모델에서 제외 — UI placeholder 는 유지하되
|
|
196
|
+
// 저장은 action 이 선택된 핸들러만.
|
|
197
|
+
const valid = (handlers || []).filter(h => !!h && !!h.action);
|
|
198
|
+
this.dispatchEvent(new CustomEvent('property-change', {
|
|
199
|
+
bubbles: true,
|
|
200
|
+
composed: true,
|
|
201
|
+
detail: { eventHandlers: valid }
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
async onValueChanged() {
|
|
205
|
+
await this.updateComplete;
|
|
206
|
+
if (this._afterRender) {
|
|
207
|
+
this._afterRender();
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
this._setHandlerIndex(0);
|
|
211
|
+
}
|
|
212
|
+
this._afterRender = null;
|
|
213
|
+
}
|
|
214
|
+
async _openHandlersPopup() {
|
|
215
|
+
// 큰 popup 으로 펼치기 — data-binding 의 _openBindingPopup 패턴 동일.
|
|
216
|
+
await import('./event-handlers-popup.js');
|
|
217
|
+
const handlers = [...this.handlers];
|
|
218
|
+
const template = html `
|
|
219
|
+
<event-handlers-popup
|
|
220
|
+
.handlers=${handlers}
|
|
221
|
+
.scene=${this.scene}
|
|
222
|
+
@handlers-change=${(e) => {
|
|
223
|
+
var _a;
|
|
224
|
+
this._dispatchHandlersChange(((_a = e.detail) === null || _a === void 0 ? void 0 : _a.handlers) || []);
|
|
225
|
+
}}
|
|
226
|
+
></event-handlers-popup>
|
|
227
|
+
`;
|
|
228
|
+
openPopup(template, {
|
|
229
|
+
backdrop: true,
|
|
230
|
+
size: 'large',
|
|
231
|
+
title: i18next.t('label.event-handlers')
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
get tabContainer() {
|
|
235
|
+
return this.tabs;
|
|
236
|
+
}
|
|
237
|
+
_onTabScroll() {
|
|
238
|
+
if (!this.tabContainer || !this.tabNavLeftButton)
|
|
239
|
+
return;
|
|
240
|
+
if (this.tabContainer.clientWidth == this.tabContainer.scrollWidth) {
|
|
241
|
+
this.tabNavLeftButton.setAttribute('disabled', '');
|
|
242
|
+
this.tabNavRightButton.setAttribute('disabled', '');
|
|
243
|
+
}
|
|
244
|
+
else if (this.tabContainer.scrollLeft == 0) {
|
|
245
|
+
this.tabNavLeftButton.setAttribute('disabled', '');
|
|
246
|
+
this.tabNavRightButton.removeAttribute('disabled');
|
|
247
|
+
}
|
|
248
|
+
else if (this.tabContainer.scrollLeft + this.tabContainer.clientWidth >= this.tabContainer.scrollWidth) {
|
|
249
|
+
this.tabNavLeftButton.removeAttribute('disabled');
|
|
250
|
+
this.tabNavRightButton.setAttribute('disabled', '');
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this.tabNavLeftButton.removeAttribute('disabled');
|
|
254
|
+
this.tabNavRightButton.removeAttribute('disabled');
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
_onTabScrollNavLeft() {
|
|
258
|
+
this.tabContainer.style.scrollBehavior = 'smooth';
|
|
259
|
+
this.tabContainer.scrollLeft -= this.tabContainer.clientWidth;
|
|
260
|
+
this.tabContainer.style.scrollBehavior = 'auto';
|
|
261
|
+
}
|
|
262
|
+
_onTabScrollNavRight() {
|
|
263
|
+
this.tabContainer.style.scrollBehavior = 'smooth';
|
|
264
|
+
this.tabContainer.scrollLeft += this.tabContainer.clientWidth;
|
|
265
|
+
this.tabContainer.style.scrollBehavior = 'auto';
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
PropertyEventHandlers.styles = [
|
|
269
|
+
PropertyGridStyles,
|
|
270
|
+
css `
|
|
271
|
+
/* panel 자체가 부모 (사이드바) 너비를 넘기지 않도록. ox-input-code 같은
|
|
272
|
+
* 자유 너비 자식이 panel 폭을 키워서 우측 open_in_new 버튼이 잘리는
|
|
273
|
+
* 현상 방지. */
|
|
274
|
+
:host {
|
|
275
|
+
display: block;
|
|
276
|
+
min-width: 0;
|
|
277
|
+
max-width: 100%;
|
|
278
|
+
box-sizing: border-box;
|
|
279
|
+
overflow: hidden;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
fieldset {
|
|
283
|
+
min-width: 0;
|
|
284
|
+
max-width: 100%;
|
|
285
|
+
box-sizing: border-box;
|
|
286
|
+
overflow: hidden;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
event-handlers-mapper {
|
|
290
|
+
display: block;
|
|
291
|
+
min-width: 0;
|
|
292
|
+
max-width: 100%;
|
|
293
|
+
box-sizing: border-box;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/* 카드 상단 — chevron + tabs 를 하나의 둥근 모서리 박스로 통합. */
|
|
297
|
+
#tab-header {
|
|
298
|
+
display: flex;
|
|
299
|
+
align-items: stretch;
|
|
300
|
+
justify-content: space-between;
|
|
301
|
+
border: 1px solid rgba(0, 0, 0, 0.18);
|
|
302
|
+
border-radius: 6px 6px 0 0;
|
|
303
|
+
overflow: hidden;
|
|
304
|
+
background: var(--md-sys-color-surface, #fff);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
#tab-header > md-icon {
|
|
308
|
+
padding: 0;
|
|
309
|
+
margin: 0;
|
|
310
|
+
width: 25px;
|
|
311
|
+
height: 25px;
|
|
312
|
+
font-size: x-large;
|
|
313
|
+
align-self: center;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
ox-buttons-radio {
|
|
317
|
+
flex: 1;
|
|
318
|
+
height: 25px;
|
|
319
|
+
/* 외곽 border 는 #tab-header 가 들고 있다 — 여기는 0. */
|
|
320
|
+
border: 0;
|
|
321
|
+
border-radius: 0;
|
|
322
|
+
text-align: center;
|
|
323
|
+
display: flex;
|
|
324
|
+
padding: 0;
|
|
325
|
+
box-sizing: border-box;
|
|
326
|
+
width: 0;
|
|
327
|
+
overflow-x: hidden;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
ox-buttons-radio > div {
|
|
331
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
332
|
+
border: 1px solid rgba(0, 0, 0, 0.07);
|
|
333
|
+
border-width: 0 0 2px 0;
|
|
334
|
+
padding: 0 8px;
|
|
335
|
+
margin: 0;
|
|
336
|
+
color: #fff;
|
|
337
|
+
font-size: 12px;
|
|
338
|
+
max-width: 110px;
|
|
339
|
+
min-width: 40px;
|
|
340
|
+
white-space: nowrap;
|
|
341
|
+
overflow: hidden;
|
|
342
|
+
text-overflow: ellipsis;
|
|
343
|
+
line-height: 23px;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
ox-buttons-radio > div[disabled] {
|
|
347
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
ox-buttons-radio > div[active] {
|
|
351
|
+
border-color: rgb(242, 71, 28);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
ox-buttons-radio > div.iron-selected {
|
|
355
|
+
background-color: var(--md-sys-color-surface);
|
|
356
|
+
color: var(--md-sys-color-on-surface);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
div[handler-toolbar] {
|
|
360
|
+
display: flex;
|
|
361
|
+
flex-direction: row-reverse;
|
|
362
|
+
background-color: var(--md-sys-color-surface);
|
|
363
|
+
color: var(--md-sys-color-on-surface);
|
|
364
|
+
overflow: hidden;
|
|
365
|
+
border: 1px solid rgba(0, 0, 0, 0.18);
|
|
366
|
+
border-width: 0 1px;
|
|
367
|
+
padding: 6px 6px 4px 6px;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
md-icon {
|
|
371
|
+
margin-left: 5px;
|
|
372
|
+
color: var(--md-sys-color-on-secondary-container);
|
|
373
|
+
opacity: 0.8;
|
|
374
|
+
cursor: pointer;
|
|
375
|
+
--md-icon-size: 18px;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
md-icon:hover {
|
|
379
|
+
color: var(--md-sys-color-on-primary-container);
|
|
380
|
+
opacity: 1;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
md-icon[disabled] {
|
|
384
|
+
color: rgba(0, 0, 0, 0.1);
|
|
385
|
+
}
|
|
386
|
+
`
|
|
387
|
+
];
|
|
388
|
+
__decorate([
|
|
389
|
+
property({ type: Object })
|
|
390
|
+
], PropertyEventHandlers.prototype, "value", void 0);
|
|
391
|
+
__decorate([
|
|
392
|
+
property({ type: Object })
|
|
393
|
+
], PropertyEventHandlers.prototype, "scene", void 0);
|
|
394
|
+
__decorate([
|
|
395
|
+
state()
|
|
396
|
+
], PropertyEventHandlers.prototype, "handlerIndex", void 0);
|
|
397
|
+
__decorate([
|
|
398
|
+
state()
|
|
399
|
+
], PropertyEventHandlers.prototype, "_afterRender", void 0);
|
|
400
|
+
__decorate([
|
|
401
|
+
query('#tabs')
|
|
402
|
+
], PropertyEventHandlers.prototype, "tabs", void 0);
|
|
403
|
+
__decorate([
|
|
404
|
+
query('#tab-nav-left-button')
|
|
405
|
+
], PropertyEventHandlers.prototype, "tabNavLeftButton", void 0);
|
|
406
|
+
__decorate([
|
|
407
|
+
query('#tab-nav-right-button')
|
|
408
|
+
], PropertyEventHandlers.prototype, "tabNavRightButton", void 0);
|
|
409
|
+
customElements.define('property-event-handlers', PropertyEventHandlers);
|
|
410
|
+
//# sourceMappingURL=event-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-handlers.js","sourceRoot":"","sources":["../../../../src/property-panel/event-handlers/event-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,qCAAqC,CAAA;AAC5C,OAAO,oCAAoC,CAAA;AAC3C,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAG1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,mBAAmB,EAAyB,MAAM,4BAA4B,CAAA;AAEvF,IAAI,SAAS,GAAG,iCAAiC,CAAA;AAEjD,MAAM,OAAO,qBAAsB,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IAAhF;;QA6HW,iBAAY,GAAW,CAAC,CAAA;IA2PnC,CAAC;IApPC;;;;OAIG;IACH,IAAI,QAAQ;;QACV,MAAM,CAAC,GAAG,IAAI,CAAC,KAAY,CAAA;QAC3B,IAAI,CAAC,CAAC;YAAE,OAAO,EAAE,CAAA;QACjB,QAAQ;QACR,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC;YAAE,OAAO,CAAC,CAAC,aAAmC,CAAA;QAChF,qCAAqC;QACrC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAA;QAClB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KAAK,CAAC,cAAc,GAAG,MAAM,CAAA;IACjD,CAAC;;AAtXM,4BAAM,GAAG;IACd,kBAAkB;IAClB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoHF;CACF,AAvHY,CAuHZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAmB;AAClB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAc;AAEhC;IAAR,KAAK,EAAE;2DAAyB;AACxB;IAAR,KAAK,EAAE;2DAA+B;AAEvB;IAAf,KAAK,CAAC,OAAO,CAAC;mDAAmB;AACH;IAA9B,KAAK,CAAC,sBAAsB,CAAC;+DAA+B;AAC7B;IAA/B,KAAK,CAAC,uBAAuB,CAAC;gEAAgC;AAwPjE,cAAc,CAAC,MAAM,CAAC,yBAAyB,EAAE,qBAAqB,CAAC,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n *\n * EventHandlers panel — 컴포넌트의 `state.eventHandlers[]` 편집기.\n *\n * 데이터바인딩 panel 의 형제로 *완전 분리*. 데이터바인딩은 데이터 흐름 전용,\n * eventHandlers 는 사용자 액션 (tap / hover / 등) 의 first-class 핸들러 등록.\n *\n * data-binding 패턴 그대로 — tabs (N handlers) + handler mapper + add/delete/copy/paste.\n */\n\nimport '@material/web/icon/icon.js'\nimport '@operato/help/ox-title-with-help.js'\nimport '@operato/input/ox-buttons-radio.js'\nimport '@operato/i18n/ox-i18n.js'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\n\nimport type { Properties, Scene } from '@hatiolab/things-scene'\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements'\nimport { PropertyGridStyles } from '@operato/styles/property-grid-styles.js'\nimport { openPopup } from '@operato/layout'\nimport { i18next } from '@operato/i18n'\n\nimport { AbstractProperty } from '../abstract-property.js'\nimport { EventHandlersMapper, type EventHandlerSpec } from './event-handlers-mapper.js'\n\nvar clipboard = '{\"trigger\":\"click\",\"action\":\"\"}'\n\nexport class PropertyEventHandlers extends ScopedElementsMixin(AbstractProperty) {\n static styles = [\n PropertyGridStyles,\n css`\n /* panel 자체가 부모 (사이드바) 너비를 넘기지 않도록. ox-input-code 같은\n * 자유 너비 자식이 panel 폭을 키워서 우측 open_in_new 버튼이 잘리는\n * 현상 방지. */\n :host {\n display: block;\n min-width: 0;\n max-width: 100%;\n box-sizing: border-box;\n overflow: hidden;\n }\n\n fieldset {\n min-width: 0;\n max-width: 100%;\n box-sizing: border-box;\n overflow: hidden;\n }\n\n event-handlers-mapper {\n display: block;\n min-width: 0;\n max-width: 100%;\n box-sizing: border-box;\n }\n\n /* 카드 상단 — chevron + tabs 를 하나의 둥근 모서리 박스로 통합. */\n #tab-header {\n display: flex;\n align-items: stretch;\n justify-content: space-between;\n border: 1px solid rgba(0, 0, 0, 0.18);\n border-radius: 6px 6px 0 0;\n overflow: hidden;\n background: var(--md-sys-color-surface, #fff);\n }\n\n #tab-header > md-icon {\n padding: 0;\n margin: 0;\n width: 25px;\n height: 25px;\n font-size: x-large;\n align-self: center;\n }\n\n ox-buttons-radio {\n flex: 1;\n height: 25px;\n /* 외곽 border 는 #tab-header 가 들고 있다 — 여기는 0. */\n border: 0;\n border-radius: 0;\n text-align: center;\n display: flex;\n padding: 0;\n box-sizing: border-box;\n width: 0;\n overflow-x: hidden;\n }\n\n ox-buttons-radio > div {\n background-color: rgba(0, 0, 0, 0.2);\n border: 1px solid rgba(0, 0, 0, 0.07);\n border-width: 0 0 2px 0;\n padding: 0 8px;\n margin: 0;\n color: #fff;\n font-size: 12px;\n max-width: 110px;\n min-width: 40px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 23px;\n }\n\n ox-buttons-radio > div[disabled] {\n background-color: rgba(0, 0, 0, 0.1);\n }\n\n ox-buttons-radio > div[active] {\n border-color: rgb(242, 71, 28);\n }\n\n ox-buttons-radio > div.iron-selected {\n background-color: var(--md-sys-color-surface);\n color: var(--md-sys-color-on-surface);\n }\n\n div[handler-toolbar] {\n display: flex;\n flex-direction: row-reverse;\n background-color: var(--md-sys-color-surface);\n color: var(--md-sys-color-on-surface);\n overflow: hidden;\n border: 1px solid rgba(0, 0, 0, 0.18);\n border-width: 0 1px;\n padding: 6px 6px 4px 6px;\n }\n\n md-icon {\n margin-left: 5px;\n color: var(--md-sys-color-on-secondary-container);\n opacity: 0.8;\n cursor: pointer;\n --md-icon-size: 18px;\n }\n\n md-icon:hover {\n color: var(--md-sys-color-on-primary-container);\n opacity: 1;\n }\n\n md-icon[disabled] {\n color: rgba(0, 0, 0, 0.1);\n }\n `\n ]\n\n @property({ type: Object }) value?: Properties\n @property({ type: Object }) scene?: Scene\n\n @state() handlerIndex: number = 0\n @state() _afterRender?: Function | null\n\n @query('#tabs') tabs!: HTMLElement\n @query('#tab-nav-left-button') tabNavLeftButton!: HTMLElement\n @query('#tab-nav-right-button') tabNavRightButton!: HTMLElement\n\n /**\n * 두 속성 통합 — 신규 `eventHandlers` 우선, 없으면 legacy `event` 객체를\n * *read-only* 변환해 표시. 사용자가 수정 시 `eventHandlers` 에만 저장 — legacy\n * 는 손대지 않음 (옛 코드 호환 / rollback 안전망).\n */\n get handlers(): EventHandlerSpec[] {\n const v = this.value as any\n if (!v) return []\n // 1. 신규\n if (Array.isArray(v.eventHandlers)) return v.eventHandlers as EventHandlerSpec[]\n // 2. legacy 객체 → 변환 (표시만, 저장 시점이 아님)\n const ev = v.event\n if (!ev || typeof ev !== 'object' || Array.isArray(ev)) return []\n const trigMap: Record<string, string> = {\n tap: 'click',\n hover: 'mouseenter',\n dblclick: 'dblclick',\n longpress: 'longpress'\n }\n const out: EventHandlerSpec[] = []\n for (const key of Object.keys(ev)) {\n const trig = trigMap[key]\n const e = ev[key]\n if (!trig || !e || typeof e !== 'object') continue\n if (e.action === 'script') {\n const code = typeof e.value === 'string' ? e.value : (e.value?.script ?? '')\n out.push({ trigger: trig, action: 'script', code, target: e.target })\n } else {\n out.push({\n trigger: trig,\n action: e.action,\n target: e.target,\n value: e.value,\n options: { emphasize: e.emphasize, restore: e.restore, pressed: e.pressed, ...(e.options ?? {}) }\n })\n }\n }\n return out\n }\n\n firstUpdated() {\n this.tabContainer.addEventListener('scroll', () => this._onTabScroll())\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value')) {\n this.onValueChanged()\n }\n }\n\n static get scopedElements() {\n return {\n 'event-handlers-mapper': EventHandlersMapper\n }\n }\n\n render() {\n const handlers = this.handlers\n const current = handlers[this.handlerIndex] || { trigger: 'click', action: '' }\n\n return html`\n <fieldset>\n <legend style=\"box-sizing:border-box;width:100%\">\n <ox-title-with-help topic=\"board-modeller/effects/event-handlers\" msgid=\"label.event-handlers\"\n >Event Handlers</ox-title-with-help\n >\n <span style=\"font-size:11px;opacity:0.65;margin-left:6px\">(${handlers.length})</span>\n <md-icon\n style=\"float:right;font-size:medium;margin:0;cursor:pointer\"\n @click=${() => this._openHandlersPopup()}\n title=\"open in popup\"\n >open_in_new</md-icon\n >\n </legend>\n\n <div id=\"tab-header\">\n <md-icon id=\"tab-nav-left-button\" @click=${() => this._onTabScrollNavLeft()} disabled\n >chevron_left</md-icon\n >\n\n <ox-buttons-radio\n id=\"tabs\"\n .value=${String(this.handlerIndex)}\n @change=${(e: Event) => {\n e.stopPropagation()\n this._setHandlerIndex((e.target as any).value)\n }}\n >\n ${handlers.map(\n (h, i) => html`\n <div data-value=${i} title=\"${h.trigger} · ${h.action || '(none)'}${h.disabled ? ' (disabled)' : ''}\">\n ${h.trigger}\n </div>\n `\n )}\n <div data-value=${handlers.length} disabled title=\"add new\">+</div>\n </ox-buttons-radio>\n\n <md-icon id=\"tab-nav-right-button\" @click=${() => this._onTabScrollNavRight()} disabled\n >chevron_right</md-icon\n >\n </div>\n\n <div handler-toolbar>\n <md-icon style=\"font-size:19px\" @click=${() => this._clearHandler()} title=\"delete current\"\n >delete_forever</md-icon\n >\n <md-icon @click=${() => this._pasteHandler()} title=\"paste\">content_paste</md-icon>\n <md-icon style=\"font-size:17px\" @click=${() => this._copyHandler()} title=\"copy\"\n >content_copy</md-icon\n >\n </div>\n\n <event-handlers-mapper\n @value-change=${(e: CustomEvent) => this._onHandlerChanged(e)}\n .scene=${this.scene}\n .handler=${current}\n ></event-handlers-mapper>\n </fieldset>\n `\n }\n\n _setHandlerIndex(idx: number) {\n this.handlerIndex = isNaN(Number(idx)) ? 0 : Number(idx)\n this._onTabScroll()\n }\n\n _clearHandler() {\n const next = [...this.handlers]\n next.splice(this.handlerIndex, 1)\n this._dispatchHandlersChange(next)\n }\n\n _copyHandler() {\n clipboard = JSON.stringify(this.handlers[this.handlerIndex] ?? {})\n }\n\n _pasteHandler() {\n try {\n const parsed = JSON.parse(clipboard)\n const next = [...this.handlers]\n next[this.handlerIndex] = parsed\n this._dispatchHandlersChange(next)\n } catch (_) {\n /* invalid clipboard */\n }\n }\n\n _onHandlerChanged(e: CustomEvent) {\n const handler = e.detail?.handler as EventHandlerSpec\n if (!handler) return\n const next = [...this.handlers]\n // 신규 — last+1 위치 추가\n if (this.handlerIndex >= next.length) {\n next.push(handler)\n } else {\n next[this.handlerIndex] = handler\n }\n const currentIdx = this.handlerIndex\n this._afterRender = () => {\n this._setHandlerIndex(currentIdx)\n this.tabContainer.scrollLeft = this.tabContainer.scrollWidth\n }\n this._dispatchHandlersChange(next)\n }\n\n private _dispatchHandlersChange(handlers: EventHandlerSpec[]) {\n // action 이 비어있는 handler 는 외부 모델에서 제외 — UI placeholder 는 유지하되\n // 저장은 action 이 선택된 핸들러만.\n const valid = (handlers || []).filter(h => !!h && !!h.action)\n this.dispatchEvent(\n new CustomEvent('property-change', {\n bubbles: true,\n composed: true,\n detail: { eventHandlers: valid }\n })\n )\n }\n\n async onValueChanged() {\n await this.updateComplete\n if (this._afterRender) {\n this._afterRender()\n } else {\n this._setHandlerIndex(0)\n }\n this._afterRender = null\n }\n\n async _openHandlersPopup() {\n // 큰 popup 으로 펼치기 — data-binding 의 _openBindingPopup 패턴 동일.\n await import('./event-handlers-popup.js')\n\n const handlers = [...this.handlers]\n\n const template = html`\n <event-handlers-popup\n .handlers=${handlers}\n .scene=${this.scene}\n @handlers-change=${(e: CustomEvent) => {\n this._dispatchHandlersChange(e.detail?.handlers || [])\n }}\n ></event-handlers-popup>\n `\n\n openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('label.event-handlers')\n })\n }\n\n get tabContainer() {\n return this.tabs\n }\n\n _onTabScroll() {\n if (!this.tabContainer || !this.tabNavLeftButton) return\n if (this.tabContainer.clientWidth == this.tabContainer.scrollWidth) {\n this.tabNavLeftButton.setAttribute('disabled', '')\n this.tabNavRightButton.setAttribute('disabled', '')\n } else if (this.tabContainer.scrollLeft == 0) {\n this.tabNavLeftButton.setAttribute('disabled', '')\n this.tabNavRightButton.removeAttribute('disabled')\n } else if (this.tabContainer.scrollLeft + this.tabContainer.clientWidth >= this.tabContainer.scrollWidth) {\n this.tabNavLeftButton.removeAttribute('disabled')\n this.tabNavRightButton.setAttribute('disabled', '')\n } else {\n this.tabNavLeftButton.removeAttribute('disabled')\n this.tabNavRightButton.removeAttribute('disabled')\n }\n }\n\n _onTabScrollNavLeft() {\n this.tabContainer.style.scrollBehavior = 'smooth'\n this.tabContainer.scrollLeft -= this.tabContainer.clientWidth\n this.tabContainer.style.scrollBehavior = 'auto'\n }\n\n _onTabScrollNavRight() {\n this.tabContainer.style.scrollBehavior = 'smooth'\n this.tabContainer.scrollLeft += this.tabContainer.clientWidth\n this.tabContainer.style.scrollBehavior = 'auto'\n }\n}\n\ncustomElements.define('property-event-handlers', PropertyEventHandlers)\n"]}
|