open-grid 1.6.1 → 1.7.1

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 (134) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/ExportProgressView-BYPw8osg.cjs +2 -0
  3. package/dist/ExportProgressView-Bt5-z7rE.js +2 -0
  4. package/dist/LcpMergeOrderer-CeP6C6G1.cjs +2 -0
  5. package/dist/LcpMergeOrderer-Ebwuir-r.js +2 -0
  6. package/dist/OpenGrid-Bh1NMOcm.cjs +98 -0
  7. package/dist/OpenGrid-CeXt04ho.js +98 -0
  8. package/dist/Registry-CrT46EAO.js +2 -0
  9. package/dist/Registry-DpHOpU5V.cjs +2 -0
  10. package/dist/XlsxChannel-CuOZ3LQz.js +2 -0
  11. package/dist/XlsxChannel-DQHLGend.cjs +2 -0
  12. package/dist/XlsxWorkbookWriter-DixuNGtw.cjs +3 -0
  13. package/dist/XlsxWorkbookWriter-VgbibI0Z.js +3 -0
  14. package/dist/fflate-Cs3txMgg.js +2 -0
  15. package/dist/fflate-G9RAFEgF.cjs +2 -0
  16. package/dist/index-1OXjJmct.js +2 -0
  17. package/dist/index-B5V7e4Xc.js +2 -0
  18. package/dist/index-DbKDox8y.cjs +2 -0
  19. package/dist/index-HaDoF1HM.cjs +2 -0
  20. package/dist/open-grid-react.cjs +1 -27
  21. package/dist/open-grid-react.js +1 -30
  22. package/dist/open-grid-vue.cjs +1 -31
  23. package/dist/open-grid-vue.js +1 -33
  24. package/dist/open-grid.cjs +6 -275
  25. package/dist/open-grid.js +6 -293
  26. package/dist/sinks-BCZFMGQJ.cjs +2 -0
  27. package/dist/sinks-qkBJ5bKn.js +2 -0
  28. package/dist/types/core/CFRenderBridge.d.ts +5 -1
  29. package/dist/types/core/CellEditManager.d.ts +26 -2
  30. package/dist/types/core/CellEventHandler.d.ts +6 -2
  31. package/dist/types/core/ColumnLayout.d.ts +8 -0
  32. package/dist/types/core/DataLayer.d.ts +48 -1
  33. package/dist/types/core/DetailManager.d.ts +43 -2
  34. package/dist/types/core/ExportManager.d.ts +25 -0
  35. package/dist/types/core/FindBarManager.d.ts +6 -2
  36. package/dist/types/core/FlatRowModel.d.ts +61 -3
  37. package/dist/types/core/FooterManager.d.ts +43 -1
  38. package/dist/types/core/FormulaController.d.ts +4 -4
  39. package/dist/types/core/GridComposer.d.ts +11 -1
  40. package/dist/types/core/GridRenderer.d.ts +84 -19
  41. package/dist/types/core/GroupTreeManager.d.ts +6 -4
  42. package/dist/types/core/KeyboardManager.d.ts +3 -2
  43. package/dist/types/core/MutationService.d.ts +10 -8
  44. package/dist/types/core/OpenGrid.d.ts +7 -5
  45. package/dist/types/core/RangeSelectionManager.d.ts +23 -2
  46. package/dist/types/core/RenderController.d.ts +126 -8
  47. package/dist/types/core/SortFilterManager.d.ts +10 -2
  48. package/dist/types/core/VirtualScroll.d.ts +12 -0
  49. package/dist/types/core/coordinate/CellTextPolicy.d.ts +58 -0
  50. package/dist/types/core/coordinate/ColumnGeometry.d.ts +60 -0
  51. package/dist/types/core/coordinate/ColumnWindow.d.ts +40 -0
  52. package/dist/types/core/coordinate/ColumnWindowPolicy.d.ts +89 -0
  53. package/dist/types/core/coordinate/ExtraColumns.d.ts +39 -0
  54. package/dist/types/core/coordinate/RangeRectCalculator.d.ts +35 -0
  55. package/dist/types/core/coordinate/ViewportHeightJudge.d.ts +28 -0
  56. package/dist/types/core/coordinate/geometryPorts.d.ts +250 -0
  57. package/dist/types/core/coordinate/ports.d.ts +5 -0
  58. package/dist/types/core/domain/footer/FooterValues.d.ts +50 -0
  59. package/dist/types/core/domain/footer/ports.d.ts +31 -0
  60. package/dist/types/core/domain/render/RenderPlanner.d.ts +17 -0
  61. package/dist/types/core/domain/render/RenderRequest.d.ts +91 -0
  62. package/dist/types/core/domain/render/ports.d.ts +169 -0
  63. package/dist/types/core/domain/resize/ResizeGesture.d.ts +25 -0
  64. package/dist/types/core/domain/resize/ResizeHitZone.d.ts +23 -0
  65. package/dist/types/core/domain/resize/ports.d.ts +64 -0
  66. package/dist/types/core/domain/sort/ComparisonOrderer.d.ts +11 -0
  67. package/dist/types/core/domain/sort/LcpMergeOrderer.d.ts +15 -0
  68. package/dist/types/core/domain/sort/RankIndex.d.ts +74 -0
  69. package/dist/types/core/domain/sort/SortCostEstimate.d.ts +36 -0
  70. package/dist/types/core/domain/sort/SortKeyColumn.d.ts +89 -0
  71. package/dist/types/core/domain/sort/SortKeyStore.d.ts +34 -0
  72. package/dist/types/core/domain/sort/Sorter.d.ts +54 -0
  73. package/dist/types/core/domain/sort/SyncSortRunner.d.ts +9 -0
  74. package/dist/types/core/domain/sort/commonPrefix.d.ts +5 -0
  75. package/dist/types/core/domain/sort/ports.d.ts +140 -0
  76. package/dist/types/core/export/ExportProgressView.d.ts +28 -0
  77. package/dist/types/core/export/channels/XlsxChannel.d.ts +38 -1
  78. package/dist/types/core/export/channels/XlsxRichTextRun.d.ts +14 -0
  79. package/dist/types/core/export/channels/XlsxSheetXml.d.ts +19 -0
  80. package/dist/types/core/export/channels/XlsxStyleEntries.d.ts +80 -0
  81. package/dist/types/core/export/channels/XlsxStylesRegistry.d.ts +20 -0
  82. package/dist/types/core/export/channels/XlsxWorkbookWriter.d.ts +20 -0
  83. package/dist/types/core/export/channels/XlsxXml.d.ts +6 -0
  84. package/dist/types/core/export/index.d.ts +2 -0
  85. package/dist/types/core/export/sinks.d.ts +81 -0
  86. package/dist/types/core/export/types.d.ts +63 -0
  87. package/dist/types/core/host/archCheck.d.ts +16 -1
  88. package/dist/types/core/i18n/locales/en.d.ts +6 -0
  89. package/dist/types/core/i18n/locales/ko.d.ts +6 -0
  90. package/dist/types/core/i18n/types.d.ts +8 -0
  91. package/dist/types/core/render/FooterView.d.ts +121 -0
  92. package/dist/types/core/render/GeometryApplier.d.ts +55 -0
  93. package/dist/types/core/render/HorizontalReveal.d.ts +26 -0
  94. package/dist/types/core/render/RangeOverlayAdapter.d.ts +10 -0
  95. package/dist/types/core/render/RenderScheduler.d.ts +225 -0
  96. package/dist/types/core/render/ResizeSinkAdapter.d.ts +35 -0
  97. package/dist/types/core/render/ScrollFollower.d.ts +34 -0
  98. package/dist/types/core/render/ScrollObserver.d.ts +47 -0
  99. package/dist/types/core/render/ScrollbarGutter.d.ts +19 -0
  100. package/dist/types/core/render/body/BodyEventRouter.d.ts +58 -0
  101. package/dist/types/core/render/body/BodyRowSet.d.ts +28 -0
  102. package/dist/types/core/render/body/BodyView.d.ts +185 -0
  103. package/dist/types/core/render/body/CellLocator.d.ts +36 -0
  104. package/dist/types/core/render/body/CellRegistry.d.ts +24 -0
  105. package/dist/types/core/render/body/ColumnPaintPlan.d.ts +19 -0
  106. package/dist/types/core/render/body/ExtraCellPainters.d.ts +20 -0
  107. package/dist/types/core/render/body/rows/BodyRowContext.d.ts +138 -0
  108. package/dist/types/core/render/body/rows/DataRowPainter.d.ts +58 -0
  109. package/dist/types/core/render/body/rows/DetailRowPainter.d.ts +24 -0
  110. package/dist/types/core/render/body/rows/GroupRowPainter.d.ts +32 -0
  111. package/dist/types/core/render/body/rows/RowPainterTable.d.ts +24 -0
  112. package/dist/types/core/render/body/rows/WindowLayout.d.ts +38 -0
  113. package/dist/types/core/render/dom.d.ts +10 -0
  114. package/dist/types/core/render/header/HeaderSortIndicator.d.ts +39 -0
  115. package/dist/types/core/render/header/HeaderView.d.ts +84 -0
  116. package/dist/types/core/render/header/ResizeHandleBinder.d.ts +110 -0
  117. package/dist/types/core/render/ports.d.ts +218 -0
  118. package/dist/types/core/renderers/CellRenderer.d.ts +7 -0
  119. package/dist/types/core/types.d.ts +94 -0
  120. package/dist/types/index.d.ts +1 -0
  121. package/dist/types/vue/OpenGrid.vue.d.ts +1 -1
  122. package/dist/xlsx.min-CMvrM6b4.cjs +138 -0
  123. package/dist/xlsx.min-i_b-4PvU.js +138 -0
  124. package/package.json +3 -8
  125. package/dist/OpenGrid-CLk8Vt7j.cjs +0 -7459
  126. package/dist/OpenGrid-D6YxCsnV.js +0 -7472
  127. package/dist/Registry-CPJYOqCn.js +0 -74
  128. package/dist/Registry-D74ZmdDz.cjs +0 -71
  129. package/dist/index-CeJ-0-80.cjs +0 -260
  130. package/dist/index-D0DJtKYI.cjs +0 -452
  131. package/dist/index-DnarQ4eR.js +0 -266
  132. package/dist/index-VkKgQ506.js +0 -481
  133. package/dist/xlsx.min-BQ1o3sB6.cjs +0 -11793
  134. package/dist/xlsx.min-Bbz2ZypC.js +0 -11794
