open-grid 1.0.7 → 1.1.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/CHANGELOG.md +34 -0
- package/dist/OpenGrid-5flQwc3W.js +8434 -0
- package/dist/OpenGrid-DahxRY7C.cjs +92 -0
- package/dist/open-grid-base.css +61 -0
- package/dist/open-grid-react.cjs +1 -1
- package/dist/open-grid-react.js +1 -1
- package/dist/open-grid-themes.css +96 -1
- package/dist/open-grid-vue.cjs +1 -1
- package/dist/open-grid-vue.js +1 -1
- package/dist/open-grid.cjs +1 -1
- package/dist/open-grid.js +2 -2
- package/dist/types/core/CellEditManager.d.ts +4 -0
- package/dist/types/core/CellEventHandler.d.ts +6 -0
- package/dist/types/core/ChartManager.d.ts +58 -0
- package/dist/types/core/DataLayer.d.ts +17 -0
- package/dist/types/core/DetailManager.d.ts +72 -0
- package/dist/types/core/FlatRowModel.d.ts +56 -0
- package/dist/types/core/GridRenderer.d.ts +34 -1
- package/dist/types/core/GroupTreeManager.d.ts +13 -0
- package/dist/types/core/KeyboardManager.d.ts +19 -0
- package/dist/types/core/OpenGrid.d.ts +109 -1
- package/dist/types/core/RangeSelectionManager.d.ts +95 -0
- package/dist/types/core/SortFilterManager.d.ts +2 -0
- package/dist/types/core/chart/CanvasAdapter.d.ts +52 -0
- package/dist/types/core/chart/DataExtractor.d.ts +49 -0
- package/dist/types/core/chart/a11y.d.ts +21 -0
- package/dist/types/core/chart/downsample.d.ts +25 -0
- package/dist/types/core/chart/hittest.d.ts +20 -0
- package/dist/types/core/chart/palette.d.ts +56 -0
- package/dist/types/core/chart/scales.d.ts +24 -0
- package/dist/types/core/chart/types.d.ts +181 -0
- package/dist/types/core/detail/DetailGlyph.d.ts +48 -0
- package/dist/types/core/detail/DetailSplice.d.ts +67 -0
- package/dist/types/core/detail/DetailState.d.ts +67 -0
- package/dist/types/core/detail/SubgridCache.d.ts +73 -0
- package/dist/types/core/detail/index.d.ts +14 -0
- package/dist/types/core/formula/FormulaEvaluator.d.ts +15 -0
- package/dist/types/core/formula/FormulaGraph.d.ts +43 -0
- package/dist/types/core/formula/FormulaParser.d.ts +6 -0
- package/dist/types/core/formula/FormulaStore.d.ts +17 -0
- package/dist/types/core/formula/RecalcCoordinator.d.ts +85 -0
- package/dist/types/core/formula/normalizeRefs.d.ts +15 -0
- package/dist/types/core/formula/numericLiteral.d.ts +7 -0
- package/dist/types/core/formula/serializeFormula.d.ts +6 -0
- package/dist/types/core/formula/types.d.ts +104 -0
- package/dist/types/core/range/ClipboardCodec.d.ts +30 -0
- package/dist/types/core/range/FillEngine.d.ts +63 -0
- package/dist/types/core/range/RangeModel.d.ts +53 -0
- package/dist/types/core/range/RangeQuery.d.ts +16 -0
- package/dist/types/core/range/types.d.ts +47 -0
- package/dist/types/core/renderers/CellRenderer.d.ts +3 -0
- package/dist/types/core/types.d.ts +242 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
- package/dist/OpenGrid-tdspERot.cjs +0 -90
- package/dist/OpenGrid-zBt01Yim.js +0 -4867
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";class oe{constructor(){this.listeners=new Map}on(t,e){const s=this.listeners.get(t)??[];return s.push({handler:e,once:!1}),this.listeners.set(t,s),this}once(t,e){const s=this.listeners.get(t)??[];return s.push({handler:e,once:!0}),this.listeners.set(t,s),this}off(t,e){if(!e)return this.listeners.delete(t),this;const s=this.listeners.get(t);if(s){const i=s.filter(o=>o.handler!==e);i.length===0?this.listeners.delete(t):this.listeners.set(t,i)}return this}emit(t,...e){const s=this.listeners.get(t);if(!s||s.length===0)return!1;const i=[];for(const o of s)o.handler(...e),o.once||i.push(o);return i.length!==s.length&&(i.length===0?this.listeners.delete(t):this.listeners.set(t,i)),!0}removeAllListeners(t){return t?this.listeners.delete(t):this.listeners.clear(),this}listenerCount(t){var e;return((e=this.listeners.get(t))==null?void 0:e.length)??0}}let ne=0;function Ft(){return`og-r-${++ne}`}class re{constructor(t="_ogRowId"){this._data=[],this._original=[],this._meta=new Map,this._displayIndexes=[],this._idMap=new Map,this._findQuery="",this._findFields=[],this._getStrategy=(e,s)=>s,this._idField=t}setStrategyResolver(t){this._getStrategy=t}setData(t){this._data=t.map(e=>{const s=Ft(),i={...e,[this._idField]:s};return this._meta.set(s,{state:"none",rowId:s}),i}),this._original=this._data.map(e=>({...e})),this._rebuildIdMap(),this._displayIndexes=this._data.map((e,s)=>s)}getData(){return this._displayIndexes.map(t=>this._data[t])}getOriginalData(){return[...this._original]}getAllData(){return[...this._data]}clearData(){this._data=[],this._original=[],this._meta.clear(),this._idMap.clear(),this._displayIndexes=[]}get rowCount(){return this._displayIndexes.length}get totalRowCount(){return this._data.length}addRow(t,e="last"){const s=Ft(),i={...t,[this._idField]:s};if(this._meta.set(s,{state:"added",rowId:s}),e==="last"){const o=this._data.push(i)-1;this._idMap.set(s,o),this._displayIndexes.push(o)}else if(e==="first")this._data.unshift(i),this._rebuildIdMap(),this._displayIndexes.unshift(0);else{const o=Math.min(e,this._displayIndexes.length),n=o<this._displayIndexes.length?this._displayIndexes[o]:this._data.length;this._data.splice(n,0,i),this._rebuildIdMap(),this._displayIndexes=this._data.map((r,l)=>l)}}removeRow(t){const e=this._displayIndexes[t];if(e===void 0)return;const s=this._data[e],i=s[this._idField],o=this._meta.get(i);return(o==null?void 0:o.state)==="added"?(this._data.splice(e,1),this._meta.delete(i)):this._meta.set(i,{...o,state:"removed"}),this._rebuildIdMap(),this._displayIndexes=this._data.map((n,r)=>({r:n,i:r})).filter(({r:n})=>{var r;return((r=this._meta.get(n[this._idField]))==null?void 0:r.state)!=="removed"}).map(({i:n})=>n),s}moveRow(t,e){const s=this._displayIndexes[t],i=this._displayIndexes[e];if(s===void 0||i===void 0)return;const[o]=this._data.splice(s,1),n=s<i?i-1:i;this._data.splice(n,0,o),this._rebuildIdMap(),this._displayIndexes=this._data.map((r,l)=>({r,i:l})).filter(({r})=>{var l;return((l=this._meta.get(r[this._idField]))==null?void 0:l.state)!=="removed"}).map(({i:r})=>r)}updateCell(t,e,s){const i=this._displayIndexes[t];if(i===void 0)return!1;const n=this._data[i][this._idField],r=this._meta.get(n);return(r==null?void 0:r.state)==="none"&&this._meta.set(n,{...r,state:"edited",original:{...this._original[i]}}),this._data[i][e]=s,!0}getRowByIndex(t){const e=this._displayIndexes[t];return e!==void 0?this._data[e]:void 0}getCellValue(t,e){var s;return(s=this.getRowByIndex(t))==null?void 0:s[e]}getEditedRows(){return this._data.filter(t=>{var e;return((e=this._meta.get(t[this._idField]))==null?void 0:e.state)==="edited"})}getChangedRows(){return this.getEditedRows()}getAddedRows(){return this._data.filter(t=>{var e;return((e=this._meta.get(t[this._idField]))==null?void 0:e.state)==="added"})}getRemovedRows(){return this._data.filter(t=>{var e;return((e=this._meta.get(t[this._idField]))==null?void 0:e.state)==="removed"})}getChanges(){const t=[],e=[],s=[];for(const i of this._data){const o=i[this._idField],n=this._meta.get(o),r=(n==null?void 0:n.state)??"none";if(r==="added")t.push({...i});else if(r==="removed")s.push({...i});else if(r==="edited"){const l=n.original??{},a=Object.keys(i).filter(c=>c!==this._idField&&i[c]!==l[c]);e.push({...i,_changedFields:a})}}return{added:t,edited:e,removed:s}}getChangedColumns(){return this._data.filter(t=>{var e;return((e=this._meta.get(t[this._idField]))==null?void 0:e.state)==="edited"}).map(t=>{var i;const e=((i=this._meta.get(t[this._idField]))==null?void 0:i.original)??{},s=[];for(const o of Object.keys(t))o!==this._idField&&t[o]!==e[o]&&s.push({field:o,oldValue:e[o],newValue:t[o]});return{row:{...t},fields:s.map(o=>o.field),diff:s}})}getOriginalRow(t){const e=this._displayIndexes[t];if(e===void 0)return;const s=this._data[e],i=this._meta.get(s[this._idField]);if(!(!i||i.state==="added"))return i.state==="edited"&&i.original?{...i.original}:{...this._original[e]}}getRowsWithState(t){return this._data.map(e=>{var i;const s=((i=this._meta.get(e[this._idField]))==null?void 0:i.state)??"none";return{...e,[t]:s}})}getRowState(t){var s;const e=this.getRowByIndex(t);return e?((s=this._meta.get(e[this._idField]))==null?void 0:s.state)??"none":"none"}applySort(t){const e=o=>{var n,r;return((r=this._meta.get((n=this._data[o])==null?void 0:n[this._idField]))==null?void 0:r.state)!=="removed"};if(t.length===0){this._displayIndexes=this._data.map((o,n)=>n).filter(e);return}const s=this._displayIndexes.filter(e).map(o=>{const n=this._data[o];return{idx:o,keys:t.map(r=>n[r.field])}}),i=this._getStrategy("sortComparator",(o,n,r,l)=>{if(o==null&&n==null)return 0;if(o==null)return-1;if(n==null)return 1;if(typeof o=="number"&&typeof n=="number")return o-n;const a=String(o),c=String(n);return a<c?-1:a>c?1:0});s.sort((o,n)=>{for(let r=0;r<t.length;r++){const l=t[r].dir,a=t[r].field,c=o.keys[r],u=n.keys[r],h=i(c,u,a,l);if(h!==0)return l==="asc"?h:-h}return 0}),this._displayIndexes=s.map(o=>o.idx)}applyFilter(t){const e=Object.keys(t),s=this._getStrategy("filterPredicate",(i,o,n)=>le(i,o));this._displayIndexes=this._data.map((i,o)=>({r:i,i:o})).filter(({r:i})=>{var o;if(((o=this._meta.get(i[this._idField]))==null?void 0:o.state)==="removed"||e.length>0&&!e.every(n=>{const r=i[n];return t[n].every(l=>s(r,l,n))}))return!1;if(this._findQuery&&this._findFields.length>0){const n=this._findQuery;if(!this._findFields.some(l=>{const a=i[l];return a!=null&&String(a).toLowerCase().includes(n)}))return!1}return!0}).map(({i})=>i)}setFindFilter(t,e){this._findQuery=t.toLowerCase(),this._findFields=e}_rebuildIdMap(){this._idMap.clear(),this._data.forEach((t,e)=>{this._idMap.set(t[this._idField],e)})}}function le(d,t){const e=d,s=t.value;switch(t.operator){case"=":return e==s;case"!=":return e!=s;case">":return e>s;case">=":return e>=s;case"<":return e<s;case"<=":return e<=s;case"contains":return String(e).includes(String(s));case"startsWith":return String(e).startsWith(String(s));case"endsWith":return String(e).endsWith(String(s));default:return!0}}class ae{constructor(t,e){this._totalRows=0,this._scrollTop=0,this._viewportHeight=0,this._rafId=null,this._onScroll=()=>{this._scrollTop=this.container.scrollTop,this._scheduleRender()},this.container=t,this.rowHeight=e.rowHeight,this.overscan=e.overscan??5,this.onRender=e.onRender,this.container.addEventListener("scroll",this._onScroll,{passive:!0})}_scheduleRender(){this._rafId===null&&(this._rafId=requestAnimationFrame(()=>{this._rafId=null;const t=this.getVisibleRange();this.onRender(t.startIndex,t.endIndex)}))}getVisibleRange(){const t=Math.ceil(this._viewportHeight/this.rowHeight),e=Math.max(0,Math.floor(this._scrollTop/this.rowHeight)-this.overscan),s=Math.min(this._totalRows-1,e+t+this.overscan*2),i=e*this.rowHeight;return{startIndex:e,endIndex:s,offsetY:i}}setTotalRows(t){this._totalRows=t,this._updateSpacerHeight(),this._scheduleRender()}setViewportHeight(t){this._viewportHeight=t,this._scheduleRender()}setRowHeight(t){this.rowHeight=t,this._updateSpacerHeight(),this._scheduleRender()}scrollToRow(t){const e=t*this.rowHeight,s=e+this.rowHeight,i=this._scrollTop+this._viewportHeight;if(e<this._scrollTop)this._scrollTop=e,this.container.scrollTop=e;else if(s>i){const o=s-this._viewportHeight;this._scrollTop=o,this.container.scrollTop=o}}getTotalHeight(){return this._totalRows*this.rowHeight}_updateSpacerHeight(){const t=this.container.querySelector(".og-spacer");t&&(t.style.height=`${this.getTotalHeight()}px`)}destroy(){this.container.removeEventListener("scroll",this._onScroll),this._rafId!==null&&cancelAnimationFrame(this._rafId)}}class Tt{constructor(t,e=0){this._flatLeaves=[],this._maxDepth=1,this._frozenCount=0,this._columns=t,this._frozenCount=e,this._process()}_process(){const t=[];let e=0;const s=(i,o)=>{for(const n of i)n.children&&n.children.length>0?(s(n.children,o+1),this._maxDepth=Math.max(this._maxDepth,o+1)):t.push({...n,_colIndex:e++,_depth:o,_leaf:!0})};this._maxDepth=1,s(this._columns,1),this._flatLeaves=t}get leaves(){return this._flatLeaves}get visibleLeaves(){return this._flatLeaves.filter(t=>!t.hidden)}get headerDepth(){return this._maxDepth}get frozenCount(){return this._frozenCount}setFrozen(t){this._frozenCount=t}setColumns(t){this._columns=t,this._process()}hideColumn(t){const e=Array.isArray(t)?t:[t];this._flatLeaves.forEach(s=>{e.includes(s.field)&&(s.hidden=!0)})}showColumn(t){const e=Array.isArray(t)?t:[t];this._flatLeaves.forEach(s=>{e.includes(s.field)&&(s.hidden=!1)})}addColumn(t,e="last"){e==="last"?this._columns.push(t):e==="first"?this._columns.unshift(t):this._columns.splice(e,0,t),this._process()}removeColumn(t){const e=s=>s.filter(i=>i.field===t?!1:(i.children&&(i.children=e(i.children)),!0));this._columns=e(this._columns),this._process()}getColumnByField(t){return this._flatLeaves.find(e=>e.field===t)}getColumnByIndex(t){return this._flatLeaves[t]}getColumnIndex(t){return this._flatLeaves.findIndex(e=>e.field===t)}buildHeaderCells(){const t=Array.from({length:this._maxDepth},()=>[]);let e=0;const s=(i,o)=>{let n=0;for(const r of i)if(!r.hidden)if(r.children&&r.children.length>0){const l=s(r.children,o+1);l>0&&(t[o-1].push({column:r,colIndex:e,depth:o,colSpan:l,rowSpan:1}),n+=l)}else t[o-1].push({column:r,colIndex:e++,depth:o,colSpan:1,rowSpan:this._maxDepth-o+1}),n++;return n};return s(this._columns,1),t}computeWidths(t,e=100){const s=this.visibleLeaves,i=s.filter(l=>l.flex),o=s.filter(l=>!l.flex&&l.width).reduce((l,a)=>l+a.width,0),n=i.reduce((l,a)=>l+(a.flex??1),0),r=Math.max(0,t-o);return s.map(l=>l.flex?Math.round(l.flex/n*r):l.width??e)}}class de{constructor(t,e,s){this._field="",this._outsideHandler=null,this._onApply=e,this._onClear=s,this._el=document.createElement("div"),this._el.className="og-filter-panel",this._el.style.cssText=`
|
|
2
|
-
position:absolute;z-index:1000;min-width:200px;max-width:280px;
|
|
3
|
-
background:var(--og-row-bg,#fff);border:1px solid var(--og-border-color,#e0e0e0);
|
|
4
|
-
border-radius:4px;box-shadow:0 4px 16px rgba(0,0,0,0.15);
|
|
5
|
-
padding:10px;box-sizing:border-box;display:none;font-size:13px;
|
|
6
|
-
`,t.appendChild(this._el)}open(t,e,s){var k;this._field=t,this._el.innerHTML="";const i=document.createElement("div");i.textContent="필터",i.style.cssText="font-weight:600;margin-bottom:8px;color:var(--og-text-color,#333);",this._el.appendChild(i);const o=document.createElement("div");o.style.cssText="display:flex;gap:4px;margin-bottom:6px;";const n=document.createElement("select");n.style.cssText="flex:1;padding:3px 4px;border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;font-size:12px;";const r=[{label:"포함",value:"contains"},{label:"같음",value:"="},{label:"같지 않음",value:"!="},{label:"시작",value:"startsWith"},{label:"끝남",value:"endsWith"},{label:"보다 큼",value:">"},{label:"보다 작음",value:"<"},{label:"이상",value:">="},{label:"이하",value:"<="}];for(const m of r){const w=document.createElement("option");w.value=m.value,w.textContent=m.label,n.appendChild(w)}s[0]&&(n.value=s[0].operator),o.appendChild(n),this._el.appendChild(o);const l=document.createElement("input");l.type="text",l.placeholder="필터 값 입력...",l.value=((k=s[0])==null?void 0:k.value)??"",l.style.cssText=`
|
|
7
|
-
width:100%;padding:4px 6px;border:1px solid var(--og-border-color,#e0e0e0);
|
|
8
|
-
border-radius:3px;font-size:12px;box-sizing:border-box;margin-bottom:8px;
|
|
9
|
-
outline:none;
|
|
10
|
-
`,l.addEventListener("keydown",m=>{m.key==="Enter"?u.click():m.key==="Escape"&&this.close()}),this._el.appendChild(l);const a=document.createElement("div");a.style.cssText="display:flex;gap:6px;justify-content:flex-end;";const c=document.createElement("button");c.textContent="초기화",c.style.cssText=`
|
|
11
|
-
padding:3px 10px;border:1px solid var(--og-border-color,#e0e0e0);
|
|
12
|
-
border-radius:3px;background:#fff;cursor:pointer;font-size:12px;color:#666;
|
|
13
|
-
`,c.addEventListener("click",()=>{this._onClear(this._field),this.close()});const u=document.createElement("button");u.textContent="적용",u.style.cssText=`
|
|
14
|
-
padding:3px 10px;border:1px solid var(--og-primary,#1976d2);
|
|
15
|
-
border-radius:3px;background:var(--og-primary,#1976d2);
|
|
16
|
-
color:#fff;cursor:pointer;font-size:12px;
|
|
17
|
-
`,u.addEventListener("click",()=>{const m=l.value.trim();m?this._onApply(this._field,[{operator:n.value,value:m}]):this._onClear(this._field),this.close()}),a.appendChild(c),a.appendChild(u),this._el.appendChild(a);const h=e.getBoundingClientRect(),g=this._el.parentElement.getBoundingClientRect();this._el.style.top=`${h.bottom-g.top+2}px`,this._el.style.left=`${Math.min(h.left-g.left,g.width-220)}px`,this._el.style.display="block",requestAnimationFrame(()=>l.focus()),this._outsideHandler&&document.removeEventListener("mousedown",this._outsideHandler),this._outsideHandler=m=>{!this._el.contains(m.target)&&m.target!==e&&this.close()},setTimeout(()=>document.addEventListener("mousedown",this._outsideHandler),0)}close(){this._el.style.display="none",this._outsideHandler&&(document.removeEventListener("mousedown",this._outsideHandler),this._outsideHandler=null)}get isOpen(){return this._el.style.display!=="none"}destroy(){this.close(),this._el.remove()}}const ce=10;function he(d,t=ce){const e=Math.pow(10,t);return Math.round(d*e)/e}class M{constructor(t,e){this._c=t,this._s=e<0?0:e}static from(t){if(t instanceof M)return t;if(typeof t=="bigint")return new M(t,0);const e=String(t).trim();if(!e||e==="null"||e==="undefined"||e==="NaN")return new M(0n,0);const s=e.startsWith("-"),i=s?e.slice(1):e,o=i.indexOf(".");let n,r;if(o===-1)n=BigInt(i),r=0;else{const l=i.slice(o+1);n=BigInt(i.slice(0,o)+l),r=l.length}return new M(s?-n:n,r)}static zero(){return new M(0n,0)}static one(){return new M(1n,0)}static _align(t,e){return t._s===e._s?[t._c,e._c,t._s]:t._s>e._s?[t._c,e._c*10n**BigInt(t._s-e._s),t._s]:[t._c*10n**BigInt(e._s-t._s),e._c,e._s]}add(t){const[e,s,i]=M._align(this,M.from(t));return new M(e+s,i)}sub(t){const[e,s,i]=M._align(this,M.from(t));return new M(e-s,i)}mul(t){const e=M.from(t);return new M(this._c*e._c,this._s+e._s)}div(t,e=20){const s=M.from(t);if(s._c===0n)throw new Error("OGDecimal: division by zero");const o=this._c*10n**BigInt(e+s._s)/s._c;return new M(o,e+this._s)}mod(t){const e=M.from(t),[s,i,o]=M._align(this,e);return new M(s%i,o)}neg(){return new M(-this._c,this._s)}abs(){return new M(this._c<0n?-this._c:this._c,this._s)}eq(t){const[e,s]=M._align(this,M.from(t));return e===s}gt(t){const[e,s]=M._align(this,M.from(t));return e>s}lt(t){const[e,s]=M._align(this,M.from(t));return e<s}gte(t){return!this.lt(t)}lte(t){return!this.gt(t)}isZero(){return this._c===0n}isNeg(){return this._c<0n}isPos(){return this._c>0n}toFixed(t){let e=this._c,s=this._s;if(s<t)e=e*10n**BigInt(t-s);else if(s>t){const c=10n**BigInt(s-t),u=c/2n,h=e<0n,g=h?-e:e,k=g%c;let m=g/c;k>=u&&(m+=1n),e=h?-m:m}s=t;const i=e<0n,n=(i?-e:e).toString().padStart(t+1,"0"),r=n.slice(0,n.length-t)||"0",l=t>0?"."+n.slice(n.length-t):"";return(i?"-":"")+r+l}toString(){if(this._s===0)return this._c.toString();let t=this._c,e=this._s;for(;e>0&&t!==0n&&t%10n===0n;)t/=10n,e--;return new M(t,e).toFixed(e)}toNumber(){return parseFloat(this.toFixed(20))}static sum(t){return t.reduce((e,s)=>e.add(s),M.zero())}static avg(t,e=20){return t.length?M.sum(t).div(t.length,e):M.zero()}static min(t){if(!t.length)throw new Error("OGDecimal.min: empty array");return t.map(M.from).reduce((e,s)=>e.lt(s)?e:s)}static max(t){if(!t.length)throw new Error("OGDecimal.max: empty array");return t.map(M.from).reduce((e,s)=>e.gt(s)?e:s)}}function Gt(d,t,e=30){return new ue(d,t,e).parse()}class ue{constructor(t,e,s){this._ctx=e,this._prec=s,this._pos=0,this._src=t.trim()}parse(){const t=this._additive();if(this._skip(),this._pos<this._src.length)throw new SyntaxError(`FormulaEngine: 예상치 못한 토큰 '${this._src[this._pos]}' (위치 ${this._pos})`);return t}_additive(){let t=this._multiplicative();for(this._skip();this._pos<this._src.length;){const e=this._src[this._pos];if(e!=="+"&&e!=="-")break;this._pos++,this._skip();const s=this._multiplicative();t=e==="+"?t.add(s):t.sub(s),this._skip()}return t}_multiplicative(){let t=this._unary();for(this._skip();this._pos<this._src.length;){const e=this._src[this._pos];if(e!=="*"&&e!=="/"&&e!=="%")break;this._pos++,this._skip();const s=this._unary();e==="*"?t=t.mul(s):e==="/"?t=t.div(s,this._prec):t=t.mod(s),this._skip()}return t}_unary(){return this._skip(),this._src[this._pos]==="-"?(this._pos++,this._unary().neg()):this._primary()}_primary(){this._skip();const t=this._src[this._pos];if(t==="("){this._pos++;const e=this._additive();if(this._skip(),this._src[this._pos]!==")")throw new SyntaxError("FormulaEngine: 닫는 괄호 ) 누락");return this._pos++,e}return t==="["?this._fieldRef():this._literal()}_fieldRef(){this._pos++;const t=this._pos;for(;this._pos<this._src.length&&this._src[this._pos]!=="]";)this._pos++;if(this._pos>=this._src.length)throw new SyntaxError("FormulaEngine: 닫는 ] 누락");const e=this._src.slice(t,this._pos);this._pos++;const s=this._ctx[e];if(s==null)throw new ReferenceError(`FormulaEngine: 필드 '[${e}]'가 행 데이터에 없습니다`);return M.from(s)}_literal(){const t=this._pos;for(;this._pos<this._src.length&&/[0-9.]/.test(this._src[this._pos]);)this._pos++;const e=this._src.slice(t,this._pos);if(!e)throw new SyntaxError(`FormulaEngine: 숫자 또는 [필드]를 기대했지만 '${this._src[this._pos]??"EOF"}' 발견 (위치 ${t})`);return M.from(e)}_skip(){for(;this._pos<this._src.length&&/\s/.test(this._src[this._pos]);)this._pos++}}function kt(d,t){if(d==null||d==="")return d??"";const e=typeof t=="string"?{type:t}:t,s=e.char??"*";switch(e.type){case"ssn":return ge(d,s);case"phone":case"mobile":return pe(d,s);case"email":return _e(d,s);case"credit":return fe(d,s);case"account":return me(d,s,e.visiblePrefix??3,e.visibleSuffix??4);case"password":return s.repeat(Math.max(d.length,6));case"name":return ye(d,s);case"ip":return we(d,s);case"partial":return rt(d,s,e.visiblePrefix??0,e.visibleSuffix??4);default:return d}}function ge(d,t){const e=d.replace(/[^0-9]/g,"");if(e.length<7){const n=d.includes("-")?"-":"",r=d.indexOf("-")>=0?d.indexOf("-"):6;return d.slice(0,r)+n+t.repeat(Math.max(1,d.length-r-n.length))}const s=e.slice(0,6),i=e[6],o=e.length-7;return`${s}-${i}${t.repeat(o)}`}function pe(d,t){const e=d.replace(/[^0-9]/g,"");return e.length===11?`${e.slice(0,3)}-${t.repeat(4)}-${e.slice(7)}`:e.length===10?e.startsWith("02")?`${e.slice(0,2)}-${t.repeat(4)}-${e.slice(6)}`:`${e.slice(0,3)}-${t.repeat(3)}-${e.slice(6)}`:e.length===9?`${e.slice(0,2)}-${t.repeat(3)}-${e.slice(5)}`:rt(d,t,3,4)}function _e(d,t){const e=d.indexOf("@");if(e<0)return rt(d,t,2,0);const s=d.slice(0,e),i=d.slice(e),o=Math.min(2,s.length),n=s.slice(0,o),r=Math.max(s.length-o,3);return`${n}${t.repeat(r)}${i}`}function fe(d,t){const e=d.replace(/[^0-9]/g,"");if(e.length<8)return d;const s=e.slice(0,4),i=e.slice(-4),o=e.length-8,n=t.repeat(Math.max(o,8)),r=[s];for(let l=0;l<n.length;l+=4){const a=n.slice(l,l+4);a&&r.push(a)}return r.push(i),r.join("-")}function me(d,t,e,s){const i=d.replace(/[^0-9]/g,"");if(i.length<=e+s)return rt(i,t,e,s);const o=i.slice(0,e),n=i.slice(-s),r=i.length-e-s;return`${o}-${t.repeat(r)}-${n}`}function ye(d,t){const e=d.trim();return e.length===0?d:e.length===1?t:e.length===2?`${e[0]}${t}`:`${e[0]}${t.repeat(e.length-2)}${e[e.length-1]}`}function we(d,t){const e=d.split(".");if(e.length!==4)return rt(d,t,3,0);const s=i=>t.repeat(Math.max(i.length,3));return`${e[0]}.${e[1]}.${s(e[2])}.${s(e[3])}`}function rt(d,t,e,s){if(d.length<=e+s)return d;const i=d.slice(0,e),o=s>0?d.slice(-s):"",n=d.length-e-s;return`${i}${t.repeat(n)}${o}`}let ot=null;function be(d){ot=d}function qt(d){const t=d.column;if(!t.formula)return null;const e=t.formulaPrecision??30;try{let s;return typeof t.formula=="function"?s=t.formula(d.row,M):s=Gt(t.formula,d.row,e),s instanceof M?t.precision!=null?s.toFixed(t.precision):s.toString():typeof s=="string"?s:t.precision!=null?M.from(s).toFixed(t.precision):String(s)}catch(s){return console.warn("[OpenGrid] Formula error:",s),"#ERR"}}function ve(d,t,e,s,i,o){if(ot){const _=ot(d,i??"",o);if(_!=null)return _}if(d==null||d==="")return"";let n=Number(d);if(isNaN(n))return String(d);if(e!=null&&(n=he(n,e)),s)try{return new Intl.NumberFormat(void 0,{style:"currency",currency:s,...e!=null?{minimumFractionDigits:e,maximumFractionDigits:e}:{}}).format(n)}catch{}if(!t)return e!=null?n.toFixed(e):String(n);const r=t.indexOf(";"),l=r>=0?t.slice(r+1):null,a=n<0&&l!=null?l:r>=0?t.slice(0,r):t,c=n<0&&l!=null?Math.abs(n):n,u=a.match(/[#0][#0,]*(?:\.[#0]+)?/);if(!u)return String(n);const h=u[0],g=a.slice(0,u.index),k=a.slice(u.index+h.length),m=h.includes(","),w=h.includes(".")?h.split(".")[1].length:e??0,x=c.toLocaleString("ko-KR",{minimumFractionDigits:w,maximumFractionDigits:w,useGrouping:m});return g+x+k}function Xt(d,t="yyyy-MM-dd",e,s){if(ot){const l=ot(d,e??"",s);if(l!=null)return l}if(!d)return"";const i=d instanceof Date?d:new Date(d);if(isNaN(i.getTime()))return String(d);const o=i.getFullYear(),n=String(i.getMonth()+1).padStart(2,"0"),r=String(i.getDate()).padStart(2,"0");return t.replace("yyyy",String(o)).replace("MM",n).replace("dd",r)}function xe(d,t,e){const s=kt(d,t.mask),i=document.createElement("span");i.style.cssText="display:flex;align-items:center;gap:3px;overflow:hidden;width:100%;box-sizing:border-box;";const o=document.createElement("span");o.style.cssText="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:monospace;letter-spacing:0.4px;color:var(--og-mask-text,#888);",o.textContent=s;const n=document.createElement("button");return n.title="클릭하면 원문 표시",n.setAttribute("aria-label","마스킹 해제"),n.innerHTML='<svg width="13" height="13" viewBox="0 0 16 16" fill="currentColor"><path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8z"/><path d="M8 5.5A2.5 2.5 0 1 0 8 10.5 2.5 2.5 0 0 0 8 5.5zm0 4A1.5 1.5 0 1 1 8 6.5a1.5 1.5 0 0 1 0 3z" fill="#fff"/></svg>',n.style.cssText="flex-shrink:0;background:none;border:none;cursor:pointer;color:#c0c0c0;padding:1px 2px;line-height:0;border-radius:3px;display:flex;align-items:center;",n.addEventListener("mouseover",()=>{n.style.color="var(--og-primary,#1976d2)",n.style.background="rgba(25,118,210,0.08)"}),n.addEventListener("mouseout",()=>{n.style.color="#c0c0c0",n.style.background="none"}),n.addEventListener("click",r=>{r.stopPropagation(),o.textContent=d,o.style.fontFamily="",o.style.letterSpacing="",o.style.color="",n.remove(),(t._maskRevealedRows??(t._maskRevealedRows=new Set)).add(e)}),i.appendChild(o),i.appendChild(n),i}class ut{render(t){var l;const e=document.createElement("span");e.className="og-cell-text";const s=qt(t);if(s!==null)return e.textContent=s,e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",e;const{value:i,column:o,rowIndex:n}=t;let r;if(o.valueMap&&i!=null&&o.valueMap[i]?r=o.valueMap[i]:r=i==null?"":String(i),o.mask){const a=o._maskRevealed===!0,c=((l=o._maskRevealedRows)==null?void 0:l.has(n))===!0;if(!a&&!c)return xe(r,o,n)}return e.textContent=r,e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",e}}class Ce{constructor(t=[],e){this._opts=t.map(s=>typeof s=="string"?{label:s,value:s}:{label:s.label??s.text??String(s.value??""),value:s.value}),this._fn=e??null}render(t){const e=document.createElement("span");e.className="og-cell-text",e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;";const s=t.value;if(s==null||s==="")return e;const i=String(s),n=(this._fn?this._fn(t.row,t.rowIndex).map(r=>typeof r=="string"?{label:r,value:r}:{label:r.label??r.text??String(r.value??""),value:r.value}):this._opts).find(r=>String(r.value)===i);return e.textContent=n?n.label:i,e}}class gt{render(t){const e=document.createElement("span");e.className="og-cell-number";const s=qt(t);return s!==null?(e.textContent=s,e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;width:100%;text-align:right;",e):(e.textContent=ve(t.value,t.column.format??"#,##0",t.column.precision,t.column.currency,t.column.field,t.row),e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;width:100%;text-align:right;",e)}}class pt{render(t){const e=document.createElement("span");return e.className="og-cell-date",e.textContent=Xt(t.value,t.column.format,t.column.field,t.row),e.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",e}}class _t{render(t){const e=document.createElement("span");e.className="og-cell-checkbox",e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=document.createElement("input");return s.type="checkbox",s.checked=!!t.value,s.disabled=!0,s.style.cssText+="cursor:pointer;pointer-events:none;",e.appendChild(s),e}}class Dt{constructor(t){this.def=t}render(t){var o,n,r;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=document.createElement("button");s.className=`og-cell-btn${(o=this.def)!=null&&o.buttonClass?" "+this.def.buttonClass:""}`;const i=(n=this.def)==null?void 0:n.label;return typeof i=="function"?s.textContent=i(t.value,t.row):s.textContent=i??String(t.value??"btn"),s.style.cssText=`
|
|
18
|
-
padding:2px 10px;border:1px solid var(--og-primary,#1976d2);
|
|
19
|
-
border-radius:4px;background:var(--og-row-bg,#fff);color:var(--og-primary,#1976d2);
|
|
20
|
-
cursor:pointer;font-size:12px;white-space:nowrap;transition:background 0.12s;
|
|
21
|
-
${((r=this.def)==null?void 0:r.style)??""}
|
|
22
|
-
`,s.addEventListener("mouseover",()=>s.style.background="var(--og-primary-light,#e3f2fd)"),s.addEventListener("mouseout",()=>s.style.background="var(--og-row-bg,#fff)"),e.appendChild(s),e}}class $t{constructor(t,e){this.colorMap=t,this.labelMap=e}render(t){var r,l,a;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;height:100%;";const s=document.createElement("span"),i=t.value==null?"":String(t.value),o=((r=this.labelMap)==null?void 0:r[i])??((l=t.column.valueMap)==null?void 0:l[i])??i;s.textContent=o;const n=((a=this.colorMap)==null?void 0:a[i])??"#666";return s.style.cssText=`
|
|
23
|
-
display:inline-block;padding:2px 8px;border-radius:12px;font-size:11px;
|
|
24
|
-
background:${n}22;color:${n};border:1px solid ${n}66;
|
|
25
|
-
white-space:nowrap;
|
|
26
|
-
`,e.appendChild(s),e}}class At{constructor(t,e){this.hrefFn=t,this.target=e}render(t){const e=document.createElement("a");return e.className="og-cell-link",e.textContent=t.value==null?"":String(t.value),e.href=this.hrefFn?this.hrefFn(t.value,t.row):"#",this.target&&(e.target=this.target),e.style.cssText="color:var(--og-primary,#1976d2);text-decoration:underline;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;",this.hrefFn||e.addEventListener("click",s=>s.preventDefault()),e}}class Me{constructor(t){this.templateFn=t}render(t){const e=document.createElement("div");return e.className="og-cell-template",e.style.cssText="display:flex;align-items:center;height:100%;overflow:hidden;",e.innerHTML=this.templateFn(t.value,t.row,t.rowIndex),e}}class ke{constructor(t){this.def=t}render(t){var a,c,u,h,g;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=document.createElement("img"),i=(a=this.def)!=null&&a.srcFn?this.def.srcFn(t.value,t.row):String(t.value??"");s.src=i;const o=((c=this.def)==null?void 0:c.width)??28,n=((u=this.def)==null?void 0:u.height)??28,r=((h=this.def)==null?void 0:h.radius)??4;s.style.cssText=`width:${o}px;height:${n}px;object-fit:cover;border-radius:${r}px;display:block;`;const l=(g=this.def)==null?void 0:g.alt;return s.alt=typeof l=="function"?l(t.value,t.row):l??"",s.onerror=()=>{s.style.display="none"},e.appendChild(s),e}}class Re{constructor(t){this.def=t}render(t){var a,c,u,h;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;gap:5px;width:100%;padding:0 4px;box-sizing:border-box;";const s=((a=this.def)==null?void 0:a.max)??100,i=Number(t.value)||0,o=Math.min(100,Math.max(0,i/s*100)),n=(c=this.def)!=null&&c.colorFn?this.def.colorFn(i):((u=this.def)==null?void 0:u.color)??"var(--og-primary,#1976d2)",r=document.createElement("div");r.className="og-progress-track",r.style.cssText="flex:1;height:10px;background:#e0e0e0;border-radius:5px;overflow:hidden;";const l=document.createElement("div");if(l.className="og-progress-fill",l.style.cssText=`width:${o}%;height:100%;background:${n};border-radius:5px;`,r.appendChild(l),e.appendChild(r),((h=this.def)==null?void 0:h.showLabel)!==!1){const g=document.createElement("span");g.style.cssText="font-size:11px;color:#666;white-space:nowrap;min-width:28px;text-align:right;",g.textContent=`${Math.round(o)}%`,e.appendChild(g)}return e}}class Ee{constructor(t){this.def=t}render(t){var c,u,h,g;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=Array.isArray(t.value)?t.value.map(Number):[];if(!s.length)return e.textContent="-",e;const i=((c=this.def)==null?void 0:c.width)??80,o=((u=this.def)==null?void 0:u.height)??22,n=((h=this.def)==null?void 0:h.color)??"#1976d2",r=((g=this.def)==null?void 0:g.chartType)??"bar",l=document.createElement("canvas");l.width=i,l.height=o,l.style.cssText="display:block;";const a=l.getContext("2d");if(a){const k=Math.max(...s,1),m=Math.min(...s,0),w=k-m||1,x=s.length;if(r==="bar"){const _=i/x;s.forEach((b,L)=>{const v=(b-m)/w*(o-2);a.fillStyle=n,a.fillRect(L*_+1,o-v-1,_-2,v)})}else{const _=s.map((b,L)=>({x:L/(x-1||1)*i,y:o-(b-m)/w*(o-4)-2}));r==="area"&&(a.fillStyle=n+"33",a.beginPath(),a.moveTo(_[0].x,o),_.forEach(b=>a.lineTo(b.x,b.y)),a.lineTo(_[_.length-1].x,o),a.closePath(),a.fill()),a.strokeStyle=n,a.lineWidth=1.5,a.beginPath(),_.forEach((b,L)=>L===0?a.moveTo(b.x,b.y):a.lineTo(b.x,b.y)),a.stroke()}}return e.appendChild(l),e}}class Ht{render(t){const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;";const s=!!t.value,i=document.createElement("span");i.className="og-switch"+(s?" og-switch--on":""),i.style.cssText=`display:inline-block;width:34px;height:18px;border-radius:9px;
|
|
27
|
-
background:${s?"var(--og-primary,#1976d2)":"#bdbdbd"};
|
|
28
|
-
position:relative;transition:background 0.2s;cursor:pointer;flex-shrink:0;pointer-events:none;`;const o=document.createElement("span");return o.style.cssText=`position:absolute;top:2px;left:${s?"16px":"2px"};
|
|
29
|
-
width:14px;height:14px;border-radius:50%;background:#fff;
|
|
30
|
-
transition:left 0.2s;box-shadow:0 1px 3px rgba(0,0,0,0.3);`,i.appendChild(o),e.appendChild(i),e}}class Se{constructor(t){this.def=t}render(t){var n,r;const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;gap:1px;height:100%;";const s=((n=this.def)==null?void 0:n.max)??5,i=Math.round(Number(t.value)||0),o=((r=this.def)==null?void 0:r.color)??"#ffa000";for(let l=1;l<=s;l++){const a=document.createElement("span");a.textContent="★",a.style.cssText=`font-size:14px;color:${l<=i?o:"#e0e0e0"};line-height:1;`,e.appendChild(a)}return e}}class ft{render(t){const e=document.createElement("span");e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;pointer-events:none;";const s=document.createElement("input");return s.type="radio",s.checked=!!t.value,s.setAttribute("aria-checked",t.value?"true":"false"),s.setAttribute("aria-label",t.column.header??"선택"),t.column.group&&(s.name=`og-radio-${t.rowIndex}-${t.column.group}`),s.style.cssText="width:14px;height:14px;cursor:pointer;accent-color:var(--og-primary,#1976d2);",e.appendChild(s),e}}class mt{render(t){const e=document.createElement("span");if(e.style.cssText="display:flex;align-items:center;justify-content:center;height:100%;overflow:hidden;",!t.value)return e;const s=document.createElement("img");return s.src=String(t.value),s.alt=t.column.alt??t.column.field,s.style.cssText="max-width:100%;max-height:100%;object-fit:contain;display:block;",s.setAttribute("role","img"),e.appendChild(s),e}}function Le(d){const t=document.createElement("div");return t.innerHTML=d,t.querySelectorAll("script,iframe,object,embed").forEach(e=>e.remove()),t.querySelectorAll("*").forEach(e=>{for(const s of[...e.attributes])s.name.startsWith("on")&&e.removeAttribute(s.name);if(e.tagName==="A"){const s=e.getAttribute("href")??"";/^javascript:/i.test(s)&&e.removeAttribute("href")}}),t.innerHTML}class yt{render(t){const e=document.createElement("span");e.style.cssText="display:block;overflow:hidden;width:100%;";const s=t.column.sanitize!==!1,i=String(t.value??"");return e.innerHTML=s?Le(i):i,e}}const Fe=["212222","222122","222221","121223","121322","131222","122213","122312","132212","221213","221312","231212","112232","122132","122231","113222","123122","123221","223211","221132","221231","213212","223112","312131","311222","321122","321221","312212","322112","322211","212123","212321","232121","111323","131123","131321","112313","132113","132311","211313","231113","231311","112133","112331","132131","113123","113321","133121","313121","211331","231131","213113","213311","213131","311123","311321","331121","312113","312311","332111","314111","221411","431111","111224","111422","121124","121421","141122","141221","112214","112412","122114","122411","142112","142211","241211","221114","413111","241112","134111","111242","121142","121241","114212","124112","124211","411212","421112","421211","212141","214121","412121","111143","111341","131141","114113","114311","411113","411311","113141","114131","311141","411131","211412","211214","211232"],Te="2331112";function zt(d){let t="",e=!0;for(const s of d)t+=(e?"1":"0").repeat(+s),e=!e;return t}function De(d){const t=[104];for(const s of d){const i=s.charCodeAt(0)-32;i>=0&&i<=94&&t.push(i)}let e=104;for(let s=1;s<t.length;s++)e+=t[s]*s;return t.push(e%103),t.map(s=>zt(Fe[s])).join("")+zt(Te)+"11"}class wt{render(t){const e=String(t.value??""),s=t.column.barcodeHeight??28,i=document.createElement("div");i.style.cssText="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;overflow:hidden;gap:1px;",i.setAttribute("role","img"),i.setAttribute("aria-label",`바코드: ${e}`),i.innerHTML=$e(e,s);const o=document.createElement("span");return o.textContent=e,o.style.cssText="font-size:9px;font-family:monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;",i.appendChild(o),i}}function $e(d,t){if(!d)return"";const e=De(d),s=1.4,i=6,o=e.length*s+i*2,n=[];let r=0,l=i;for(;r<e.length;)if(e[r]==="1"){let a=0;for(;r+a<e.length&&e[r+a]==="1";)a++;n.push(`<rect x="${l.toFixed(2)}" y="0" width="${(a*s).toFixed(2)}" height="${t}"/>`),l+=a*s,r+=a}else l+=s,r++;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${o.toFixed(2)} ${t}" width="${o.toFixed(2)}" height="${t}" style="display:block" aria-hidden="true"><g fill="currentColor">${n.join("")}</g></svg>`}function Ae(d){const t=d.renderer;if(!t)switch(d.type){case"number":return new gt;case"date":return new pt;case"boolean":return new _t;case"radio":return new ft;case"img":return new mt;case"html":return new yt;case"barcode":return new wt;case"select":return new Ce(d.options??[],d.optionsFn);default:return new ut}if(typeof t=="string")switch(t){case"number":return new gt;case"date":return new pt;case"checkbox":return new _t;case"button":return new Dt;case"link":return new At;case"badge":return new $t;case"switch":return new Ht;case"radio":return new ft;case"img":return new mt;case"html":return new yt;case"barcode":return new wt;default:return new ut}switch(t.type){case"button":return new Dt(t);case"checkbox":return new _t;case"link":return new At(t.hrefFn,t.target);case"template":return new Me(t.templateFn);case"badge":return new $t(t.colorMap,t.labelMap??t.valueMap);case"image":return new ke(t);case"progress":return new Re(t);case"sparkline":return new Ee(t);case"switch":return new Ht;case"rating":return new Se(t);case"number":return new gt;case"date":return new pt;case"radio":return new ft;case"img":return new mt;case"html":return new yt;case"barcode":return new wt;default:return new ut}}class He{constructor(t,e,s){this._cellMap=new Map,this._root=t,this._opts=e,this._cbs=s,this._header=D("div","og-header"),this._header.style.cssText="flex-shrink:0;overflow-x:auto;overflow-y:hidden;border:0;border-bottom:1px solid var(--og-border-color,#e0e0e0);scrollbar-width:none;",this._bodyWrap=D("div","og-body-wrapper"),this._bodyWrap.style.cssText="flex:1;overflow:auto;position:relative;",this._bodyWrap.style.setProperty("--scrollbar-size","8px"),this._body=D("div","og-body"),this._body.style.cssText="position:relative;",this._bodyWrap.appendChild(this._body),t.appendChild(this._header),t.appendChild(this._bodyWrap),this._bodyWrap.addEventListener("scroll",()=>{this._header.scrollLeft=this._bodyWrap.scrollLeft},{passive:!0})}get bodyWrapper(){return this._bodyWrap}updateSize(t,e){this._bodyWrap.style.height=`${t-e}px`}getHeaderHeight(){return this._header.offsetHeight}renderHeader(t,e,s,i,o){var g,k;this._header.innerHTML="";const n=o._frozenCount??0;let r=0;o.stateColumn&&(r+=24),o.draggable&&(r+=18),o.rowNumber&&(r+=44),o.checkColumn&&(r+=36);const l=r+e.reduce((m,w,x)=>m+(s[x]??o.defaultColumnWidth),0);this._header.style.background="var(--og-header-bg,#f5f5f5)";const a=D("table","og-header-table");a.setAttribute("role","presentation"),a.style.cssText=`table-layout:fixed;border-collapse:collapse;border-spacing:0;margin:0;width:${l}px;background:var(--og-header-bg,#f5f5f5);`;const c=t.length;let u=0;const h=(m,w,x,_="")=>{const b=D("th",`og-header-cell og-extra-col ${_}`);b.setAttribute("rowspan",String(c)),b.textContent=x,Bt(b,{width:`${w}px`,minWidth:`${w}px`,textAlign:"center",borderRight:"1px solid var(--og-border-color,#e0e0e0)",borderBottom:"1px solid var(--og-border-color,#e0e0e0)",borderTop:"0",borderLeft:"0",lineHeight:"normal",verticalAlign:"middle",padding:"0",fontSize:"11px",color:"#999",userSelect:"none",boxSizing:"border-box",background:"var(--og-header-bg,#f5f5f5)"}),n>0&&(b.style.position="sticky",b.style.left=`${u}px`,b.style.zIndex="4"),u+=w,m.appendChild(b)};for(let m=0;m<t.length;m++){const w=D("tr","og-header-row");if(w.style.height=`${o.headerHeight}px`,m===0&&(o.stateColumn&&h(w,24,""),o.draggable&&h(w,18,""),o.rowNumber&&h(w,44,"No"),o.checkColumn)){const x=D("th","og-header-cell og-extra-col");x.setAttribute("rowspan",String(c)),x.style.cssText="width:36px;min-width:36px;text-align:center;border-right:1px solid var(--og-border-color,#e0e0e0);border-bottom:1px solid var(--og-border-color,#e0e0e0);border-top:0;border-left:0;line-height:normal;vertical-align:middle;background:var(--og-header-bg,#f5f5f5);box-sizing:border-box;",n>0&&(x.style.position="sticky",x.style.left=`${u}px`,x.style.zIndex="4"),u+=36;const _=document.createElement("input");_.type="checkbox",_.setAttribute("aria-label","전체 행 선택"),_.style.cssText="width:16px;height:16px;",_.addEventListener("change",()=>this._cbs.onAllCheck(_.checked)),x.appendChild(_),w.appendChild(x)}for(const x of t[m]??[]){const _=D("th","og-header-cell"),b=x.column;x.colSpan>1&&(_.colSpan=x.colSpan),x.rowSpan>1&&(_.rowSpan=x.rowSpan);const L=x.colSpan===1?e.findIndex(p=>p.field===b.field):-1;if(x.colSpan===1){const p=L>=0?s[L]??o.defaultColumnWidth:b.width??o.defaultColumnWidth;_.style.width=`${p}px`,_.style.minWidth=`${p}px`}const v=i.find(p=>p.field===b.field),R=b.sortable!==!1&&o.sortable&&x.colSpan===1;if(_.setAttribute("role","columnheader"),_.setAttribute("scope","col"),R&&(_.setAttribute("aria-sort",v?v.dir==="asc"?"ascending":"descending":"none"),_.tabIndex=L===0?0:-1,_.addEventListener("keydown",p=>{if(p.key==="Enter"||p.key===" ")p.preventDefault(),this._cbs.onHeaderClick(b.field,p.shiftKey);else if(p.key==="ArrowRight"){p.preventDefault();const C=_.nextElementSibling;(C==null?void 0:C.tagName)==="TH"&&C.focus()}else if(p.key==="ArrowLeft"){p.preventDefault();const C=_.previousElementSibling;(C==null?void 0:C.tagName)==="TH"&&C.focus()}})),L>=0&&L<n){let p=0;o.stateColumn&&(p+=24),o.draggable&&(p+=18),o.rowNumber&&(p+=44),o.checkColumn&&(p+=36);for(let C=0;C<L;C++)p+=s[C]??o.defaultColumnWidth;_.classList.add("og-frozen"),L===n-1&&_.classList.add("og-frozen-last"),_.style.left=`${p}px`}const F=b.header??b.field,I=typeof F=="string"&&F.indexOf(`
|
|
31
|
-
`)>=0,T=b.headerWrap===!0||I;Bt(_,{padding:"4px 8px",boxSizing:"border-box",background:"var(--og-header-bg)",color:"var(--og-header-color)",lineHeight:T?"1.3":"normal",verticalAlign:"middle",fontSize:"var(--og-font-size)",textAlign:b.headerAlign??"center",borderTop:"0",borderLeft:"0",borderRight:"1px solid var(--og-border-color,#e0e0e0)",borderBottom:"1px solid var(--og-border-color,#e0e0e0)",userSelect:"none",cursor:R?"pointer":"default",whiteSpace:T?"normal":"nowrap",overflow:T?"visible":"hidden",textOverflow:T?"clip":"ellipsis",wordBreak:T?"break-word":"normal",position:"relative"}),_.title=(typeof b.tooltip=="string"?b.tooltip:F)??"";const A=D("span");if(T?(A.style.cssText="overflow:visible;text-overflow:clip;white-space:normal;word-break:break-word;",String(F).split(`
|
|
32
|
-
`).forEach((C,O)=>{O>0&&A.appendChild(document.createElement("br")),A.appendChild(document.createTextNode(C))})):(A.textContent=F,A.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"),_.appendChild(A),v){_.classList.add("og-sorted");const p=D("span","og-sort-icon");p.textContent=v.dir==="asc"?" ↑":" ↓",_.appendChild(p)}if(b.filterable!==!1&&o.filterable&&x.colSpan===1){const p=D("span","og-filter-icon"),C=((k=(g=o._activeFilters)==null?void 0:g[b.field])==null?void 0:k.length)>0;p.textContent=C?"⊿":"▿",p.title="필터",p.style.cssText="margin-left:3px;cursor:pointer;font-size:10px;opacity:0.6;",C&&p.classList.add("og-filter-icon--active"),p.addEventListener("click",O=>{O.stopPropagation(),this._cbs.onFilterIconClick(b.field,p)}),_.appendChild(p)}if(b.resizable!==!1){const p=D("div","og-resize-handle");p.style.cssText="position:absolute;right:0;top:0;bottom:0;width:4px;cursor:col-resize;z-index:1;",_.appendChild(p);const C=L;ze(p,_,O=>{C>=0&&this._cbs.onColResize(C,O)})}o.columnReorder&&L>=0&&x.colSpan===1&&(_.draggable=!0,_.addEventListener("dragstart",p=>{var C;this._cbs.onColDragStart(L),_.classList.add("og-col-dragging"),(C=p.dataTransfer)==null||C.setData("text/plain",String(L))}),_.addEventListener("dragend",()=>{_.classList.remove("og-col-dragging"),this._header.querySelectorAll(".og-col-drop-over").forEach(p=>p.classList.remove("og-col-drop-over"))}),_.addEventListener("dragover",p=>{p.preventDefault();const C=this._cbs.getColDragIdx();C!==null&&C!==L&&(this._header.querySelectorAll(".og-col-drop-over").forEach(O=>O.classList.remove("og-col-drop-over")),_.classList.add("og-col-drop-over"))}),_.addEventListener("dragleave",()=>{_.classList.remove("og-col-drop-over")}),_.addEventListener("drop",p=>{p.preventDefault(),_.classList.remove("og-col-drop-over"),this._cbs.onColDrop(L)})),R&&_.addEventListener("click",p=>{p.target.classList.contains("og-resize-handle")||this._cbs.onHeaderClick(b.field,p.shiftKey)}),w.appendChild(_)}a.appendChild(w)}this._header.appendChild(a)}renderBody(t,e,s,i,o,n,r,l,a,c,u=null,h,g,k={},m){var b,L;Object.keys(k).length&&(n={...n,...k}),this._body.innerHTML="",this._cellMap.clear();const w=n.autoHeight===!0;this._body.classList.toggle("og-autoheight",w),this._body.style.height=w?"":`${l}px`;const x=n._frozenCount??0;{let v=0;n.stateColumn&&(v+=24),n.draggable&&(v+=18),n.rowNumber&&(v+=44),n.checkColumn&&(v+=36);const R=v+i.reduce((F,I,T)=>F+(o[T]??n.defaultColumnWidth),0);this._body.style.minWidth=`${R}px`}if(e<t)return;const _=document.createDocumentFragment();for(let v=t;v<=e;v++){const R=u?u[v]:null,F=R&&R._isGroup===!0,I=R&&R._isTree===!0;if(F){const f=R,S=`__${f._groupField}:${f._groupValue}`,H=D("div","og-group-row"),tt=r+(v-t)*n.rowHeight;H.style.cssText=[w?"":`top:${tt}px;height:${n.rowHeight}px;`,"display:flex;align-items:stretch;cursor:pointer;",`padding-left:${4+f._depth*12}px;`,"background:var(--og-header-bg,#f5f5f5);","border:0;border-bottom:1px solid var(--og-border-color,#e0e0e0);"].join(""),H.setAttribute("role","row"),H.setAttribute("aria-expanded",f._expanded?"true":"false"),H.setAttribute("aria-rowindex",String(v+1)),H.setAttribute("aria-level",String(f._depth+1));let j=0;if(n.stateColumn&&(j+=24),n.draggable&&(j+=18),n.rowNumber&&(j+=44),n.checkColumn&&(j+=36),j>0){const y=D("div","og-group-state-cell");y.style.cssText=[`width:${j}px;min-width:${j}px;flex-shrink:0;`,"display:flex;align-items:center;justify-content:center;","font-size:10px;font-weight:700;gap:2px;","border-right:1px solid var(--og-border-color,#e0e0e0);"].join("");const B=f._states??{added:0,edited:0,removed:0};if(B.added>0){const z=D("span");z.textContent=`+${B.added}`,z.style.cssText="color:var(--og-row-added-bg,#2e7d32);background:#e8f5e9;padding:1px 3px;border-radius:3px;",y.appendChild(z)}if(B.edited>0){const z=D("span");z.textContent=`M${B.edited}`,z.style.cssText="color:#e65100;background:#fff8e1;padding:1px 3px;border-radius:3px;",y.appendChild(z)}if(B.removed>0){const z=D("span");z.textContent=`D${B.removed}`,z.style.cssText="color:var(--og-row-removed-bg,#c62828);background:#ffebee;padding:1px 3px;border-radius:3px;",y.appendChild(z)}H.appendChild(y)}let P=!1;for(let y=0;y<i.length;y++){const B=i[y],z=o[y]??n.defaultColumnWidth,at=f._summaryFmt!==void 0&&B.field in(f._summaryFmt??{}),W=D("div","og-group-cell");if(W.style.cssText=[`width:${z}px;min-width:${z}px;flex-shrink:0;`,"padding:2px 8px;box-sizing:border-box;overflow:hidden;","border-right:1px solid var(--og-border-color,#e0e0e0);","display:flex;align-items:center;","white-space:nowrap;text-overflow:ellipsis;"].join(""),at){const U=f._summaryFmt[B.field];W.textContent=U!==""?U:"-",W.style.justifyContent="flex-end",W.style.color="var(--og-primary,#1976d2)",W.style.fontWeight="600"}else if(!P){P=!0;const U=D("span","og-group-arrow");U.textContent=f._expanded?"▾ ":"▸ ",U.style.cssText="color:var(--og-primary,#1976d2);margin-right:4px;flex-shrink:0;",W.appendChild(U);const G=D("span","og-group-label");G.textContent=`${f._groupLabel} (${f._childCount}건)`,G.style.cssText="overflow:hidden;text-overflow:ellipsis;font-weight:600;",W.appendChild(G),W.style.gap="0"}H.appendChild(W)}H.addEventListener("click",()=>h==null?void 0:h(S)),_.appendChild(H);continue}const T=I?R:null,A=T?T.data:u?R:s.getRowByIndex(v);if(!A)continue;const $=I||F?"none":s.getRowState(v),p=D("div","og-row");if(p.setAttribute("role","row"),p.setAttribute("aria-rowindex",String(v+1)),!w){const f=r+(v-t)*n.rowHeight;p.style.top=`${f}px`,p.style.height=`${n.rowHeight}px`}let C=v%2===0?"var(--og-row-bg,#fff)":"var(--og-row-alt-bg,#fafafa)";p.style.background=C,$==="added"&&p.classList.add("og-state-added"),$==="edited"&&p.classList.add("og-state-edited"),$==="removed"&&p.classList.add("og-state-removed"),a.has(v)&&p.classList.add("og-selected"),p.setAttribute("aria-selected",a.has(v)?"true":"false"),$==="added"&&(C="var(--og-row-added-bg,#e8f5e9)"),$==="edited"&&(C="var(--og-row-edited-bg,#fff8e1)"),$==="removed"&&(C="var(--og-row-removed-bg,#ffebee)"),a.has(v)&&(C="var(--og-row-selected-bg,#bbdefb)");const O=v;p.addEventListener("click",f=>{this._cbs.onCellClick(O,-1,f)});const lt=new Map;let X=0;if(n.stateColumn){const f=D("div","og-cell og-col-state"),S={added:"✚",edited:"✎",removed:"✖",none:""},H={added:"#2e7d32",edited:"#bf360c",removed:"#c62828",none:""};f.textContent=S[$]??"",f.style.color=H[$]??"",f.title=$,x>0&&(f.style.position="sticky",f.style.left=`${X}px`,f.style.zIndex="2",f.style.background=C),X+=24,p.appendChild(f)}const st=this._cbs.getDndManager();if(n.draggable&&st){const f=st.attachHandle(p,v,n._totalRows??e+1);x>0&&(f.style.position="sticky",f.style.left=`${X}px`,f.style.zIndex="2",f.style.background=C),X+=18,p.appendChild(f)}if(n.rowNumber){const f=D("div","og-cell og-col-rownum");f.textContent=String(v+1),x>0&&(f.style.position="sticky",f.style.left=`${X}px`,f.style.zIndex="2",f.style.background=C),X+=44,p.appendChild(f)}if(n.checkColumn){const f=D("div","og-cell og-col-check"),S=document.createElement("input");S.type="checkbox",S.checked=c.has(v),S.setAttribute("aria-label",`${v+1}행 선택`),S.addEventListener("click",H=>H.stopPropagation()),S.addEventListener("change",H=>{H.stopPropagation(),this._cbs.onRowCheck(v,S.checked)}),f.appendChild(S),x>0&&(f.style.position="sticky",f.style.left=`${X}px`,f.style.zIndex="2",f.style.background=C),X+=36,p.appendChild(f)}for(let f=0;f<i.length;f++){const S=i[f],H=o[f]??n.defaultColumnWidth,tt=n.editable&&S.editable!==!1,j=f===0,P=m&&!m.isEmpty?m.getInfo(v,f):null;if(P!=null&&P.hidden){const E=D("div","og-cell og-cell--merge-ph");E.style.cssText=`width:${H}px;min-width:${H}px;flex-shrink:0;visibility:hidden;box-sizing:border-box;`,p.appendChild(E);continue}const y=D("div","og-cell");y.setAttribute("role","gridcell"),y.setAttribute("aria-colindex",String(f+1));const B=(P==null?void 0:P.rowSpan)??1,z=(P==null?void 0:P.colSpan)??1,at=B>1?B*n.rowHeight:n.rowHeight;let W=H;if(z>1)for(let E=1;E<z;E++)W+=o[f+E]??n.defaultColumnWidth;const U=f<x;let G=0;if(U){n.stateColumn&&(G+=24),n.draggable&&(G+=18),n.rowNumber&&(G+=44),n.checkColumn&&(G+=36);for(let E=0;E<f;E++)G+=o[E]??n.defaultColumnWidth;y.classList.add("og-frozen-cell"),f===x-1&&y.classList.add("og-frozen-last")}y.style.width=`${W}px`,y.style.minWidth=`${W}px`,y.style.maxWidth=`${W}px`,B>1&&(y.style.height=`${at}px`),U&&(y.style.background=C),T&&j&&(y.style.padding="0"),y.style.overflow="hidden",B>1?(y.style.height=`${at}px`,y.style.position="absolute",y.style.zIndex="3",y.style.background=C&&C!=="inherit"?C:"var(--og-row-bg, #fff)",y.style.borderTop="0",y.style.borderLeft="0",y.style.borderBottom="1px solid var(--og-border-color, #e0e0e0)"):U&&(y.style.position="sticky",y.style.left=`${G}px`,y.style.zIndex="1"),S.type==="number"||S.align==="right"?y.classList.add("og-cell--right"):S.align==="center"&&y.classList.add("og-cell--center"),tt&&y.classList.add("og-cell--editable"),S.wrap&&y.classList.add("og-cell--wrap"),tt||y.setAttribute("aria-readonly","true"),z>1&&y.setAttribute("aria-colspan",String(z)),B>1&&y.setAttribute("aria-rowspan",String(B)),((b=n._focusCell)==null?void 0:b.ri)===v&&((L=n._focusCell)==null?void 0:L.ci)===f&&(y.classList.add("og-cell-focused"),y.tabIndex=-1);const et=A?A[S.field]:null;y.setAttribute("aria-label",`${S.header}: ${et==null?"":String(et)}`),S.tooltip!=null?y.title=typeof S.tooltip=="function"?String(S.tooltip(et,A)??""):String(S.tooltip):n.tooltips&&et!=null&&et!==""&&(y.title=String(et));let Lt=y;if(T&&j){const E=D("div","og-tree-cell"),q=T._ancestorHasMore??[];for(let K=0;K<T._depth;K++){const Y=D("span","og-tree-guide");q[K]&&Y.classList.add("og-tree-guide--line"),E.appendChild(Y)}if(T._depth>0){const K=D("span","og-tree-connector");K.classList.add(T._isLastChild?"og-tree-connector--last":"og-tree-connector--mid"),E.appendChild(K)}const dt=D("span","og-tree-toggle-wrap");if(!T._hasChildren){const K=D("span","og-tree-leaf-dot");dt.appendChild(K)}E.appendChild(dt);const N=document.createElement("i");if(T._hasChildren){const K=It(S.treeNodeIcon,A,!0,T._expanded);N.className=T._expanded?`${K} og-tree-node-icon og-tree-node-icon--branch og-tree-node-icon--open og-tree-node-icon--toggle`:`${K} og-tree-node-icon og-tree-node-icon--branch og-tree-node-icon--toggle`,N.setAttribute("role","button"),N.setAttribute("tabindex","0"),N.setAttribute("aria-expanded",T._expanded?"true":"false"),N.setAttribute("aria-label",T._expanded?"접기":"펼치기"),N.addEventListener("click",Y=>{Y.stopPropagation(),g==null||g(T._treeId)}),N.addEventListener("keydown",Y=>{(Y.key==="Enter"||Y.key===" ")&&(Y.preventDefault(),Y.stopPropagation(),g==null||g(T._treeId))})}else{const K=It(S.treeNodeIcon,A,!1,!1);N.setAttribute("aria-hidden","true"),N.className=`${K} og-tree-node-icon og-tree-node-icon--leaf`}E.appendChild(N),y.appendChild(E),Lt=E}if(S.cellStyle){const E=A[S.field],q=typeof S.cellStyle=="function"?S.cellStyle(E,A,v):S.cellStyle;Object.assign(y.style,q)}const ie=Ae(S).render({value:A[S.field],row:A,rowIndex:v,column:S,colIndex:f,isSelected:a.has(v),rowState:$});Lt.appendChild(ie);const J=v,Q=f;if(y.addEventListener("click",E=>{E.stopPropagation(),this._cbs.onCellClick(J,Q,E)}),y.addEventListener("dblclick",E=>{E.stopPropagation(),this._cbs.onCellDblClick(J,Q,E)}),y.addEventListener("mouseover",E=>{E.stopPropagation(),this._cbs.onCellMouseOver(J,Q,E)}),y.addEventListener("mouseout",E=>{E.stopPropagation(),this._cbs.onCellMouseOut(J,Q,E)}),y.addEventListener("mousedown",E=>{E.stopPropagation(),this._cbs.onCellMouseDown(J,Q,E)}),y.addEventListener("mouseup",E=>{E.stopPropagation(),this._cbs.onCellMouseUp(J,Q,E)}),y.addEventListener("mousemove",E=>{E.stopPropagation(),this._cbs.onCellMouseMove(J,Q,E)}),lt.set(f,y),B>1){const E=document.createElement("div");E.style.cssText=[`width:${H}px;min-width:${H}px;height:${n.rowHeight}px;`,"flex-shrink:0;box-sizing:border-box;","border-right:1px solid var(--og-border-color,#e0e0e0);"].join(""),p.appendChild(E);let q=0;n.stateColumn&&(q+=24),n.draggable&&(q+=18),n.rowNumber&&(q+=44),n.checkColumn&&(q+=36);for(let N=0;N<f;N++)q+=o[N]??n.defaultColumnWidth;const dt=r+(v-t)*n.rowHeight;y.style.left=`${q}px`,y.style.top=`${dt}px`,_.appendChild(y)}else p.appendChild(y)}this._cellMap.set(v,lt),_.appendChild(p)}if(s.rowCount===0){const v=D("div","og-empty-message");v.textContent="데이터가 없습니다.",v.style.cssText="width:100%;",_.appendChild(v)}this._body.appendChild(_)}getCellEl(t,e){var s;return(s=this._cellMap.get(t))==null?void 0:s.get(e)}destroy(){this._root.innerHTML=""}}function It(d,t,e,s){let i;return d?typeof d=="function"?i=d(t,e,s):e?i=s?d.branchOpen??"bi-folder2-open":d.branch??"bi-folder2":i=d.leaf??"bi-file-earmark":i=e?s?"bi-folder2-open":"bi-folder2":"bi-file-earmark",i.startsWith("bi ")?i:`bi ${i}`}function D(d,t){const e=document.createElement(d);return t&&(e.className=t),e}function Bt(d,t){Object.assign(d.style,t)}function Ot(d,t,e="text/plain;charset=utf-8"){const s=new Blob([d],{type:e}),i=URL.createObjectURL(s),o=document.createElement("a");o.href=i,o.download=t,o.click(),URL.revokeObjectURL(i)}function ze(d,t,e){let s=0,i=0;d.addEventListener("mousedown",o=>{o.stopPropagation(),o.preventDefault(),s=o.clientX,i=t.offsetWidth;const n=l=>{const a=Math.max(40,i+l.clientX-s);t.style.width=`${a}px`,t.style.minWidth=`${a}px`},r=l=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",r),e(Math.max(40,i+l.clientX-s))};document.addEventListener("mousemove",n),document.addEventListener("mouseup",r)})}class Ie{constructor(t){this._selectedRows=new Set,this._checkedRows=new Set,this._data=t}get selectedRows(){return this._selectedRows}get checkedRows(){return this._checkedRows}selectSingle(t){this._selectedRows.clear(),this._selectedRows.add(t)}selectToggle(t){this._selectedRows.has(t)?this._selectedRows.delete(t):this._selectedRows.add(t)}clearSelection(){this._selectedRows.clear()}check(t,e){e?this._checkedRows.add(t):this._checkedRows.delete(t)}checkAll(t,e){if(t)for(let s=0;s<e;s++)this._checkedRows.add(s);else this._checkedRows.clear()}checkByValue(t,e){for(let s=0;s<this._data.rowCount;s++)e.includes(this._data.getCellValue(s,t))&&this._checkedRows.add(s)}uncheckAll(){this._checkedRows.clear()}checkById(t){}addCheckById(t){}uncheckById(t){}getSelections(){return[...this._selectedRows].map(t=>this._data.getRowByIndex(t)).filter(Boolean)}getChecked(){return[...this._checkedRows].map(t=>({row:this._data.getRowByIndex(t),rowIndex:t}))}getAllChecked(){return this.getChecked().map(t=>t.row)}getActiveRow(){return this._selectedRows.size>0?[...this._selectedRows][0]:-1}activate(t){this._selectedRows.clear(),this._selectedRows.add(t)}deselect(){this._selectedRows.clear()}reset(){this._selectedRows.clear(),this._checkedRows.clear()}}class bt{constructor(){this._onKeyDown=t=>{t.stopPropagation(),t.key==="Enter"?(t.preventDefault(),this._onCommit(this.input.value)):t.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._onCommit(this.input.value)}}mount(t,e,s,i){this._container=t,this._onCommit=s,this._onCancel=i,t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-expanded","true"),this.input=document.createElement("input"),this.input.type="date",this.input.className="og-cell-input",this.input.setAttribute("aria-label",e.column.header??"날짜 선택");const o=e.value;if(o){const n=o instanceof Date?o:new Date(o);isNaN(n.getTime())||(this.input.value=Xt(n,"yyyy-MM-dd"))}this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),t.appendChild(this.input)}getValue(){var t;return(t=this.input)==null?void 0:t.value}focus(){var t;(t=this.input)==null||t.focus()}destroy(){var t,e,s;(t=this._container)==null||t.setAttribute("aria-expanded","false"),(e=this.input)==null||e.removeEventListener("keydown",this._onKeyDown),(s=this.input)==null||s.removeEventListener("blur",this._onBlur)}}function Wt(d){return d.map(t=>typeof t=="string"?{label:t,value:t}:{label:t.label??t.text??String(t.value??""),value:t.value})}class vt{constructor(t=[],e){this._options=Wt(t),this._optionsFn=e??null}mount(t,e,s,i){this._container=t,this._onCommit=s,this._onCancel=i,t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-expanded","true"),this.select=document.createElement("select"),this.select.className="og-cell-select",this.select.setAttribute("aria-label",e.column.header??"선택");const o=this._optionsFn?Wt(this._optionsFn(e.row,e.rowIndex)):this._options;for(const r of o){const l=document.createElement("option");l.value=String(r.value),l.textContent=r.label,this.select.appendChild(l)}const n=e.value==null?"":String(e.value);o.some(r=>String(r.value)===n)&&(this.select.value=n),this.select.addEventListener("change",()=>s(this.select.value)),this.select.addEventListener("blur",()=>s(this.select.value)),this.select.addEventListener("keydown",r=>{r.key==="Escape"&&i()}),t.appendChild(this.select)}getValue(){var t;return(t=this.select)==null?void 0:t.value}focus(){var t;(t=this.select)==null||t.focus()}destroy(){var t;(t=this._container)==null||t.setAttribute("aria-expanded","false")}}class xt{constructor(){this._onKeyDown=t=>{t.stopPropagation(),t.key==="Enter"||t.key==="Tab"?(t.preventDefault(),this._onCommit(this.input.value)):t.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._onCommit(this.input.value)}}mount(t,e,s,i){this._onCommit=s,this._onCancel=i,this.input=document.createElement("input"),this.input.type="text",this.input.value=e.value==null?"":String(e.value),this.input.style.cssText=`
|
|
33
|
-
width:100%;height:100%;border:none;outline:none;padding:0 8px;
|
|
34
|
-
font-size:var(--og-font-size,13px);font-family:var(--og-font-family,sans-serif);
|
|
35
|
-
background:var(--og-row-bg,#fff);box-sizing:border-box;
|
|
36
|
-
`,this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),t.appendChild(this.input)}getValue(){var t;return(t=this.input)==null?void 0:t.value}focus(){var t,e;(t=this.input)==null||t.focus(),(e=this.input)==null||e.select()}destroy(){var t,e;(t=this.input)==null||t.removeEventListener("keydown",this._onKeyDown),(e=this.input)==null||e.removeEventListener("blur",this._onBlur)}}class Ct{constructor(t){this._onKeyDown=e=>{e.stopPropagation(),e.key==="Enter"||e.key==="Tab"?(e.preventDefault(),this._commit()):e.key==="Escape"&&this._onCancel()},this._onBlur=()=>{this._commit()},this.min=t==null?void 0:t.min,this.max=t==null?void 0:t.max,this.step=t==null?void 0:t.step}mount(t,e,s,i){this._onCommit=s,this._onCancel=i,this.input=document.createElement("input"),this.input.type="number",this.input.value=e.value==null?"":String(e.value),this.min!=null&&(this.input.min=String(this.min)),this.max!=null&&(this.input.max=String(this.max)),this.step!=null&&(this.input.step=String(this.step)),this.input.style.cssText=`
|
|
37
|
-
width:100%;height:100%;border:none;outline:none;padding:0 8px;
|
|
38
|
-
font-size:var(--og-font-size,13px);text-align:right;
|
|
39
|
-
background:var(--og-row-bg,#fff);box-sizing:border-box;
|
|
40
|
-
`,this.input.addEventListener("keydown",this._onKeyDown),this.input.addEventListener("blur",this._onBlur),t.appendChild(this.input)}_commit(){const t=this.input.value===""?null:Number(this.input.value);this._onCommit(t)}getValue(){var t,e;return((t=this.input)==null?void 0:t.value)===""?null:Number((e=this.input)==null?void 0:e.value)}focus(){var t,e;(t=this.input)==null||t.focus(),(e=this.input)==null||e.select()}destroy(){var t,e;(t=this.input)==null||t.removeEventListener("keydown",this._onKeyDown),(e=this.input)==null||e.removeEventListener("blur",this._onBlur)}}class Mt{mount(t,e,s,i){this._onCommit=s,t.style.cssText+="display:flex;align-items:center;justify-content:center;",this.chk=document.createElement("input"),this.chk.type="checkbox",this.chk.checked=!!e.value,this.chk.style.cursor="pointer",this.chk.addEventListener("change",()=>s(this.chk.checked)),t.appendChild(this.chk)}getValue(){var t;return(t=this.chk)==null?void 0:t.checked}focus(){var t;(t=this.chk)==null||t.focus()}destroy(){}}function Nt(d){const t=d.editor;if(!t)switch(d.type){case"number":return new Ct;case"date":return new bt;case"boolean":return new Mt;case"select":return new vt(d.options??[],d.optionsFn);default:return new xt}if(typeof t=="string")switch(t){case"number":return new Ct;case"date":return new bt;case"select":return new vt(d.options??[],d.optionsFn);case"checkbox":return new Mt;default:return new xt}switch(t.type){case"number":{const e={};return t.min!=null&&(e.min=t.min),t.max!=null&&(e.max=t.max),t.step!=null&&(e.step=t.step),new Ct(e)}case"date":return new bt;case"select":return new vt(t.options??[],d.optionsFn);case"checkbox":return new Mt;default:return new xt}}function nt(d){const t=typeof d.renderer=="string"?d.renderer:d.renderer&&typeof d.renderer=="object"?d.renderer.type:"";return d.type==="boolean"||d.type==="checkbox"||t==="checkbox"||t==="switch"}class Be{constructor(t){this._activeEditor=null,this._editCell=null,this._focusCell=null,this._dragColIdx=null,this._d=t}get activeEditor(){return this._activeEditor}get editCell(){return this._editCell}get focusCell(){return this._focusCell}get dragColIdx(){return this._dragColIdx}set dragColIdx(t){this._dragColIdx=t}setFocusCell(t,e){this._focusCell={ri:t,ci:e},this._d.scrollToRow(t),this._d.doRender();const s=this._d.getVisibleLeaves()[e],i=this._d.data.getRowByIndex(t);if(s&&i){const o=i[s.field];this._d.announce(`${t+1}행 ${e+1}열, ${s.header}: ${o==null?"빈 값":String(o)}`)}}clearFocusCell(){this._focusCell=null}startEditByKey(t,e){var a,c,u;const s=this._d.getVisibleLeaves()[e];if(!s)return;if(nt(s)){const h=this._d.getOptions();if(s.editable!==!1&&(s.editable!==void 0||h.editable)){const k=this._d.data.getRowByIndex(t);k&&this._d.writeCell(t,s.field,!k[s.field])}return}const i=this._d.data.getRowByIndex(t);if(s.editable===!1||typeof s.editable=="function"&&!s.editable(i,t))return;this.commitEdit();const o=(a=this._d.getRenderer())==null?void 0:a.getCellEl(t,e);if(!o)return;o.innerHTML="";const n=Nt(s);this._activeEditor=n,this._editCell={ri:t,ci:e};const r={type:"editStart",rowIndex:t,columnIndex:e,field:s.field,oldValue:i==null?void 0:i[s.field],newValue:i==null?void 0:i[s.field],row:i,column:s};this._d.emit("editStart",r),(u=(c=this._d.getOptions()).onEditStart)==null||u.call(c,r),o.classList.add("og-editing");const l={value:i==null?void 0:i[s.field],row:i,rowIndex:t,column:s,colIndex:e,isSelected:!0,rowState:"none"};n.mount(o,l,h=>this.commitEditWithValue(t,e,h),()=>this.cancelEdit()),requestAnimationFrame(()=>n.focus())}startEdit(t,e,s){var u,h;const i=this._d.getOptions();if(!i.editable)return;const o=this._d.getVisibleLeaves()[e];if(!o||nt(o))return;const n=this._d.data.getRowByIndex(t);if(o.editable===!1||typeof o.editable=="function"&&!o.editable(n,t)||!o.editable&&!i.editable)return;this.commitEdit();const r=(u=this._d.getRenderer())==null?void 0:u.getCellEl(t,e);if(!r)return;r.innerHTML="";const l=Nt(o);this._activeEditor=l,this._editCell={ri:t,ci:e};const a={type:"editStart",rowIndex:t,columnIndex:e,field:o.field,oldValue:n==null?void 0:n[o.field],newValue:n==null?void 0:n[o.field],row:n,column:o};this._d.emit("editStart",a),(h=i.onEditStart)==null||h.call(i,a),r.classList.add("og-editing");const c={value:n==null?void 0:n[o.field],row:n,rowIndex:t,column:o,colIndex:e,isSelected:!0,rowState:"none"};l.mount(r,c,g=>this.commitEditWithValue(t,e,g),()=>this.cancelEdit()),requestAnimationFrame(()=>l.focus())}commitEdit(){if(!this._activeEditor||!this._editCell)return;const t=this._activeEditor.getValue(),{ri:e,ci:s}=this._editCell;this._finishEdit(e,s,t,!1)}commitEditWithValue(t,e,s){this._finishEdit(t,e,s,!1)}cancelEdit(){if(!this._editCell)return;const{ri:t,ci:e}=this._editCell;this._finishEdit(t,e,void 0,!0)}_finishEdit(t,e,s,i){var r,l,a;if(!this._activeEditor)return;const o=this._d.getVisibleLeaves()[e],n=(r=this._d.getRenderer())==null?void 0:r.getCellEl(t,e);if(n&&(this._activeEditor.destroy(),n.classList.remove("og-editing")),this._activeEditor=null,this._editCell=null,!i&&o){const c=this._d.data.getCellValue(t,o.field);if(s!==c){this._d.data.updateCell(t,o.field,s);const u=this._d.data.getRowByIndex(t),h=this._d.getOptions(),g={type:"editEnd",rowIndex:t,columnIndex:e,field:o.field,oldValue:c,newValue:s,row:u,column:o};this._d.emit("editEnd",g),(l=h.onEditEnd)==null||l.call(h,g),this._d.emit("dataChange",this._d.data.getData()),(a=h.onDataChange)==null||a.call(h,this._d.data.getData())}}this._d.doRender(),requestAnimationFrame(()=>this._d.getContainer().focus({preventScroll:!0}))}}class Oe{constructor(t,e,s,i,o){this._selects=new Map,this._selected={},this._config=e,this._onFilter=s,this._onReset=i,this._el=document.createElement("fieldset"),this._el.className="og-filter-select";const n=document.createElement("legend");n.className="og-filter-select-legend",n.textContent=e.legend??"필터",this._el.appendChild(n);const r=document.createElement("div");r.className="og-filter-select-row";for(const a of e.columns){const c=`og-fsel-${a.field}`,u=document.createElement("div");u.className="og-filter-select-group";const h=document.createElement("label");h.htmlFor=c,h.textContent=a.label,h.className="og-filter-select-label";const g=document.createElement("select");g.id=c,g.className="og-filter-select-sel",g.setAttribute("aria-label",a.label),o&&g.setAttribute("aria-controls",o),a.dependsOn?this._fill(g,[],!1):this._fill(g,this._resolve(a,""),!0),g.addEventListener("change",()=>this._onChange(a.field,g.value)),u.appendChild(h),u.appendChild(g),r.appendChild(u),this._selects.set(a.field,g)}const l=document.createElement("button");l.type="button",l.textContent="초기화",l.className="og-filter-select-reset",l.setAttribute("aria-label","필터 초기화"),l.addEventListener("click",()=>this._reset()),this._el.appendChild(r),this._el.appendChild(l),t.insertBefore(this._el,t.firstChild)}_resolve(t,e){if(t.options)return t.options;let s=t.data??[];t.dependsOn&&t.dependsOnKey&&e&&(s=s.filter(n=>String(n[t.dependsOnKey]??"")===e));const i=t.valueKey??"value",o=t.textKey??i;return s.map(n=>({value:String(n[i]??""),text:String(n[o]??n[i]??"")}))}_fill(t,e,s){t.innerHTML="";const i=document.createElement("option");i.value="",i.textContent="전체",t.appendChild(i);for(const o of e){const n=document.createElement("option");n.value=o.value,n.textContent=o.text,t.appendChild(n)}t.disabled=!s}_onChange(t,e){const s=this._config.columns.find(o=>o.field===t),i=s.filterKey??s.field;e?(this._selected[t]=e,this._onFilter(i,[{operator:"=",value:e}])):(delete this._selected[t],this._onReset(i)),this._cascade(t)}_cascade(t){const e=this._selected[t]??"";for(const s of this._config.columns){if(s.dependsOn!==t)continue;const i=this._selects.get(s.field);if(!i)continue;const o=s.filterKey??s.field;e?(this._fill(i,this._resolve(s,e),!0),i.value="",delete this._selected[s.field],this._onReset(o)):(this._fill(i,[],!1),delete this._selected[s.field],this._onReset(o),this._cascade(s.field))}}_reset(){this._selected={};for(const t of this._config.columns){const e=this._selects.get(t.field),s=t.filterKey??t.field;e&&(t.dependsOn?this._fill(e,[],!1):(e.value="",e.disabled=!1),this._onReset(s))}}reset(){this._reset()}destroy(){this._el.remove()}}class We{constructor(t,e,s){this._page=1,this._totalRows=0,this._pageSize=e,this._onChange=s,this._el=document.createElement("div"),this._el.className="og-pagination",this._el.style.cssText=`
|
|
41
|
-
display:flex;align-items:center;justify-content:center;gap:4px;
|
|
42
|
-
padding:6px 8px;border-top:1px solid var(--og-border-color,#e0e0e0);
|
|
43
|
-
background:var(--og-header-bg,#f5f5f5);flex-shrink:0;user-select:none;
|
|
44
|
-
font-size:12px;color:var(--og-text-color,#333);
|
|
45
|
-
`,t.appendChild(this._el),this._render()}get page(){return this._page}get pageSize(){return this._pageSize}get totalPages(){return Math.max(1,Math.ceil(this._totalRows/this._pageSize))}setTotalRows(t){this._totalRows=t,this._page>this.totalPages&&(this._page=this.totalPages),this._render()}setPageSize(t){this._pageSize=t,this._page=1,this._render(),this._emit()}goTo(t){const e=Math.max(1,Math.min(t,this.totalPages));e!==this._page&&(this._page=e,this._render(),this._emit())}getRange(){const t=(this._page-1)*this._pageSize,e=Math.min(t+this._pageSize-1,this._totalRows-1);return{start:t,end:e}}_emit(){this._onChange({page:this._page,pageSize:this._pageSize,totalRows:this._totalRows,totalPages:this.totalPages})}_render(){this._el.innerHTML="";const t=this.totalPages,e=document.createElement("span");e.style.cssText="display:flex;align-items:center;gap:3px;margin-right:8px;";const s=document.createElement("span");s.textContent="행/페이지:",s.style.color="#888";const i=document.createElement("select");i.style.cssText="padding:2px 4px;border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;font-size:11px;cursor:pointer;";for(const c of[10,20,50,100,200]){const u=document.createElement("option");u.value=String(c),u.textContent=String(c),c===this._pageSize&&(u.selected=!0),i.appendChild(u)}i.addEventListener("change",()=>this.setPageSize(Number(i.value))),e.appendChild(s),e.appendChild(i),this._el.appendChild(e);const o=document.createElement("span"),{start:n,end:r}=this.getRange();o.textContent=this._totalRows>0?`${n+1}–${r+1} / ${this._totalRows}건`:"0건",o.style.cssText="margin-right:8px;color:#888;",this._el.appendChild(o);const l=(c,u,h)=>{const g=document.createElement("button");return g.textContent=c,g.disabled=h,g.style.cssText=`
|
|
46
|
-
min-width:28px;height:24px;padding:0 6px;
|
|
47
|
-
border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;
|
|
48
|
-
background:${h?"#f5f5f5":"#fff"};
|
|
49
|
-
color:${h?"#bbb":"var(--og-text-color,#333)"};
|
|
50
|
-
cursor:${h?"default":"pointer"};font-size:12px;
|
|
51
|
-
`,h||g.addEventListener("click",()=>this.goTo(u)),g};this._el.appendChild(l("«",1,this._page===1)),this._el.appendChild(l("‹",this._page-1,this._page===1));const a=Ne(this._page,t);for(const c of a)if(c===-1){const u=document.createElement("span");u.textContent="…",u.style.padding="0 3px",this._el.appendChild(u)}else{const u=l(String(c),c,c===this._page);c===this._page&&(u.style.background="var(--og-primary,#1976d2)",u.style.color="#fff",u.style.borderColor="var(--og-primary,#1976d2)"),this._el.appendChild(u)}this._el.appendChild(l("›",this._page+1,this._page===t)),this._el.appendChild(l("»",t,this._page===t))}destroy(){this._el.remove()}}function Ne(d,t){if(t<=7)return Array.from({length:t},(s,i)=>i+1);const e=[1];d>3&&e.push(-1);for(let s=Math.max(2,d-1);s<=Math.min(t-1,d+1);s++)e.push(s);return d<t-2&&e.push(-1),e.push(t),e}class Ke{constructor(t,e,s,i){this._dx=e-t.left,this._dy=s-t.top;const o=document.createElement("div");o.className="og-drag-ghost",o.style.cssText=`position:fixed;left:0;top:0;width:${t.width}px;height:${Math.min(t.height,40)}px;transform:translate(${t.left}px,${t.top}px);background:rgba(25,118,210,0.12);border:2px dashed #1976d2;box-sizing:border-box;pointer-events:none;z-index:10000;border-radius:3px;opacity:0.92;display:flex;align-items:center;padding-left:10px;font-size:12px;color:#1565c0;font-weight:600;white-space:nowrap;overflow:hidden;`,i>1&&(o.textContent=`${i}개 행 이동`),document.body.appendChild(o),this._el=o}move(t,e){this._el.style.transform=`translate(${t-this._dx}px,${e-this._dy}px)`}destroy(){this._el.remove()}}class Kt{constructor(t="#1976d2"){const e=document.createElement("div");e.className="og-drop-indicator",e.style.cssText="position:absolute;left:0;right:0;display:none;align-items:center;pointer-events:none;z-index:9998;transform:translateY(-50%);";const s=o=>{const n=document.createElement("div"),r=o==="left"?`border-left:7px solid ${t}`:`border-right:7px solid ${t}`;return n.style.cssText=`width:0;height:0;flex-shrink:0;border-top:5px solid transparent;border-bottom:5px solid transparent;${r};`,n},i=document.createElement("div");i.style.cssText=`flex:1;height:3px;background:${t};border-radius:2px;box-shadow:0 0 0 1px rgba(255,255,255,0.7);`,e.append(s("left"),i,s("right")),this._el=e}showIn(t,e){this._el.parentElement!==t&&(this._el.remove(),t.appendChild(this._el)),this._el.style.display="flex",this._el.style.top=`${e}px`}hide(){this._el.style.display="none"}destroy(){this._el.remove()}}const Pt=(d,t,e)=>Math.max(t,Math.min(e,d));class Pe{constructor(t,e,s,i=null,o=()=>1){this._bodyEl=t,this._rowHeight=e,this._onDrop=s,this._cross=i,this._getDragCount=o,this._drag=null,this._selfIndicator=new Kt("#1976d2"),this._crossIndicator=new Kt("#2e7d32"),this._onMouseMove=this._onMouseMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this)}attachHandle(t,e,s){const i=document.createElement("div");return i.className="og-drag-handle",i.innerHTML="⠿",i.style.cssText=`
|
|
52
|
-
width:18px;min-width:18px;height:100%;
|
|
53
|
-
display:flex;align-items:center;justify-content:center;
|
|
54
|
-
cursor:grab;font-size:14px;color:#bbb;flex-shrink:0;
|
|
55
|
-
user-select:none;border-right:1px solid var(--og-border-color,#e0e0e0);
|
|
56
|
-
`,i.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation(),this._startDrag(o,t,e,s)}),i}_startDrag(t,e,s,i){const o=e.getBoundingClientRect(),n=this._getDragCount(s);this._drag={fromIndex:s,bodyEl:this._bodyEl,rowHeight:this._rowHeight,totalRows:i,ghost:new Ke(o,t.clientX,t.clientY,n),currentTarget:s,crossTarget:null},document.addEventListener("mousemove",this._onMouseMove,!0),document.addEventListener("mouseup",this._onMouseUp,!0)}_onMouseMove(t){if(!this._drag)return;const e=this._drag;if(e.ghost.move(t.clientX,t.clientY),this._cross){const o=this._cross.resolveTarget(t.clientX,t.clientY);if(o&&o.bodyEl!==e.bodyEl){const n=o.bodyEl.getBoundingClientRect(),r=t.clientY-n.top+o.bodyEl.scrollTop,l=Pt(Math.round(r/o.rowHeight),0,o.totalRows);e.crossTarget={bodyEl:o.bodyEl,index:l},this._selfIndicator.hide(),this._crossIndicator.showIn(o.bodyEl,l*o.rowHeight);return}}e.crossTarget=null,this._crossIndicator.hide();const s=e.bodyEl.getBoundingClientRect(),i=t.clientY-s.top+e.bodyEl.scrollTop;e.currentTarget=Pt(Math.round(i/e.rowHeight),0,e.totalRows-1),this._selfIndicator.showIn(e.bodyEl,e.currentTarget*e.rowHeight)}_onMouseUp(t){if(document.removeEventListener("mousemove",this._onMouseMove,!0),document.removeEventListener("mouseup",this._onMouseUp,!0),!this._drag)return;const{fromIndex:e,currentTarget:s,ghost:i,crossTarget:o}=this._drag;this._drag=null,i.destroy(),this._selfIndicator.hide(),this._crossIndicator.hide(),o&&this._cross?this._cross.onCrossDrop(e,o.bodyEl,o.index):e!==s&&this._onDrop(e,s)}destroy(){var t;document.removeEventListener("mousemove",this._onMouseMove,!0),document.removeEventListener("mouseup",this._onMouseUp,!0),(t=this._drag)==null||t.ghost.destroy(),this._selfIndicator.destroy(),this._crossIndicator.destroy(),this._drag=null}}class Z{constructor(){this._map=new Map}static _key(t,e){return`${t}:${e}`}applyMergeCells(t){this._map.clear();for(const e of t){const s=Math.max(1,e.rowSpan??1),i=Math.max(1,e.colSpan??1);this._map.set(Z._key(e.row,e.col),{rowSpan:s,colSpan:i,hidden:!1});for(let o=0;o<s;o++)for(let n=0;n<i;n++)o===0&&n===0||this._map.set(Z._key(e.row+o,e.col+n),{rowSpan:1,colSpan:1,hidden:!0})}}applyAutoMerge(t,e,s){var i,o;this._map.clear();for(let n=0;n<e.length;n++){const r=e[n],l=s[n];let a=0;for(let c=1;c<=t.length;c++){const u=(i=t[c-1])==null?void 0:i[l],h=c<t.length?(o=t[c])==null?void 0:o[l]:void 0;if(c===t.length||h!==u){const g=c-a;if(g>1){this._map.set(Z._key(a,r),{rowSpan:g,colSpan:1,hidden:!1});for(let k=a+1;k<c;k++)this._map.set(Z._key(k,r),{rowSpan:1,colSpan:1,hidden:!0})}a=c}}}}getInfo(t,e){return this._map.get(Z._key(t,e))??null}clear(){this._map.clear()}get isEmpty(){return this._map.size===0}}const Ve=[{id:"sort-asc",label:"오름차순 정렬",icon:"↑",action:"sortAsc"},{id:"sort-desc",label:"내림차순 정렬",icon:"↓",action:"sortDesc"},{type:"divider"},{id:"find",label:"찾기",icon:"🔍",action:"find"},{type:"divider"},{id:"excel",label:"Excel로 저장",icon:"📊",action:"excel"},{id:"csv",label:"CSV로 저장",icon:"📄",action:"csv"},{id:"print",label:"인쇄",icon:"🖨",action:"print"}];class je{constructor(t,e){this._anchor=t,this._actions=e,this._el=null,this._docClick=null,this._docKey=null,this._docScroll=null,this._docMouseMove=null,this._focusIdx=-1}open(t,e){this.close();const s=e??Ve,i=document.createElement("div");i.className="og-context-menu",i.setAttribute("role","menu");for(const r of s){if(r.type==="divider"){const c=document.createElement("div");c.className="og-cm-divider",c.setAttribute("role","separator"),i.appendChild(c);continue}const l=document.createElement("button");if(l.className="og-cm-item",l.setAttribute("role","menuitem"),l.setAttribute("tabindex","-1"),r.disabled&&(l.classList.add("og-cm-disabled"),l.setAttribute("aria-disabled","true")),r.icon){const c=document.createElement("span");if(c.className="og-cm-icon",/^[a-zA-Z][\w-]*(\s+[\w-]+)+$/.test(r.icon.trim())){const u=document.createElement("i");u.className=r.icon,c.appendChild(u)}else c.textContent=r.icon;c.setAttribute("aria-hidden","true"),l.appendChild(c)}const a=document.createElement("span");a.className="og-cm-label",a.textContent=r.label??"",l.appendChild(a),l.addEventListener("click",c=>{c.stopPropagation(),r.disabled||this._runAction(r),this.close()}),i.appendChild(l)}const o=this._anchor.closest("[data-og-theme]"),n=o==null?void 0:o.getAttribute("data-og-theme");n&&i.setAttribute("data-og-theme",n),document.body.appendChild(i),this._el=i,this._docMouseMove=r=>{if(!this._el)return;const l=this._el.getBoundingClientRect();(r.clientX<l.left-4||r.clientX>l.right+4||r.clientY<l.top-4||r.clientY>l.bottom+4)&&this.close()},this._position(i,t.clientX,t.clientY,()=>{this._el===i&&document.addEventListener("mousemove",this._docMouseMove,{capture:!0,passive:!0})}),this._docClick=r=>{i.contains(r.target)||this.close()},this._docKey=r=>{if(r.key==="Escape"){this.close();return}if(r.key==="ArrowDown"){r.preventDefault(),this._moveFocus(1);return}if(r.key==="ArrowUp"){r.preventDefault(),this._moveFocus(-1);return}if(r.key==="Enter"){const l=i.querySelector(".og-cm-item:focus");l==null||l.click()}},this._docScroll=()=>this.close(),setTimeout(()=>{document.addEventListener("click",this._docClick),document.addEventListener("keydown",this._docKey),window.addEventListener("scroll",this._docScroll,{passive:!0})},0),this._focusIdx=-1,this._moveFocus(1)}close(){var t;(t=this._el)==null||t.remove(),this._el=null,this._docClick&&document.removeEventListener("click",this._docClick),this._docKey&&document.removeEventListener("keydown",this._docKey),this._docScroll&&window.removeEventListener("scroll",this._docScroll),this._docMouseMove&&document.removeEventListener("mousemove",this._docMouseMove,{capture:!0}),this._docClick=this._docKey=this._docScroll=this._docMouseMove=null,this._focusIdx=-1}destroy(){this.close()}_position(t,e,s,i){t.style.cssText="position:fixed;visibility:hidden;left:0;top:0;",requestAnimationFrame(()=>{const{width:o,height:n}=t.getBoundingClientRect(),r=window.innerWidth,l=window.innerHeight,a=e+o>r?Math.max(0,e-o):e,c=s+n>l?Math.max(0,s-n):s;t.style.cssText=`position:fixed;left:${a}px;top:${c}px;z-index:9999;`,i==null||i()})}_moveFocus(t){var s;if(!this._el)return;const e=Array.from(this._el.querySelectorAll(".og-cm-item:not(.og-cm-disabled)"));e.length&&(this._focusIdx=(this._focusIdx+t+e.length)%e.length,(s=e[this._focusIdx])==null||s.focus())}_runAction(t){if(typeof t.action=="function"){t.action();return}switch(t.action){case"sortAsc":this._actions.onSortAsc();break;case"sortDesc":this._actions.onSortDesc();break;case"find":this._actions.onFind();break;case"excel":this._actions.onExcel();break;case"csv":this._actions.onCsv();break;case"print":this._actions.onPrint();break}}}class Vt{constructor(t,e){this._sheets=new Map,this._active="",this._onSwitch=e,this._tabBar=this._buildTabBar(t)}add(t,e=[],s=[]){if(this._sheets.has(t))throw new Error(`WorksheetManager: 시트 '${t}'이 이미 존재합니다`);this._sheets.set(t,{name:t,columns:e,data:s}),this._renderTabs(),this._sheets.size===1&&this.switch(t)}remove(t){if(!this._sheets.has(t))return;if(this._sheets.size===1)throw new Error("WorksheetManager: 마지막 시트는 삭제할 수 없습니다");const e=this._active===t;this._sheets.delete(t),this._renderTabs(),e&&this.switch(this._sheets.keys().next().value)}rename(t,e){if(!this._sheets.has(t))return;if(this._sheets.has(e))throw new Error(`WorksheetManager: 시트 '${e}'이 이미 존재합니다`);this._sheets.get(t);const s=Array.from(this._sheets.entries()).map(([i,o])=>i===t?[e,{...o,name:e}]:[i,o]);this._sheets=new Map(s),this._active===t&&(this._active=e),this._renderTabs()}switch(t){const e=this._sheets.get(t);if(!e)throw new Error(`WorksheetManager: 시트 '${t}'을 찾을 수 없습니다`);this._active=t,this._renderTabs(),this._onSwitch(t,e)}get(t){return this._sheets.get(t)}getNames(){return Array.from(this._sheets.keys())}getActive(){return this._active}syncData(t,e){const s=this._sheets.get(t);s&&(s.data=e)}destroy(){this._tabBar.remove()}_buildTabBar(t){const e=document.createElement("div");return e.className="og-sheet-tabs",t.appendChild(e),e}_renderTabs(){this._tabBar.innerHTML="";for(const e of this._sheets.keys()){const s=document.createElement("button");s.className="og-sheet-tab",s.textContent=e,s.setAttribute("role","tab"),s.setAttribute("aria-selected",e===this._active?"true":"false"),e===this._active&&s.classList.add("og-sheet-tab--active"),s.addEventListener("click",()=>{e!==this._active&&this.switch(e)}),s.addEventListener("dblclick",()=>this._startRename(s,e)),this._tabBar.appendChild(s)}const t=document.createElement("button");t.className="og-sheet-add",t.textContent="+",t.setAttribute("aria-label","새 워크시트 추가"),t.addEventListener("click",()=>{const e=`Sheet${this._sheets.size+1}`;this.add(e,[],[]),this.switch(e)}),this._tabBar.appendChild(t)}_startRename(t,e){const s=document.createElement("input");s.className="og-sheet-tab-rename",s.value=e,t.replaceWith(s),s.focus(),s.select();const i=()=>{const o=s.value.trim()||e;try{o!==e?this.rename(e,o):this._renderTabs()}catch{this._renderTabs()}};s.addEventListener("blur",i),s.addEventListener("keydown",o=>{o.key==="Enter"&&s.blur(),o.key==="Escape"&&(s.value=e,s.blur())})}}class Ue{constructor(t){this._d=t}_readCssVar(t){return getComputedStyle(this._d.getContainer()).getPropertyValue(t).trim()}_hexToXlsxRgb(t){const e=t.trim(),s=e.match(/^rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/i);if(s)return[s[1],s[2],s[3]].map(o=>parseInt(o).toString(16).padStart(2,"0")).join("").toUpperCase();const i=e.replace("#","").toUpperCase();return i.length===3?i[0]+i[0]+i[1]+i[1]+i[2]+i[2]:i.length===6?i:""}exportExcel(t){const e=typeof t=="string"?{filename:t}:t??{};let s=e.filename??"export";s.toLowerCase().endsWith(".xlsx")||(s+=".xlsx");const i=e.sheetName??(this._d.getOptions().ariaLabel||"Sheet1"),o=this._d.getData(),n=this._d.getColLayout().visibleLeaves.filter(a=>{var c;return!((c=e.exceptFields)!=null&&c.includes(a.field))}),r=e.includeHeader!==!1,l=(this._d.getStrategy??((a,c)=>c))("cellSerializer",(a,c,u)=>c.type==="number"&&typeof a=="number"?a:typeof a=="boolean"?a?"✓":"":typeof a=="object"?"":String(a));Promise.resolve().then(()=>require("./xlsx.min-Bx-LxWOf.cjs")).then(a=>a.xlsx_min).then(({utils:a,writeFile:c})=>{var A;const u=[];r&&u.push(n.map($=>$.header));for(const $ of o)u.push(n.map(p=>{const C=$[p.field];if(e.maskOnExport&&p.mask&&this._d.getMaskEnabled(p.field))return kt(C==null?"":String(C),p.mask);const O=C;return O==null||O===""?"":l(O,p,$)}));const h=a.aoa_to_sheet(u),g=this._d.getColWidths(),k=this._d.getColLayout();h["!cols"]=n.map($=>({wpx:g[k.getColumnIndex($.field)]??100})),h["!rows"]=u.map(($,p)=>({hpx:p===0&&r?22:19}));const m=e.styleMode??"theme";let w="1565C0",x="FFFFFF",_="FFFFFF",b="EEF2FF",L="212121",v="BDBDBD",R=10;if(m==="theme"){const $=C=>this._hexToXlsxRgb(C);w=$(this._readCssVar("--og-header-bg"))||w,x=$(this._readCssVar("--og-header-color"))||x,_=$(this._readCssVar("--og-row-bg"))||_,b=$(this._readCssVar("--og-row-alt-bg"))||b,L=$(this._readCssVar("--og-row-color"))||L,v=$(this._readCssVar("--og-border-color"))||v;const p=this._readCssVar("--og-font-size");p&&(R=Math.max(8,Math.round(parseFloat(p)*.75)))}const F=m==="none",I={hdrFont:F?{}:{bold:!0,color:{rgb:x},sz:R,name:"맑은 고딕"},dataFont:F?{}:{sz:R,color:{rgb:L},name:"맑은 고딕"},hdrFill:F?{}:{patternType:"solid",fgColor:{rgb:w}},evenFill:F?{}:{patternType:"solid",fgColor:{rgb:_}},oddFill:F?{}:{patternType:"solid",fgColor:{rgb:b}},hdrBorder:F?{}:{top:{style:"medium",color:{rgb:w}},bottom:{style:"medium",color:{rgb:w}},left:{style:"thin",color:{rgb:w}},right:{style:"thin",color:{rgb:w}}},dataBorder:F?{}:{top:{style:"thin",color:{rgb:v}},bottom:{style:"thin",color:{rgb:v}},left:{style:"thin",color:{rgb:v}},right:{style:"thin",color:{rgb:v}}}};u.forEach(($,p)=>{const C=r&&p===0,lt=(r?p-1:p)%2===0;$.forEach((X,st)=>{const f=a.encode_cell({r:p,c:st});h[f]||(h[f]={t:"s",v:""});const S=n[st],H=S.type==="number"||S.align==="right",tt=C?"center":H?"right":S.align??"left";h[f].s={font:C?I.hdrFont:I.dataFont,fill:C?I.hdrFill:lt?I.evenFill:I.oddFill,border:C?I.hdrBorder:I.dataBorder,alignment:{horizontal:tt,vertical:"center",wrapText:!1}}})});const T=a.book_new();a.book_append_sheet(T,h,i),c(T,s,{cellStyles:!0}),(A=e.onAfter)==null||A.call(e,new Blob([]))}).catch(()=>{console.error("Excel 내보내기 실패: xlsx 패키지를 확인하세요.")})}exportCsv(t){const e=typeof t=="string"?{filename:t}:t??{},s=this._d.getData(),i=this._d.getColLayout().visibleLeaves,o=i.map(l=>`"${l.header}"`).join(","),n=s.map(l=>i.map(a=>{const c=l[a.field]??"";if(e.maskOnExport&&a.mask&&this._d.getMaskEnabled(a.field))return kt(String(c),a.mask);const u=c;return typeof u=="string"&&u.includes(",")?`"${u}"`:u}).join(",")),r=e.filename??"export.csv";Ot("\uFEFF"+[o,...n].join(`
|
|
57
|
-
`),r)}exportJson(t){const e=typeof t=="string"?t:(t==null?void 0:t.filename)??"export.json";Ot(JSON.stringify(this._d.getData(),null,2),e,"application/json")}print(t){const e=(t==null?void 0:t.title)??"OPEN_GRID",s=(t==null?void 0:t.footerText)??"",i=this._d.getData(),o=this._d.getColLayout().visibleLeaves.filter(u=>{var h;return!((h=t==null?void 0:t.excludeFields)!=null&&h.includes(u.field))}),n=o.map(u=>`<th>${u.header??u.field}</th>`).join(""),r=i.map(u=>`<tr>${o.map(h=>`<td>${String(u[h.field]??"")}</td>`).join("")}</tr>`).join(""),l=s?`<div class="og-print-footer">${s}</div>`:"",a=`<!DOCTYPE html>
|
|
58
|
-
<html lang="ko"><head>
|
|
59
|
-
<meta charset="UTF-8"><title>${e}</title>
|
|
60
|
-
<style>
|
|
61
|
-
@page{margin:0;}
|
|
62
|
-
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;font-size:12px;margin:0;padding:1cm;}
|
|
63
|
-
h2{margin:0 0 10px;font-size:14px;color:#333;}
|
|
64
|
-
p{margin:0 0 8px;font-size:11px;color:#999;}
|
|
65
|
-
table{border-collapse:collapse;width:100%;}
|
|
66
|
-
th,td{border:1px solid #ccc;padding:5px 8px;text-align:left;white-space:nowrap;}
|
|
67
|
-
th{background:#f5f5f5;font-weight:600;color:#333;}
|
|
68
|
-
tr:nth-child(even) td{background:#fafafa;}
|
|
69
|
-
.og-print-footer{position:fixed;bottom:0;left:0;right:0;padding:6px 1cm;font-size:10px;color:#888;border-top:1px solid #e5e7eb;background:#fff;text-align:center;}
|
|
70
|
-
</style>
|
|
71
|
-
</head><body>
|
|
72
|
-
<h2>${e}</h2>
|
|
73
|
-
<p>${i.length}행 × ${o.length}열 · ${new Date().toLocaleString("ko-KR")}</p>
|
|
74
|
-
<table>
|
|
75
|
-
<thead><tr>${n}</tr></thead>
|
|
76
|
-
<tbody>${r}</tbody>
|
|
77
|
-
</table>
|
|
78
|
-
${l}
|
|
79
|
-
<script>window.addEventListener('load',()=>{window.print();window.addEventListener('afterprint',()=>window.close());});<\/script>
|
|
80
|
-
</body></html>`,c=window.open("","_blank","width=960,height=640");c&&(c.document.write(a),c.document.close())}exportSheetsExcel(t){const e=this._d.getWsManager();if(!e){this.exportExcel(t??"workbook");return}const s=t??"workbook.xlsx",i=(this._d.getStrategy??((o,n)=>n))("cellSerializer",(o,n,r)=>typeof o=="boolean"?o?"✓":"":n.type==="number"&&typeof o=="number"?o:String(o));Promise.resolve().then(()=>require("./xlsx.min-Bx-LxWOf.cjs")).then(o=>o.xlsx_min).then(({utils:o,writeFile:n})=>{const r=o.book_new(),l=this._d.getOptions();for(const a of e.getNames()){const c=e.get(a),u=c.columns.length?c.columns:l.columns,h=[u.map(k=>k.header)];for(const k of c.data)h.push(u.map(m=>{const w=k[m.field];return w==null?"":i(w,m,k)}));const g=o.aoa_to_sheet(h);g["!cols"]=u.map(()=>({wpx:100})),o.book_append_sheet(r,g,a)}n(r,s.endsWith(".xlsx")?s:s+".xlsx",{cellStyles:!0})}).catch(()=>console.error("exportSheetsExcel: xlsx 패키지를 확인하세요."))}}class Ge{constructor(t){this._d=t}fmtNum(t,e){if(!e)return Math.round(t).toLocaleString("ko-KR");const s=e.match(/[#0][#0,]*(?:\.[#0]+)?|\d+/),i=s?e.slice(0,s.index):"",o=s?e.slice(s.index+s[0].length):"",n=s?s[0]:e,r=n.includes("#")||n.includes(","),l=n.match(/\.(\d+)$/),a=l?parseInt(l[1],10):/^\d+$/.test(n)?parseInt(n,10):0,c=Math.abs(t).toFixed(a),[u="0",h]=c.split("."),g=r?u.replace(/\B(?=(\d{3})+(?!\d))/g,","):u,k=h!==void 0?`${g}.${h}`:g,m=`${i}${k}${o}`;return t<0?`-${m}`:m}computeValues(){const t=this._d.getOptions().footer;if(!t||t.length===0)return[];const e=this._d.getData();return t.filter(s=>s.field&&s.op).map(s=>{const i=s.field,o=s.op,n=e.map(h=>h[i]).filter(h=>h!=null&&h!=="");let r=null;const l=o.toUpperCase(),a=(this._d.getStrategy??((h,g)=>g))("summaryOp",null);if(a){const h=a(l,n,i);if(h!=null)return{_field:i,_value:h,_formatted:this.fmtNum(h,s.format)}}if(l==="SUM")r=n.length>0?M.sum(n.map(h=>String(h))):null;else if(l==="AVG")r=n.length>0?M.sum(n.map(h=>String(h))).div(M.from(String(n.length))):null;else if(l==="COUNT"){const h=n.length;return{_field:i,_value:h,_formatted:h.toLocaleString("ko-KR")}}else l==="MAX"?r=n.length>0?M.max(n.map(h=>String(h))):null:l==="MIN"&&(r=n.length>0?M.min(n.map(h=>String(h))):null);if(!r)return{_field:i,_value:null,_formatted:""};const c=r.toNumber(),u=this.fmtNum(c,s.format);return{_field:i,_value:c,_formatted:u}})}render(){var u;const t=this._d.getContainer(),e=t.querySelector(".og-footer-bar");e==null||e.remove();const s=this._d.getOptions(),i=s.footer;if(!i||i.length===0)return;const o=this._d.getColLayout().visibleLeaves,n=this._d.getColWidths()??o.map(h=>h.width??100),r=new Map(this.computeValues().map(h=>[h._field,h])),l=document.createElement("div");l.className="og-footer-bar",l.style.cssText=["display:flex;align-items:stretch;",`min-height:${s.footerHeight}px;`,"border-top:2px solid var(--og-primary,#1976d2);","background:var(--og-header-bg,#f5f5f5);","overflow:hidden;flex-shrink:0;font-size:13px;font-weight:600;"].join("");let a=0;if(s.stateColumn&&(a+=24),s.draggable&&(a+=18),s.rowNumber&&(a+=44),s.checkColumn&&(a+=36),a>0){const h=document.createElement("div");h.style.cssText=`width:${a}px;flex-shrink:0;border-right:1px solid var(--og-border-color,#e0e0e0);`,l.appendChild(h)}let c=0;for(const h of i){const g=Math.max(1,h.colspan??1);let k=0;for(let b=0;b<g;b++)k+=n[c+b]??100;const m=o[c];c+=g;const w=document.createElement("div");w.style.cssText=[`width:${k}px;min-width:${k}px;flex-shrink:0;`,"padding:4px 8px;box-sizing:border-box;overflow:hidden;","border-right:1px solid var(--og-border-color,#e0e0e0);","white-space:nowrap;text-overflow:ellipsis;"].join("");const x=h.field,_=x?r.get(x):null;if(_){const b=_._formatted??String(_._value??""),L=h.label?`${h.label}: `:"";w.textContent=L+b,w.title=`${((u=h.op)==null?void 0:u.toUpperCase())??""} = ${b}`,w.style.color="var(--og-primary,#1976d2)",w.style.textAlign=h.align??((m==null?void 0:m.type)==="number","right")}else h.label&&(w.textContent=h.label,w.style.textAlign=h.align??"left",w.style.color="var(--og-row-color,#212121)");l.appendChild(w)}s.footerPosition==="top"?t.insertBefore(l,t.firstChild):t.appendChild(l)}}class qe{constructor(t){this._d=t}handleKeyDown(t){const e=this._d.getEditMgr();if(e.activeEditor)return;this._d.handleCellKeyEvt("cellKeyDown",t);const s=this._d.getData(),i=this._d.getColLayout(),o=s.rowCount,n=i.visibleLeaves.length;if(o===0||n===0)return;if((t.ctrlKey||t.metaKey)&&t.key==="c"){t.preventDefault(),this._copyToClipboard();return}if((t.ctrlKey||t.metaKey)&&t.key==="v"){t.preventDefault(),this._pasteFromClipboard();return}const r=this._d.getOptions();if((t.ctrlKey||t.metaKey)&&r.draggable&&e.focusCell){if(t.key==="ArrowDown"){t.preventDefault();const l=e.focusCell.ci!==void 0?e.focusCell.ri:0;l<o-1&&(this._d.handleRowDrop(l,l+1),this._d.setFocusCell(l+1,e.focusCell.ci),this._d.announce(`행 ${l+1}을(를) ${l+2}번째 위치로 이동`));return}if(t.key==="ArrowUp"){t.preventDefault();const l=e.focusCell.ri;l>0&&(this._d.handleRowDrop(l,l-1),this._d.setFocusCell(l-1,e.focusCell.ci),this._d.announce(`행 ${l+1}을(를) ${l}번째 위치로 이동`));return}}switch(t.key){case"ArrowDown":{t.preventDefault();const l=e.focusCell,a=l?Math.min(l.ri+1,o-1):0;this._d.setFocusCell(a,(l==null?void 0:l.ci)??0);break}case"ArrowUp":{t.preventDefault();const l=e.focusCell,a=l?Math.max(l.ri-1,0):0;this._d.setFocusCell(a,(l==null?void 0:l.ci)??0);break}case"ArrowRight":{t.preventDefault();const l=e.focusCell;if(!l){this._d.setFocusCell(0,0);break}l.ci<n-1?this._d.setFocusCell(l.ri,l.ci+1):l.ri<o-1&&this._d.setFocusCell(l.ri+1,0);break}case"ArrowLeft":{t.preventDefault();const l=e.focusCell;if(!l){this._d.setFocusCell(0,0);break}l.ci>0?this._d.setFocusCell(l.ri,l.ci-1):l.ri>0&&this._d.setFocusCell(l.ri-1,n-1);break}case"Tab":{t.preventDefault();const l=e.focusCell;if(!l){this._d.setFocusCell(0,0);break}t.shiftKey?l.ci>0?this._d.setFocusCell(l.ri,l.ci-1):l.ri>0&&this._d.setFocusCell(l.ri-1,n-1):l.ci<n-1?this._d.setFocusCell(l.ri,l.ci+1):l.ri<o-1&&this._d.setFocusCell(l.ri+1,0);break}case"Home":{if(t.preventDefault(),t.ctrlKey||t.metaKey)this._d.setFocusCell(0,0);else{const l=e.focusCell;this._d.setFocusCell((l==null?void 0:l.ri)??0,0)}break}case"End":{if(t.preventDefault(),t.ctrlKey||t.metaKey)this._d.setFocusCell(o-1,n-1);else{const l=e.focusCell;this._d.setFocusCell((l==null?void 0:l.ri)??0,n-1)}break}case"PageDown":{t.preventDefault();const l=e.focusCell,a=this._d.getOptions().pageSize??10,c=Math.min(l?l.ri+a:a-1,o-1);this._d.setFocusCell(c,(l==null?void 0:l.ci)??0);break}case"PageUp":{t.preventDefault();const l=e.focusCell,a=this._d.getOptions().pageSize??10,c=l?Math.max(l.ri-a,0):0;this._d.setFocusCell(c,(l==null?void 0:l.ci)??0);break}case" ":{if(e.focusCell){t.preventDefault();const l=e.focusCell.ri,a=this._d.getRowMgr();this._d.getOptions().checkColumn?(a.check(l,!a.checkedRows.has(l)),this._d.doRender()):(a.selectToggle(l),this._d.doRender())}break}case"F2":case"Enter":{e.focusCell&&this._d.getOptions().editable&&(t.preventDefault(),e.startEditByKey(e.focusCell.ri,e.focusCell.ci));break}case"Escape":{e.clearFocusCell(),this._d.doRender();break}}}_copyToClipboard(){var n;if(!this._d.getOptions().clipboard)return;const e=this._d.getEditMgr(),s=this._d.getColLayout(),i=this._d.getData();let o="";if(e.focusCell){const{ri:r,ci:l}=e.focusCell,a=s.visibleLeaves[l];a&&(o=String(i.getCellValue(r,a.field)??""))}else if(this._d.getRowMgr().selectedRows.size>0){const r=s.visibleLeaves;o=[...this._d.getRowMgr().selectedRows].sort((a,c)=>a-c).map(a=>{const c=i.getRowByIndex(a);return r.map(u=>String((c==null?void 0:c[u.field])??"")).join(" ")}).join(`
|
|
81
|
-
`)}o&&((n=navigator.clipboard)==null||n.writeText(o).catch(()=>{}))}_pasteFromClipboard(){var s;const t=this._d.getOptions();if(!t.clipboard||!t.editable)return;const e=this._d.getEditMgr();e.focusCell&&((s=navigator.clipboard)==null||s.readText().then(i=>{if(!i)return;const{ri:o,ci:n}=e.focusCell,r=i.split(`
|
|
82
|
-
`),l=this._d.getColLayout().visibleLeaves,a=this._d.getData();for(let c=0;c<r.length;c++){const u=r[c].split(" ");for(let h=0;h<u.length;h++){const g=o+c,k=n+h,m=l[k];m&&g<a.rowCount&&a.updateCell(g,m.field,u[h])}}this._d.emit("dataChange",a.getData()),this._d.doRender()}).catch(()=>{}))}}class Xe{constructor(t){this._bar=null,this._input=null,this._count=null,this._filter="",this._d=t}get findFilter(){return this._filter}init(t){const e=document.createElement("div");e.className="og-find-bar",e.hidden=!0;const s=document.createElement("span");s.className="og-find-label",s.textContent="찾기";const i=document.createElement("input");i.type="text",i.className="og-find-input",i.placeholder="검색어 입력...",i.setAttribute("aria-label","그리드 내 검색");const o=document.createElement("span");o.className="og-find-count";const n=document.createElement("button");n.className="og-find-close",n.textContent="✕",n.setAttribute("aria-label","찾기 닫기"),e.appendChild(s),e.appendChild(i),e.appendChild(o),e.appendChild(n),t.insertBefore(e,t.firstChild),i.addEventListener("input",()=>{this._filter=i.value.trim(),this._apply()}),i.addEventListener("keydown",r=>{r.key==="Escape"&&this.close()}),n.addEventListener("click",()=>this.close()),this._bar=e,this._input=i,this._count=o}open(){this._bar&&(this._bar.hidden=!1,this._input.focus(),this._input.select())}close(){this._bar&&(this._bar.hidden=!0,this._filter="",this._input.value="",this._count&&(this._count.textContent=""),this._apply())}_apply(){var i,o;const t=this._d.getData(),e=this._d.getColLayout().visibleLeaves.map(n=>n.field);t.setFindFilter(this._filter,e),t.applyFilter(this._d.getFilters());const s=t.rowCount;(i=this._d.getVs())==null||i.setTotalRows(s),(o=this._d.getPagination())==null||o.setTotalRows(s),this._count&&(this._count.textContent=this._filter?`${s}건`:""),this._d.doRender()}}function Yt(d){return d&&d._isGroup===!0}function jt(d,t,e=[],s=new Set,i,o){return t.length?Jt(d,t,0,e,s,"",i,o):[]}function Jt(d,t,e,s,i,o,n,r){const l=t[e],a=new Map;for(const u of d){const h=r?r(u,t.slice(e)):u[l];a.has(h)||a.set(h,[]),a.get(h).push(u)}const c=[];for(const[u,h]of a){const g=`${o}__${l}:${u}`,k=i.has(g);let m;e<t.length-1?m=Jt(h,t,e+1,s,i,g,n,r):m=h;const{summary:w,summaryFmt:x}=Ye(h,s),_=Je(h,n);c.push({_isGroup:!0,_groupField:l,_groupValue:u,_groupLabel:u==null?"(없음)":String(u),_depth:e,_expanded:k,_childCount:h.length,_summary:w,_summaryFmt:x,_states:_,children:m})}return c}function Ye(d,t){const e={},s={};for(const i of t){const o=d.map(a=>a[i.field]).filter(a=>a!=null&&a!=="");let n=null;const r=i.op.toUpperCase();if(r==="SUM")n=o.length>0?M.sum(o.map(String)):null;else if(r==="AVG")n=o.length>0?M.sum(o.map(String)).div(M.from(String(o.length))):null;else if(r==="COUNT"){e[i.field]=d.length,s[i.field]=d.length.toLocaleString("ko-KR");continue}else r==="MAX"?n=o.length>0?M.max(o.map(String)):null:r==="MIN"&&(n=o.length>0?M.min(o.map(String)):null);if(!n){e[i.field]=null,s[i.field]="";continue}const l=n.toNumber();e[i.field]=l,s[i.field]=Qe(l,i.format)}return{summary:e,summaryFmt:s}}function Je(d,t){if(!t)return{added:0,edited:0,removed:0};let e=0,s=0,i=0;for(const o of d){const n=t(o);n==="added"?e++:n==="edited"?s++:n==="removed"&&i++}return{added:e,edited:s,removed:i}}function Qe(d,t){if(t==null)return d%1===0?d.toLocaleString("ko-KR"):parseFloat(d.toFixed(6)).toLocaleString("ko-KR",{minimumFractionDigits:2,maximumFractionDigits:6});const e=t.includes("#")||t.includes(","),s=t.match(/\.(\d+)$/),i=s?parseInt(s[1],10):/^\d+$/.test(t)?parseInt(t,10):0,o=Math.abs(d).toFixed(i),[n="0",r]=o.split("."),l=e?n.replace(/\B(?=(\d{3})+(?!\d))/g,","):n,a=r!==void 0?`${l}.${r}`:l;return d<0?`-${a}`:a}function Qt(d){const t=[];for(const e of d)if(t.push(e),e._expanded)for(const s of e.children)Yt(s)?t.push(...Qt([s])):t.push(s);return t}function Zt(d,t=""){const e=[];for(const s of d){const i=`${t}__${s._groupField}:${s._groupValue}`;e.push(i);const o=s.children.filter(n=>Yt(n));o.length&&e.push(...Zt(o,i))}return e}function Rt(d,t,e=new Set){const{idField:s,parentIdField:i,expandOnLoad:o=!1}=t,n=new Map,r=[];for(const c of d){const u=c[s],h={_isTree:!0,_treeId:u,_treeParentId:c[i],_depth:0,_expanded:o||e.has(u),_hasChildren:!1,_childCount:0,_isLastChild:!1,_ancestorHasMore:[],data:c,children:[]};n.set(u,h)}for(const c of n.values()){const u=c._treeParentId;if(u==null||u===""||!n.has(u))r.push(c);else{const g=n.get(u);g.children.push(c),g._hasChildren=!0}}function l(c,u){for(const h of c)h._depth=u,h._childCount=te(h),l(h.children,u+1)}l(r,0);function a(c,u){for(let h=0;h<c.length;h++){const g=c[h],k=h===c.length-1;g._isLastChild=k,g._ancestorHasMore=u,g.children.length>0&&a(g.children,[...u,!k])}}return a(r,[]),r}function te(d){let t=d.children.length;for(const e of d.children)t+=te(e);return t}function ee(d){const t=[];for(const e of d)t.push(e),e._expanded&&e.children.length>0&&t.push(...ee(e.children));return t}function Ze(d,t){d.has(t)?d.delete(t):d.add(t)}function Et(d){const t=[];for(const e of d)t.push(e._treeId),e.children.length&&t.push(...Et(e.children));return t}class ts{constructor(t){this._groupFields=[],this._groupExpandedKeys=new Set,this._groupFlatRows=[],this._isGroupMode=!1,this._treeRoots=[],this._treeFlatRows=[],this._treeExpandedKeys=new Set,this._isTreeMode=!1,this._d=t}get isGroupMode(){return this._isGroupMode}get isTreeMode(){return this._isTreeMode}get groupFlatRows(){return this._groupFlatRows}get treeFlatRows(){return this._treeFlatRows}groupBy(t){this._groupFields=t,this._groupExpandedKeys.clear(),this._isGroupMode=t.length>0,this.rebuildGroups()}clearGroup(){var e;this._groupFields=[],this._groupExpandedKeys.clear(),this._isGroupMode=!1,this._groupFlatRows=[];const t=this._d.getData().length;(e=this._d.getVs())==null||e.setTotalRows(t),this._d.doRender()}expandAll(){if(!this._isGroupMode)return;const t=jt(this._d.getData(),this._groupFields,this._getSummaryDefs(),void 0,void 0,this._groupKeyFn());Zt(t).forEach(e=>this._groupExpandedKeys.add(e)),this.rebuildGroups()}_groupKeyFn(){return this._d.getStrategy?this._d.getStrategy("groupKeyFn",void 0):void 0}collapseAll(){this._groupExpandedKeys.clear(),this._isGroupMode&&this.rebuildGroups()}handleGroupToggle(t){this._groupExpandedKeys.has(t)?this._groupExpandedKeys.delete(t):this._groupExpandedKeys.add(t),this.rebuildGroups()}rebuildGroups(){var o;const t=this._d.getData(),e=this._d.getDataLayer(),s=n=>{const r=t.indexOf(n);return r>=0?e.getRowState(r):"none"},i=jt(t,this._groupFields,this._getSummaryDefs(),this._groupExpandedKeys,s,this._groupKeyFn());this._groupFlatRows=Qt(i),(o=this._d.getVs())==null||o.setTotalRows(this._groupFlatRows.length),this._d.doRenderFull(this._groupFlatRows.length)}enableTree(){this._isTreeMode=!0,this._isGroupMode=!1;const t=this._d.getOptions();if(t.expandOnLoad){const e=Rt(this._d.getData(),{idField:t.treeId,parentIdField:t.treeParentId});Et(e).forEach(s=>this._treeExpandedKeys.add(s))}this.rebuildTree()}disableTree(){var e;this._isTreeMode=!1,this._treeRoots=[],this._treeFlatRows=[],this._treeExpandedKeys.clear();const t=this._d.getData().length;(e=this._d.getVs())==null||e.setTotalRows(t),this._d.doRender()}expandNodes(t,e=!0){const s=Array.isArray(t)?t:[t];for(const i of s)e?this._treeExpandedKeys.add(i):this._treeExpandedKeys.delete(i);this._isTreeMode&&this.rebuildTree()}expandAllNodes(){this._isTreeMode&&(Et(this._treeRoots).forEach(t=>this._treeExpandedKeys.add(t)),this.rebuildTree())}collapseAllNodes(){this._isTreeMode&&(this._treeExpandedKeys.clear(),this.rebuildTree())}handleTreeToggle(t){Ze(this._treeExpandedKeys,t),this.rebuildTree()}rebuildTree(){var e;const t=this._d.getOptions();this._treeRoots=Rt(this._d.getData(),{idField:t.treeId,parentIdField:t.treeParentId,expandOnLoad:t.expandOnLoad},this._treeExpandedKeys),this._treeFlatRows=ee(this._treeRoots),(e=this._d.getVs())==null||e.setTotalRows(this._treeFlatRows.length),this._d.doRenderFull(this._treeFlatRows.length)}_getSummaryDefs(){const t=this._d.getOptions().summary;if(!t)return[];if(t.rows&&t.rows.length>0)return t.fields.flatMap(s=>t.rows.map(i=>({field:s,op:i.op,format:i.format})));const e=Array.isArray(t.ops)?t.ops:t.ops?[t.ops]:["SUM"];return t.fields.map(s=>({field:s,op:e[0]??"SUM",format:t.format}))}}class es{constructor(t){this._sortList=[],this._filters={},this._d=t}get sortList(){return this._sortList}get filters(){return this._filters}handleSortClick(t,e){var r;const s=this._d.getOptions();if(!s.sortable)return;const i=this._sortList.findIndex(l=>l.field===t);if(i>=0){const l=this._sortList[i];l.dir==="asc"?l.dir="desc":this._sortList.splice(i,1)}else(!e||!s.multiSort)&&(this._sortList=[]),this._sortList.push({field:t,dir:"asc"});this._d.getData().applySort(this._sortList),this._d.renderHeader(),this._d.doRender();const o=this._sortList.find(l=>l.field===t),n=o?o.dir==="asc"?"오름차순":"내림차순":"정렬 해제";this._d.announce(`${t} ${n} 정렬`),this._d.emit("sortChange",{sortList:this._sortList}),(r=s.onSortChange)==null||r.call(s,{field:t,dir:(o==null?void 0:o.dir)??"asc",sortList:this._sortList})}sort(t,e="asc"){if(Array.isArray(t))this._sortList=t;else{const s=this._sortList.findIndex(i=>i.field===t);s>=0?this._sortList[s].dir=e:this._sortList=[{field:t,dir:e}],this._d.getOptions().multiSort||(this._sortList=this._sortList.slice(-1))}this._d.getData().applySort(this._sortList),this._d.renderHeader(),this._d.doRender(),this._d.emit("sortChange",{sortList:this._sortList})}resetSort(){this._sortList=[],this._d.getData().applySort([]),this._d.renderHeader(),this._d.doRender()}initSort(t){this._sortList=[...t],this._d.getData().applySort(this._sortList)}getSortState(){return[...this._sortList]}setFilter(t,e){var s,i;this._filters[t]=e,this.applyFilters(),this._d.renderHeader(),this._d.doRender(),this._d.emit("filterChange",{field:t,filterItems:e,allFilters:this._filters}),(i=(s=this._d.getOptions()).onFilterChange)==null||i.call(s,{field:t,filterItems:e,allFilters:this._filters})}resetFilter(t){t?delete this._filters[t]:this._filters={},this.applyFilters(),this._d.renderHeader(),this._d.doRender()}getFilterState(){return{...this._filters}}restoreFilter(t){this._filters={...t},this.applyFilters()}applyFilters(){var s,i;const t=this._d.getData();t.setFindFilter(this._d.getFindFilter(),this._d.getColLayout().visibleLeaves.map(o=>o.field)),t.applyFilter(this._filters);const e=t.rowCount;(s=this._d.getVs())==null||s.setTotalRows(e),(i=this._d.getPagination())==null||i.setTotalRows(e)}}class ss{constructor(t){this._d=t}handleCellClick(t,e,s){var a,c,u,h,g,k,m;const i=this._d.getOptions(),o=this._d.getRowMgr(),n=this._d.getEditMgr();i.selection==="single"||i.selection==="row"?o.selectSingle(t):i.selection==="multiple"&&(s.ctrlKey||s.metaKey?o.selectToggle(t):o.selectSingle(t));const r=this._d.getData().getRowByIndex(t),l=this._d.getColLayout().visibleLeaves[e];if(r&&l){const w=l.editable!==!1&&(l.editable!==void 0||i.editable);if(nt(l)&&w){const R=r[l.field];this._d.writeCell(t,l.field,!R)}if(l.type==="radio"){const R=l.group;for(const F of this._d.getColLayout().visibleLeaves)F.type==="radio"&&F.field!==l.field&&(!R||F.group===R)&&this._d.getData().updateCell(t,F.field,!1);this._d.writeCell(t,l.field,!0)}let x=r[l.field];if(x===void 0&&l.formula)try{const R=l.formulaPrecision??30,F=Gt(l.formula,r,R);x=F instanceof M?l.precision!=null?F.toFixed(l.precision):F.toString():String(F)}catch{}const _={type:"cellClick",rowIndex:t,columnIndex:e,field:l.field,value:x,row:r,column:l,target:s.target,originalEvent:s};this._d.emit("cellClick",_),(a=i.onCellClick)==null||a.call(i,_);const b={type:"rowClick",rowIndex:t,row:r,target:s.target,originalEvent:s};this._d.emit("rowClick",b),(c=i.onRowClick)==null||c.call(i,b);const L=l.type==="select";!(n.activeEditor!=null&&((u=n.editCell)==null?void 0:u.ri)===t&&((h=n.editCell)==null?void 0:h.ci)===e)&&(i.editMode==="click"||L)&&!nt(l)&&n.startEdit(t,e,s)}n.activeEditor&&((g=n.editCell)==null?void 0:g.ri)===t&&((k=n.editCell)==null?void 0:k.ci)===e||(this._d.doRender(),this._d.emit("selectionChange",{rows:o.getSelections(),rowIndexes:[...o.selectedRows]}),(m=i.onSelectionChange)==null||m.call(i,{rows:o.getSelections(),rowIndexes:[...o.selectedRows],cells:[]}))}handleCellDblClick(t,e,s){var a,c;const i=this._d.getData().getRowByIndex(t),o=this._d.getColLayout().visibleLeaves[e];if(!i||!o)return;const n=this._d.getOptions(),r={type:"cellDblClick",rowIndex:t,columnIndex:e,field:o.field,value:i[o.field],row:i,column:o,target:s.target,originalEvent:s};this._d.emit("cellDblClick",r),(a=n.onCellDblClick)==null||a.call(n,r);const l={type:"rowDblClick",rowIndex:t,row:i,target:s.target,originalEvent:s};this._d.emit("rowDblClick",l),(c=n.onRowDblClick)==null||c.call(n,l),n.editMode==="dblclick"&&this._d.getEditMgr().startEdit(t,e,s)}handleCellMouseOver(t,e,s){var a,c;const i=this._d.getData().getRowByIndex(t),o=this._d.getColLayout().visibleLeaves[e];if(!i||!o)return;const n=this._d.getOptions(),r={type:"cellMouseOver",rowIndex:t,columnIndex:e,field:o.field,value:i[o.field],row:i,column:o,target:s.target,originalEvent:s};this._d.emit("cellMouseOver",r),(a=n.onCellMouseOver)==null||a.call(n,r);const l={type:"rowMouseOver",rowIndex:t,row:i,target:s.target,originalEvent:s};this._d.emit("rowMouseOver",l),(c=n.onRowMouseOver)==null||c.call(n,l)}handleCellMouseOut(t,e,s){var a,c;const i=this._d.getData().getRowByIndex(t),o=this._d.getColLayout().visibleLeaves[e];if(!i||!o)return;const n=this._d.getOptions(),r={type:"cellMouseOut",rowIndex:t,columnIndex:e,field:o.field,value:i[o.field],row:i,column:o,target:s.target,originalEvent:s};this._d.emit("cellMouseOut",r),(a=n.onCellMouseOut)==null||a.call(n,r);const l={type:"rowMouseOut",rowIndex:t,row:i,target:s.target,originalEvent:s};this._d.emit("rowMouseOut",l),(c=n.onRowMouseOut)==null||c.call(n,l)}handleCellMouseDown(t,e,s){var a,c;const i=this._d.getData().getRowByIndex(t),o=this._d.getColLayout().visibleLeaves[e];if(!i||!o)return;const n=this._d.getOptions(),r={type:"cellMouseDown",rowIndex:t,columnIndex:e,field:o.field,value:i[o.field],row:i,column:o,target:s.target,originalEvent:s};this._d.emit("cellMouseDown",r),(a=n.onCellMouseDown)==null||a.call(n,r);const l={type:"rowMouseDown",rowIndex:t,row:i,target:s.target,originalEvent:s};this._d.emit("rowMouseDown",l),(c=n.onRowMouseDown)==null||c.call(n,l)}handleCellMouseUp(t,e,s){var a,c;const i=this._d.getData().getRowByIndex(t),o=this._d.getColLayout().visibleLeaves[e];if(!i||!o)return;const n=this._d.getOptions(),r={type:"cellMouseUp",rowIndex:t,columnIndex:e,field:o.field,value:i[o.field],row:i,column:o,target:s.target,originalEvent:s};this._d.emit("cellMouseUp",r),(a=n.onCellMouseUp)==null||a.call(n,r);const l={type:"rowMouseUp",rowIndex:t,row:i,target:s.target,originalEvent:s};this._d.emit("rowMouseUp",l),(c=n.onRowMouseUp)==null||c.call(n,l)}handleCellMouseMove(t,e,s){var a,c;const i=this._d.getData().getRowByIndex(t),o=this._d.getColLayout().visibleLeaves[e];if(!i||!o)return;const n=this._d.getOptions(),r={type:"cellMouseMove",rowIndex:t,columnIndex:e,field:o.field,value:i[o.field],row:i,column:o,target:s.target,originalEvent:s};this._d.emit("cellMouseMove",r),(a=n.onCellMouseMove)==null||a.call(n,r);const l={type:"rowMouseMove",rowIndex:t,row:i,target:s.target,originalEvent:s};this._d.emit("rowMouseMove",l),(c=n.onRowMouseMove)==null||c.call(n,l)}handleCellKeyEvt(t,e){var c,u,h;const s=this._d.getEditMgr();if(!s.focusCell||s.activeEditor)return;const{ri:i,ci:o}=s.focusCell,n=this._d.getData().getRowByIndex(i),r=this._d.getColLayout().visibleLeaves[o];if(!n||!r)return;const l=this._d.getOptions(),a={type:t,rowIndex:i,columnIndex:o,field:r.field,value:n[r.field],row:n,column:r,key:e.key,target:this._d.getContainer(),originalEvent:e};this._d.emit(t,a),t==="cellKeyDown"?(c=l.onCellKeyDown)==null||c.call(l,a):t==="cellKeyUp"?(u=l.onCellKeyUp)==null||u.call(l,a):(h=l.onCellKeyPress)==null||h.call(l,a)}}class is{constructor(){this._triggers=new Map}add(t,e){this._triggers.has(t)||this._triggers.set(t,[]),this._triggers.get(t).push(e)}remove(t,e){const s=this._triggers.get(t);if(s){const i=s.indexOf(e);i>=0&&s.splice(i,1)}}clear(t){t?this._triggers.delete(t):this._triggers.clear()}mkCtx(t,e){let s=!1;return{operation:t,args:e,result:void 0,extra:{},timestamp:Date.now(),get cancelled(){return s},cancel(){s=!0}}}exec(t,e){const s=this._triggers.get(t)??[];for(const i of s)if(i(e),e.cancelled)return!1;if(t.startsWith("after:")){const i=this._triggers.get("complete")??[];for(const o of i)o(e)}return!0}}const ht="";function se(d){const t=Object.entries(d).filter(([,e])=>e!==ht).map(([e,s])=>` ${JSON.stringify(e)}: src[${JSON.stringify(s)}],`);return`// crossGridMapping 옵션에 이 함수를 그대로 지정하세요.
|
|
83
|
-
function mapRow(src) {
|
|
84
|
-
return {
|
|
85
|
-
`+t.join(`
|
|
86
|
-
`)+(t.length?`
|
|
87
|
-
`:"")+` };
|
|
88
|
-
}`}function os(d){return t=>{const e={};for(const[s,i]of Object.entries(d))i!==ht&&(e[s]=t[i]);return e}}function ns(d,t){if(d.length!==t.length)return!1;const e=new Set(t);return d.every(s=>e.has(s))}function rs(d,t){return new Promise(e=>{const s=new Set(d.map(R=>R.field)),i={};for(const R of t)i[R.field]=s.has(R.field)?R.field:ht;const o=document.createElement("div");o.className="og-mapper-overlay",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-label","그리드 필드 매핑"),o.style.cssText="position:fixed;inset:0;z-index:100000;background:rgba(0,0,0,0.45);display:flex;align-items:center;justify-content:center;font-family:var(--og-font-family,-apple-system,sans-serif);";const n=document.createElement("div");n.style.cssText="background:#fff;border-radius:10px;box-shadow:0 12px 40px rgba(0,0,0,0.3);width:min(620px,92vw);max-height:88vh;overflow:auto;color:#222;",o.appendChild(n);const r=document.createElement("div");r.style.cssText="padding:18px 20px 8px;",r.innerHTML='<div style="font-size:16px;font-weight:700;">필드 매핑</div><div style="font-size:12.5px;color:#666;margin-top:4px;line-height:1.5;">두 그리드의 필드 구조가 다릅니다. <b>타깃 필드</b>마다 어떤 <b>소스 필드</b>의 값을 가져올지 지정하세요. 아래 스크립트를 복사해 <code>crossGridMapping</code> 에 baking 하면 다음부터는 이 창 없이 자동 변환됩니다.</div>',n.appendChild(r);const l=document.createElement("div");l.style.cssText="padding:6px 20px;";const a='<option value="">(비움)</option>'+d.map(R=>`<option value="${it(R.field)}">${it(R.header)} <${it(R.field)}></option>`).join("");for(const R of t){const F=document.createElement("div");F.style.cssText="display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid #f0f0f0;";const I=document.createElement("div");I.style.cssText="flex:1;font-size:13px;min-width:0;",I.innerHTML=`<span style="font-weight:600;">${it(R.header)}</span><span style="color:#999;font-size:11.5px;"> <${it(R.field)}></span>`;const T=document.createElement("span");T.textContent="←",T.style.cssText="color:#888;flex-shrink:0;";const A=document.createElement("select");A.style.cssText="flex:1;min-width:0;padding:6px 8px;border:1px solid #ccc;border-radius:6px;font-size:13px;background:#fff;",A.innerHTML=a,A.value=i[R.field]??ht,A.addEventListener("change",()=>{i[R.field]=A.value,m()}),F.append(I,T,A),l.appendChild(F)}n.appendChild(l);const c=document.createElement("div");c.style.cssText="padding:10px 20px 4px;";const u=document.createElement("div");u.style.cssText="display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;",u.innerHTML='<span style="font-size:12.5px;font-weight:600;color:#444;">생성된 변환 스크립트</span>';const h=document.createElement("button");h.type="button",h.textContent="복사",h.style.cssText="font-size:12px;padding:4px 10px;border:1px solid #ccc;border-radius:6px;background:#f7f7f7;cursor:pointer;",u.appendChild(h);const g=document.createElement("pre");g.style.cssText="margin:0;background:#0d1117;color:#c9d1d9;padding:12px;border-radius:8px;font-family:ui-monospace,Consolas,monospace;font-size:12px;line-height:1.5;overflow:auto;max-height:180px;",c.append(u,g),n.appendChild(c);function k(){return se(i)}function m(){g.textContent=k()}m(),h.addEventListener("click",()=>{var F;const R=k();(F=navigator.clipboard)==null||F.writeText(R).then(()=>{h.textContent="복사됨!",setTimeout(()=>h.textContent="복사",1200)},()=>{h.textContent="복사 실패",setTimeout(()=>h.textContent="복사",1200)})});const w=document.createElement("div");w.style.cssText="display:flex;justify-content:flex-end;gap:8px;padding:14px 20px 18px;";const x=document.createElement("button");x.type="button",x.textContent="취소",x.style.cssText="font-size:13px;padding:8px 16px;border:1px solid #ccc;border-radius:7px;background:#fff;cursor:pointer;";const _=document.createElement("button");_.type="button",_.textContent="적용 후 이동",_.style.cssText="font-size:13px;padding:8px 16px;border:0;border-radius:7px;background:#1976d2;color:#fff;cursor:pointer;font-weight:600;",w.append(x,_),n.appendChild(w);let b=!1;function L(R){b||(b=!0,document.removeEventListener("keydown",v),o.remove(),e(R))}function v(R){R.key==="Escape"&&L(null)}x.addEventListener("click",()=>L(null)),o.addEventListener("mousedown",R=>{R.target===o&&L(null)}),_.addEventListener("click",()=>L({mapping:{...i},script:k()})),document.addEventListener("keydown",v),document.body.appendChild(o),_.focus()})}function it(d){return String(d).replace(/[&<>"]/g,t=>({"&":"&","<":"<",">":">",'"':"""})[t])}class ls{constructor(){this._map=new Map}register(t,e){this._map.set(t,e)}unregister(t){this._map.delete(t)}get(t){return this._map.get(t)}get size(){return this._map.size}resolveAt(t,e,s){const i=document.elementFromPoint(t,e),o=i==null?void 0:i.closest(".og-body-wrapper");if(!o)return null;const n=this._map.get(o);return!n||n===s?null:n}}const ct=new ls;class as{constructor(t,e){this._originals=new Map,this._hadOwn=new Map,this._stack=new Map,this._strategies=new Map,this._callPath=[],this._host=t,this._strict=(e==null?void 0:e.strict)??!0,this._maxDepth=(e==null?void 0:e.maxDepth)??32}override(t,e,s={}){if(typeof e!="function")throw new TypeError(`OverrideKernel.override: fn for "${t}" must be a function`);if(!this._originals.has(t)){const o=this._host[t];if(typeof o!="function")throw new TypeError(`OverrideKernel.override: host["${t}"] is not a function`);this._hadOwn.set(t,Object.prototype.hasOwnProperty.call(this._host,t)),this._originals.set(t,o.bind(this._host))}const i=this._stack.get(t)??[];return i.push({fn:e,opts:s}),this._stack.set(t,i),this._host[t]=this._buildDispatcher(t),this._host}_buildDispatcher(t){var a;const e=this._originals.get(t),s=this._stack.get(t)??[],i=s.reduce((c,u)=>(...h)=>u.fn(c,...h),e),o=((a=s[s.length-1])==null?void 0:a.opts)??{},n=o.reentrant===!0,r=o.onError==="fallback",l=this;return function(...c){if(!n&&l._callPath.indexOf(t)!==-1)return e(...c);if(l._callPath.length>=l._maxDepth){if(l._strict&&!r)throw new Error(`OverrideKernel: max override depth (${l._maxDepth}) exceeded at "${t}"`);return e(...c)}l._callPath.push(t);try{return i(...c)}catch(u){if(r&&!l._strict)return console.warn(`[og.override:${t}]`,u),e(...c);if(r&&l._strict)return console.warn(`[og.override:${t}]`,u),e(...c);throw u}finally{l._callPath.pop()}}}strategy(t,e){if(typeof e!="function")throw new TypeError(`OverrideKernel.strategy: fn for "${t}" must be a function`);return this._strategies.set(t,e),this._host}getStrategy(t,e){return this._strategies.get(t)??e}hasStrategy(t){return this._strategies.has(t)}restore(t){return this._originals.has(t)?(this._hadOwn.get(t)?this._host[t]=this._originals.get(t):delete this._host[t],this._originals.delete(t),this._hadOwn.delete(t),this._stack.delete(t),this._host):this._host}restoreAll(){for(const t of[...this._originals.keys()])this.restore(t);return this._strategies.clear(),this._callPath=[],this._host}hasOverride(t){return this._originals.has(t)}getOverrideNames(){return[...this._originals.keys()]}}const Ut="_ogRowId",V=class V extends oe{constructor(t,e){var o;super(),this._vs=null,this._ro=null,this._renderer=null,this._trigMgr=new is,this._destroyed=!1,this._autoHeightWarned=!1,this._colWidths=[],this._userWidths=new Map,this._filterPanel=null,this._filterSelect=null,this._pagination=null,this._dnd=null,this._mergeEngine=new Z,this._liveRegion=null,this._ctxMenu=null,this._cmHandler=null,this._cmKbdHandler=null,this._wsManager=null;const s=typeof t=="string"?document.querySelector(t):t;if(!s)throw new Error(`OpenGrid: container not found: ${t}`);this._container=s,this._options={height:"100%",width:"100%",rowHeight:32,headerHeight:34,footerHeight:30,autoHeight:!1,fillWidth:!1,defaultColumnWidth:100,editable:!1,editMode:"dblclick",history:!0,historySize:100,selection:"single",clipboard:!0,sortable:!0,multiSort:!0,filterable:!0,defaultSort:[],frozenColumns:0,frozenRows:0,rowNumber:!1,stateColumn:!1,checkColumn:!1,draggable:!1,crossGrid:!1,crossGridMapping:"auto",mergeCells:!1,groupBy:[],summary:void 0,treeMode:"auto",treeId:"id",treeParentId:"parentId",expandOnLoad:!1,pagination:!1,pageSize:50,footer:void 0,footerPosition:"bottom",theme:"default",cssVars:{},ariaLabel:"OPEN_GRID 데이터 그리드",...e},this._data=new re(Ut),this._rowMgr=new Ie(this._data),this._colLayout=new Tt(this._options.columns,this._options.frozenColumns),this._editMgr=new Be({data:this._data,colLayout:this._colLayout,getRenderer:()=>this._renderer,getContainer:()=>this._container,getOptions:()=>this._options,emit:(n,...r)=>this.emit(n,...r),doRender:()=>this._doRender(...this._visRange()),announce:n=>this._announce(n),writeCell:(n,r,l)=>this.writeCell(n,r,l),scrollToRow:n=>{var r;return(r=this._vs)==null?void 0:r.scrollToRow(n)},getVisibleLeaves:()=>this._colLayout.visibleLeaves}),this._exportMgr=new Ue({getData:()=>this._data.getData(),getColLayout:()=>this._colLayout,getColWidths:()=>this._colWidths,getOptions:()=>this._options,getContainer:()=>this._container,getMaskEnabled:n=>this.getMaskEnabled(n),getWsManager:()=>this._wsManager,getStrategy:(n,r)=>this._ovk.getStrategy(n,r)}),this._footerMgr=new Ge({getData:()=>this._data.getData(),getColLayout:()=>this._colLayout,getColWidths:()=>this._colWidths,getOptions:()=>this._options,getContainer:()=>this._container,getStrategy:(n,r)=>this._ovk.getStrategy(n,r)}),this._kbdMgr=new qe({getEditMgr:()=>this._editMgr,getRowMgr:()=>this._rowMgr,getData:()=>this._data,getColLayout:()=>this._colLayout,getOptions:()=>this._options,setFocusCell:(n,r)=>this._setFocusCell(n,r),handleRowDrop:(n,r)=>this._handleRowDrop(n,r),doRender:()=>this._doRender(...this._visRange()),announce:n=>this._announce(n),emit:(n,...r)=>this.emit(n,...r),visRange:()=>this._visRange(),handleCellKeyEvt:(n,r)=>this._handleCellKeyEvt(n,r)}),this._sfMgr=new es({getData:()=>this._data,getColLayout:()=>this._colLayout,getFindFilter:()=>this._findMgr.findFilter,getVs:()=>this._vs,getPagination:()=>this._pagination,getOptions:()=>this._options,renderHeader:()=>this._renderHeader(),doRender:()=>this._doRender(...this._visRange()),announce:n=>this._announce(n),emit:(n,...r)=>this.emit(n,...r)}),this._findMgr=new Xe({getColLayout:()=>this._colLayout,getData:()=>this._data,getFilters:()=>this._sfMgr.filters,getVs:()=>this._vs,getPagination:()=>this._pagination,doRender:()=>this._doRender(...this._visRange())}),this._cellEvt=new ss({getData:()=>this._data,getColLayout:()=>this._colLayout,getOptions:()=>this._options,getEditMgr:()=>this._editMgr,getRowMgr:()=>this._rowMgr,emit:(n,...r)=>this.emit(n,...r),writeCell:(n,r,l)=>this.writeCell(n,r,l),doRender:()=>this._doRender(...this._visRange()),getContainer:()=>this._container}),this._grpMgr=new ts({getData:()=>this._data.getData(),getDataLayer:()=>this._data,getOptions:()=>this._options,getVs:()=>this._vs,doRenderFull:n=>this._doRender(0,n-1),doRender:()=>this._doRender(...this._visRange()),getStrategy:(n,r)=>this._ovk.getStrategy(n,r)}),this._ovk=new as(this,{strict:this._options.overrideStrict??!0}),this._data.setStrategyResolver((n,r)=>this._ovk.getStrategy(n,r)),be((n,r,l)=>{var a;return((a=this._ovk.getStrategy("displayFormatter",null))==null?void 0:a(n,r,l))??null}),this._mount(),this._bindOptionEvents(),(o=this._options.defaultSort)!=null&&o.length&&this._sfMgr.initSort(this._options.defaultSort),this.override=Object.assign((n,r,l)=>this._ovk.override(n,r,l),{strategy:(n,r)=>this._ovk.strategy(n,r)});const i=this.destroy.bind(this);this.destroy=()=>{try{i()}finally{this._ovk.restoreAll()}};for(const[n,r]of V._defaultStrategies)this._ovk.strategy(n,r);for(const[n,r,l]of V._defaultOverrides)this._ovk.override(n,r,l);requestAnimationFrame(()=>{var n,r;this.emit("ready",this),(r=(n=this._options).onReady)==null||r.call(n,this)})}static defaultOverride(t,e,s={}){return V._defaultOverrides.push([t,e,s]),V}restore(t){return this._ovk.restore(t),this}restoreAll(){return this._ovk.restoreAll(),this}hasOverride(t){return this._ovk.hasOverride(t)}getOverrideNames(){return this._ovk.getOverrideNames()}getStrategy(t,e){return this._ovk.getStrategy(t,e)}_mount(){var s,i;this._container.classList.add("og-container");const t=this._options.height,e=this._options.width;this._container.style.height=typeof t=="number"?`${t}px`:String(t),this._container.style.width=typeof e=="number"?`${e}px`:String(e),this._container.style.display="flex",this._container.style.flexDirection="column",this._container.style.overflow="hidden",this._container.style.boxSizing="border-box",this._container.style.border="1px solid var(--og-border-color, #e0e0e0)",this._container.style.fontFamily="var(--og-font-family, -apple-system, sans-serif)",this._container.style.fontSize="var(--og-font-size, 13px)",this._container.setAttribute("data-og-theme",this._options.theme);for(const[o,n]of Object.entries(this._options.cssVars))this._container.style.setProperty(o,n);this._renderer=new He(this._container,this._options,{onHeaderClick:(o,n)=>this._handleSortClick(o,n),onCellClick:(o,n,r)=>this._handleCellClick(o,n,r),onCellDblClick:(o,n,r)=>this._handleCellDblClick(o,n,r),onCellMouseOver:(o,n,r)=>this._handleCellMouseOver(o,n,r),onCellMouseOut:(o,n,r)=>this._handleCellMouseOut(o,n,r),onCellMouseDown:(o,n,r)=>this._handleCellMouseDown(o,n,r),onCellMouseUp:(o,n,r)=>this._handleCellMouseUp(o,n,r),onCellMouseMove:(o,n,r)=>this._handleCellMouseMove(o,n,r),onRowCheck:(o,n)=>this._handleRowCheck(o,n),onAllCheck:o=>this._handleAllCheck(o),onColResize:(o,n)=>this._handleColResize(o,n),onFilterIconClick:(o,n)=>this._handleFilterIconClick(o,n),getDndManager:()=>this._dnd,onColDragStart:o=>{this._editMgr.dragColIdx=o},onColDrop:o=>{this._editMgr.dragColIdx!==null&&this._editMgr.dragColIdx!==o&&this._reorderColumn(this._editMgr.dragColIdx,o),this._editMgr.dragColIdx=null},getColDragIdx:()=>this._editMgr.dragColIdx}),this._filterPanel=new de(this._container,(o,n)=>this.setFilter(o,n),o=>this.resetFilter(o)),this._container.setAttribute("role","grid"),this._container.setAttribute("aria-label",this._options.ariaLabel??((s=this._options.cssVars)==null?void 0:s["aria-label"])??"OPEN_GRID 데이터 그리드"),this._container.setAttribute("aria-rowcount","0"),this._container.setAttribute("aria-colcount",String(this._options.columns.filter(o=>!o.hidden).length)),this._liveRegion=document.createElement("div"),this._liveRegion.setAttribute("aria-live","polite"),this._liveRegion.setAttribute("aria-atomic","true"),this._liveRegion.className="og-live-region",this._container.insertAdjacentElement("beforebegin",this._liveRegion),this._container.tabIndex=0,this._container.addEventListener("keydown",o=>this._handleKeyDown(o)),this._container.addEventListener("keyup",o=>this._handleCellKeyEvt("cellKeyUp",o)),this._container.addEventListener("keypress",o=>this._handleCellKeyEvt("cellKeyPress",o)),this._vs=new ae(this._renderer.bodyWrapper,{rowHeight:this._options.rowHeight,onRender:(o,n)=>this._doRender(o,n)}),ct.register(this._renderer.bodyWrapper,this),this._options.draggable&&(this._dnd=new Pe(this._renderer.bodyWrapper,this._options.rowHeight,(o,n)=>this._handleRowDrop(o,n),this._options.crossGrid?{resolveTarget:(o,n)=>{const r=ct.resolveAt(o,n,this);return!r||!r._options.crossGrid?null:{bodyEl:r._crossBodyEl(),rowHeight:r._options.rowHeight,totalRows:r._data.rowCount}},onCrossDrop:(o,n,r)=>this._handleCrossGridDrop(o,n,r)}:void 0,o=>this._dragRowSet(o).length)),this._options.pagination&&(this._pagination=new We(this._container,this._options.pageSize,o=>{this.emit("pageChange",o),this._doRender(...this._visRange())})),this._findMgr.init(this._container),this._initContextMenu(),(i=this._options.worksheets)!=null&&i.length&&this._initWorksheets(),this._ro=new ResizeObserver(()=>this._onResize()),this._ro.observe(this._container),this._onResize()}_initContextMenu(){const t=this._options.contextMenu;t!==!1&&(this._cmHandler&&this._container.removeEventListener("contextmenu",this._cmHandler),this._cmKbdHandler&&this._container.removeEventListener("keydown",this._cmKbdHandler),this._cmHandler=this._cmKbdHandler=null,this._ctxMenu=new je(this._container,{onSortAsc:()=>{const e=this._colLayout.visibleLeaves[0];e&&this.orderBy(e.field,"asc")},onSortDesc:()=>{const e=this._colLayout.visibleLeaves[0];e&&this.orderBy(e.field,"desc")},onFind:()=>this._findMgr.open(),onExcel:()=>this.exportExcel(),onCsv:()=>this.exportCsv(),onPrint:()=>this.print()}),this._cmHandler=e=>{var r;const s=e.target.closest(".og-cell");if(!s)return;e.preventDefault();const i=Number(s.dataset.colIndex??-1),o=this._colLayout.visibleLeaves[i];o&&this._ctxMenu&&(this._ctxMenu._actions.onSortAsc=()=>this.orderBy(o.field,"asc"),this._ctxMenu._actions.onSortDesc=()=>this.orderBy(o.field,"desc"));const n=Array.isArray(t)?t:void 0;(r=this._ctxMenu)==null||r.open(e,n)},this._container.addEventListener("contextmenu",this._cmHandler),this._cmKbdHandler=e=>{var s;if(e.shiftKey&&e.key==="F10"){e.preventDefault();const i=this._container.getBoundingClientRect(),o={clientX:i.left+80,clientY:i.top+40};(s=this._ctxMenu)==null||s.open(o)}},this._container.addEventListener("keydown",this._cmKbdHandler))}openContextMenu(t,e){var s;(s=this._ctxMenu)==null||s.open(t,e)}closeContextMenu(){var t;(t=this._ctxMenu)==null||t.close()}setFilterSelect(t){var e;(e=this._filterSelect)==null||e.destroy(),this._filterSelect=null,t&&(this._container.id||(this._container.id=`og-${Math.random().toString(36).slice(2,7)}`),this._filterSelect=new Oe(this._container,t,(s,i)=>this.setFilter(s,i),s=>this.resetFilter(s),this._container.id))}setOptions(t){var e;if(Object.assign(this._options,t),"contextMenu"in t&&((e=this._ctxMenu)==null||e.destroy(),this._ctxMenu=null,this._initContextMenu()),"groupBy"in t||"summary"in t){const s=t.groupBy??[];s.length>0?this._grpMgr.groupBy(s):this.clearGroup();return}this._renderHeader(),this._doRender(...this._visRange())}setMaskEnabled(t,e){var i;const s=this._colLayout.getColumnByField(t);s&&(e?(s._maskRevealed=!1,(i=s._maskRevealedRows)==null||i.clear()):s._maskRevealed=!0,this._doRender(...this._visRange()))}getMaskEnabled(t){const e=this._colLayout.getColumnByField(t);return e?e._maskRevealed!==!0:!1}_initWorksheets(){const t=this._options.worksheets;this._wsManager=new Vt(this._container,(e,s)=>this._loadWorksheetState(s));for(const e of t)this._wsManager.add(e.name,e.columns??this._options.columns,e.data??[])}_loadWorksheetState(t){var s,i;this._rowMgr.reset(),this._data.setData(t.data),this._colLayout=new Tt(t.columns.length?t.columns:this._options.columns,this._options.frozenColumns),(s=this._vs)==null||s.setTotalRows(this._data.rowCount),(i=this._pagination)==null||i.setTotalRows(this._data.rowCount),this._container.setAttribute("aria-rowcount",String(this._data.rowCount)),this._container.setAttribute("aria-colcount",String(this._colLayout.visibleLeaves.length));const{width:e}=this._container.getBoundingClientRect();e&&this._recalcWidths(e),this._renderHeader(),this._doRender(...this._visRange())}addWorksheet(t,e,s){this._wsManager||(this._wsManager=new Vt(this._container,(i,o)=>this._loadWorksheetState(o))),this._wsManager.add(t,e??this._options.columns,s??[])}removeWorksheet(t){var e;(e=this._wsManager)==null||e.remove(t)}switchWorksheet(t){var e;(e=this._wsManager)==null||e.switch(t)}renameWorksheet(t,e){var s;(s=this._wsManager)==null||s.rename(t,e)}getWorksheet(t){var e;return(e=this._wsManager)==null?void 0:e.get(t)}getWorksheetNames(){var t;return((t=this._wsManager)==null?void 0:t.getNames())??[]}exportSheetsExcel(t){this._exportMgr.exportSheetsExcel(t)}_paginationHeight(){return this._options.pagination?38:0}_onResize(){const{width:t}=this._container.getBoundingClientRect();t&&(this._recalcWidths(t),this._renderHeader(),this._doRender(...this._visRange()))}_recalcWidths(t){this._colWidths=this._colLayout.computeWidths(t-(this._options.stateColumn?24:0)-(this._options.draggable?18:0)-(this._options.rowNumber?44:0)-(this._options.checkColumn?36:0),this._options.defaultColumnWidth),this._userWidths.size&&this._colLayout.visibleLeaves.forEach((e,s)=>{const i=this._userWidths.get(e.field);i!=null&&(this._colWidths[s]=i)})}_renderHeader(){var t;(t=this._renderer)==null||t.renderHeader(this._colLayout.buildHeaderCells(),this._colLayout.visibleLeaves,this._colWidths,this._sfMgr.sortList,{...this._options,_activeFilters:this._sfMgr.filters,_frozenCount:this._colLayout.frozenCount}),this._syncHeaderLayout()}_syncHeaderLayout(){if(!this._renderer||!this._vs)return;const{height:t}=this._container.getBoundingClientRect();if(!t)return;const e=this._renderer.getHeaderHeight(),s=e>this._options.headerHeight?e:this._options.headerHeight;this._renderer.updateSize(t-this._paginationHeight(),s),this._vs.setViewportHeight(t-s-this._paginationHeight())}_doRender(t,e){var o;if(!this._renderer||!this._vs)return;const s=this._vs.getVisibleRange(),i=this._options.autoHeight===!0;i&&([t,e]=this._visRange(),!this._autoHeightWarned&&e-t+1>2e3&&(this._autoHeightWarned=!0,console.warn(`[OpenGrid] autoHeight 는 가상 스크롤이 아니라 전 행(${e-t+1}행)을 렌더합니다. 행이 많으면 고정 rowHeight(가상 스크롤) 사용을 권장합니다.`))),this._renderer.renderBody(t,e,this._data,this._colLayout.visibleLeaves,this._colWidths,this._options,i?0:s.offsetY,i?0:this._vs.getTotalHeight(),this._rowMgr.selectedRows,this._rowMgr.checkedRows,this._grpMgr.isGroupMode?this._grpMgr.groupFlatRows:this._grpMgr.isTreeMode?this._grpMgr.treeFlatRows:null,n=>this._grpMgr.handleGroupToggle(n),this._grpMgr.isTreeMode?n=>this._grpMgr.handleTreeToggle(n):void 0,{_totalRows:this._data.rowCount,_frozenCount:this._colLayout.frozenCount,_focusCell:this._editMgr.focusCell},this._mergeEngine),(o=this._options.footer)!=null&&o.length&&this._renderFooterEl()}_handleGroupToggle(t){this._grpMgr.handleGroupToggle(t)}_visRange(){var e;if(this._options.pagination&&this._pagination){const{start:s,end:i}=this._pagination.getRange();return[s,i]}if(this._options.autoHeight)return[0,(this._grpMgr.isGroupMode?this._grpMgr.groupFlatRows.length:this._grpMgr.isTreeMode?this._grpMgr.treeFlatRows.length:this._data.rowCount)-1];const t=(e=this._vs)==null?void 0:e.getVisibleRange();return[(t==null?void 0:t.startIndex)??0,Math.min(((t==null?void 0:t.endIndex)??30)+this._visCount()+5,this._data.rowCount-1)]}_visCount(){const t=this._container.getBoundingClientRect().height;return Math.ceil((t-this._options.headerHeight-this._paginationHeight())/this._options.rowHeight)+5}_handleSortClick(t,e){this._sfMgr.handleSortClick(t,e)}_isToggleCol(t){return nt(t)}_handleCellClick(t,e,s){this._cellEvt.handleCellClick(t,e,s)}_handleCellDblClick(t,e,s){this._cellEvt.handleCellDblClick(t,e,s)}_handleCellMouseOver(t,e,s){this._cellEvt.handleCellMouseOver(t,e,s)}_handleCellMouseOut(t,e,s){this._cellEvt.handleCellMouseOut(t,e,s)}_handleCellMouseDown(t,e,s){this._cellEvt.handleCellMouseDown(t,e,s)}_handleCellMouseUp(t,e,s){this._cellEvt.handleCellMouseUp(t,e,s)}_handleCellMouseMove(t,e,s){this._cellEvt.handleCellMouseMove(t,e,s)}_handleCellKeyEvt(t,e){this._cellEvt.handleCellKeyEvt(t,e)}_handleRowCheck(t,e){this._rowMgr.check(t,e),this._doRender(...this._visRange()),this.emit("rowCheck",{rowIndex:t,checked:e,row:this._data.getRowByIndex(t)})}_handleFilterIconClick(t,e){var i,o;if((i=this._filterPanel)!=null&&i.isOpen){this._filterPanel.close();return}const s=this._sfMgr.filters[t]??[];(o=this._filterPanel)==null||o.open(t,e,s)}_handleAllCheck(t){this._rowMgr.checkAll(t,this._data.rowCount),this._doRender(...this._visRange()),this.emit("allCheck",{checked:t})}_handleRowDrop(t,e){var s,i;this._data.moveRow(t,e),this._doRender(...this._visRange()),this.emit("rowDrop",{fromIndex:t,toIndex:e}),(i=(s=this._options).onRowDrop)==null||i.call(s,{fromIndex:t,toIndex:e})}_crossBodyEl(){return this._renderer.bodyWrapper}_dragRowSet(t){const e=[...this._rowMgr.selectedRows];return e.length>1&&e.includes(t)?e.sort((s,i)=>s-i):[t]}_handleCrossGridDrop(t,e,s){const i=ct.get(e);!i||i===this||this.moveRowsTo(i,this._dragRowSet(t),s)}async moveRowsTo(t,e,s){const i=t;if(!i||i===this||!e.length)return!1;const o=[...new Set(e)].sort((c,u)=>c-u),n=s??i._data.rowCount;let r=o.map(c=>{const u={...this._data.getRowByIndex(c)};return delete u[Ut],u});const l=await this._resolveCrossTransform(i);if(l===!1)return!1;l&&(r=r.map(c=>l(c)));const a={sourceGrid:this,targetGrid:i,rows:r,sourceIndexes:o,targetIndex:n};return this._fireGridDropBefore(a)===!1||a.cancel||i._fireGridDropBefore(a)===!1||a.cancel?!1:(r.forEach((c,u)=>i.insertRow(c,n+u)),[...o].sort((c,u)=>u-c).forEach(c=>this.deleteRow(c)),this._fireGridDropAfter(a),i._fireGridDropAfter(a),this._fireGridDropComplete(a),i._fireGridDropComplete(a),!0)}async moveCheckedTo(t){const e=this._rowMgr.getChecked().map(s=>s.rowIndex);return e.length?(this._rowMgr.uncheckAll(),this.moveRowsTo(t,e)):!1}async _resolveCrossTransform(t){var r,l;const e=this._options.crossGridMapping;if(typeof e=="function")return e;if(e!=="interactive")return null;const s=this._colLayout.visibleLeaves.map(a=>({field:a.field,header:a.header})),i=t._colLayout.visibleLeaves.map(a=>({field:a.field,header:a.header}));if(ns(s.map(a=>a.field),i.map(a=>a.field)))return null;const o=await rs(s,i);if(!o)return!1;const n={sourceGrid:this,targetGrid:t,mapping:o.mapping,script:o.script};return this.emit("gridDropMapping",n),(l=(r=this._options).onGridDropMapping)==null||l.call(r,n),console.log(`[OpenGrid] cross-grid mapping script:
|
|
89
|
-
`+se(o.mapping)),os(o.mapping)}_fireGridDropBefore(t){var e,s;return this.emit("gridDropBefore",t),(s=(e=this._options).onGridDropBefore)==null?void 0:s.call(e,t)}_fireGridDropAfter(t){var e,s;this.emit("gridDropAfter",t),(s=(e=this._options).onGridDropAfter)==null||s.call(e,t)}_fireGridDropComplete(t){var e,s;this.emit("gridDropComplete",t),(s=(e=this._options).onGridDropComplete)==null||s.call(e,t)}reorderRow(t,e){this._data.moveRow(t,e),this._doRender(...this._visRange())}_handleColResize(t,e){this._colWidths[t]!==void 0&&(this._colWidths[t]=e);const s=this._colLayout.visibleLeaves[t];s&&this._userWidths.set(s.field,e),this._renderHeader(),this._doRender(...this._visRange())}_handleKeyDown(t){this._kbdMgr.handleKeyDown(t)}_setFocusCell(t,e){this._rowMgr.selectSingle(t),this._editMgr.setFocusCell(t,e)}_announce(t){this._liveRegion&&(this._liveRegion.textContent="",setTimeout(()=>{this._liveRegion&&(this._liveRegion.textContent=t)},50))}_bindOptionEvents(){this._options.onCellClick&&this.on("cellClick",this._options.onCellClick),this._options.onCellDblClick&&this.on("cellDblClick",this._options.onCellDblClick),this._options.onRowClick&&this.on("rowClick",this._options.onRowClick),this._options.onEditStart&&this.on("editStart",this._options.onEditStart),this._options.onEditEnd&&this.on("editEnd",this._options.onEditEnd),this._options.onSortChange&&this.on("sortChange",this._options.onSortChange),this._options.onFilterChange&&this.on("filterChange",this._options.onFilterChange),this._options.onScroll&&this.on("scroll",this._options.onScroll),this._options.onDataChange&&this.on("dataChange",this._options.onDataChange),this._options.onSelectionChange&&this.on("selectionChange",this._options.onSelectionChange),this._options.onRowDblClick&&this.on("rowDblClick",this._options.onRowDblClick),this._options.onRowMouseOver&&this.on("rowMouseOver",this._options.onRowMouseOver),this._options.onRowMouseOut&&this.on("rowMouseOut",this._options.onRowMouseOut),this._options.onRowMouseDown&&this.on("rowMouseDown",this._options.onRowMouseDown),this._options.onRowMouseUp&&this.on("rowMouseUp",this._options.onRowMouseUp),this._options.onRowMouseMove&&this.on("rowMouseMove",this._options.onRowMouseMove),this._options.onCellMouseOver&&this.on("cellMouseOver",this._options.onCellMouseOver),this._options.onCellMouseOut&&this.on("cellMouseOut",this._options.onCellMouseOut),this._options.onCellMouseDown&&this.on("cellMouseDown",this._options.onCellMouseDown),this._options.onCellMouseUp&&this.on("cellMouseUp",this._options.onCellMouseUp),this._options.onCellMouseMove&&this.on("cellMouseMove",this._options.onCellMouseMove),this._options.onCellKeyDown&&this.on("cellKeyDown",this._options.onCellKeyDown),this._options.onCellKeyUp&&this.on("cellKeyUp",this._options.onCellKeyUp),this._options.onCellKeyPress&&this.on("cellKeyPress",this._options.onCellKeyPress)}setData(t){var s;const e=this._trigMgr.mkCtx("setData",[t]);this._trigMgr.exec("before:setData",e)&&(this._rowMgr.reset(),this._data.setData(t),this._applyFilters(),this._grpMgr.isTreeMode?this._grpMgr.rebuildTree():this._grpMgr.isGroupMode?this._grpMgr.rebuildGroups():(s=this._vs)==null||s.setTotalRows(this._data.rowCount),this._container.setAttribute("aria-rowcount",String(this._data.rowCount)),this._container.setAttribute("aria-colcount",String(this._colLayout.visibleLeaves.length)),this._announce(`${this._data.rowCount}행 데이터 로드됨`),this.emit("dataChange",this._data.getData()),e.result=t.length,this._trigMgr.exec("after:setData",e))}getData(){return this._data.getData()}getSourceRows(){return this._data.getOriginalData()}pushData(t){var i,o;const e=[...this._data.getAllData(),...t];this._data.setData(e);const s=this._data.rowCount;(i=this._vs)==null||i.setTotalRows(s),(o=this._pagination)==null||o.setTotalRows(s)}prefixData(t){var i,o;const e=[...t,...this._data.getAllData()];this._data.setData(e);const s=this._data.rowCount;(i=this._vs)==null||i.setTotalRows(s),(o=this._pagination)==null||o.setTotalRows(s)}clearData(){var t,e;this._rowMgr.reset(),this._data.clearData(),(t=this._vs)==null||t.setTotalRows(0),(e=this._pagination)==null||e.setTotalRows(0),this._doRender(0,-1),this.emit("dataChange",[])}insertRow(t,e="last"){var n,r,l,a;const s=this._trigMgr.mkCtx("insertRow",[t,e]);if(!this._trigMgr.exec("before:insertRow",s))return;const i=e==="before"?0:e==="after"?this._data.rowCount:e;this._data.addRow(t,i);const o=this._data.rowCount;(n=this._vs)==null||n.setTotalRows(o),(r=this._pagination)==null||r.setTotalRows(o),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(a=(l=this._options).onDataChange)==null||a.call(l,this._data.getData()),s.result={rowCount:o,item:t},this._trigMgr.exec("after:insertRow",s)}pushRow(t){var i,o,n,r;(Array.isArray(t)?t:[t]).forEach(l=>this._data.addRow(l,"last"));const s=this._data.rowCount;(i=this._vs)==null||i.setTotalRows(s),(o=this._pagination)==null||o.setTotalRows(s),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(r=(n=this._options).onDataChange)==null||r.call(n,this._data.getData())}appendRows(t){this.pushRow(t)}unshiftRow(t){var i,o,n,r;(Array.isArray(t)?t:[t]).forEach(l=>this._data.addRow(l,"first"));const s=this._data.rowCount;(i=this._vs)==null||i.setTotalRows(s),(o=this._pagination)==null||o.setTotalRows(s),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(r=(n=this._options).onDataChange)==null||r.call(n,this._data.getData())}prependRows(t){this.unshiftRow(t)}deleteRow(t){var n,r,l,a;const e=this._trigMgr.mkCtx("deleteRow",[t]),s=Array.isArray(t)?[...t]:[t];if(e.extra={rows:s.map(c=>this._data.getRowByIndex(c))},!this._trigMgr.exec("before:deleteRow",e))return;const i=s.sort((c,u)=>u-c);i.forEach(c=>this._data.removeRow(c));const o=this._data.rowCount;(n=this._vs)==null||n.setTotalRows(o),(r=this._pagination)==null||r.setTotalRows(o),this._doRender(...this._visRange()),this.emit("dataChange",this._data.getData()),(a=(l=this._options).onDataChange)==null||a.call(l,this._data.getData()),e.result={deleted:i.length,rowCount:o},this._trigMgr.exec("after:deleteRow",e)}deleteById(t){}readCell(t,e){return this._data.getCellValue(t,e)}getDisplayValue(t,e){const s=this.readCell(t,e);return this._ovk.getStrategy("displayFormatter",(o,n,r)=>o==null?"":String(o))(s,e,this._data.getRowByIndex(t))}writeCell(t,e,s){var c,u,h,g;const i=this.readCell(t,e),o=this._trigMgr.mkCtx("writeCell",[t,e,s]);if(o.extra={oldValue:i,rowIndex:t,field:e},!this._trigMgr.exec("before:writeCell",o))return;this._data.updateCell(t,e,s);const n=this._data.getRowByIndex(t),r=this._colLayout.getColumnByField(e),l=this._colLayout.getColumnIndex(e),a={type:"editEnd",rowIndex:t,columnIndex:l,field:e,oldValue:i,newValue:s,row:n,column:r};this.emit("editEnd",a),(u=(c=this._options).onEditEnd)==null||u.call(c,a),this.emit("dataChange",this._data.getData()),(g=(h=this._options).onDataChange)==null||g.call(h,this._data.getData()),this._doRender(...this._visRange()),o.result={rowIndex:t,field:e,oldValue:i,newValue:s},this._trigMgr.exec("after:writeCell",o)}getRowAt(t){return this._data.getRowByIndex(t)}getChanges(){return this._data.getChanges()}getEditedRows(){return this._data.getEditedRows()}getChangedRows(){return this._data.getChangedRows()}getChangedColumns(){return this._data.getChangedColumns()}getAddedRows(){return this._data.getAddedRows()}getRemovedRows(){return this._data.getRemovedRows()}getOriginalRow(t){return this._data.getOriginalRow(t)}getRowsWithState(t){return this._data.getRowsWithState(t)}undo(){}redo(){}clearHistory(){}getColumnDefs(){return this._colLayout.visibleLeaves}getAllColumnDefs(){return this._colLayout.leaves}getColumnCount(){return this._colLayout.visibleLeaves.length}applyColumns(t){const e=this._trigMgr.mkCtx("applyColumns",[t]);this._trigMgr.exec("before:applyColumns",e)&&(this._colLayout.setColumns(t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange()),e.result={columnCount:t.length},this._trigMgr.exec("after:applyColumns",e))}insertColumn(t,e){this._colLayout.addColumn(t,e),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}deleteColumn(t){this._colLayout.removeColumn(t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}_reorderColumn(t,e){var n,r;const s=this._colLayout.visibleLeaves.map(l=>l);if(t<0||e<0||t>=s.length||e>=s.length)return;const i=[...this._options.columns],[o]=i.splice(t,1);i.splice(e,0,o),this._options.columns=i,this.applyColumns(i),(r=(n=this._options).onColumnReorder)==null||r.call(n,{fromIndex:t,toIndex:e,field:o.field??""})}hideColumn(t){this._colLayout.hideColumn(t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}showColumn(t){this._colLayout.showColumn(t),this._recalcWidths(this._container.getBoundingClientRect().width),this._renderHeader(),this._doRender(...this._visRange())}getColumnIndex(t){return this._colLayout.getColumnIndex(t)}getFieldAt(t){var e;return((e=this._colLayout.getColumnByIndex(t))==null?void 0:e.field)??""}getColValues(t,e=!1){return this._data.getData().map(s=>s[t])}getUniqueValues(t,e=!1){return[...new Set(this.getColValues(t,e))]}setColWidths(t){}calcColWidths(t=!1){return[]}getSelections(){return this._rowMgr.getSelections()}getActiveRow(){return this._rowMgr.getActiveRow()}activate(t){this._rowMgr.activate(t),this._doRender(...this._visRange())}deselect(){this._rowMgr.deselect(),this._doRender(...this._visRange())}getChecked(){return this._rowMgr.getChecked()}getAllChecked(){return this._rowMgr.getAllChecked()}checkById(t){}addCheckById(t){}checkByValue(t,e){this._rowMgr.checkByValue(t,e),this._doRender(...this._visRange())}uncheckById(t){}uncheckAll(){this._rowMgr.uncheckAll(),this._doRender(...this._visRange())}orderBy(t,e="asc"){const s=this._trigMgr.mkCtx("orderBy",[t,e]);this._trigMgr.exec("before:orderBy",s)&&(this._sfMgr.sort(t,e),s.result={sortList:this._sfMgr.sortList},this._trigMgr.exec("after:orderBy",s))}resetOrder(){this._sfMgr.resetSort()}setFilter(t,e){const s=this._trigMgr.mkCtx("setFilter",[t,e]);this._trigMgr.exec("before:setFilter",s)&&(this._sfMgr.setFilter(t,e),s.result={field:t,filteredCount:this._data.rowCount},this._trigMgr.exec("after:setFilter",s))}resetFilter(t){this._sfMgr.resetFilter(t)}getFilterState(){return this._sfMgr.getFilterState()}restoreFilter(t){this._sfMgr.restoreFilter(t)}_applyFilters(){this._sfMgr.applyFilters()}freeze(t){this._colLayout.setFrozen(t),this._renderHeader(),this._doRender(...this._visRange())}mergeCells(t){this._mergeEngine.applyMergeCells(t),this._doRender(...this._visRange())}autoMerge(t){const e=this._colLayout.visibleLeaves,s=[],i=[];for(const o of t){const n=e.findIndex(r=>r.field===o);n>=0&&(s.push(n),i.push(o))}this._mergeEngine.applyAutoMerge(this._data.getData(),s,i),this._doRender(...this._visRange())}clearMerge(){this._mergeEngine.clear(),this._doRender(...this._visRange())}freezeRows(t){}groupBy(t){const e=this._trigMgr.mkCtx("groupBy",[t]);this._trigMgr.exec("before:groupBy",e)&&(this._grpMgr.groupBy(t),e.result={fields:t},this._trigMgr.exec("after:groupBy",e))}clearGroup(){this._grpMgr.clearGroup()}expandAll(){this._grpMgr.expandAll()}collapseAll(){this._grpMgr.collapseAll()}enableTree(){this._grpMgr.enableTree()}disableTree(){this._grpMgr.disableTree()}expandNodes(t,e=!0){this._grpMgr.expandNodes(t,e)}expandAllNodes(){this._grpMgr.expandAllNodes()}collapseAllNodes(){this._grpMgr.collapseAllNodes()}addTreeRow(t,e,s){}exportExcel(t){this._exportMgr.exportExcel(t)}exportCsv(t){this._exportMgr.exportCsv(t)}exportJson(t){this._exportMgr.exportJson(t)}print(t){this._exportMgr.print(t)}toArray(t=!0){const e=this._data.getData();if(t)return e;const s=this._colLayout.visibleLeaves;return e.map(i=>s.map(o=>i[o.field]))}jumpToRow(t){var e;this._rowMgr.selectSingle(t),(e=this._vs)==null||e.scrollToRow(t),this._doRender(...this._visRange())}jumpToCol(t){}getScrollPos(){var t,e;return{x:((t=this._renderer)==null?void 0:t.bodyWrapper.scrollLeft)??0,y:((e=this._renderer)==null?void 0:e.bodyWrapper.scrollTop)??0}}setFooter(t){this._options.footer=t,this._renderFooterEl()}getFooterData(){return this._footerMgr.computeValues()}getFooterValue(t){var e;return((e=this._footerMgr.computeValues().find(s=>s._field===t))==null?void 0:e._value)??null}_renderFooterEl(){this._footerMgr.render()}resize(t,e){t&&(this._container.style.width=`${t}px`),e&&(this._container.style.height=`${e}px`),this._onResize()}setTheme(t){this._container.setAttribute("data-og-theme",t)}setThemeVar(t,e){this._container.style.setProperty(t,e)}addTrigger(t,e){return this._trigMgr.add(t,e),this}removeTrigger(t,e){return this._trigMgr.remove(t,e),this}clearTriggers(t){return this._trigMgr.clear(t),this}_mkCtx(t,e){return this._trigMgr.mkCtx(t,e)}_trig(t,e){return this._trigMgr.exec(t,e)}destroy(){var t,e,s,i,o,n,r,l;this._destroyed||(this._destroyed=!0,this._renderer&&ct.unregister(this._renderer.bodyWrapper),this._trigMgr.clear(),(t=this._ro)==null||t.disconnect(),(e=this._vs)==null||e.destroy(),(s=this._filterPanel)==null||s.destroy(),(i=this._dnd)==null||i.destroy(),this._cmHandler&&this._container.removeEventListener("contextmenu",this._cmHandler),this._cmKbdHandler&&this._container.removeEventListener("keydown",this._cmKbdHandler),this._cmHandler=this._cmKbdHandler=null,(o=this._ctxMenu)==null||o.destroy(),(n=this._wsManager)==null||n.destroy(),(r=this._renderer)==null||r.destroy(),(l=this._liveRegion)==null||l.remove(),this._liveRegion=null,this._container.innerHTML="",this._container.classList.remove("og-container"),this.removeAllListeners())}};V._defaultOverrides=[],V._defaultStrategies=[],V.defaults={strategy(t,e){return V._defaultStrategies.push([t,e]),V}};let St=V;exports.OpenGrid=St;exports.buildTree=Rt;
|
|
90
|
-
//# sourceMappingURL=OpenGrid-tdspERot.cjs.map
|