open-grid 0.3.2 → 0.4.0
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/README.md +3 -2
- package/dist/OpenGrid-ClmeIJYR.cjs +88 -0
- package/dist/OpenGrid-ClmeIJYR.cjs.map +1 -0
- package/dist/{OpenGrid-Dult64jp.js → OpenGrid-doS5aFVl.js} +976 -708
- package/dist/OpenGrid-doS5aFVl.js.map +1 -0
- package/dist/open-grid-base.css +14 -0
- package/dist/open-grid-react.cjs +1 -1
- package/dist/open-grid-react.js +1 -1
- package/dist/open-grid-vue.cjs +1 -1
- package/dist/open-grid-vue.js +1 -1
- package/dist/open-grid.cjs +6 -6
- package/dist/open-grid.cjs.map +1 -1
- package/dist/open-grid.js +224 -172
- package/dist/open-grid.js.map +1 -1
- package/dist/types/core/CrossGridMapper.d.ts +21 -0
- package/dist/types/core/CrossGridRegistry.d.ts +13 -0
- package/dist/types/core/DragVisuals.d.ts +23 -0
- package/dist/types/core/GridShuttle.d.ts +25 -0
- package/dist/types/core/OpenGrid.d.ts +28 -0
- package/dist/types/core/RowDragDrop.d.ts +25 -5
- package/dist/types/core/renderers/CellRenderer.d.ts +12 -1
- package/dist/types/core/types.d.ts +57 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +2 -5
- package/dist/OpenGrid-CzP1mcZW.cjs +0 -90
- package/dist/OpenGrid-CzP1mcZW.cjs.map +0 -1
- package/dist/OpenGrid-Dult64jp.js.map +0 -1
package/dist/open-grid.js
CHANGED
|
@@ -1,7 +1,57 @@
|
|
|
1
|
-
import { b as E } from "./OpenGrid-
|
|
2
|
-
import { O as
|
|
1
|
+
import { b as E } from "./OpenGrid-doS5aFVl.js";
|
|
2
|
+
import { O as L } from "./OpenGrid-doS5aFVl.js";
|
|
3
|
+
class C {
|
|
4
|
+
constructor(t, e, r, i = {}) {
|
|
5
|
+
this._left = t, this._right = e;
|
|
6
|
+
const o = document.createElement("div");
|
|
7
|
+
o.className = "og-shuttle", o.style.cssText = `display:flex;gap:6px;align-items:center;justify-content:center;flex-direction:${i.layout === "horizontal" ? "row" : "column"};`;
|
|
8
|
+
const c = (m, g, u) => {
|
|
9
|
+
const a = document.createElement("button");
|
|
10
|
+
return a.type = "button", a.className = "og-shuttle-btn", a.textContent = m, a.title = g, a.style.cssText = "min-width:34px;height:30px;padding:0 8px;border:1px solid #bbb;border-radius:7px;background:#fff;cursor:pointer;font-size:14px;color:#444;line-height:1;box-shadow:0 1px 2px rgba(0,0,0,0.06);", a.addEventListener("mouseover", () => {
|
|
11
|
+
a.style.background = "#f0f6ff", a.style.borderColor = "#1976d2";
|
|
12
|
+
}), a.addEventListener("mouseout", () => {
|
|
13
|
+
a.style.background = "#fff", a.style.borderColor = "#bbb";
|
|
14
|
+
}), a.addEventListener("click", u), a;
|
|
15
|
+
}, _ = i.labels ?? {};
|
|
16
|
+
o.appendChild(c(
|
|
17
|
+
_.toRight ?? "▶",
|
|
18
|
+
"체크한 행을 오른쪽 그리드로 이동",
|
|
19
|
+
() => {
|
|
20
|
+
this._left.moveCheckedTo(this._right);
|
|
21
|
+
}
|
|
22
|
+
)), o.appendChild(c(
|
|
23
|
+
_.toLeft ?? "◀",
|
|
24
|
+
"체크한 행을 왼쪽 그리드로 이동",
|
|
25
|
+
() => {
|
|
26
|
+
this._right.moveCheckedTo(this._left);
|
|
27
|
+
}
|
|
28
|
+
)), i.includeAll && (o.appendChild(c(
|
|
29
|
+
_.allRight ?? "⏩",
|
|
30
|
+
"왼쪽 전체를 오른쪽으로 이동",
|
|
31
|
+
() => {
|
|
32
|
+
this._moveAll(this._left, this._right);
|
|
33
|
+
}
|
|
34
|
+
)), o.appendChild(c(
|
|
35
|
+
_.allLeft ?? "⏪",
|
|
36
|
+
"오른쪽 전체를 왼쪽으로 이동",
|
|
37
|
+
() => {
|
|
38
|
+
this._moveAll(this._right, this._left);
|
|
39
|
+
}
|
|
40
|
+
))), r.appendChild(o), this._el = o;
|
|
41
|
+
}
|
|
42
|
+
_moveAll(t, e) {
|
|
43
|
+
const r = t.getData().length;
|
|
44
|
+
r > 0 && t.moveRowsTo(e, Array.from({ length: r }, (i, o) => o));
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this._el.remove();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function v(b, t, e, r) {
|
|
51
|
+
return new C(b, t, e, r);
|
|
52
|
+
}
|
|
3
53
|
class N {
|
|
4
|
-
constructor(t,
|
|
54
|
+
constructor(t, e) {
|
|
5
55
|
this._data = [], this._roots = [], this._expandedKeys = /* @__PURE__ */ new Set(), this._selectedId = null, this._container = typeof t == "string" ? document.querySelector(t) : t, this._opts = {
|
|
6
56
|
nodeWidth: 160,
|
|
7
57
|
nodeHeight: 72,
|
|
@@ -10,21 +60,21 @@ class N {
|
|
|
10
60
|
expandOnLoad: !0,
|
|
11
61
|
onNodeClick: () => {
|
|
12
62
|
},
|
|
13
|
-
...
|
|
63
|
+
...e
|
|
14
64
|
}, this._container.classList.add("og-orgchart");
|
|
15
65
|
}
|
|
16
66
|
setData(t) {
|
|
17
67
|
this._data = t;
|
|
18
|
-
const { idField:
|
|
19
|
-
|
|
68
|
+
const { idField: e, parentIdField: r, expandOnLoad: i } = this._opts;
|
|
69
|
+
i && this._expandedKeys.size === 0 && t.forEach((o) => this._expandedKeys.add(o[e])), this._roots = E(t, { idField: e, parentIdField: r }, this._expandedKeys), this._render();
|
|
20
70
|
}
|
|
21
71
|
setTheme(t) {
|
|
22
72
|
this._container.setAttribute("data-og-theme", t);
|
|
23
73
|
}
|
|
24
74
|
expandAll() {
|
|
25
|
-
const t = (
|
|
26
|
-
for (const
|
|
27
|
-
this._expandedKeys.add(
|
|
75
|
+
const t = (e) => {
|
|
76
|
+
for (const r of e)
|
|
77
|
+
this._expandedKeys.add(r._treeId), r.children.length && t(r.children);
|
|
28
78
|
};
|
|
29
79
|
t(this._roots), this._rebuild();
|
|
30
80
|
}
|
|
@@ -35,100 +85,100 @@ class N {
|
|
|
35
85
|
this._expandedKeys.has(t) ? this._expandedKeys.delete(t) : this._expandedKeys.add(t), this._rebuild();
|
|
36
86
|
}
|
|
37
87
|
_rebuild() {
|
|
38
|
-
const { idField: t, parentIdField:
|
|
39
|
-
this._roots = E(this._data, { idField: t, parentIdField:
|
|
88
|
+
const { idField: t, parentIdField: e } = this._opts;
|
|
89
|
+
this._roots = E(this._data, { idField: t, parentIdField: e }, this._expandedKeys), this._render();
|
|
40
90
|
}
|
|
41
91
|
// ── 레이아웃 계산 (post-order: 리프부터 배치, 부모는 자식 중앙) ──
|
|
42
92
|
_calcLayout() {
|
|
43
|
-
const { nodeWidth: t, nodeHeight:
|
|
44
|
-
let
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
const
|
|
49
|
-
return
|
|
93
|
+
const { nodeWidth: t, nodeHeight: e, levelGap: r, siblingGap: i } = this._opts, o = /* @__PURE__ */ new Map();
|
|
94
|
+
let c = 0;
|
|
95
|
+
const _ = (u) => {
|
|
96
|
+
const a = u._depth * (e + r), p = u._expanded ? u.children : [];
|
|
97
|
+
if (!p.length) {
|
|
98
|
+
const f = c;
|
|
99
|
+
return c += t + i, o.set(u._treeId, { x: f, y: a }), { minX: f, maxX: f };
|
|
50
100
|
}
|
|
51
|
-
let n = 1 / 0,
|
|
52
|
-
for (const
|
|
53
|
-
const { minX:
|
|
54
|
-
|
|
101
|
+
let n = 1 / 0, l = -1 / 0;
|
|
102
|
+
for (const f of p) {
|
|
103
|
+
const { minX: s, maxX: h } = _(f);
|
|
104
|
+
s < n && (n = s), h > l && (l = h);
|
|
55
105
|
}
|
|
56
|
-
const
|
|
57
|
-
return
|
|
106
|
+
const d = n + (l - n + t) / 2 - t / 2;
|
|
107
|
+
return o.set(u._treeId, { x: d, y: a }), { minX: n, maxX: l };
|
|
58
108
|
};
|
|
59
|
-
for (const
|
|
60
|
-
let
|
|
61
|
-
for (const { x:
|
|
62
|
-
|
|
63
|
-
return { layout:
|
|
109
|
+
for (const u of this._roots) _(u);
|
|
110
|
+
let m = 0, g = 0;
|
|
111
|
+
for (const { x: u, y: a } of o.values())
|
|
112
|
+
u + t > m && (m = u + t), a + e > g && (g = a + e);
|
|
113
|
+
return { layout: o, totalW: m + i, totalH: g + r + 16 };
|
|
64
114
|
}
|
|
65
115
|
// ── SVG 직선 헬퍼 ──
|
|
66
|
-
_line(t,
|
|
67
|
-
const
|
|
68
|
-
|
|
116
|
+
_line(t, e, r, i, o) {
|
|
117
|
+
const c = document.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
118
|
+
c.setAttribute("x1", String(e)), c.setAttribute("y1", String(r)), c.setAttribute("x2", String(i)), c.setAttribute("y2", String(o)), c.setAttribute("class", "og-orgchart-line"), t.appendChild(c);
|
|
69
119
|
}
|
|
70
120
|
// ── 렌더 ──
|
|
71
121
|
_render() {
|
|
72
|
-
const { nodeWidth: t, nodeHeight:
|
|
122
|
+
const { nodeWidth: t, nodeHeight: e, levelGap: r, columns: i } = this._opts, { layout: o, totalW: c, totalH: _ } = this._calcLayout();
|
|
73
123
|
this._container.innerHTML = "";
|
|
74
|
-
const
|
|
75
|
-
|
|
124
|
+
const m = document.createElement("div");
|
|
125
|
+
m.className = "og-orgchart-wrap", m.style.cssText = `width:${c}px;height:${_}px;`;
|
|
76
126
|
const g = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
77
|
-
g.setAttribute("width", String(
|
|
78
|
-
const
|
|
79
|
-
for (const n of
|
|
127
|
+
g.setAttribute("width", String(c)), g.setAttribute("height", String(_)), g.style.cssText = "position:absolute;top:0;left:0;pointer-events:none;overflow:visible;";
|
|
128
|
+
const u = (p) => {
|
|
129
|
+
for (const n of p) {
|
|
80
130
|
if (!n._expanded || !n.children.length) continue;
|
|
81
|
-
const
|
|
82
|
-
if (this._line(g,
|
|
83
|
-
const
|
|
84
|
-
this._line(g,
|
|
131
|
+
const l = o.get(n._treeId), d = l.x + t / 2, f = l.y + e, s = f + r / 2, h = n.children;
|
|
132
|
+
if (this._line(g, d, f, d, s), h.length > 1) {
|
|
133
|
+
const x = o.get(h[0]._treeId), y = o.get(h[h.length - 1]._treeId);
|
|
134
|
+
this._line(g, x.x + t / 2, s, y.x + t / 2, s);
|
|
85
135
|
}
|
|
86
|
-
for (const
|
|
87
|
-
const y =
|
|
88
|
-
this._line(g, A,
|
|
136
|
+
for (const x of h) {
|
|
137
|
+
const y = o.get(x._treeId), A = y.x + t / 2;
|
|
138
|
+
this._line(g, A, s, A, y.y);
|
|
89
139
|
}
|
|
90
|
-
|
|
140
|
+
u(h);
|
|
91
141
|
}
|
|
92
142
|
};
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
for (const n of
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
for (const
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
const y = typeof
|
|
106
|
-
|
|
143
|
+
u(this._roots), m.appendChild(g);
|
|
144
|
+
const a = (p) => {
|
|
145
|
+
for (const n of p) {
|
|
146
|
+
const l = o.get(n._treeId);
|
|
147
|
+
if (!l) continue;
|
|
148
|
+
const d = document.createElement("div");
|
|
149
|
+
d.className = "og-orgchart-node", n._hasChildren && d.classList.add("og-orgchart-node--branch"), n._expanded && d.classList.add("og-orgchart-node--expanded"), this._selectedId === n._treeId && d.classList.add("og-orgchart-node--selected"), d.style.cssText = `left:${l.x}px;top:${l.y}px;width:${t}px;height:${e}px;`;
|
|
150
|
+
const f = document.createElement("div");
|
|
151
|
+
f.className = "og-orgchart-node-content";
|
|
152
|
+
for (const s of i) {
|
|
153
|
+
const h = n.data[s.field], x = document.createElement("div");
|
|
154
|
+
if (x.className = "og-orgchart-col" + (s.className ? " " + s.className : ""), s.style) {
|
|
155
|
+
const y = typeof s.style == "function" ? s.style(h, n.data) : s.style;
|
|
156
|
+
x.setAttribute("style", y);
|
|
107
157
|
}
|
|
108
|
-
if (
|
|
109
|
-
const y =
|
|
110
|
-
typeof y == "string" ?
|
|
158
|
+
if (s.renderer) {
|
|
159
|
+
const y = s.renderer(h, n.data);
|
|
160
|
+
typeof y == "string" ? x.innerHTML = y : x.appendChild(y);
|
|
111
161
|
} else
|
|
112
|
-
|
|
113
|
-
|
|
162
|
+
x.textContent = h ?? "";
|
|
163
|
+
f.appendChild(x);
|
|
114
164
|
}
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}),
|
|
165
|
+
if (d.appendChild(f), n._hasChildren) {
|
|
166
|
+
const s = document.createElement("button");
|
|
167
|
+
s.type = "button", s.className = "og-orgchart-toggle", s.setAttribute("aria-expanded", n._expanded ? "true" : "false"), s.setAttribute("aria-label", n._expanded ? "접기" : "펼치기");
|
|
168
|
+
const h = document.createElement("i");
|
|
169
|
+
h.setAttribute("aria-hidden", "true"), h.className = n._expanded ? "bi bi-dash-circle" : "bi bi-plus-circle", s.appendChild(h), s.addEventListener("click", (x) => {
|
|
170
|
+
x.stopPropagation(), this._toggle(n._treeId);
|
|
171
|
+
}), d.appendChild(s);
|
|
122
172
|
}
|
|
123
|
-
|
|
124
|
-
this._selectedId = n._treeId, this._opts.onNodeClick(n._treeId, n.data), this._container.querySelectorAll(".og-orgchart-node--selected").forEach((
|
|
125
|
-
}),
|
|
173
|
+
d.addEventListener("click", () => {
|
|
174
|
+
this._selectedId = n._treeId, this._opts.onNodeClick(n._treeId, n.data), this._container.querySelectorAll(".og-orgchart-node--selected").forEach((s) => s.classList.remove("og-orgchart-node--selected")), d.classList.add("og-orgchart-node--selected");
|
|
175
|
+
}), m.appendChild(d), n._expanded && n.children.length && a(n.children);
|
|
126
176
|
}
|
|
127
177
|
};
|
|
128
|
-
|
|
178
|
+
a(this._roots), this._container.appendChild(m);
|
|
129
179
|
}
|
|
130
180
|
}
|
|
131
|
-
class
|
|
181
|
+
class w {
|
|
132
182
|
// ── 1. XML → 데이터 배열 ────────────────────────────────────
|
|
133
183
|
/**
|
|
134
184
|
* XML 문자열을 파싱하여 그리드 데이터 배열로 변환.
|
|
@@ -136,65 +186,65 @@ class b {
|
|
|
136
186
|
*
|
|
137
187
|
* @throws XML 파싱 오류 시 Error 발생
|
|
138
188
|
*/
|
|
139
|
-
static parse(t,
|
|
140
|
-
var
|
|
141
|
-
const { fieldMap:
|
|
142
|
-
if (
|
|
143
|
-
const
|
|
144
|
-
let g =
|
|
189
|
+
static parse(t, e = {}) {
|
|
190
|
+
var p, n;
|
|
191
|
+
const { fieldMap: r = {}, trim: i = !0 } = e, c = new DOMParser().parseFromString(t.trim(), "text/xml"), _ = c.querySelector("parsererror");
|
|
192
|
+
if (_) throw new Error(`XML 파싱 오류: ${(p = _.textContent) == null ? void 0 : p.trim()}`);
|
|
193
|
+
const m = c.documentElement;
|
|
194
|
+
let g = e.rowTag;
|
|
145
195
|
if (!g) {
|
|
146
|
-
const
|
|
147
|
-
g = ((n =
|
|
196
|
+
const l = e.rootTag ? c.querySelector(e.rootTag) : m;
|
|
197
|
+
g = ((n = l == null ? void 0 : l.children[0]) == null ? void 0 : n.tagName) ?? "row";
|
|
148
198
|
}
|
|
149
|
-
const
|
|
150
|
-
for (let
|
|
151
|
-
const
|
|
152
|
-
for (const
|
|
153
|
-
const
|
|
154
|
-
|
|
199
|
+
const u = c.getElementsByTagName(g), a = [];
|
|
200
|
+
for (let l = 0; l < u.length; l++) {
|
|
201
|
+
const d = u[l], f = {};
|
|
202
|
+
for (const s of Array.from(d.attributes)) {
|
|
203
|
+
const h = r[s.name] ?? s.name;
|
|
204
|
+
f[h] = i ? s.value.trim() : s.value;
|
|
155
205
|
}
|
|
156
|
-
for (const
|
|
157
|
-
const
|
|
158
|
-
|
|
206
|
+
for (const s of Array.from(d.children)) {
|
|
207
|
+
const h = r[s.tagName] ?? s.tagName, x = s.textContent ?? "";
|
|
208
|
+
f[h] = i ? x.trim() : x;
|
|
159
209
|
}
|
|
160
|
-
|
|
210
|
+
a.push(f);
|
|
161
211
|
}
|
|
162
|
-
return
|
|
212
|
+
return a;
|
|
163
213
|
}
|
|
164
214
|
// ── 2. 데이터 배열 → XML ─────────────────────────────────────
|
|
165
215
|
/**
|
|
166
216
|
* 그리드 데이터 배열을 XML 문자열로 직렬화.
|
|
167
217
|
*/
|
|
168
|
-
static stringify(t,
|
|
218
|
+
static stringify(t, e = {}) {
|
|
169
219
|
const {
|
|
170
|
-
rootTag:
|
|
171
|
-
rowTag:
|
|
172
|
-
mode:
|
|
173
|
-
fieldMap:
|
|
174
|
-
declaration:
|
|
175
|
-
indent:
|
|
220
|
+
rootTag: r = "rows",
|
|
221
|
+
rowTag: i = "row",
|
|
222
|
+
mode: o = "element",
|
|
223
|
+
fieldMap: c = {},
|
|
224
|
+
declaration: _ = !0,
|
|
225
|
+
indent: m = 2,
|
|
176
226
|
nullAs: g = "",
|
|
177
|
-
excludeFields:
|
|
178
|
-
} =
|
|
179
|
-
|
|
227
|
+
excludeFields: u = []
|
|
228
|
+
} = e, a = " ".repeat(m), p = [];
|
|
229
|
+
_ && p.push('<?xml version="1.0" encoding="UTF-8"?>'), p.push(`<${r}>`);
|
|
180
230
|
for (const n of t) {
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
return `${
|
|
231
|
+
const l = Object.entries(n).filter(([d]) => !u.includes(d));
|
|
232
|
+
if (o === "attribute") {
|
|
233
|
+
const d = l.map(([f, s]) => {
|
|
234
|
+
const h = c[f] ?? f, x = s == null ? g : String(s);
|
|
235
|
+
return `${h}="${this._escAttr(x)}"`;
|
|
186
236
|
}).join(" ");
|
|
187
|
-
|
|
237
|
+
p.push(`${a}<${i}${d ? " " + d : ""} />`);
|
|
188
238
|
} else {
|
|
189
|
-
|
|
190
|
-
for (const [
|
|
191
|
-
const
|
|
192
|
-
|
|
239
|
+
p.push(`${a}<${i}>`);
|
|
240
|
+
for (const [d, f] of l) {
|
|
241
|
+
const s = c[d] ?? d, h = f == null ? g : String(f);
|
|
242
|
+
p.push(`${a}${a}<${s}>${this._escText(h)}</${s}>`);
|
|
193
243
|
}
|
|
194
|
-
|
|
244
|
+
p.push(`${a}</${i}>`);
|
|
195
245
|
}
|
|
196
246
|
}
|
|
197
|
-
return
|
|
247
|
+
return p.push(`</${r}>`), p.join(`
|
|
198
248
|
`);
|
|
199
249
|
}
|
|
200
250
|
// ── 3. SAP BAPI XML 응답 파싱 ────────────────────────────────
|
|
@@ -207,42 +257,42 @@ class b {
|
|
|
207
257
|
* <RETURN><TYPE>S</TYPE><MESSAGE>...</MESSAGE></RETURN>
|
|
208
258
|
*/
|
|
209
259
|
static parseSap(t) {
|
|
210
|
-
var
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
213
|
-
for (const
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
for (const
|
|
260
|
+
var m, g, u, a;
|
|
261
|
+
const r = new DOMParser().parseFromString(t.trim(), "text/xml"), i = { header: {}, items: [], returns: [], raw: r }, o = r.getElementsByTagName("DOCUMENTHEADER")[0];
|
|
262
|
+
if (o)
|
|
263
|
+
for (const p of Array.from(o.children))
|
|
264
|
+
i.header[p.tagName] = ((m = p.textContent) == null ? void 0 : m.trim()) ?? "";
|
|
265
|
+
const c = r.getElementsByTagName("RETURN");
|
|
266
|
+
for (const p of Array.from(c)) {
|
|
217
267
|
const n = {};
|
|
218
|
-
for (const
|
|
219
|
-
n[
|
|
220
|
-
|
|
268
|
+
for (const l of Array.from(p.children))
|
|
269
|
+
n[l.tagName] = ((g = l.textContent) == null ? void 0 : g.trim()) ?? "";
|
|
270
|
+
i.returns.push(n);
|
|
221
271
|
}
|
|
222
|
-
const
|
|
223
|
-
for (const
|
|
224
|
-
const n =
|
|
272
|
+
const _ = ["ACCOUNTGL", "ACCOUNTRECEIVABLE", "ACCOUNTPAYABLE", "ITEMS"];
|
|
273
|
+
for (const p of _) {
|
|
274
|
+
const n = r.getElementsByTagName(p)[0];
|
|
225
275
|
if (!n) continue;
|
|
226
|
-
const
|
|
227
|
-
for (const
|
|
228
|
-
const
|
|
229
|
-
for (const
|
|
230
|
-
|
|
231
|
-
|
|
276
|
+
const l = n.getElementsByTagName("ITEM"), d = l.length > 0 ? Array.from(l) : [n];
|
|
277
|
+
for (const f of d) {
|
|
278
|
+
const s = {};
|
|
279
|
+
for (const h of Array.from(f.children))
|
|
280
|
+
s[h.tagName] = ((u = h.textContent) == null ? void 0 : u.trim()) ?? "";
|
|
281
|
+
i.items.push(s);
|
|
232
282
|
}
|
|
233
283
|
break;
|
|
234
284
|
}
|
|
235
|
-
if (
|
|
236
|
-
const
|
|
237
|
-
for (const
|
|
238
|
-
if (
|
|
239
|
-
const
|
|
240
|
-
for (const
|
|
241
|
-
|
|
242
|
-
Object.keys(
|
|
285
|
+
if (i.items.length === 0) {
|
|
286
|
+
const p = r.documentElement, n = Array.from(p.children).filter((l) => l.hasAttribute("SEGMENT"));
|
|
287
|
+
for (const l of n) {
|
|
288
|
+
if (l.tagName === "EDI_DC40") continue;
|
|
289
|
+
const d = {};
|
|
290
|
+
for (const f of Array.from(l.children))
|
|
291
|
+
d[f.tagName] = ((a = f.textContent) == null ? void 0 : a.trim()) ?? "";
|
|
292
|
+
Object.keys(d).length > 0 && i.items.push(d);
|
|
243
293
|
}
|
|
244
294
|
}
|
|
245
|
-
return
|
|
295
|
+
return i;
|
|
246
296
|
}
|
|
247
297
|
// ── 4. SAP BAPI 페이로드 → XML 직렬화 ───────────────────────
|
|
248
298
|
/**
|
|
@@ -250,30 +300,30 @@ class b {
|
|
|
250
300
|
* sapGenPayload()의 결과 또는 단일 document 객체를 받음.
|
|
251
301
|
*/
|
|
252
302
|
static stringifySap(t) {
|
|
253
|
-
const
|
|
303
|
+
const e = [
|
|
254
304
|
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
255
305
|
"<BAPI_CALL>"
|
|
256
306
|
];
|
|
257
|
-
if (t.BAPI_FUNCTION &&
|
|
258
|
-
|
|
259
|
-
for (const [
|
|
260
|
-
|
|
261
|
-
|
|
307
|
+
if (t.BAPI_FUNCTION && e.push(` <FUNCTION>${this._escText(t.BAPI_FUNCTION)}</FUNCTION>`), t.DOCUMENTHEADER && typeof t.DOCUMENTHEADER == "object") {
|
|
308
|
+
e.push(" <DOCUMENTHEADER>");
|
|
309
|
+
for (const [i, o] of Object.entries(t.DOCUMENTHEADER))
|
|
310
|
+
o != null && o !== "" && e.push(` <${i}>${this._escText(String(o))}</${i}>`);
|
|
311
|
+
e.push(" </DOCUMENTHEADER>");
|
|
262
312
|
}
|
|
263
|
-
const
|
|
264
|
-
(
|
|
313
|
+
const r = Object.keys(t).find(
|
|
314
|
+
(i) => Array.isArray(t[i]) && !i.startsWith("_")
|
|
265
315
|
);
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
for (const
|
|
269
|
-
|
|
270
|
-
for (const [
|
|
271
|
-
|
|
272
|
-
|
|
316
|
+
if (r) {
|
|
317
|
+
e.push(` <${r}>`);
|
|
318
|
+
for (const i of t[r]) {
|
|
319
|
+
e.push(" <ITEM>");
|
|
320
|
+
for (const [o, c] of Object.entries(i))
|
|
321
|
+
c != null && c !== "" && !o.startsWith("_") && e.push(` <${o}>${this._escText(String(c))}</${o}>`);
|
|
322
|
+
e.push(" </ITEM>");
|
|
273
323
|
}
|
|
274
|
-
|
|
324
|
+
e.push(` </${r}>`);
|
|
275
325
|
}
|
|
276
|
-
return
|
|
326
|
+
return e.push("</BAPI_CALL>"), e.join(`
|
|
277
327
|
`);
|
|
278
328
|
}
|
|
279
329
|
// ── 5. 다건 documents 배열 → XML (sapGenPayload 결과 전체) ───
|
|
@@ -282,17 +332,17 @@ class b {
|
|
|
282
332
|
* 다건 BAPI XML로 직렬화.
|
|
283
333
|
*/
|
|
284
334
|
static stringifySapBatch(t) {
|
|
285
|
-
const
|
|
335
|
+
const e = [
|
|
286
336
|
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
287
337
|
`<BAPI_BATCH total="${t.documents.length}">`
|
|
288
338
|
];
|
|
289
|
-
return t.documents.forEach((
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
`).filter((
|
|
339
|
+
return t.documents.forEach((r, i) => {
|
|
340
|
+
e.push(` <BAPI_CALL seq="${i + 1}">`);
|
|
341
|
+
const o = this.stringifySap(r).split(`
|
|
342
|
+
`).filter((c) => !c.startsWith("<?xml")).map((c) => " " + c).join(`
|
|
293
343
|
`);
|
|
294
|
-
|
|
295
|
-
}),
|
|
344
|
+
e.push(o), e.push(" </BAPI_CALL>");
|
|
345
|
+
}), e.push("</BAPI_BATCH>"), e.join(`
|
|
296
346
|
`);
|
|
297
347
|
}
|
|
298
348
|
// ── 내부 이스케이프 헬퍼 ─────────────────────────────────────
|
|
@@ -304,8 +354,10 @@ class b {
|
|
|
304
354
|
}
|
|
305
355
|
}
|
|
306
356
|
export {
|
|
307
|
-
|
|
357
|
+
C as GridShuttle,
|
|
358
|
+
L as OpenGrid,
|
|
308
359
|
N as OrgChart,
|
|
309
|
-
|
|
360
|
+
w as XmlConverter,
|
|
361
|
+
v as createGridShuttle
|
|
310
362
|
};
|
|
311
363
|
//# sourceMappingURL=open-grid.js.map
|