@@ -1,276 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const OpenGrid = require("./OpenGrid-CLk8Vt7j.cjs"), Registry = require("./Registry-D74ZmdDz.cjs");
4
- class GridShuttle {
5
- constructor(t, e, n, o = {}) {
6
- this._left = t, this._right = e;
7
- const s = document.createElement("div");
8
- s.className = "og-shuttle", s.style.cssText = `display:flex;gap:6px;align-items:center;justify-content:center;flex-direction:${o.layout === "horizontal" ? "row" : "column"};`;
9
- const a = (d, h, g) => {
10
- const r = document.createElement("button");
11
- return r.type = "button", r.className = "og-shuttle-btn", r.textContent = d, r.title = h, r.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);", r.addEventListener("mouseover", () => {
12
- r.style.background = "#f0f6ff", r.style.borderColor = "#1976d2";
13
- }), r.addEventListener("mouseout", () => {
14
- r.style.background = "#fff", r.style.borderColor = "#bbb";
15
- }), r.addEventListener("click", g), r;
16
- }, _ = o.labels ?? {}, p = (d) => this._left.t(d);
17
- s.appendChild(a(_.toRight ?? "▶", p("shuttle.toRight"), () => {
18
- this._left.moveCheckedTo(this._right);
19
- })), s.appendChild(a(_.toLeft ?? "◀", p("shuttle.toLeft"), () => {
20
- this._right.moveCheckedTo(this._left);
21
- })), o.includeAll && (s.appendChild(a(_.allRight ?? "⏩", p("shuttle.allRight"), () => {
22
- this._moveAll(this._left, this._right);
23
- })), s.appendChild(a(_.allLeft ?? "⏪", p("shuttle.allLeft"), () => {
24
- this._moveAll(this._right, this._left);
25
- }))), n.appendChild(s), this._el = s;
26
- }
27
- _moveAll(t, e) {
28
- const n = t.getData().length;
29
- n > 0 && t.moveRowsTo(e, Array.from({ length: n }, (o, s) => s));
30
- }
31
- destroy() {
32
- this._el.remove();
33
- }
34
- }
35
- function createGridShuttle(E, t, e, n) {
36
- return new GridShuttle(E, t, e, n);
37
- }
38
- class OrgChart {
39
- constructor(t, e) {
40
- this._data = [], this._roots = [], this._expandedKeys = /* @__PURE__ */ new Set(), this._selectedId = null, this._destroyed = false, this._container = typeof t == "string" ? document.querySelector(t) : t, this._opts = { nodeWidth: 160, nodeHeight: 72, levelGap: 52, siblingGap: 20, expandOnLoad: true, onNodeClick: () => {
41
- }, ...e }, this._container.classList.add("og-orgchart");
42
- }
43
- setData(t) {
44
- this._data = t;
45
- const { idField: e, parentIdField: n, expandOnLoad: o } = this._opts;
46
- o && this._expandedKeys.size === 0 && t.forEach((s) => this._expandedKeys.add(s[e])), this._roots = OpenGrid.buildTree(t, { idField: e, parentIdField: n }, this._expandedKeys), this._render();
47
- }
48
- setTheme(t) {
49
- this._container.setAttribute("data-og-theme", t);
50
- }
51
- setSkin(t) {
52
- this._container.setAttribute("data-og-skin", t);
53
- }
54
- expandAll() {
55
- const t = (e) => {
56
- for (const n of e) this._expandedKeys.add(n._treeId), n.children.length && t(n.children);
57
- };
58
- t(this._roots), this._rebuild();
59
- }
60
- collapseAll() {
61
- this._expandedKeys.clear(), this._rebuild();
62
- }
63
- destroy() {
64
- this._destroyed || (this._destroyed = true, this._container.innerHTML = "", this._container.classList.remove("og-orgchart"), this._data = [], this._roots = [], this._expandedKeys.clear(), this._selectedId = null);
65
- }
66
- _toggle(t) {
67
- this._expandedKeys.has(t) ? this._expandedKeys.delete(t) : this._expandedKeys.add(t), this._rebuild();
68
- }
69
- _rebuild() {
70
- const { idField: t, parentIdField: e } = this._opts;
71
- this._roots = OpenGrid.buildTree(this._data, { idField: t, parentIdField: e }, this._expandedKeys), this._render();
72
- }
73
- _calcLayout() {
74
- const { nodeWidth: t, nodeHeight: e, levelGap: n, siblingGap: o } = this._opts, s = /* @__PURE__ */ new Map();
75
- let a = 0;
76
- const _ = (h) => {
77
- const g = h._depth * (e + n), r = h._expanded ? h.children : [];
78
- if (!r.length) {
79
- const u = a;
80
- return a += t + o, s.set(h._treeId, { x: u, y: g }), { minX: u, maxX: u };
81
- }
82
- let i = 1 / 0, f = -1 / 0;
83
- for (const u of r) {
84
- const { minX: c, maxX: m } = _(u);
85
- c < i && (i = c), m > f && (f = m);
86
- }
87
- const l = i + (f - i + t) / 2 - t / 2;
88
- return s.set(h._treeId, { x: l, y: g }), { minX: i, maxX: f };
89
- };
90
- for (const h of this._roots) _(h);
91
- let p = 0, d = 0;
92
- for (const { x: h, y: g } of s.values()) h + t > p && (p = h + t), g + e > d && (d = g + e);
93
- return { layout: s, totalW: p + o, totalH: d + n + 16 };
94
- }
95
- _line(t, e, n, o, s) {
96
- const a = document.createElementNS("http://www.w3.org/2000/svg", "line");
97
- a.setAttribute("x1", String(e)), a.setAttribute("y1", String(n)), a.setAttribute("x2", String(o)), a.setAttribute("y2", String(s)), a.setAttribute("class", "og-orgchart-line"), t.appendChild(a);
98
- }
99
- _render() {
100
- const { nodeWidth: t, nodeHeight: e, levelGap: n, columns: o } = this._opts, { layout: s, totalW: a, totalH: _ } = this._calcLayout();
101
- this._container.innerHTML = "";
102
- const p = document.createElement("div");
103
- p.className = "og-orgchart-wrap", p.style.cssText = `width:${a}px;height:${_}px;`;
104
- const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
105
- d.setAttribute("width", String(a)), d.setAttribute("height", String(_)), d.style.cssText = "position:absolute;top:0;left:0;pointer-events:none;overflow:visible;";
106
- const h = (r) => {
107
- for (const i of r) {
108
- if (!i._expanded || !i.children.length) continue;
109
- const f = s.get(i._treeId), l = f.x + t / 2, u = f.y + e, c = u + n / 2, m = i.children;
110
- if (this._line(d, l, u, l, c), m.length > 1) {
111
- const x = s.get(m[0]._treeId), y = s.get(m[m.length - 1]._treeId);
112
- this._line(d, x.x + t / 2, c, y.x + t / 2, c);
113
- }
114
- for (const x of m) {
115
- const y = s.get(x._treeId), b = y.x + t / 2;
116
- this._line(d, b, c, b, y.y);
117
- }
118
- h(m);
119
- }
120
- };
121
- h(this._roots), p.appendChild(d);
122
- const g = (r) => {
123
- for (const i of r) {
124
- const f = s.get(i._treeId);
125
- if (!f) continue;
126
- const l = document.createElement("div");
127
- l.className = "og-orgchart-node", i._hasChildren && l.classList.add("og-orgchart-node--branch"), i._expanded && l.classList.add("og-orgchart-node--expanded"), this._selectedId === i._treeId && l.classList.add("og-orgchart-node--selected"), l.style.cssText = `left:${f.x}px;top:${f.y}px;width:${t}px;height:${e}px;`;
128
- const u = document.createElement("div");
129
- u.className = "og-orgchart-node-content";
130
- for (const c of o) {
131
- const m = i.data[c.field], x = document.createElement("div");
132
- if (x.className = "og-orgchart-col" + (c.className ? " " + c.className : ""), c.style) {
133
- const y = typeof c.style == "function" ? c.style(m, i.data) : c.style;
134
- x.setAttribute("style", y);
135
- }
136
- if (c.renderer) {
137
- const y = c.renderer(m, i.data);
138
- typeof y == "string" ? x.innerHTML = y : x.appendChild(y);
139
- } else x.textContent = m ?? "";
140
- u.appendChild(x);
141
- }
142
- if (l.appendChild(u), i._hasChildren) {
143
- const c = document.createElement("button");
144
- c.type = "button", c.className = "og-orgchart-toggle", c.setAttribute("aria-expanded", i._expanded ? "true" : "false"), c.setAttribute("aria-label", OpenGrid.t(i._expanded ? "tree.collapse" : "tree.expand"));
145
- const m = document.createElement("i");
146
- m.setAttribute("aria-hidden", "true"), m.className = i._expanded ? "bi bi-dash-circle" : "bi bi-plus-circle", c.appendChild(m), c.addEventListener("click", (x) => {
147
- x.stopPropagation(), this._toggle(i._treeId);
148
- }), l.appendChild(c);
149
- }
150
- l.addEventListener("click", () => {
151
- this._selectedId = i._treeId, this._opts.onNodeClick(i._treeId, i.data), this._container.querySelectorAll(".og-orgchart-node--selected").forEach((c) => c.classList.remove("og-orgchart-node--selected")), l.classList.add("og-orgchart-node--selected");
152
- }), p.appendChild(l), i._expanded && i.children.length && g(i.children);
153
- }
154
- };
155
- g(this._roots), this._container.appendChild(p);
156
- }
157
- }
158
- class XmlConverter {
159
- static parse(t, e = {}) {
160
- var _a, _b, _c;
161
- const { fieldMap: n = {}, trim: o = true } = e, a = new DOMParser().parseFromString(t.trim(), "text/xml"), _ = a.querySelector("parsererror");
162
- if (_) throw new Error(`XML 파싱 오류: ${(_a = _.textContent) == null ? void 0 : _a.trim()}`);
163
- const p = a.documentElement;
164
- let d = e.rowTag;
165
- d || (d = ((_c = (_b = e.rootTag ? a.querySelector(e.rootTag) : p) == null ? void 0 : _b.children[0]) == null ? void 0 : _c.tagName) ?? "row");
166
- const h = a.getElementsByTagName(d), g = [];
167
- for (let r = 0; r < h.length; r++) {
168
- const i = h[r], f = {};
169
- for (const l of Array.from(i.attributes)) {
170
- const u = n[l.name] ?? l.name;
171
- f[u] = o ? l.value.trim() : l.value;
172
- }
173
- for (const l of Array.from(i.children)) {
174
- const u = n[l.tagName] ?? l.tagName, c = l.textContent ?? "";
175
- f[u] = o ? c.trim() : c;
176
- }
177
- g.push(f);
178
- }
179
- return g;
180
- }
181
- static stringify(t, e = {}) {
182
- const { rootTag: n = "rows", rowTag: o = "row", mode: s = "element", fieldMap: a = {}, declaration: _ = true, indent: p = 2, nullAs: d = "", excludeFields: h = [] } = e, g = " ".repeat(p), r = [];
183
- _ && r.push('<?xml version="1.0" encoding="UTF-8"?>'), r.push(`<${n}>`);
184
- for (const i of t) {
185
- const f = Object.entries(i).filter(([l]) => !h.includes(l));
186
- if (s === "attribute") {
187
- const l = f.map(([u, c]) => {
188
- const m = a[u] ?? u, x = c == null ? d : String(c);
189
- return `${m}="${this._escAttr(x)}"`;
190
- }).join(" ");
191
- r.push(`${g}<${o}${l ? " " + l : ""} />`);
192
- } else {
193
- r.push(`${g}<${o}>`);
194
- for (const [l, u] of f) {
195
- const c = a[l] ?? l, m = u == null ? d : String(u);
196
- r.push(`${g}${g}<${c}>${this._escText(m)}</${c}>`);
197
- }
198
- r.push(`${g}</${o}>`);
199
- }
200
- }
201
- return r.push(`</${n}>`), r.join(`
202
- `);
203
- }
204
- static parseSap(t) {
205
- var _a, _b, _c, _d;
206
- const n = new DOMParser().parseFromString(t.trim(), "text/xml"), o = { header: {}, items: [], returns: [], raw: n }, s = n.getElementsByTagName("DOCUMENTHEADER")[0];
207
- if (s) for (const p of Array.from(s.children)) o.header[p.tagName] = ((_a = p.textContent) == null ? void 0 : _a.trim()) ?? "";
208
- const a = n.getElementsByTagName("RETURN");
209
- for (const p of Array.from(a)) {
210
- const d = {};
211
- for (const h of Array.from(p.children)) d[h.tagName] = ((_b = h.textContent) == null ? void 0 : _b.trim()) ?? "";
212
- o.returns.push(d);
213
- }
214
- const _ = ["ACCOUNTGL", "ACCOUNTRECEIVABLE", "ACCOUNTPAYABLE", "ITEMS"];
215
- for (const p of _) {
216
- const d = n.getElementsByTagName(p)[0];
217
- if (!d) continue;
218
- const h = d.getElementsByTagName("ITEM"), g = h.length > 0 ? Array.from(h) : [d];
219
- for (const r of g) {
220
- const i = {};
221
- for (const f of Array.from(r.children)) i[f.tagName] = ((_c = f.textContent) == null ? void 0 : _c.trim()) ?? "";
222
- o.items.push(i);
223
- }
224
- break;
225
- }
226
- if (o.items.length === 0) {
227
- const p = n.documentElement, d = Array.from(p.children).filter((h) => h.hasAttribute("SEGMENT"));
228
- for (const h of d) {
229
- if (h.tagName === "EDI_DC40") continue;
230
- const g = {};
231
- for (const r of Array.from(h.children)) g[r.tagName] = ((_d = r.textContent) == null ? void 0 : _d.trim()) ?? "";
232
- Object.keys(g).length > 0 && o.items.push(g);
233
- }
234
- }
235
- return o;
236
- }
237
- static stringifySap(t) {
238
- const e = ['<?xml version="1.0" encoding="UTF-8"?>', "<BAPI_CALL>"];
239
- if (t.BAPI_FUNCTION && e.push(` <FUNCTION>${this._escText(t.BAPI_FUNCTION)}</FUNCTION>`), t.DOCUMENTHEADER && typeof t.DOCUMENTHEADER == "object") {
240
- e.push(" <DOCUMENTHEADER>");
241
- for (const [o, s] of Object.entries(t.DOCUMENTHEADER)) s != null && s !== "" && e.push(` <${o}>${this._escText(String(s))}</${o}>`);
242
- e.push(" </DOCUMENTHEADER>");
243
- }
244
- const n = Object.keys(t).find((o) => Array.isArray(t[o]) && !o.startsWith("_"));
245
- if (n) {
246
- e.push(` <${n}>`);
247
- for (const o of t[n]) {
248
- e.push(" <ITEM>");
249
- for (const [s, a] of Object.entries(o)) a != null && a !== "" && !s.startsWith("_") && e.push(` <${s}>${this._escText(String(a))}</${s}>`);
250
- e.push(" </ITEM>");
251
- }
252
- e.push(` </${n}>`);
253
- }
254
- return e.push("</BAPI_CALL>"), e.join(`
255
- `);
256
- }
257
- static stringifySapBatch(t) {
258
- const e = ['<?xml version="1.0" encoding="UTF-8"?>', `<BAPI_BATCH total="${t.documents.length}">`];
259
- return t.documents.forEach((n, o) => {
260
- e.push(` <BAPI_CALL seq="${o + 1}">`);
261
- const s = this.stringifySap(n).split(`
262
- `).filter((a) => !a.startsWith("<?xml")).map((a) => " " + a).join(`
263
- `);
264
- e.push(s), e.push(" </BAPI_CALL>");
265
- }), e.push("</BAPI_BATCH>"), e.join(`
266
- `);
267
- }
268
- static _escText(t) {
269
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
270
- }
271
- static _escAttr(t) {
272
- return this._escText(t).replace(/"/g, "&quot;").replace(/'/g, "&apos;");
273
- }
274
- }
275
- exports.DEFAULT_ICON_ROLES = OpenGrid.DEFAULT_ICON_ROLES, exports.IconRegistry = OpenGrid.IconRegistry, exports.LocaleRegistry = OpenGrid.LocaleRegistry, exports.OpenGrid = OpenGrid.OpenGrid, exports.SkinRegistry = OpenGrid.SkinRegistry, exports.iconRegistry = OpenGrid.iconRegistry, exports.localeRegistry = OpenGrid.localeRegistry, exports.renderIcon = OpenGrid.renderIcon, exports.skinRegistry = OpenGrid.skinRegistry, exports.t = OpenGrid.t, exports.RESERVED_PREFIXES = Registry.RESERVED_PREFIXES, exports.TypedRegistry = Registry.TypedRegistry, exports.isReserved = Registry.isReserved, exports.GridShuttle = GridShuttle, exports.OrgChart = OrgChart, exports.XmlConverter = XmlConverter, exports.createGridShuttle = createGridShuttle;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const OpenGrid=require("./OpenGrid-Bh1NMOcm.cjs"),Registry=require("./Registry-DpHOpU5V.cjs");class GridShuttle{constructor(t,e,i,c={}){this.$w=t,this.$fo=e;const r=document.createElement("div");r.className="og-shuttle",r.style.cssText=`display:flex;gap:6px;align-items:center;justify-content:center;flex-direction:${c.layout==="horizontal"?"row":"column"};`;const a=(u,m,f)=>{const o=document.createElement("button");return o.type="button",o.className="og-shuttle-btn",o.textContent=u,o.title=m,o.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);",o.addEventListener("mouseover",()=>{o.style.background="#f0f6ff",o.style.borderColor="#1976d2"}),o.addEventListener("mouseout",()=>{o.style.background="#fff",o.style.borderColor="#bbb"}),o.addEventListener("click",f),o},x=c.labels??{},h=u=>this.$w.t(u);r.appendChild(a(x.toRight??"▶",h("shuttle.toRight"),()=>{this.$w.moveCheckedTo(this.$fo)})),r.appendChild(a(x.toLeft??"◀",h("shuttle.toLeft"),()=>{this.$fo.moveCheckedTo(this.$w)})),c.includeAll&&(r.appendChild(a(x.allRight??"⏩",h("shuttle.allRight"),()=>{this.$jw(this.$w,this.$fo)})),r.appendChild(a(x.allLeft??"⏪",h("shuttle.allLeft"),()=>{this.$jw(this.$fo,this.$w)}))),i.appendChild(r),this.$d=r}$jw(t,e){const i=t.getData().length;i>0&&t.moveRowsTo(e,Array.from({length:i},(c,r)=>r))}destroy(){this.$d.remove()}}function createGridShuttle(b,t,e,i){return new GridShuttle(b,t,e,i)}class OrgChart{constructor(t,e){this._data=[],this.$cf=[],this.$aI=new Set,this.$hn=null,this.$aG=!1,this._container=typeof t=="string"?document.querySelector(t):t,this.$aA={nodeWidth:160,nodeHeight:72,levelGap:52,siblingGap:20,expandOnLoad:!0,onNodeClick:()=>{},...e},this._container.classList.add("og-orgchart")}setData(t){this._data=t;const{idField:e,parentIdField:i,expandOnLoad:c}=this.$aA;c&&this.$aI.size===0&&t.forEach(r=>this.$aI.add(r[e])),this.$cf=OpenGrid.buildTree(t,{idField:e,parentIdField:i},this.$aI),this._render()}setTheme(t){this._container.setAttribute("data-og-theme",t)}setSkin(t){this._container.setAttribute("data-og-skin",t)}expandAll(){const t=e=>{for(const i of e)this.$aI.add(i._treeId),i.children.length&&t(i.children)};t(this.$cf),this._rebuild()}collapseAll(){this.$aI.clear(),this._rebuild()}destroy(){this.$aG||(this.$aG=!0,this._container.innerHTML="",this._container.classList.remove("og-orgchart"),this._data=[],this.$cf=[],this.$aI.clear(),this.$hn=null)}$ns(t){this.$aI.has(t)?this.$aI.delete(t):this.$aI.add(t),this._rebuild()}_rebuild(){const{idField:t,parentIdField:e}=this.$aA;this.$cf=OpenGrid.buildTree(this._data,{idField:t,parentIdField:e},this.$aI),this._render()}$lp(){const{nodeWidth:t,nodeHeight:e,levelGap:i,siblingGap:c}=this.$aA,r=new Map;let a=0;const x=m=>{const f=m._depth*(e+i),o=m._expanded?m.children:[];if(!o.length){const p=a;return a+=t+c,r.set(m._treeId,{x:p,y:f}),{minX:p,maxX:p}}let n=1/0,l=-1/0;for(const p of o){const{minX:s,maxX:g}=x(p);s<n&&(n=s),g>l&&(l=g)}const d=n+(l-n+t)/2-t/2;return r.set(m._treeId,{x:d,y:f}),{minX:n,maxX:l}};for(const m of this.$cf)x(m);let h=0,u=0;for(const{x:m,y:f}of r.values())m+t>h&&(h=m+t),f+e>u&&(u=f+e);return{layout:r,totalW:h+c,totalH:u+i+16}}$gC(t,e,i,c,r){const a=document.createElementNS("http://www.w3.org/2000/svg","line");a.setAttribute("x1",String(e)),a.setAttribute("y1",String(i)),a.setAttribute("x2",String(c)),a.setAttribute("y2",String(r)),a.setAttribute("class","og-orgchart-line"),t.appendChild(a)}_render(){const{nodeWidth:t,nodeHeight:e,levelGap:i,columns:c}=this.$aA,{layout:r,totalW:a,totalH:x}=this.$lp();this._container.innerHTML="";const h=document.createElement("div");h.className="og-orgchart-wrap",h.style.cssText=`width:${a}px;height:${x}px;`;const u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("width",String(a)),u.setAttribute("height",String(x)),u.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:visible;";const m=o=>{for(const n of o){if(!n._expanded||!n.children.length)continue;const l=r.get(n._treeId),d=l.x+t/2,p=l.y+e,s=p+i/2,g=n.children;if(this.$gC(u,d,p,d,s),g.length>1){const y=r.get(g[0]._treeId),E=r.get(g[g.length-1]._treeId);this.$gC(u,y.x+t/2,s,E.x+t/2,s)}for(const y of g){const E=r.get(y._treeId),_=E.x+t/2;this.$gC(u,_,s,_,E.y)}m(g)}};m(this.$cf),h.appendChild(u);const f=o=>{for(const n of o){const l=r.get(n._treeId);if(!l)continue;const d=document.createElement("div");d.className="og-orgchart-node",n._hasChildren&&d.classList.add("og-orgchart-node--branch"),n._expanded&&d.classList.add("og-orgchart-node--expanded"),this.$hn===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;`;const p=document.createElement("div");p.className="og-orgchart-node-content";for(const s of c){const g=n.data[s.field],y=document.createElement("div");if(y.className="og-orgchart-col"+(s.className?" "+s.className:""),s.style){const E=typeof s.style=="function"?s.style(g,n.data):s.style;y.setAttribute("style",E)}if(s.renderer){const E=s.renderer(g,n.data);typeof E=="string"?y.innerHTML=E:y.appendChild(E)}else y.textContent=g??"";p.appendChild(y)}if(d.appendChild(p),n._hasChildren){const s=document.createElement("button");s.type="button",s.className="og-orgchart-toggle",s.setAttribute("aria-expanded",n._expanded?"true":"false"),s.setAttribute("aria-label",OpenGrid.t(n._expanded?"tree.collapse":"tree.expand"));const g=document.createElement("i");g.setAttribute("aria-hidden","true"),g.className=n._expanded?"bi bi-dash-circle":"bi bi-plus-circle",s.appendChild(g),s.addEventListener("click",y=>{y.stopPropagation(),this.$ns(n._treeId)}),d.appendChild(s)}d.addEventListener("click",()=>{this.$hn=n._treeId,this.$aA.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")}),h.appendChild(d),n._expanded&&n.children.length&&f(n.children)}};f(this.$cf),this._container.appendChild(h)}}class XmlConverter{static parse(t,e={}){var i,c;const{fieldMap:r={},trim:a=!0}=e,h=new DOMParser().parseFromString(t.trim(),"text/xml"),u=h.querySelector("parsererror");if(u)throw new Error(`XML 파싱 오류: ${(i=u.textContent)==null?void 0:i.trim()}`);const m=h.documentElement;let f=e.rowTag;if(!f){const l=e.rootTag?h.querySelector(e.rootTag):m;f=((c=l==null?void 0:l.children[0])==null?void 0:c.tagName)??"row"}const o=h.getElementsByTagName(f),n=[];for(let l=0;l<o.length;l++){const d=o[l],p={};for(const s of Array.from(d.attributes)){const g=r[s.name]??s.name;p[g]=a?s.value.trim():s.value}for(const s of Array.from(d.children)){const g=r[s.tagName]??s.tagName,y=s.textContent??"";p[g]=a?y.trim():y}n.push(p)}return n}static stringify(t,e={}){const{rootTag:i="rows",rowTag:c="row",mode:r="element",fieldMap:a={},declaration:x=!0,indent:h=2,nullAs:u="",excludeFields:m=[]}=e,f=" ".repeat(h),o=[];x&&o.push('<?xml version="1.0" encoding="UTF-8"?>'),o.push(`<${i}>`);for(const n of t){const l=Object.entries(n).filter(([d])=>!m.includes(d));if(r==="attribute"){const d=l.map(([p,s])=>{const g=a[p]??p,y=s==null?u:String(s);return`${g}="${this.$lD(y)}"`}).join(" ");o.push(`${f}<${c}${d?" "+d:""} />`)}else{o.push(`${f}<${c}>`);for(const[d,p]of l){const s=a[d]??d,g=p==null?u:String(p);o.push(`${f}${f}<${s}>${this.$dy(g)}</${s}>`)}o.push(`${f}</${c}>`)}}return o.push(`</${i}>`),o.join(`
2
+ `)}static parseSap(t){var e,i,c,r;const x=new DOMParser().parseFromString(t.trim(),"text/xml"),h={header:{},items:[],returns:[],raw:x},u=x.getElementsByTagName("DOCUMENTHEADER")[0];if(u)for(const o of Array.from(u.children))h.header[o.tagName]=((e=o.textContent)==null?void 0:e.trim())??"";const m=x.getElementsByTagName("RETURN");for(const o of Array.from(m)){const n={};for(const l of Array.from(o.children))n[l.tagName]=((i=l.textContent)==null?void 0:i.trim())??"";h.returns.push(n)}const f=["ACCOUNTGL","ACCOUNTRECEIVABLE","ACCOUNTPAYABLE","ITEMS"];for(const o of f){const n=x.getElementsByTagName(o)[0];if(!n)continue;const l=n.getElementsByTagName("ITEM"),d=l.length>0?Array.from(l):[n];for(const p of d){const s={};for(const g of Array.from(p.children))s[g.tagName]=((c=g.textContent)==null?void 0:c.trim())??"";h.items.push(s)}break}if(h.items.length===0){const o=x.documentElement,n=Array.from(o.children).filter(l=>l.hasAttribute("SEGMENT"));for(const l of n){if(l.tagName==="EDI_DC40")continue;const d={};for(const p of Array.from(l.children))d[p.tagName]=((r=p.textContent)==null?void 0:r.trim())??"";Object.keys(d).length>0&&h.items.push(d)}}return h}static stringifySap(t){const e=['<?xml version="1.0" encoding="UTF-8"?>',"<BAPI_CALL>"];if(t.BAPI_FUNCTION&&e.push(` <FUNCTION>${this.$dy(t.BAPI_FUNCTION)}</FUNCTION>`),t.DOCUMENTHEADER&&typeof t.DOCUMENTHEADER=="object"){e.push(" <DOCUMENTHEADER>");for(const[c,r]of Object.entries(t.DOCUMENTHEADER))r!=null&&r!==""&&e.push(` <${c}>${this.$dy(String(r))}</${c}>`);e.push(" </DOCUMENTHEADER>")}const i=Object.keys(t).find(c=>Array.isArray(t[c])&&!c.startsWith("_"));if(i){e.push(` <${i}>`);for(const c of t[i]){e.push(" <ITEM>");for(const[r,a]of Object.entries(c))a!=null&&a!==""&&!r.startsWith("_")&&e.push(` <${r}>${this.$dy(String(a))}</${r}>`);e.push(" </ITEM>")}e.push(` </${i}>`)}return e.push("</BAPI_CALL>"),e.join(`
3
+ `)}static stringifySapBatch(t){const e=['<?xml version="1.0" encoding="UTF-8"?>',`<BAPI_BATCH total="${t.documents.length}">`];return t.documents.forEach((i,c)=>{e.push(` <BAPI_CALL seq="${c+1}">`);const r=this.stringifySap(i).split(`
4
+ `).filter(a=>!a.startsWith("<?xml")).map(a=>" "+a).join(`
5
+ `);e.push(r),e.push(" </BAPI_CALL>")}),e.push("</BAPI_BATCH>"),e.join(`
6
+ `)}static $dy(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}static $lD(t){return this.$dy(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}}exports.DEFAULT_ICON_ROLES=OpenGrid.DEFAULT_ICON_ROLES,exports.IconRegistry=OpenGrid.IconRegistry,exports.LocaleRegistry=OpenGrid.LocaleRegistry,exports.OpenGrid=OpenGrid.OpenGrid,exports.SkinRegistry=OpenGrid.SkinRegistry,exports.iconRegistry=OpenGrid.iconRegistry,exports.localeRegistry=OpenGrid.localeRegistry,exports.renderIcon=OpenGrid.renderIcon,exports.skinRegistry=OpenGrid.skinRegistry,exports.t=OpenGrid.t,exports.RESERVED_PREFIXES=Registry.RESERVED_PREFIXES,exports.TypedRegistry=Registry.TypedRegistry,exports.isReserved=Registry.isReserved,exports.GridShuttle=GridShuttle,exports.OrgChart=OrgChart,exports.XmlConverter=XmlConverter,exports.createGridShuttle=createGridShuttle;
276
7
  //# sourceMappingURL=open-grid.cjs.map
package/dist/open-grid.js CHANGED
@@ -1,294 +1,7 @@
1
- import { b, t as T } from "./OpenGrid-D6YxCsnV.js";
2
- import { D, I, L, O, S, i, l, r, s } from "./OpenGrid-D6YxCsnV.js";
3
- import { R, T as T2, i as i2 } from "./Registry-CPJYOqCn.js";
4
- class C {
5
- constructor(t, e, r2, o = {}) {
6
- this._left = t, this._right = e;
7
- const s2 = document.createElement("div");
8
- s2.className = "og-shuttle", s2.style.cssText = `display:flex;gap:6px;align-items:center;justify-content:center;flex-direction:${o.layout === "horizontal" ? "row" : "column"};`;
9
- const c = (d, h, g) => {
10
- const n = document.createElement("button");
11
- return n.type = "button", n.className = "og-shuttle-btn", n.textContent = d, n.title = h, n.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);", n.addEventListener("mouseover", () => {
12
- n.style.background = "#f0f6ff", n.style.borderColor = "#1976d2";
13
- }), n.addEventListener("mouseout", () => {
14
- n.style.background = "#fff", n.style.borderColor = "#bbb";
15
- }), n.addEventListener("click", g), n;
16
- }, _ = o.labels ?? {}, p = (d) => this._left.t(d);
17
- s2.appendChild(c(_.toRight ?? "▶", p("shuttle.toRight"), () => {
18
- this._left.moveCheckedTo(this._right);
19
- })), s2.appendChild(c(_.toLeft ?? "◀", p("shuttle.toLeft"), () => {
20
- this._right.moveCheckedTo(this._left);
21
- })), o.includeAll && (s2.appendChild(c(_.allRight ?? "⏩", p("shuttle.allRight"), () => {
22
- this._moveAll(this._left, this._right);
23
- })), s2.appendChild(c(_.allLeft ?? "⏪", p("shuttle.allLeft"), () => {
24
- this._moveAll(this._right, this._left);
25
- }))), r2.appendChild(s2), this._el = s2;
26
- }
27
- _moveAll(t, e) {
28
- const r2 = t.getData().length;
29
- r2 > 0 && t.moveRowsTo(e, Array.from({ length: r2 }, (o, s2) => s2));
30
- }
31
- destroy() {
32
- this._el.remove();
33
- }
34
- }
35
- function v(E, t, e, r2) {
36
- return new C(E, t, e, r2);
37
- }
38
- class N {
39
- constructor(t, e) {
40
- this._data = [], this._roots = [], this._expandedKeys = /* @__PURE__ */ new Set(), this._selectedId = null, this._destroyed = false, this._container = typeof t == "string" ? document.querySelector(t) : t, this._opts = { nodeWidth: 160, nodeHeight: 72, levelGap: 52, siblingGap: 20, expandOnLoad: true, onNodeClick: () => {
41
- }, ...e }, this._container.classList.add("og-orgchart");
42
- }
43
- setData(t) {
44
- this._data = t;
45
- const { idField: e, parentIdField: r2, expandOnLoad: o } = this._opts;
46
- o && this._expandedKeys.size === 0 && t.forEach((s2) => this._expandedKeys.add(s2[e])), this._roots = b(t, { idField: e, parentIdField: r2 }, this._expandedKeys), this._render();
47
- }
48
- setTheme(t) {
49
- this._container.setAttribute("data-og-theme", t);
50
- }
51
- setSkin(t) {
52
- this._container.setAttribute("data-og-skin", t);
53
- }
54
- expandAll() {
55
- const t = (e) => {
56
- for (const r2 of e) this._expandedKeys.add(r2._treeId), r2.children.length && t(r2.children);
57
- };
58
- t(this._roots), this._rebuild();
59
- }
60
- collapseAll() {
61
- this._expandedKeys.clear(), this._rebuild();
62
- }
63
- destroy() {
64
- this._destroyed || (this._destroyed = true, this._container.innerHTML = "", this._container.classList.remove("og-orgchart"), this._data = [], this._roots = [], this._expandedKeys.clear(), this._selectedId = null);
65
- }
66
- _toggle(t) {
67
- this._expandedKeys.has(t) ? this._expandedKeys.delete(t) : this._expandedKeys.add(t), this._rebuild();
68
- }
69
- _rebuild() {
70
- const { idField: t, parentIdField: e } = this._opts;
71
- this._roots = b(this._data, { idField: t, parentIdField: e }, this._expandedKeys), this._render();
72
- }
73
- _calcLayout() {
74
- const { nodeWidth: t, nodeHeight: e, levelGap: r2, siblingGap: o } = this._opts, s2 = /* @__PURE__ */ new Map();
75
- let c = 0;
76
- const _ = (h) => {
77
- const g = h._depth * (e + r2), n = h._expanded ? h.children : [];
78
- if (!n.length) {
79
- const f = c;
80
- return c += t + o, s2.set(h._treeId, { x: f, y: g }), { minX: f, maxX: f };
81
- }
82
- let i3 = 1 / 0, u = -1 / 0;
83
- for (const f of n) {
84
- const { minX: a, maxX: m } = _(f);
85
- a < i3 && (i3 = a), m > u && (u = m);
86
- }
87
- const l2 = i3 + (u - i3 + t) / 2 - t / 2;
88
- return s2.set(h._treeId, { x: l2, y: g }), { minX: i3, maxX: u };
89
- };
90
- for (const h of this._roots) _(h);
91
- let p = 0, d = 0;
92
- for (const { x: h, y: g } of s2.values()) h + t > p && (p = h + t), g + e > d && (d = g + e);
93
- return { layout: s2, totalW: p + o, totalH: d + r2 + 16 };
94
- }
95
- _line(t, e, r2, o, s2) {
96
- const c = document.createElementNS("http://www.w3.org/2000/svg", "line");
97
- c.setAttribute("x1", String(e)), c.setAttribute("y1", String(r2)), c.setAttribute("x2", String(o)), c.setAttribute("y2", String(s2)), c.setAttribute("class", "og-orgchart-line"), t.appendChild(c);
98
- }
99
- _render() {
100
- const { nodeWidth: t, nodeHeight: e, levelGap: r2, columns: o } = this._opts, { layout: s2, totalW: c, totalH: _ } = this._calcLayout();
101
- this._container.innerHTML = "";
102
- const p = document.createElement("div");
103
- p.className = "og-orgchart-wrap", p.style.cssText = `width:${c}px;height:${_}px;`;
104
- const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
105
- d.setAttribute("width", String(c)), d.setAttribute("height", String(_)), d.style.cssText = "position:absolute;top:0;left:0;pointer-events:none;overflow:visible;";
106
- const h = (n) => {
107
- for (const i3 of n) {
108
- if (!i3._expanded || !i3.children.length) continue;
109
- const u = s2.get(i3._treeId), l2 = u.x + t / 2, f = u.y + e, a = f + r2 / 2, m = i3.children;
110
- if (this._line(d, l2, f, l2, a), m.length > 1) {
111
- const x = s2.get(m[0]._treeId), y = s2.get(m[m.length - 1]._treeId);
112
- this._line(d, x.x + t / 2, a, y.x + t / 2, a);
113
- }
114
- for (const x of m) {
115
- const y = s2.get(x._treeId), A = y.x + t / 2;
116
- this._line(d, A, a, A, y.y);
117
- }
118
- h(m);
119
- }
120
- };
121
- h(this._roots), p.appendChild(d);
122
- const g = (n) => {
123
- for (const i3 of n) {
124
- const u = s2.get(i3._treeId);
125
- if (!u) continue;
126
- const l2 = document.createElement("div");
127
- l2.className = "og-orgchart-node", i3._hasChildren && l2.classList.add("og-orgchart-node--branch"), i3._expanded && l2.classList.add("og-orgchart-node--expanded"), this._selectedId === i3._treeId && l2.classList.add("og-orgchart-node--selected"), l2.style.cssText = `left:${u.x}px;top:${u.y}px;width:${t}px;height:${e}px;`;
128
- const f = document.createElement("div");
129
- f.className = "og-orgchart-node-content";
130
- for (const a of o) {
131
- const m = i3.data[a.field], x = document.createElement("div");
132
- if (x.className = "og-orgchart-col" + (a.className ? " " + a.className : ""), a.style) {
133
- const y = typeof a.style == "function" ? a.style(m, i3.data) : a.style;
134
- x.setAttribute("style", y);
135
- }
136
- if (a.renderer) {
137
- const y = a.renderer(m, i3.data);
138
- typeof y == "string" ? x.innerHTML = y : x.appendChild(y);
139
- } else x.textContent = m ?? "";
140
- f.appendChild(x);
141
- }
142
- if (l2.appendChild(f), i3._hasChildren) {
143
- const a = document.createElement("button");
144
- a.type = "button", a.className = "og-orgchart-toggle", a.setAttribute("aria-expanded", i3._expanded ? "true" : "false"), a.setAttribute("aria-label", T(i3._expanded ? "tree.collapse" : "tree.expand"));
145
- const m = document.createElement("i");
146
- m.setAttribute("aria-hidden", "true"), m.className = i3._expanded ? "bi bi-dash-circle" : "bi bi-plus-circle", a.appendChild(m), a.addEventListener("click", (x) => {
147
- x.stopPropagation(), this._toggle(i3._treeId);
148
- }), l2.appendChild(a);
149
- }
150
- l2.addEventListener("click", () => {
151
- this._selectedId = i3._treeId, this._opts.onNodeClick(i3._treeId, i3.data), this._container.querySelectorAll(".og-orgchart-node--selected").forEach((a) => a.classList.remove("og-orgchart-node--selected")), l2.classList.add("og-orgchart-node--selected");
152
- }), p.appendChild(l2), i3._expanded && i3.children.length && g(i3.children);
153
- }
154
- };
155
- g(this._roots), this._container.appendChild(p);
156
- }
157
- }
158
- class I2 {
159
- static parse(t, e = {}) {
160
- var _a, _b, _c;
161
- const { fieldMap: r2 = {}, trim: o = true } = e, c = new DOMParser().parseFromString(t.trim(), "text/xml"), _ = c.querySelector("parsererror");
162
- if (_) throw new Error(`XML 파싱 오류: ${(_a = _.textContent) == null ? void 0 : _a.trim()}`);
163
- const p = c.documentElement;
164
- let d = e.rowTag;
165
- d || (d = ((_c = (_b = e.rootTag ? c.querySelector(e.rootTag) : p) == null ? void 0 : _b.children[0]) == null ? void 0 : _c.tagName) ?? "row");
166
- const h = c.getElementsByTagName(d), g = [];
167
- for (let n = 0; n < h.length; n++) {
168
- const i3 = h[n], u = {};
169
- for (const l2 of Array.from(i3.attributes)) {
170
- const f = r2[l2.name] ?? l2.name;
171
- u[f] = o ? l2.value.trim() : l2.value;
172
- }
173
- for (const l2 of Array.from(i3.children)) {
174
- const f = r2[l2.tagName] ?? l2.tagName, a = l2.textContent ?? "";
175
- u[f] = o ? a.trim() : a;
176
- }
177
- g.push(u);
178
- }
179
- return g;
180
- }
181
- static stringify(t, e = {}) {
182
- const { rootTag: r2 = "rows", rowTag: o = "row", mode: s2 = "element", fieldMap: c = {}, declaration: _ = true, indent: p = 2, nullAs: d = "", excludeFields: h = [] } = e, g = " ".repeat(p), n = [];
183
- _ && n.push('<?xml version="1.0" encoding="UTF-8"?>'), n.push(`<${r2}>`);
184
- for (const i3 of t) {
185
- const u = Object.entries(i3).filter(([l2]) => !h.includes(l2));
186
- if (s2 === "attribute") {
187
- const l2 = u.map(([f, a]) => {
188
- const m = c[f] ?? f, x = a == null ? d : String(a);
189
- return `${m}="${this._escAttr(x)}"`;
190
- }).join(" ");
191
- n.push(`${g}<${o}${l2 ? " " + l2 : ""} />`);
192
- } else {
193
- n.push(`${g}<${o}>`);
194
- for (const [l2, f] of u) {
195
- const a = c[l2] ?? l2, m = f == null ? d : String(f);
196
- n.push(`${g}${g}<${a}>${this._escText(m)}</${a}>`);
197
- }
198
- n.push(`${g}</${o}>`);
199
- }
200
- }
201
- return n.push(`</${r2}>`), n.join(`
202
- `);
203
- }
204
- static parseSap(t) {
205
- var _a, _b, _c, _d;
206
- const r2 = new DOMParser().parseFromString(t.trim(), "text/xml"), o = { header: {}, items: [], returns: [], raw: r2 }, s2 = r2.getElementsByTagName("DOCUMENTHEADER")[0];
207
- if (s2) for (const p of Array.from(s2.children)) o.header[p.tagName] = ((_a = p.textContent) == null ? void 0 : _a.trim()) ?? "";
208
- const c = r2.getElementsByTagName("RETURN");
209
- for (const p of Array.from(c)) {
210
- const d = {};
211
- for (const h of Array.from(p.children)) d[h.tagName] = ((_b = h.textContent) == null ? void 0 : _b.trim()) ?? "";
212
- o.returns.push(d);
213
- }
214
- const _ = ["ACCOUNTGL", "ACCOUNTRECEIVABLE", "ACCOUNTPAYABLE", "ITEMS"];
215
- for (const p of _) {
216
- const d = r2.getElementsByTagName(p)[0];
217
- if (!d) continue;
218
- const h = d.getElementsByTagName("ITEM"), g = h.length > 0 ? Array.from(h) : [d];
219
- for (const n of g) {
220
- const i3 = {};
221
- for (const u of Array.from(n.children)) i3[u.tagName] = ((_c = u.textContent) == null ? void 0 : _c.trim()) ?? "";
222
- o.items.push(i3);
223
- }
224
- break;
225
- }
226
- if (o.items.length === 0) {
227
- const p = r2.documentElement, d = Array.from(p.children).filter((h) => h.hasAttribute("SEGMENT"));
228
- for (const h of d) {
229
- if (h.tagName === "EDI_DC40") continue;
230
- const g = {};
231
- for (const n of Array.from(h.children)) g[n.tagName] = ((_d = n.textContent) == null ? void 0 : _d.trim()) ?? "";
232
- Object.keys(g).length > 0 && o.items.push(g);
233
- }
234
- }
235
- return o;
236
- }
237
- static stringifySap(t) {
238
- const e = ['<?xml version="1.0" encoding="UTF-8"?>', "<BAPI_CALL>"];
239
- if (t.BAPI_FUNCTION && e.push(` <FUNCTION>${this._escText(t.BAPI_FUNCTION)}</FUNCTION>`), t.DOCUMENTHEADER && typeof t.DOCUMENTHEADER == "object") {
240
- e.push(" <DOCUMENTHEADER>");
241
- for (const [o, s2] of Object.entries(t.DOCUMENTHEADER)) s2 != null && s2 !== "" && e.push(` <${o}>${this._escText(String(s2))}</${o}>`);
242
- e.push(" </DOCUMENTHEADER>");
243
- }
244
- const r2 = Object.keys(t).find((o) => Array.isArray(t[o]) && !o.startsWith("_"));
245
- if (r2) {
246
- e.push(` <${r2}>`);
247
- for (const o of t[r2]) {
248
- e.push(" <ITEM>");
249
- for (const [s2, c] of Object.entries(o)) c != null && c !== "" && !s2.startsWith("_") && e.push(` <${s2}>${this._escText(String(c))}</${s2}>`);
250
- e.push(" </ITEM>");
251
- }
252
- e.push(` </${r2}>`);
253
- }
254
- return e.push("</BAPI_CALL>"), e.join(`
255
- `);
256
- }
257
- static stringifySapBatch(t) {
258
- const e = ['<?xml version="1.0" encoding="UTF-8"?>', `<BAPI_BATCH total="${t.documents.length}">`];
259
- return t.documents.forEach((r2, o) => {
260
- e.push(` <BAPI_CALL seq="${o + 1}">`);
261
- const s2 = this.stringifySap(r2).split(`
262
- `).filter((c) => !c.startsWith("<?xml")).map((c) => " " + c).join(`
263
- `);
264
- e.push(s2), e.push(" </BAPI_CALL>");
265
- }), e.push("</BAPI_BATCH>"), e.join(`
266
- `);
267
- }
268
- static _escText(t) {
269
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
270
- }
271
- static _escAttr(t) {
272
- return this._escText(t).replace(/"/g, "&quot;").replace(/'/g, "&apos;");
273
- }
274
- }
275
- export {
276
- D as DEFAULT_ICON_ROLES,
277
- C as GridShuttle,
278
- I as IconRegistry,
279
- L as LocaleRegistry,
280
- O as OpenGrid,
281
- N as OrgChart,
282
- R as RESERVED_PREFIXES,
283
- S as SkinRegistry,
284
- T2 as TypedRegistry,
285
- I2 as XmlConverter,
286
- v as createGridShuttle,
287
- i as iconRegistry,
288
- i2 as isReserved,
289
- l as localeRegistry,
290
- r as renderIcon,
291
- s as skinRegistry,
292
- T as t
293
- };
1
+ import{b as A,t as v}from"./OpenGrid-CeXt04ho.js";import{D as T,I as N,L as w,O as I,S as L,i as $,l as S,r as O,s as R}from"./OpenGrid-CeXt04ho.js";import{R as D,T as M,i as k}from"./Registry-CrT46EAO.js";class C{constructor(t,e,o,a={}){this.$w=t,this.$fo=e;const n=document.createElement("div");n.className="og-shuttle",n.style.cssText=`display:flex;gap:6px;align-items:center;justify-content:center;flex-direction:${a.layout==="horizontal"?"row":"column"};`;const c=(f,m,p)=>{const i=document.createElement("button");return i.type="button",i.className="og-shuttle-btn",i.textContent=f,i.title=m,i.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);",i.addEventListener("mouseover",()=>{i.style.background="#f0f6ff",i.style.borderColor="#1976d2"}),i.addEventListener("mouseout",()=>{i.style.background="#fff",i.style.borderColor="#bbb"}),i.addEventListener("click",p),i},x=a.labels??{},h=f=>this.$w.t(f);n.appendChild(c(x.toRight??"▶",h("shuttle.toRight"),()=>{this.$w.moveCheckedTo(this.$fo)})),n.appendChild(c(x.toLeft??"◀",h("shuttle.toLeft"),()=>{this.$fo.moveCheckedTo(this.$w)})),a.includeAll&&(n.appendChild(c(x.allRight??"⏩",h("shuttle.allRight"),()=>{this.$jw(this.$w,this.$fo)})),n.appendChild(c(x.allLeft??"⏪",h("shuttle.allLeft"),()=>{this.$jw(this.$fo,this.$w)}))),o.appendChild(n),this.$d=n}$jw(t,e){const o=t.getData().length;o>0&&t.moveRowsTo(e,Array.from({length:o},(a,n)=>n))}destroy(){this.$d.remove()}}function B(b,t,e,o){return new C(b,t,e,o)}class U{constructor(t,e){this._data=[],this.$cf=[],this.$aI=new Set,this.$hn=null,this.$aG=!1,this._container=typeof t=="string"?document.querySelector(t):t,this.$aA={nodeWidth:160,nodeHeight:72,levelGap:52,siblingGap:20,expandOnLoad:!0,onNodeClick:()=>{},...e},this._container.classList.add("og-orgchart")}setData(t){this._data=t;const{idField:e,parentIdField:o,expandOnLoad:a}=this.$aA;a&&this.$aI.size===0&&t.forEach(n=>this.$aI.add(n[e])),this.$cf=A(t,{idField:e,parentIdField:o},this.$aI),this._render()}setTheme(t){this._container.setAttribute("data-og-theme",t)}setSkin(t){this._container.setAttribute("data-og-skin",t)}expandAll(){const t=e=>{for(const o of e)this.$aI.add(o._treeId),o.children.length&&t(o.children)};t(this.$cf),this._rebuild()}collapseAll(){this.$aI.clear(),this._rebuild()}destroy(){this.$aG||(this.$aG=!0,this._container.innerHTML="",this._container.classList.remove("og-orgchart"),this._data=[],this.$cf=[],this.$aI.clear(),this.$hn=null)}$ns(t){this.$aI.has(t)?this.$aI.delete(t):this.$aI.add(t),this._rebuild()}_rebuild(){const{idField:t,parentIdField:e}=this.$aA;this.$cf=A(this._data,{idField:t,parentIdField:e},this.$aI),this._render()}$lp(){const{nodeWidth:t,nodeHeight:e,levelGap:o,siblingGap:a}=this.$aA,n=new Map;let c=0;const x=m=>{const p=m._depth*(e+o),i=m._expanded?m.children:[];if(!i.length){const u=c;return c+=t+a,n.set(m._treeId,{x:u,y:p}),{minX:u,maxX:u}}let r=1/0,l=-1/0;for(const u of i){const{minX:s,maxX:g}=x(u);s<r&&(r=s),g>l&&(l=g)}const d=r+(l-r+t)/2-t/2;return n.set(m._treeId,{x:d,y:p}),{minX:r,maxX:l}};for(const m of this.$cf)x(m);let h=0,f=0;for(const{x:m,y:p}of n.values())m+t>h&&(h=m+t),p+e>f&&(f=p+e);return{layout:n,totalW:h+a,totalH:f+o+16}}$gC(t,e,o,a,n){const c=document.createElementNS("http://www.w3.org/2000/svg","line");c.setAttribute("x1",String(e)),c.setAttribute("y1",String(o)),c.setAttribute("x2",String(a)),c.setAttribute("y2",String(n)),c.setAttribute("class","og-orgchart-line"),t.appendChild(c)}_render(){const{nodeWidth:t,nodeHeight:e,levelGap:o,columns:a}=this.$aA,{layout:n,totalW:c,totalH:x}=this.$lp();this._container.innerHTML="";const h=document.createElement("div");h.className="og-orgchart-wrap",h.style.cssText=`width:${c}px;height:${x}px;`;const f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("width",String(c)),f.setAttribute("height",String(x)),f.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:visible;";const m=i=>{for(const r of i){if(!r._expanded||!r.children.length)continue;const l=n.get(r._treeId),d=l.x+t/2,u=l.y+e,s=u+o/2,g=r.children;if(this.$gC(f,d,u,d,s),g.length>1){const E=n.get(g[0]._treeId),y=n.get(g[g.length-1]._treeId);this.$gC(f,E.x+t/2,s,y.x+t/2,s)}for(const E of g){const y=n.get(E._treeId),_=y.x+t/2;this.$gC(f,_,s,_,y.y)}m(g)}};m(this.$cf),h.appendChild(f);const p=i=>{for(const r of i){const l=n.get(r._treeId);if(!l)continue;const d=document.createElement("div");d.className="og-orgchart-node",r._hasChildren&&d.classList.add("og-orgchart-node--branch"),r._expanded&&d.classList.add("og-orgchart-node--expanded"),this.$hn===r._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;`;const u=document.createElement("div");u.className="og-orgchart-node-content";for(const s of a){const g=r.data[s.field],E=document.createElement("div");if(E.className="og-orgchart-col"+(s.className?" "+s.className:""),s.style){const y=typeof s.style=="function"?s.style(g,r.data):s.style;E.setAttribute("style",y)}if(s.renderer){const y=s.renderer(g,r.data);typeof y=="string"?E.innerHTML=y:E.appendChild(y)}else E.textContent=g??"";u.appendChild(E)}if(d.appendChild(u),r._hasChildren){const s=document.createElement("button");s.type="button",s.className="og-orgchart-toggle",s.setAttribute("aria-expanded",r._expanded?"true":"false"),s.setAttribute("aria-label",v(r._expanded?"tree.collapse":"tree.expand"));const g=document.createElement("i");g.setAttribute("aria-hidden","true"),g.className=r._expanded?"bi bi-dash-circle":"bi bi-plus-circle",s.appendChild(g),s.addEventListener("click",E=>{E.stopPropagation(),this.$ns(r._treeId)}),d.appendChild(s)}d.addEventListener("click",()=>{this.$hn=r._treeId,this.$aA.onNodeClick(r._treeId,r.data),this._container.querySelectorAll(".og-orgchart-node--selected").forEach(s=>s.classList.remove("og-orgchart-node--selected")),d.classList.add("og-orgchart-node--selected")}),h.appendChild(d),r._expanded&&r.children.length&&p(r.children)}};p(this.$cf),this._container.appendChild(h)}}class F{static parse(t,e={}){var o,a;const{fieldMap:n={},trim:c=!0}=e,h=new DOMParser().parseFromString(t.trim(),"text/xml"),f=h.querySelector("parsererror");if(f)throw new Error(`XML 파싱 오류: ${(o=f.textContent)==null?void 0:o.trim()}`);const m=h.documentElement;let p=e.rowTag;if(!p){const l=e.rootTag?h.querySelector(e.rootTag):m;p=((a=l==null?void 0:l.children[0])==null?void 0:a.tagName)??"row"}const i=h.getElementsByTagName(p),r=[];for(let l=0;l<i.length;l++){const d=i[l],u={};for(const s of Array.from(d.attributes)){const g=n[s.name]??s.name;u[g]=c?s.value.trim():s.value}for(const s of Array.from(d.children)){const g=n[s.tagName]??s.tagName,E=s.textContent??"";u[g]=c?E.trim():E}r.push(u)}return r}static stringify(t,e={}){const{rootTag:o="rows",rowTag:a="row",mode:n="element",fieldMap:c={},declaration:x=!0,indent:h=2,nullAs:f="",excludeFields:m=[]}=e,p=" ".repeat(h),i=[];x&&i.push('<?xml version="1.0" encoding="UTF-8"?>'),i.push(`<${o}>`);for(const r of t){const l=Object.entries(r).filter(([d])=>!m.includes(d));if(n==="attribute"){const d=l.map(([u,s])=>{const g=c[u]??u,E=s==null?f:String(s);return`${g}="${this.$lD(E)}"`}).join(" ");i.push(`${p}<${a}${d?" "+d:""} />`)}else{i.push(`${p}<${a}>`);for(const[d,u]of l){const s=c[d]??d,g=u==null?f:String(u);i.push(`${p}${p}<${s}>${this.$dy(g)}</${s}>`)}i.push(`${p}</${a}>`)}}return i.push(`</${o}>`),i.join(`
2
+ `)}static parseSap(t){var e,o,a,n;const x=new DOMParser().parseFromString(t.trim(),"text/xml"),h={header:{},items:[],returns:[],raw:x},f=x.getElementsByTagName("DOCUMENTHEADER")[0];if(f)for(const i of Array.from(f.children))h.header[i.tagName]=((e=i.textContent)==null?void 0:e.trim())??"";const m=x.getElementsByTagName("RETURN");for(const i of Array.from(m)){const r={};for(const l of Array.from(i.children))r[l.tagName]=((o=l.textContent)==null?void 0:o.trim())??"";h.returns.push(r)}const p=["ACCOUNTGL","ACCOUNTRECEIVABLE","ACCOUNTPAYABLE","ITEMS"];for(const i of p){const r=x.getElementsByTagName(i)[0];if(!r)continue;const l=r.getElementsByTagName("ITEM"),d=l.length>0?Array.from(l):[r];for(const u of d){const s={};for(const g of Array.from(u.children))s[g.tagName]=((a=g.textContent)==null?void 0:a.trim())??"";h.items.push(s)}break}if(h.items.length===0){const i=x.documentElement,r=Array.from(i.children).filter(l=>l.hasAttribute("SEGMENT"));for(const l of r){if(l.tagName==="EDI_DC40")continue;const d={};for(const u of Array.from(l.children))d[u.tagName]=((n=u.textContent)==null?void 0:n.trim())??"";Object.keys(d).length>0&&h.items.push(d)}}return h}static stringifySap(t){const e=['<?xml version="1.0" encoding="UTF-8"?>',"<BAPI_CALL>"];if(t.BAPI_FUNCTION&&e.push(` <FUNCTION>${this.$dy(t.BAPI_FUNCTION)}</FUNCTION>`),t.DOCUMENTHEADER&&typeof t.DOCUMENTHEADER=="object"){e.push(" <DOCUMENTHEADER>");for(const[a,n]of Object.entries(t.DOCUMENTHEADER))n!=null&&n!==""&&e.push(` <${a}>${this.$dy(String(n))}</${a}>`);e.push(" </DOCUMENTHEADER>")}const o=Object.keys(t).find(a=>Array.isArray(t[a])&&!a.startsWith("_"));if(o){e.push(` <${o}>`);for(const a of t[o]){e.push(" <ITEM>");for(const[n,c]of Object.entries(a))c!=null&&c!==""&&!n.startsWith("_")&&e.push(` <${n}>${this.$dy(String(c))}</${n}>`);e.push(" </ITEM>")}e.push(` </${o}>`)}return e.push("</BAPI_CALL>"),e.join(`
3
+ `)}static stringifySapBatch(t){const e=['<?xml version="1.0" encoding="UTF-8"?>',`<BAPI_BATCH total="${t.documents.length}">`];return t.documents.forEach((o,a)=>{e.push(` <BAPI_CALL seq="${a+1}">`);const n=this.stringifySap(o).split(`
4
+ `).filter(c=>!c.startsWith("<?xml")).map(c=>" "+c).join(`
5
+ `);e.push(n),e.push(" </BAPI_CALL>")}),e.push("</BAPI_BATCH>"),e.join(`
6
+ `)}static $dy(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}static $lD(t){return this.$dy(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")}}export{T as DEFAULT_ICON_ROLES,C as GridShuttle,N as IconRegistry,w as LocaleRegistry,I as OpenGrid,U as OrgChart,D as RESERVED_PREFIXES,L as SkinRegistry,M as TypedRegistry,F as XmlConverter,B as createGridShuttle,$ as iconRegistry,k as isReserved,S as localeRegistry,O as renderIcon,R as skinRegistry,v as t};
294
7
  //# sourceMappingURL=open-grid.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ENC=new TextEncoder;class MemoryByteSink{constructor(e=8*1024*1024){this.$dF=e,this.$ia=[],this.$aE=0,this.$x=!1,this.$ak=!1}write(e){return this.$x||this.$ak?Promise.reject(new Error("sink closed/aborted")):(this.$ia.push(e),this.$aE+=typeof e=="string"?ENC.encode(e).length:e.length,Promise.resolve())}close(){return this.$x=!0,Promise.resolve()}abort(e){this.$ak=!0,e!==void 0&&(this.$hD=e)}get desiredSize(){return this.$dF-this.$aE}toString(){return this.$ia.map(e=>typeof e=="string"?e:new TextDecoder().decode(e)).join("")}get bytesWritten(){return this.$aE}get closed(){return this.$x}get aborted(){return this.$ak}get abortReason(){return this.$hD}}class DownloadByteSink{constructor(e,t=Number.POSITIVE_INFINITY){this.$dw=e,this.$dF=t,this.$as="",this.$aE=0,this.$x=!1}write(e){const t=typeof e=="string"?e:new TextDecoder().decode(e);return this.$as+=t,this.$aE+=ENC.encode(t).length,Promise.resolve()}close(){return this.$x||(this.$x=!0,this.$dw(this.$as)),Promise.resolve()}abort(){this.$x=!0}get desiredSize(){return this.$dF-this.$aE}}const XLSX_MIME="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";function byteLen(i){return typeof i=="string"?ENC.encode(i).length:i.length}class FileSystemByteSink{constructor(e,t=8*1024*1024){this.$hB=e,this.$dF=t,this.$ap=0,this.$x=!1,this.$ak=!1}async write(e){if(this.$x||this.$ak)throw new Error("sink closed/aborted");const t=byteLen(e);this.$ap+=t;try{await this.$hB.write(e)}finally{this.$ap-=t}}async close(){this.$x||this.$ak||(this.$x=!0,await this.$hB.close())}abort(e){var t,r;if(!this.$ak){this.$ak=!0;try{const s=(r=(t=this.$hB).abort)==null?void 0:r.call(t,e);s&&typeof s.catch=="function"&&s.catch(()=>{})}catch{}}}get desiredSize(){return this.$dF-this.$ap}}class BlobDownloadByteSink{constructor(e={}){this.$eX=[],this.$aE=0,this.$x=!1,this.$ak=!1,this.$gf=e.fileName??"export.xlsx",this.$jt=e.mime??XLSX_MIME,this.$iV=e.highWaterMark??1024*1024*1024,this.$dw=e.download}write(e){if(this.$x||this.$ak)return Promise.reject(new Error("sink closed/aborted"));const t=typeof e=="string"?ENC.encode(e):e;return this.$eX.push(t),this.$aE+=t.length,Promise.resolve()}close(){if(this.$x||this.$ak)return Promise.resolve();this.$x=!0;const e=new Blob(this.$eX,{type:this.$jt});return this.$eX.length=0,this.$dw?this.$dw(e,this.$gf):BlobDownloadByteSink.$kY(e,this.$gf),Promise.resolve()}abort(){this.$ak=!0,this.$eX.length=0}get desiredSize(){return this.$iV-this.$aE}get bytesWritten(){return this.$aE}static $kY(e,t){if(typeof document>"u"||typeof URL>"u"||!URL.createObjectURL)return;const r=URL.createObjectURL(e);try{const s=document.createElement("a");s.href=r,s.download=t,s.style.display="none",document.body.appendChild(s),s.click(),s.remove()}finally{URL.revokeObjectURL(r)}}}function canUseFileSystemAccess(i={}){if(i.fsAccess==="off")return!1;const e=i.env!==void 0?i.env:typeof window<"u"?window:void 0;return!!e&&typeof e.showSaveFilePicker=="function"}function pickExcelSink(i={}){const e=i.fileName??"export.xlsx",t=i.mime??XLSX_MIME;if(canUseFileSystemAccess(i)){const r=i.env!==void 0?i.env:window;return{kind:"fs",async create(){const s=await r.showSaveFilePicker({suggestedName:e,types:[{description:"Excel",accept:{[t]:[".xlsx"]}}]});return new FileSystemByteSink(await s.createWritable(),i.highWaterMark)}}}return{kind:"blob",create:()=>Promise.resolve(new BlobDownloadByteSink({fileName:e,mime:t,highWaterMark:i.highWaterMark,download:i.download}))}}exports.BlobDownloadByteSink=BlobDownloadByteSink,exports.DownloadByteSink=DownloadByteSink,exports.FileSystemByteSink=FileSystemByteSink,exports.MemoryByteSink=MemoryByteSink,exports.XLSX_MIME=XLSX_MIME,exports.canUseFileSystemAccess=canUseFileSystemAccess,exports.pickExcelSink=pickExcelSink;
2
+ //# sourceMappingURL=sinks-BCZFMGQJ.cjs.map