@operato/data-mapper 9.0.0-beta.50 → 9.0.0-beta.52
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 +16 -0
- package/dist/src/components/function-box-options-builder.d.ts +18 -0
- package/dist/src/components/function-box-options-builder.js +145 -0
- package/dist/src/components/function-box-options-builder.js.map +1 -0
- package/dist/src/components/function-box-popup.d.ts +15 -0
- package/dist/src/components/function-box-popup.js +236 -0
- package/dist/src/components/function-box-popup.js.map +1 -0
- package/dist/src/components/property-editor.d.ts +34 -0
- package/dist/src/components/property-editor.js +76 -0
- package/dist/src/components/property-editor.js.map +1 -0
- package/dist/src/context/data-mapper-context.d.ts +12 -0
- package/dist/src/context/data-mapper-context.js +3 -0
- package/dist/src/context/data-mapper-context.js.map +1 -0
- package/dist/src/functions/custom-script.d.ts +10 -0
- package/dist/src/functions/custom-script.js +49 -0
- package/dist/src/functions/custom-script.js.map +1 -0
- package/dist/src/functions/date-formatting.d.ts +10 -0
- package/dist/src/functions/date-formatting.js +59 -0
- package/dist/src/functions/date-formatting.js.map +1 -0
- package/dist/src/functions/index.d.ts +10 -0
- package/dist/src/functions/index.js +19 -0
- package/dist/src/functions/index.js.map +1 -0
- package/dist/src/functions/json-query.d.ts +10 -0
- package/dist/src/functions/json-query.js +116 -0
- package/dist/src/functions/json-query.js.map +1 -0
- package/dist/src/functions/passthrough.d.ts +6 -0
- package/dist/src/functions/passthrough.js +38 -0
- package/dist/src/functions/passthrough.js.map +1 -0
- package/dist/src/functions/range-mapping.d.ts +10 -0
- package/dist/src/functions/range-mapping.js +106 -0
- package/dist/src/functions/range-mapping.js.map +1 -0
- package/dist/src/functions/string-manipulation.d.ts +33 -0
- package/dist/src/functions/string-manipulation.js +215 -0
- package/dist/src/functions/string-manipulation.js.map +1 -0
- package/dist/src/functions/text-transform.d.ts +25 -0
- package/dist/src/functions/text-transform.js +167 -0
- package/dist/src/functions/text-transform.js.map +1 -0
- package/dist/src/functions/value-mapping.d.ts +10 -0
- package/dist/src/functions/value-mapping.js +109 -0
- package/dist/src/functions/value-mapping.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-data-mapper.d.ts +12 -13
- package/dist/src/ox-data-mapper.js +159 -118
- package/dist/src/ox-data-mapper.js.map +1 -1
- package/dist/src/ox-mapping-area.d.ts +36 -0
- package/dist/src/ox-mapping-area.js +382 -0
- package/dist/src/ox-mapping-area.js.map +1 -0
- package/dist/src/types.d.ts +19 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/stories/ox-data-mapper.stories.d.ts +4 -4
- package/dist/stories/ox-data-mapper.stories.js +39 -17
- package/dist/stories/ox-data-mapper.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -3
- package/translations/en.json +3 -0
- package/translations/ja.json +3 -0
- package/translations/ko.json +3 -0
- package/translations/ms.json +3 -0
- package/translations/zh.json +3 -0
|
@@ -1,105 +1,61 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@operato/data-tree/ox-tree.js';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import './ox-mapping-area.js';
|
|
4
|
+
import { LitElement, html, css } from 'lit';
|
|
5
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
6
|
+
import { provide } from '@lit/context';
|
|
7
|
+
import { dataMapperContext } from './context/data-mapper-context.js';
|
|
5
8
|
let OxDataMapper = class OxDataMapper extends LitElement {
|
|
6
9
|
constructor() {
|
|
7
10
|
super(...arguments);
|
|
8
|
-
this.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
label: 'Item',
|
|
16
|
-
multiplicity: '*',
|
|
17
|
-
children: [
|
|
18
|
-
{ id: 's1-1-1', label: 'Name' },
|
|
19
|
-
{ id: 's1-1-2', label: 'Price' }
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
};
|
|
24
|
-
this.targetScheme = {
|
|
25
|
-
id: 't1',
|
|
26
|
-
label: 'Invoice',
|
|
27
|
-
children: [
|
|
28
|
-
{
|
|
29
|
-
id: 't1-1',
|
|
30
|
-
label: 'Products',
|
|
31
|
-
multiplicity: '*',
|
|
32
|
-
children: [
|
|
33
|
-
{ id: 't1-1-1', label: 'Product Name' },
|
|
34
|
-
{ id: 't1-1-2', label: 'Cost' }
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
};
|
|
39
|
-
this.mappings = [
|
|
40
|
-
{
|
|
41
|
-
inputs: ['s1-1-1'],
|
|
42
|
-
outputs: ['t1-1-1'],
|
|
43
|
-
transformLogic: 'toUpperCase()'
|
|
11
|
+
this.sourceSchema = { id: 'source', label: 'source' };
|
|
12
|
+
this.targetSchema = { id: 'target', label: 'target' };
|
|
13
|
+
this.mappings = [];
|
|
14
|
+
this.selected = null;
|
|
15
|
+
this.dataMapperContext = {
|
|
16
|
+
getUniqueId: () => {
|
|
17
|
+
return Math.random().toString(36).substring(2, 9);
|
|
44
18
|
},
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
19
|
+
updateMappings: (mappings) => {
|
|
20
|
+
this.mappings = mappings;
|
|
21
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
22
|
+
detail: this.mappings
|
|
23
|
+
}));
|
|
24
|
+
},
|
|
25
|
+
getNodePosition: this.getNodePosition.bind(this)
|
|
26
|
+
};
|
|
27
|
+
this.dragStartElement = null;
|
|
51
28
|
}
|
|
52
29
|
render() {
|
|
53
30
|
return html `
|
|
54
31
|
<div class="container">
|
|
55
32
|
<div class="tree-container source">
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
33
|
+
<ox-tree
|
|
34
|
+
.data=${this.sourceSchema}
|
|
35
|
+
@collapsed=${() => this.mappingsArea.requestUpdate()}
|
|
36
|
+
@expanded=${() => this.mappingsArea.requestUpdate()}
|
|
37
|
+
@dragstart=${this.onDragStart}
|
|
38
|
+
@dragover=${this.onDragOver}
|
|
39
|
+
@drop=${this.onDrop}
|
|
40
|
+
label-extends
|
|
41
|
+
></ox-tree>
|
|
62
42
|
</div>
|
|
43
|
+
|
|
63
44
|
<div class="tree-container target">
|
|
64
|
-
<h3>Target Structure</h3>
|
|
65
45
|
<ox-tree
|
|
66
|
-
.data=${this.
|
|
67
|
-
@
|
|
46
|
+
.data=${this.targetSchema}
|
|
47
|
+
@collapsed=${() => this.mappingsArea.requestUpdate()}
|
|
48
|
+
@expanded=${() => this.mappingsArea.requestUpdate()}
|
|
49
|
+
@dragstart=${this.onDragStart}
|
|
50
|
+
@dragover=${this.onDragOver}
|
|
51
|
+
@drop=${this.onDrop}
|
|
68
52
|
direction="rtl"
|
|
69
53
|
label-extends
|
|
70
54
|
></ox-tree>
|
|
71
55
|
</div>
|
|
72
|
-
</div>
|
|
73
|
-
`;
|
|
74
|
-
}
|
|
75
|
-
handleSourceSelect() {
|
|
76
|
-
this.requestUpdate();
|
|
77
|
-
}
|
|
78
|
-
handleTargetSelect() { }
|
|
79
|
-
renderMapping(mapping) {
|
|
80
|
-
const sourcePoses = mapping.inputs.map(input => this.getNodePosition(input, true)).filter(Boolean);
|
|
81
|
-
const targetPoses = mapping.outputs.map(output => this.getNodePosition(output, false)).filter(Boolean);
|
|
82
|
-
const positions = [...sourcePoses, ...targetPoses];
|
|
83
|
-
if (positions.length == 0) {
|
|
84
|
-
return nothing;
|
|
85
|
-
}
|
|
86
|
-
const mappingsRect = this.mappingsArea.getBoundingClientRect();
|
|
87
|
-
const centerY = positions.reduce((sum, pos) => {
|
|
88
|
-
return sum + pos.y;
|
|
89
|
-
}, 0);
|
|
90
|
-
const boxX = mappingsRect.width / 2 - 50;
|
|
91
|
-
const boxY = centerY / positions.length - 10;
|
|
92
|
-
return svg `
|
|
93
|
-
<g>
|
|
94
|
-
${sourcePoses.map(sourcePos => svg `<line class="mapping-line" x1=${sourcePos.x} y1=${sourcePos.y} x2=${boxX} y2=${boxY + 10}></line>`)}
|
|
95
56
|
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
${mapping.transformLogic || 'map'}
|
|
99
|
-
</text>
|
|
100
|
-
|
|
101
|
-
${targetPoses.map(targetPos => svg `<line class="mapping-line" x1=${boxX + 100} y1=${boxY + 10} x2=${targetPos.x} y2=${targetPos.y}></line>`)}
|
|
102
|
-
</g>
|
|
57
|
+
<ox-mapping-area .mappings=${this.mappings}></ox-mapping-area>
|
|
58
|
+
</div>
|
|
103
59
|
`;
|
|
104
60
|
}
|
|
105
61
|
getNodePosition(nodeId, source) {
|
|
@@ -107,83 +63,165 @@ let OxDataMapper = class OxDataMapper extends LitElement {
|
|
|
107
63
|
if (!tree) {
|
|
108
64
|
return;
|
|
109
65
|
}
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
66
|
+
const nodeRect = tree.findNodeSelfBounds(nodeId);
|
|
67
|
+
if (!nodeRect) {
|
|
112
68
|
return;
|
|
113
69
|
}
|
|
114
|
-
const
|
|
115
|
-
const nodeRect = node.getBoundingClientRect();
|
|
70
|
+
const mappingAreaRect = this.mappingsArea.getBoundingClientRect();
|
|
116
71
|
return {
|
|
117
|
-
x: source ? 0 :
|
|
118
|
-
y: nodeRect.top
|
|
72
|
+
x: source ? 0 : mappingAreaRect.width,
|
|
73
|
+
y: nodeRect.top - mappingAreaRect.top + nodeRect.height / 2
|
|
119
74
|
};
|
|
120
75
|
}
|
|
76
|
+
onDragStart(e) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const path = e.composedPath();
|
|
79
|
+
const target = path.find(el => { var _a; return (_a = el.dataset) === null || _a === void 0 ? void 0 : _a.id; });
|
|
80
|
+
const nodeId = (_a = target === null || target === void 0 ? void 0 : target.dataset) === null || _a === void 0 ? void 0 : _a.id;
|
|
81
|
+
if (!nodeId) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const from = e.target === this.sourceTree ? 'source' : 'target';
|
|
85
|
+
e.dataTransfer.setData('application/node-id', nodeId);
|
|
86
|
+
e.dataTransfer.setData('application/from', from);
|
|
87
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
88
|
+
// ✅ 노드의 라벨을 찾아 미리보기로 사용
|
|
89
|
+
const nodeLabel = ((_b = target === null || target === void 0 ? void 0 : target.querySelector('span[label]')) === null || _b === void 0 ? void 0 : _b.textContent) || nodeId;
|
|
90
|
+
// ✅ 미리보기 요소 생성
|
|
91
|
+
const dragPreview = document.createElement('div');
|
|
92
|
+
dragPreview.textContent = nodeLabel;
|
|
93
|
+
dragPreview.style.fontSize = '14px';
|
|
94
|
+
dragPreview.style.padding = '4px 8px';
|
|
95
|
+
dragPreview.style.background = 'rgba(255, 255, 255, 0.3)';
|
|
96
|
+
dragPreview.style.borderRadius = '4px';
|
|
97
|
+
dragPreview.style.position = 'absolute';
|
|
98
|
+
dragPreview.style.top = '-100px'; // 화면 밖으로 배치 (임시)
|
|
99
|
+
dragPreview.style.left = '-100px';
|
|
100
|
+
dragPreview.style.pointerEvents = 'none';
|
|
101
|
+
dragPreview.style.zIndex = '1000';
|
|
102
|
+
document.body.appendChild(dragPreview);
|
|
103
|
+
// ✅ 커스텀 드래깅 이미지 적용
|
|
104
|
+
e.dataTransfer.setDragImage(dragPreview, 0, 0);
|
|
105
|
+
this.dragStartElement = e.target;
|
|
106
|
+
// ✅ 일정 시간 후 미리보기 요소 삭제
|
|
107
|
+
setTimeout(() => document.body.removeChild(dragPreview), 0);
|
|
108
|
+
}
|
|
109
|
+
onDragOver(e) {
|
|
110
|
+
var _a;
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
const from = e.dataTransfer.getData('application/from');
|
|
113
|
+
if (this.dragStartElement === e.target) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const path = e.composedPath();
|
|
117
|
+
const target = path.find(el => { var _a; return (_a = el.dataset) === null || _a === void 0 ? void 0 : _a.id; });
|
|
118
|
+
const nodeId = (_a = target === null || target === void 0 ? void 0 : target.dataset) === null || _a === void 0 ? void 0 : _a.id;
|
|
119
|
+
if (!nodeId)
|
|
120
|
+
return;
|
|
121
|
+
e.target.selected = target.item;
|
|
122
|
+
}
|
|
123
|
+
onDrop(e) {
|
|
124
|
+
var _a;
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
const nodeId = e.dataTransfer.getData('application/node-id');
|
|
127
|
+
const from = e.dataTransfer.getData('application/from');
|
|
128
|
+
if (!nodeId ||
|
|
129
|
+
(from == 'source' && e.target !== this.targetTree) ||
|
|
130
|
+
(from == 'target' && e.target !== this.sourceTree)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// 드롭된 타겟 노드 찾기
|
|
134
|
+
const path = e.composedPath();
|
|
135
|
+
const targetNode = path.find(el => { var _a; return (_a = el.dataset) === null || _a === void 0 ? void 0 : _a.id; });
|
|
136
|
+
const targetNodeId = (_a = targetNode === null || targetNode === void 0 ? void 0 : targetNode.dataset) === null || _a === void 0 ? void 0 : _a.id;
|
|
137
|
+
if (!targetNodeId) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// 중복 매핑 확인
|
|
141
|
+
const existingMapping = (this.mappings || []).find(m => m.inputs.includes(from == 'source' ? nodeId : targetNodeId) &&
|
|
142
|
+
m.outputs.includes(from == 'source' ? targetNodeId : nodeId));
|
|
143
|
+
if (!existingMapping) {
|
|
144
|
+
const { width, height } = this.mappingsArea.getBoundingClientRect();
|
|
145
|
+
const { y: sourceY = 0 } = this.dataMapperContext.getNodePosition(from == 'source' ? nodeId : targetNodeId, true) || {};
|
|
146
|
+
const { y: targetY = height } = this.dataMapperContext.getNodePosition(from == 'target' ? nodeId : targetNodeId, false) || {};
|
|
147
|
+
const newMapping = {
|
|
148
|
+
id: this.dataMapperContext.getUniqueId(),
|
|
149
|
+
mappingFunction: 'passthrough',
|
|
150
|
+
inputs: [from == 'source' ? nodeId : targetNodeId],
|
|
151
|
+
outputs: [from == 'source' ? targetNodeId : nodeId],
|
|
152
|
+
position: {
|
|
153
|
+
x: width / 2 - 50,
|
|
154
|
+
y: (sourceY + targetY) / 2
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
this.dataMapperContext.updateMappings([...(this.mappings || []), newMapping]);
|
|
158
|
+
this.mappingsArea.selectMappingBox(newMapping);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
121
161
|
};
|
|
122
162
|
OxDataMapper.styles = css `
|
|
123
163
|
.container {
|
|
124
164
|
display: flex;
|
|
125
165
|
width: 100%;
|
|
126
|
-
height: 100%;
|
|
166
|
+
min-height: 100%;
|
|
127
167
|
position: relative;
|
|
168
|
+
overflow-y: auto;
|
|
169
|
+
align-items: stretch;
|
|
128
170
|
}
|
|
129
171
|
|
|
130
172
|
.tree-container {
|
|
173
|
+
position: relative;
|
|
131
174
|
flex: 1;
|
|
132
175
|
display: flex;
|
|
133
176
|
flex-direction: column;
|
|
134
|
-
padding:
|
|
135
|
-
|
|
136
|
-
overflow-y: auto;
|
|
177
|
+
padding: 0;
|
|
178
|
+
margin: 0;
|
|
137
179
|
}
|
|
138
180
|
|
|
139
181
|
.tree-container.source {
|
|
182
|
+
order: 0;
|
|
140
183
|
padding-right: 0px;
|
|
141
184
|
}
|
|
142
185
|
|
|
143
186
|
.tree-container.target {
|
|
187
|
+
order: 2;
|
|
144
188
|
padding-left: 0px;
|
|
145
189
|
text-align: right;
|
|
146
190
|
}
|
|
147
191
|
|
|
148
|
-
|
|
192
|
+
ox-mapping-area {
|
|
193
|
+
order: 1;
|
|
194
|
+
position: relative;
|
|
149
195
|
flex: 1;
|
|
150
|
-
padding:
|
|
196
|
+
padding: 0;
|
|
151
197
|
margin: 0;
|
|
152
|
-
border: 1px solid #ccc;
|
|
153
198
|
text-align: center;
|
|
154
199
|
position: relative;
|
|
155
200
|
}
|
|
156
201
|
|
|
157
|
-
|
|
202
|
+
.tree-container.source::after,
|
|
203
|
+
ox-mapping-area::after {
|
|
204
|
+
content: '';
|
|
158
205
|
position: absolute;
|
|
206
|
+
right: 0;
|
|
159
207
|
top: 0;
|
|
160
|
-
|
|
161
|
-
width: 100%;
|
|
208
|
+
width: 1px;
|
|
162
209
|
height: 100%;
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.mapping-box {
|
|
167
|
-
fill: rgba(0, 0, 255, 0.2);
|
|
168
|
-
stroke: blue;
|
|
169
|
-
stroke-width: 0.5;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.mapping-line {
|
|
173
|
-
stroke: black;
|
|
174
|
-
stroke-width: 0.5;
|
|
175
|
-
fill: none;
|
|
210
|
+
background-color: black;
|
|
176
211
|
}
|
|
177
212
|
`;
|
|
178
213
|
__decorate([
|
|
179
|
-
|
|
180
|
-
], OxDataMapper.prototype, "
|
|
214
|
+
property({ type: Object })
|
|
215
|
+
], OxDataMapper.prototype, "sourceSchema", void 0);
|
|
181
216
|
__decorate([
|
|
182
|
-
|
|
183
|
-
], OxDataMapper.prototype, "
|
|
217
|
+
property({ type: Object })
|
|
218
|
+
], OxDataMapper.prototype, "targetSchema", void 0);
|
|
184
219
|
__decorate([
|
|
185
|
-
|
|
220
|
+
property({ type: Array })
|
|
186
221
|
], OxDataMapper.prototype, "mappings", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
state()
|
|
224
|
+
], OxDataMapper.prototype, "selected", void 0);
|
|
187
225
|
__decorate([
|
|
188
226
|
query('.tree-container.source > ox-tree')
|
|
189
227
|
], OxDataMapper.prototype, "sourceTree", void 0);
|
|
@@ -191,8 +229,11 @@ __decorate([
|
|
|
191
229
|
query('.tree-container.target > ox-tree')
|
|
192
230
|
], OxDataMapper.prototype, "targetTree", void 0);
|
|
193
231
|
__decorate([
|
|
194
|
-
query('
|
|
232
|
+
query('ox-mapping-area')
|
|
195
233
|
], OxDataMapper.prototype, "mappingsArea", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
provide({ context: dataMapperContext })
|
|
236
|
+
], OxDataMapper.prototype, "dataMapperContext", void 0);
|
|
196
237
|
OxDataMapper = __decorate([
|
|
197
238
|
customElement('ox-data-mapper')
|
|
198
239
|
], OxDataMapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-data-mapper.js","sourceRoot":"","sources":["../../src/ox-data-mapper.ts"],"names":[],"mappings":";AAAA,OAAO,+BAA+B,CAAA;AAGtC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACzD,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAgBlE,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QA0DY,iBAAY,GAAa;YACxC,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,OAAO;YACd,YAAY,EAAE,GAAG;YACjB,QAAQ,EAAE;gBACR;oBACE,EAAE,EAAE,MAAM;oBACV,KAAK,EAAE,MAAM;oBACb,YAAY,EAAE,GAAG;oBACjB,QAAQ,EAAE;wBACR,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE;wBAC/B,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;qBACjC;iBACF;aACF;SACF,CAAA;QAEgB,iBAAY,GAAa;YACxC,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE;gBACR;oBACE,EAAE,EAAE,MAAM;oBACV,KAAK,EAAE,UAAU;oBACjB,YAAY,EAAE,GAAG;oBACjB,QAAQ,EAAE;wBACR,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE;wBAC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CAAA;QACpE,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAM;QACR,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE,CAAA;QAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;QAE7C,OAAO;YACL,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK;YAClC,CAAC,EAAE,QAAQ,CAAC,GAAG;SAChB,CAAA;IACH,CAAC;;AA/LM,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDlB,AAvDY,CAuDZ;AAEgB;IAAhB,KAAK,EAAE;kDAeP;AAEgB;IAAhB,KAAK,EAAE;kDAcP;AAEgB;IAAhB,KAAK,EAAE;8CAWP;AAEkD;IAAlD,KAAK,CAAC,kCAAkC,CAAC;gDAA4B;AACnB;IAAlD,KAAK,CAAC,kCAAkC,CAAC;gDAA4B;AACtC;IAA/B,KAAK,CAAC,eAAe,CAAC;kDAAsC;AA1GlD,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAiMxB","sourcesContent":["import '@operato/data-tree/ox-tree.js'\nimport { OxTree } from '@operato/data-tree/ox-tree.js'\n\nimport { LitElement, html, svg, css, nothing } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\ninterface TreeNode {\n id: string\n label: string\n children?: TreeNode[]\n multiplicity?: '1' | '*' | '1..*' | '0..1'\n}\n\ninterface Mapping {\n inputs: string[]\n outputs: string[]\n transformLogic?: string\n}\n\n@customElement('ox-data-mapper')\nexport class OxDataMapper extends LitElement {\n static styles = css`\n .container {\n display: flex;\n width: 100%;\n height: 100%;\n position: relative;\n }\n\n .tree-container {\n flex: 1;\n display: flex;\n flex-direction: column;\n padding: 10px;\n border: 1px solid #ccc;\n overflow-y: auto;\n }\n\n .tree-container.source {\n padding-right: 0px;\n }\n\n .tree-container.target {\n padding-left: 0px;\n text-align: right;\n }\n\n .mapping-area {\n flex: 1;\n padding: 10px 0;\n margin: 0;\n border: 1px solid #ccc;\n text-align: center;\n position: relative;\n }\n\n svg {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n\n .mapping-box {\n fill: rgba(0, 0, 255, 0.2);\n stroke: blue;\n stroke-width: 0.5;\n }\n\n .mapping-line {\n stroke: black;\n stroke-width: 0.5;\n fill: none;\n }\n `\n\n @state() private sourceScheme: TreeNode = {\n id: 's1',\n label: 'Order',\n multiplicity: '*',\n children: [\n {\n id: 's1-1',\n label: 'Item',\n multiplicity: '*',\n children: [\n { id: 's1-1-1', label: 'Name' },\n { id: 's1-1-2', label: 'Price' }\n ]\n }\n ]\n }\n\n @state() private targetScheme: TreeNode = {\n id: 't1',\n label: 'Invoice',\n children: [\n {\n id: 't1-1',\n label: 'Products',\n multiplicity: '*',\n children: [\n { id: 't1-1-1', label: 'Product Name' },\n { id: 't1-1-2', label: 'Cost' }\n ]\n }\n ]\n }\n\n @state() private mappings: Mapping[] = [\n {\n inputs: ['s1-1-1'],\n outputs: ['t1-1-1'],\n transformLogic: 'toUpperCase()'\n },\n {\n inputs: ['s1-1-2'],\n outputs: ['t1-1-2'],\n transformLogic: 'convertCurrency()'\n }\n ]\n\n @query('.tree-container.source > ox-tree') private sourceTree!: OxTree\n @query('.tree-container.target > ox-tree') private targetTree!: OxTree\n @query('.mapping-area') private mappingsArea!: HTMLDivElement\n\n render() {\n return html`\n <div class=\"container\">\n <div class=\"tree-container source\">\n <h3>Source Structure</h3>\n <ox-tree .data=${this.sourceScheme} @select=${this.handleSourceSelect} label-extends></ox-tree>\n </div>\n <div class=\"mapping-area\">\n <h3>Mappings</h3>\n <svg>${this.mappings.map(m => this.renderMapping(m))}</svg>\n </div>\n <div class=\"tree-container target\">\n <h3>Target Structure</h3>\n <ox-tree\n .data=${this.targetScheme}\n @select=${this.handleTargetSelect}\n direction=\"rtl\"\n label-extends\n ></ox-tree>\n </div>\n </div>\n `\n }\n\n handleSourceSelect() {\n this.requestUpdate()\n }\n handleTargetSelect() {}\n\n renderMapping(mapping: Mapping) {\n const sourcePoses = mapping.inputs.map(input => this.getNodePosition(input, true)).filter(Boolean) as {\n x: number\n y: number\n }[]\n const targetPoses = mapping.outputs.map(output => this.getNodePosition(output, false)).filter(Boolean) as {\n x: number\n y: number\n }[]\n\n const positions = [...sourcePoses, ...targetPoses]\n if (positions.length == 0) {\n return nothing\n }\n\n const mappingsRect = this.mappingsArea.getBoundingClientRect()\n const centerY = positions.reduce((sum, pos) => {\n return sum + pos.y\n }, 0)\n\n const boxX = mappingsRect.width / 2 - 50\n const boxY = centerY / positions.length - 10\n\n return svg`\n <g>\n ${sourcePoses.map(sourcePos => svg`<line class=\"mapping-line\" x1=${sourcePos!.x} y1=${sourcePos!.y} x2=${boxX} y2=${boxY + 10}></line>`)}\n\n <rect class=\"mapping-box\" x=${boxX} y=${boxY} width=\"100\" height=\"20\"></rect>\n <text x=${boxX + 50} y=${boxY + 15} fill=\"black\" font-size=\"12\" text-anchor=\"middle\">\n ${mapping.transformLogic || 'map'}\n </text>\n\n ${targetPoses.map(targetPos => svg`<line class=\"mapping-line\" x1=${boxX + 100} y1=${boxY + 10} x2=${targetPos!.x} y2=${targetPos!.y}></line>`)}\n </g>\n `\n }\n\n getNodePosition(nodeId: string, source: boolean) {\n const tree = source ? this.sourceTree : this.targetTree\n if (!tree) {\n return\n }\n\n const node = tree!.renderRoot.querySelector(`[data-id='${nodeId}']`)\n if (!node) {\n return\n }\n\n const mappingsRect = this.mappingsArea.getBoundingClientRect()\n const nodeRect = node.getBoundingClientRect()\n\n return {\n x: source ? 0 : mappingsRect.width,\n y: nodeRect.top\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-data-mapper.js","sourceRoot":"","sources":["../../src/ox-data-mapper.ts"],"names":[],"mappings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AE,MAAM,EAAE,CAAC;kDAA2D;AAC3D;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAAyB;AAElC;IAAhB,KAAK,EAAE;8CAA6B;AAEc;IAAlD,KAAK,CAAC,kCAAkC,CAAC;gDAA4B;AACnB;IAAlD,KAAK,CAAC,kCAAkC,CAAC;gDAA4B;AACpC;IAAjC,KAAK,CAAC,iBAAiB,CAAC;kDAAqC;AAGtD;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;uDAcvC;AA7EU,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAoPxB","sourcesContent":["import '@operato/data-tree/ox-tree.js'\nimport './ox-mapping-area.js'\n\nimport { LitElement, html, css, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { provide } from '@lit/context'\n\nimport { OxTree } from '@operato/data-tree/ox-tree.js'\n\nimport { TreeNode, Mapping } from './types.js'\nimport { dataMapperContext, DataMapperContextType } from './context/data-mapper-context.js'\nimport { OxMappingArea } from './ox-mapping-area.js'\n\n@customElement('ox-data-mapper')\nexport class OxDataMapper extends LitElement {\n static styles = css`\n .container {\n display: flex;\n width: 100%;\n min-height: 100%;\n position: relative;\n overflow-y: auto;\n align-items: stretch;\n }\n\n .tree-container {\n position: relative;\n flex: 1;\n display: flex;\n flex-direction: column;\n padding: 0;\n margin: 0;\n }\n\n .tree-container.source {\n order: 0;\n padding-right: 0px;\n }\n\n .tree-container.target {\n order: 2;\n padding-left: 0px;\n text-align: right;\n }\n\n ox-mapping-area {\n order: 1;\n position: relative;\n flex: 1;\n padding: 0;\n margin: 0;\n text-align: center;\n position: relative;\n }\n\n .tree-container.source::after,\n ox-mapping-area::after {\n content: '';\n position: absolute;\n right: 0;\n top: 0;\n width: 1px;\n height: 100%;\n background-color: black;\n }\n `\n\n @property({ type: Object }) sourceSchema: TreeNode = { id: 'source', label: 'source' }\n @property({ type: Object }) targetSchema: TreeNode = { id: 'target', label: 'target' }\n @property({ type: Array }) mappings: Mapping[] = []\n\n @state() private selected: any = null\n\n @query('.tree-container.source > ox-tree') private sourceTree!: OxTree\n @query('.tree-container.target > ox-tree') private targetTree!: OxTree\n @query('ox-mapping-area') private mappingsArea!: OxMappingArea\n\n @provide({ context: dataMapperContext })\n private dataMapperContext: DataMapperContextType = {\n getUniqueId: () => {\n return Math.random().toString(36).substring(2, 9)\n },\n updateMappings: (mappings: Mapping[]) => {\n this.mappings = mappings\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.mappings\n })\n )\n },\n getNodePosition: this.getNodePosition.bind(this)\n }\n\n private dragStartElement: EventTarget | null = null\n\n render() {\n return html`\n <div class=\"container\">\n <div class=\"tree-container source\">\n <ox-tree\n .data=${this.sourceSchema}\n @collapsed=${() => this.mappingsArea.requestUpdate()}\n @expanded=${() => this.mappingsArea.requestUpdate()}\n @dragstart=${this.onDragStart}\n @dragover=${this.onDragOver}\n @drop=${this.onDrop}\n label-extends\n ></ox-tree>\n </div>\n\n <div class=\"tree-container target\">\n <ox-tree\n .data=${this.targetSchema}\n @collapsed=${() => this.mappingsArea.requestUpdate()}\n @expanded=${() => this.mappingsArea.requestUpdate()}\n @dragstart=${this.onDragStart}\n @dragover=${this.onDragOver}\n @drop=${this.onDrop}\n direction=\"rtl\"\n label-extends\n ></ox-tree>\n </div>\n\n <ox-mapping-area .mappings=${this.mappings}></ox-mapping-area>\n </div>\n `\n }\n\n getNodePosition(nodeId: string, source: boolean) {\n const tree = source ? this.sourceTree : this.targetTree\n if (!tree) {\n return\n }\n\n const nodeRect = tree.findNodeSelfBounds(nodeId)\n if (!nodeRect) {\n return\n }\n const mappingAreaRect = this.mappingsArea.getBoundingClientRect()\n\n return {\n x: source ? 0 : mappingAreaRect.width,\n y: nodeRect.top - mappingAreaRect.top + nodeRect!.height / 2\n }\n }\n\n onDragStart(e: DragEvent) {\n const path = e.composedPath()\n const target = path.find(el => (el as HTMLElement).dataset?.id) as HTMLElement | undefined\n const nodeId = target?.dataset?.id\n\n if (!nodeId) {\n return\n }\n\n const from = e.target === this.sourceTree ? 'source' : 'target'\n\n e.dataTransfer!.setData('application/node-id', nodeId)\n e.dataTransfer!.setData('application/from', from)\n e.dataTransfer!.effectAllowed = 'move'\n\n // ✅ 노드의 라벨을 찾아 미리보기로 사용\n const nodeLabel = target?.querySelector('span[label]')?.textContent || nodeId\n\n // ✅ 미리보기 요소 생성\n const dragPreview = document.createElement('div')\n dragPreview.textContent = nodeLabel\n dragPreview.style.fontSize = '14px'\n dragPreview.style.padding = '4px 8px'\n dragPreview.style.background = 'rgba(255, 255, 255, 0.3)'\n dragPreview.style.borderRadius = '4px'\n dragPreview.style.position = 'absolute'\n dragPreview.style.top = '-100px' // 화면 밖으로 배치 (임시)\n dragPreview.style.left = '-100px'\n dragPreview.style.pointerEvents = 'none'\n dragPreview.style.zIndex = '1000'\n\n document.body.appendChild(dragPreview)\n\n // ✅ 커스텀 드래깅 이미지 적용\n e.dataTransfer!.setDragImage(dragPreview, 0, 0)\n\n this.dragStartElement = e.target\n\n // ✅ 일정 시간 후 미리보기 요소 삭제\n setTimeout(() => document.body.removeChild(dragPreview), 0)\n }\n\n onDragOver(e: DragEvent) {\n e.preventDefault()\n\n const from = e.dataTransfer!.getData('application/from')\n\n if (this.dragStartElement === e.target) {\n return\n }\n\n const path = e.composedPath()\n const target = path.find(el => (el as HTMLElement).dataset?.id) as HTMLElement | undefined\n const nodeId = target?.dataset?.id\n\n if (!nodeId) return\n ;(e.target as OxTree).selected = (target as any).item\n }\n\n onDrop(e: DragEvent) {\n e.preventDefault()\n\n const nodeId = e.dataTransfer!.getData('application/node-id')\n const from = e.dataTransfer!.getData('application/from')\n\n if (\n !nodeId ||\n (from == 'source' && e.target !== this.targetTree) ||\n (from == 'target' && e.target !== this.sourceTree)\n ) {\n return\n }\n\n // 드롭된 타겟 노드 찾기\n const path = e.composedPath()\n const targetNode = path.find(el => (el as HTMLElement).dataset?.id) as HTMLElement | undefined\n const targetNodeId = targetNode?.dataset?.id\n\n if (!targetNodeId) {\n return\n }\n\n // 중복 매핑 확인\n const existingMapping = (this.mappings || []).find(\n m =>\n m.inputs.includes(from == 'source' ? nodeId : targetNodeId) &&\n m.outputs.includes(from == 'source' ? targetNodeId : nodeId)\n )\n\n if (!existingMapping) {\n const { width, height } = this.mappingsArea.getBoundingClientRect()\n const { y: sourceY = 0 } =\n this.dataMapperContext.getNodePosition(from == 'source' ? nodeId : targetNodeId, true) || {}\n const { y: targetY = height } =\n this.dataMapperContext.getNodePosition(from == 'target' ? nodeId : targetNodeId, false) || {}\n\n const newMapping: Mapping = {\n id: this.dataMapperContext.getUniqueId(),\n mappingFunction: 'passthrough',\n inputs: [from == 'source' ? nodeId : targetNodeId],\n outputs: [from == 'source' ? targetNodeId : nodeId],\n position: {\n x: width / 2 - 50,\n y: (sourceY + targetY) / 2\n }\n }\n\n this.dataMapperContext.updateMappings([...(this.mappings || []), newMapping])\n\n this.mappingsArea.selectMappingBox(newMapping)\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { Mapping } from './types.js';
|
|
3
|
+
import './components/function-box-popup.js';
|
|
4
|
+
export declare class OxMappingArea extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
mappings: Mapping[];
|
|
7
|
+
selectedMapping?: Mapping;
|
|
8
|
+
selectedLine?: {
|
|
9
|
+
mapping: Mapping;
|
|
10
|
+
nodeId: string;
|
|
11
|
+
isInput: boolean;
|
|
12
|
+
};
|
|
13
|
+
popupVisible: boolean;
|
|
14
|
+
popupPosition: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
};
|
|
18
|
+
private dataMapperContext;
|
|
19
|
+
connectedCallback(): void;
|
|
20
|
+
disconnectedCallback(): void;
|
|
21
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
22
|
+
renderMapping(mapping: Mapping): import("lit-html").TemplateResult<2>;
|
|
23
|
+
startDragForMappingBox(e: PointerEvent, mapping: Mapping): void;
|
|
24
|
+
handleDragOver(e: DragEvent): void;
|
|
25
|
+
handleDrop(e: DragEvent): void;
|
|
26
|
+
selectMappingBox(mapping: Mapping): void;
|
|
27
|
+
selectMappingLine(mapping: Mapping, nodeId: string, isInput: boolean): void;
|
|
28
|
+
isLineSelected(mapping: Mapping, nodeId: string, isInput: boolean): boolean;
|
|
29
|
+
openPopup(e: PointerEvent, mapping: Mapping): void;
|
|
30
|
+
getSelectedTransformLogic(): string;
|
|
31
|
+
updateTransformLogic(e: Event): void;
|
|
32
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
33
|
+
deleteSelectedLine(): void;
|
|
34
|
+
deleteSelectedMapping(): void;
|
|
35
|
+
private handleResize;
|
|
36
|
+
}
|