@guiexpert/svelte-table 1.0.10 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@guiexpert/svelte-table",
3
+ "version": "4.0.0",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "types": "./index.d.ts",
7
+ "lib": {
8
+ "entryFile": "src/index.ts"
9
+ },
10
+ "scripts": {
11
+ "i": "pnpm i",
12
+ "build": "vite build",
13
+ "npm-pub:svelte-table": "npm publish --access public"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "import": "./index.js",
18
+ "require": "./index.cjs"
19
+ }
20
+ },
21
+ "dependencies": {
22
+ "tslib": "^2.3.0",
23
+ "@guiexpert/table": "workspace:^",
24
+ "preact": "^10.19.4"
25
+ },
26
+ "devDependencies": {
27
+ "svelte": "^4.2.1",
28
+ "svelte-check": "^2.10.2",
29
+ "svelte-jester": "^2.3.2",
30
+ "svelte-preprocess": "^5.0.4",
31
+ "@sveltejs/vite-plugin-svelte": "^2.5.2",
32
+ "@testing-library/svelte": "^4.0.5",
33
+ "@tsconfig/svelte": "^4.0.1",
34
+ "eslint-plugin-svelte3": "^4.0.0",
35
+
36
+ "@types/react": "^18.2.37",
37
+ "@types/react-dom": "^18.2.15",
38
+ "@types/node": "^20.11.17",
39
+ "vite": "^5.1.1",
40
+ "vite-plugin-dts": "^3.7.2",
41
+ "vite-plugin-eslint": "^1.8.1",
42
+ "vite-plugin-static-copy": "^0.17.0",
43
+ "vite-tsconfig-paths": "^4.2.1",
44
+ "vite-plugin-babel": "^1.2.0",
45
+ "@vitejs/plugin-react": "^4.1.1",
46
+ "ts-node": "10.9.1",
47
+ "tsconfig": "^7.0.0",
48
+ "typescript": "5.2.2"
49
+ }
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/svelte-table",
3
- "version": "1.0.10",
3
+ "version": "4.0.1",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -8,12 +8,43 @@
8
8
  "entryFile": "src/index.ts"
9
9
  },
10
10
  "scripts": {
11
- "npm-pub:svelte-table": "npm publish --access public"
11
+ "i": "pnpm i",
12
+ "patch-version": "node patch.js",
13
+ "build": "vite build",
14
+ "npm-pub": "npm publish --access public"
12
15
  },
13
16
  "exports": {
14
17
  ".": {
15
18
  "import": "./index.js",
16
19
  "require": "./index.cjs"
17
20
  }
21
+ },
22
+ "dependencies": {
23
+ "tslib": "^2.3.0",
24
+ "@guiexpert/table": "workspace:^",
25
+ "preact": "^10.19.4"
26
+ },
27
+ "devDependencies": {
28
+ "svelte": "^4.2.1",
29
+ "svelte-check": "^2.10.2",
30
+ "svelte-jester": "^2.3.2",
31
+ "svelte-preprocess": "^5.0.4",
32
+ "@sveltejs/vite-plugin-svelte": "^2.5.2",
33
+ "@testing-library/svelte": "^4.0.5",
34
+ "@tsconfig/svelte": "^4.0.1",
35
+ "eslint-plugin-svelte3": "^4.0.0",
36
+ "@types/react": "^18.2.37",
37
+ "@types/react-dom": "^18.2.15",
38
+ "@types/node": "^20.11.17",
39
+ "vite": "^5.1.1",
40
+ "vite-plugin-dts": "^3.7.2",
41
+ "vite-plugin-eslint": "^1.8.1",
42
+ "vite-plugin-static-copy": "^0.17.0",
43
+ "vite-tsconfig-paths": "^4.2.1",
44
+ "vite-plugin-babel": "^1.2.0",
45
+ "@vitejs/plugin-react": "^4.1.1",
46
+ "ts-node": "10.9.1",
47
+ "tsconfig": "^7.0.0",
48
+ "typescript": "5.2.2"
18
49
  }
19
- }
50
+ }
package/patch.js ADDED
@@ -0,0 +1,16 @@
1
+ import fs from 'fs';
2
+
3
+ const packageJsonPath = 'package.json';
4
+
5
+ try {
6
+ const pack = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
7
+ const currentVersion = pack.version;
8
+ const [major, minor, patch] = currentVersion.split('.').map(Number);
9
+ const newPatchVersion = `${major}.${minor}.${patch + 1}`;
10
+ pack.version = newPatchVersion;
11
+ fs.writeFileSync(packageJsonPath, JSON.stringify(pack, null, 2));
12
+ console.log(`${pack.name} -> version patched to ${newPatchVersion}.`);
13
+
14
+ } catch (error) {
15
+ console.error('Error:', error);
16
+ }
@@ -0,0 +1,38 @@
1
+ import { AreaIdent, AreaModelIf, CellRendererIf, DomServiceIf, RendererCleanupFnType } from "@guiexpert/table";
2
+
3
+
4
+ export class ComponentRendererWrapper implements CellRendererIf {
5
+
6
+ constructor(
7
+ private readonly Component:any
8
+ ) {
9
+ }
10
+
11
+ render(
12
+ cellDiv: HTMLDivElement,
13
+ rowIndex: number,
14
+ columnIndex: number,
15
+ areaIdent: AreaIdent,
16
+ areaModel: AreaModelIf,
17
+ cellValue: any,
18
+ _domService: DomServiceIf): RendererCleanupFnType | undefined {
19
+
20
+
21
+ const c = new this.Component({
22
+ target: cellDiv,
23
+ props: {
24
+ cellDiv,
25
+ rowIndex,
26
+ columnIndex,
27
+ areaIdent,
28
+ areaModel,
29
+ cellValue
30
+ }
31
+ });
32
+ return () => {
33
+ c.$destroy();
34
+ };
35
+ }
36
+
37
+
38
+ }
@@ -0,0 +1,67 @@
1
+ <script lang="ts">
2
+ import { createEventDispatcher, onMount } from 'svelte';
3
+ import { EventListenerIf, FocusModelIf, LicenseManager, SelectionModelIf, SimpleDomService, TableOptions, TableScope } from '../../table/src'; // "@guiexpert/table";
4
+
5
+ export let tableModel: any;
6
+ export let tableOptions = new TableOptions();
7
+ export let licenseKey: string | undefined;
8
+
9
+ let root: any;
10
+ const dispatch = createEventDispatcher();
11
+
12
+ onMount(() => {
13
+
14
+ const listener: EventListenerIf = {
15
+ onSelectionChanged(model: SelectionModelIf): void {
16
+ dispatch('selectionChanged', model);
17
+ },
18
+ onFocusChanged(model: FocusModelIf): void{
19
+ dispatch('focusChanged', model);
20
+ },
21
+ onCheckboxChanged: (evt: any) => {
22
+ dispatch('checkboxChanged', evt);
23
+ },
24
+
25
+ onContextmenu: (evt: any) => {
26
+ dispatch('contextmenu', evt);
27
+ },
28
+
29
+ onModelChanged: (evt: any) => {
30
+ dispatch('modelChanged', evt);
31
+ },
32
+
33
+ onMouseClicked: (evt: any) => {
34
+ dispatch('mouseClicked', evt);
35
+ },
36
+
37
+ onMouseDragging: (evt: any) => {
38
+ dispatch('mouseDragging', evt);
39
+ },
40
+
41
+ onMouseDraggingEnd: (evt: any) => {
42
+ dispatch('mouseDraggingEnd', evt);
43
+ },
44
+
45
+ onMouseMoved: (evt: any) => {
46
+ dispatch('mouseMoved', evt);
47
+ }
48
+ };
49
+
50
+ const tableScope = new TableScope(
51
+ root, tableModel, new SimpleDomService(), tableOptions, listener
52
+ );
53
+ tableScope.firstInit();
54
+ dispatch('tableReady', tableScope.getApi());
55
+
56
+ if (licenseKey) LicenseManager.getInstance().setLicenseKey(licenseKey);
57
+ });
58
+ </script>
59
+
60
+ <div
61
+ bind:this={root}
62
+ class="ge-table"
63
+ style="width: 100%; height: 100%; background-color: transparent; padding: 0; margin: 0"></div>
64
+
65
+ <style>
66
+
67
+ </style>
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default as GuiexpertTable } from "./GuiexpertTable.svelte";
2
+ export { ComponentRendererWrapper } from "./ComponentRendererWrapper";
@@ -0,0 +1,2 @@
1
+ /// <reference types="svelte" />
2
+ /// <reference types="vite/client" />
@@ -0,0 +1,10 @@
1
+ const sveltePreprocess = require("svelte-preprocess");
2
+
3
+ module.exports = {
4
+ // Consult https://github.com/sveltejs/svelte-preprocess
5
+ // for more information about preprocessors
6
+ preprocess: sveltePreprocess(),
7
+ vitePlugin: {
8
+ prebundleSvelteLibraries: false
9
+ }
10
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "strict": true,
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
8
+ "moduleResolution": "node",
9
+ "allowSyntheticDefaultImports": true,
10
+ "esModuleInterop": false,
11
+ "jsx": "preserve",
12
+ "jsxImportSource": "svelte-js",
13
+ "noEmit": true,
14
+ "isolatedModules": true,
15
+ "skipLibCheck": true,
16
+ "types": [
17
+ ],
18
+ },
19
+ "files": [],
20
+ "include": ["src"],
21
+ "exclude": ["node_modules", "dist"],
22
+ "references": [
23
+ {
24
+ "path": "./tsconfig.lib.json"
25
+ },
26
+ {
27
+ "path": "./tsconfig.spec.json"
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc"
5
+ },
6
+ "include": [
7
+ "src/**/*"
8
+ ],
9
+ "exclude": [
10
+ "**/*.spec.ts",
11
+ "**/*_spec.ts",
12
+ "public/*"
13
+ ]
14
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": [
7
+ "jest",
8
+ "node"
9
+ ]
10
+ },
11
+ "include": [
12
+ "**/*.spec.ts",
13
+ "**/*.spec.tsx",
14
+ "**/*.spec.js",
15
+ "**/*.spec.jsx",
16
+ "**/*.d.ts"
17
+ ]
18
+ }
@@ -0,0 +1,70 @@
1
+
2
+ import {defineConfig} from "vite";
3
+ import {svelte} from '@sveltejs/vite-plugin-svelte';
4
+ import dts from "vite-plugin-dts";
5
+ import {join} from "path";
6
+ import {viteStaticCopy} from "vite-plugin-static-copy";
7
+
8
+
9
+ export default defineConfig({
10
+ cacheDir: "../../node_modules/.vite/svelte-table",
11
+
12
+ plugins: [
13
+ dts({
14
+ entryRoot: "src",
15
+ tsconfigPath: join(__dirname, "tsconfig.lib.json"),
16
+
17
+ }),
18
+ svelte({
19
+ prebundleSvelteLibraries: true
20
+ }),
21
+
22
+ viteStaticCopy({
23
+ targets: [
24
+ {
25
+ src: 'README.md',
26
+ dest: './'
27
+ },
28
+ {
29
+ src: 'package.json',
30
+ dest: './'
31
+ }
32
+ ]
33
+ })
34
+ ],
35
+
36
+ // Uncomment this if you are using workers.
37
+ // worker: {
38
+ // plugins: [
39
+ // viteTsConfigPaths({
40
+ // root: '../../',
41
+ // }),
42
+ // ],
43
+ // },
44
+
45
+ // Configuration for building your library.
46
+ // See: https://vitejs.dev/guide/build.html#library-mode
47
+ build: {
48
+ lib: {
49
+ // Could also be a dictionary or array of multiple entry points.
50
+ entry: "src/index.ts",
51
+ name: "svelte-table",
52
+ fileName: "index",
53
+ // Change this to the formats you want to support.
54
+ // Don't forgot to update your package.json as well.
55
+ formats: ["es", "cjs"]
56
+ },
57
+ rollupOptions: {
58
+ // External packages that should not be bundled into your library.
59
+ external: ["svelte", "react-dom", "react/jsx-runtime"]
60
+ }
61
+ },
62
+ resolve: {
63
+ alias: [
64
+ {
65
+ find: /@guiexpert\/table/,
66
+ replacement: join(__dirname, '..', 'table', 'src'),
67
+ },
68
+ ],
69
+ }
70
+ });
package/index.cjs DELETED
@@ -1,20 +0,0 @@
1
- "use strict";var ue=Object.defineProperty;var Se=(l,e,t)=>e in l?ue(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var k=(l,e,t)=>(Se(l,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("svelte");function L(){}function le(l){return l()}function se(){return Object.create(null)}function P(l){l.forEach(le)}function re(l){return typeof l=="function"}function ge(l,e){return l!=l?e==e:l!==e||l&&typeof l=="object"||typeof l=="function"}function fe(l){return Object.keys(l).length===0}function me(l,e,t){l.insertBefore(e,t||null)}function ne(l){l.parentNode&&l.parentNode.removeChild(l)}function be(l){return document.createElement(l)}function ye(l,e,t){t==null?l.removeAttribute(e):l.getAttribute(e)!==t&&l.setAttribute(e,t)}function ve(l){return Array.from(l.childNodes)}function _(l,e,t,s){t==null?l.style.removeProperty(e):l.style.setProperty(e,t,s?"important":"")}let z;function B(l){z=l}const O=[],G=[];let $=[];const ie=[],xe=Promise.resolve();let N=!1;function Ce(){N||(N=!0,xe.then(ae))}function j(l){$.push(l)}const V=new Set;let F=0;function ae(){if(F!==0)return;const l=z;do{try{for(;F<O.length;){const e=O[F];F++,B(e),we(e.$$)}}catch(e){throw O.length=0,F=0,e}for(B(null),O.length=0,F=0;G.length;)G.pop()();for(let e=0;e<$.length;e+=1){const t=$[e];V.has(t)||(V.add(t),t())}$.length=0}while(O.length);for(;ie.length;)ie.pop()();N=!1,V.clear(),B(l)}function we(l){if(l.fragment!==null){l.update(),P(l.before_update);const e=l.dirty;l.dirty=[-1],l.fragment&&l.fragment.p(l.ctx,e),l.after_update.forEach(j)}}function Ee(l){const e=[],t=[];$.forEach(s=>l.indexOf(s)===-1?e.push(s):t.push(s)),t.forEach(s=>s()),$=e}const Ae=new Set;function Me(l,e){l&&l.i&&(Ae.delete(l),l.i(e))}function Re(l,e,t){const{fragment:s,after_update:i}=l.$$;s&&s.m(e,t),j(()=>{const o=l.$$.on_mount.map(le).filter(re);l.$$.on_destroy?l.$$.on_destroy.push(...o):P(o),l.$$.on_mount=[]}),i.forEach(j)}function Te(l,e){const t=l.$$;t.fragment!==null&&(Ee(t.after_update),P(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function De(l,e){l.$$.dirty[0]===-1&&(O.push(l),Ce(),l.$$.dirty.fill(0)),l.$$.dirty[e/31|0]|=1<<e%31}function Ie(l,e,t,s,i,o,r=null,a=[-1]){const n=z;B(l);const d=l.$$={fragment:null,ctx:[],props:o,update:L,not_equal:i,bound:se(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(n?n.$$.context:[])),callbacks:se(),dirty:a,skip_bound:!1,root:e.target||n.$$.root};r&&r(d.root);let h=!1;if(d.ctx=t?t(l,e.props||{},(c,S,...f)=>{const p=f.length?f[0]:S;return d.ctx&&i(d.ctx[c],d.ctx[c]=p)&&(!d.skip_bound&&d.bound[c]&&d.bound[c](p),h&&De(l,c)),S}):[],d.update(),h=!0,P(d.before_update),d.fragment=s?s(d.ctx):!1,e.target){if(e.hydrate){const c=ve(e.target);d.fragment&&d.fragment.l(c),c.forEach(ne)}else d.fragment&&d.fragment.c();e.intro&&Me(l.$$.fragment),Re(l,e.target,e.anchor),ae()}B(n)}class Fe{constructor(){k(this,"$$");k(this,"$$set")}$destroy(){Te(this,1),this.$destroy=L}$on(e,t){if(!re(t))return L;const s=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return s.push(t),()=>{const i=s.indexOf(t);i!==-1&&s.splice(i,1)}}$set(e){this.$$set&&!fe(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Oe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Oe);class D{constructor(){this.alreadySet=!1}static getInstance(){return D.instance||(D.instance=new D),D.instance}setLicenseKey(e){if(e&&!this.alreadySet){const t=document.createElement("meta");t.content="license="+e,t.name="guiexperttable",document.getElementsByTagName("head")[0].appendChild(t),this.alreadySet=!0}}}function K(l){return l&&l.type==="TreeRow"}function X(l){return l&&l.type==="AreaModelTree"}class Y{constructor(e=-1,t=-1,s=-1,i=-1,o,r,a,n=0,d=0,h=0,c=""){this.rowIndex=e,this.rowTop=t,this.columnIndex=s,this.columnLeft=i,this.areaIdent=o,this.sideIdent=r,this.originalEvent=a,this.clickCount=n,this.draggingX=d,this.draggingY=h,this.action=c}clone(){return new Y(this.rowIndex,this.rowTop,this.columnIndex,this.columnLeft,this.areaIdent,this.sideIdent,this.originalEvent,this.clickCount,this.draggingX,this.draggingY,this.action)}}class I{constructor(e=">",t="",s=[]){this.content=e,this.style=t,this.classes=s}}class de{constructor(e=new I(">","transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",["gt-table-tree-arrow-expanded"]),t=new I(">","",["ge-table-tree-arrow-collapsed"]),s=new I(">","color:transparent;",["gt-table-tree-arrow-hidden"]),i=new I("↕","",["gt-table-tree-arrow-expanded-all"])){this.arrowExpanded=e,this.arrowCollapsed=t,this.arrowPlaceholder=s,this.arrowExpandCollapseAll=i}}class he{constructor(e=new I("↑","",["ge-header-sorted-asc"]),t=new I("↓","",["ge-header-sorted-desc"]),s=new I("↑","color:transparent;",[])){this.iconAsc=e,this.iconDesc=t,this.iconPlaceholder=s}}class Le{constructor(e){this.domService=e}setStyle(e,t,s){return this.domService.setStyle(e,t,s),e}applyStyle(e,t){for(const s in t)this.domService.setStyle(e,s,t[s]);return e}applyDisplayNoneStyle(e){return this.domService.setStyle(e,"display","none"),e}applyDisplayBlockStyle(e){return this.domService.setStyle(e,"display","block"),e}applyStyleInPx(e,t){return Object.entries(t).forEach(([s,i])=>this.domService.setStyle(e,s,i+"px")),e}applyStylePosistionRelative(e){return this.domService.setStyle(e,"position","relative"),this.domService.setStyle(e,"overflow","clip"),e}applyStylePosistionAbsolute(e){return this.domService.setStyle(e,"position","absolute"),e}applyStyleFullSize(e){return this.domService.setStyle(e,"width","100%"),this.domService.setStyle(e,"height","100%"),e}applyStyleOverflowAuto(e="auto",t="auto",s){return this.domService.setStyle(s,"overflow-x",e),this.domService.setStyle(s,"overflow-y",t),s}applyStyleNoPadding(e){return this.domService.setStyle(e,"padding","0"),this.domService.setStyle(e,"margin","0"),this.domService.setStyle(e,"border","0"),e}appendRelativeChildDiv(e){const t=this.applyStylePosistionRelative(this.applyStyleFullSize(this.applyStyleNoPadding(this.domService.createElement("div"))));return this.domService.appendChild(e,t),this.applyStylePosistionAbsolute(e),{parent:e,child:t,cache:{}}}appendText(e,t){const s=this.domService.createText(t);return this.domService.appendChild(e,s),s}addClass(e,t){return e.includes(" ")?e.split(" ").forEach(s=>this.domService.addClass(t,s)):this.domService.addClass(t,e),t}removeClass(e,t){return e.includes(" ")?e.split(" ").forEach(s=>this.domService.removeClass(t,s)):this.domService.removeClass(t,e),t}addClasses(e,t){if(e)for(const s of e)this.domService.addClass(t,s);return t}setAttribute(e,t,s){return t&&s&&this.domService.setAttribute(e,t,s),e}createAreaDivWithClass(e,t,s,i){const o=this.domService.createElement("div");return this.addClass(e,o),this.domService.setAttribute(o,"data-area",s),this.domService.setAttribute(o,"data-side",i),this.domService.appendChild(t,o),o}createDivWithClass(e,t){const s=this.domService.createElement("div");return this.addClass(e,s),this.domService.appendChild(t,s),s}addRowDiv(e,t,s=-1,i,o,r=""){const a=t.index??-1,n=this.getDivOrCreateDiv(a,e);if(this.domService.addClass(n,"ge-table-row-div"),this.domService.addClass(n,`ge-table-row-div-${t.index}`),i==="body"&&o==="center"){const d=((t==null?void 0:t.index)??0)%2===0?"even":"odd";this.domService.addClass(n,`ge-table-row-${d}`)}if(this.domService.setStyle(n,"display","clip"),this.domService.setStyle(n,"position","absolute"),this.domService.setStyle(n,"left",`${t.left}px`),this.domService.setStyle(n,"top",`${t.top}px`),this.domService.setStyle(n,"width",`${t.width}px`),this.domService.setStyle(n,"height",`${t.height}px`),this.domService.setAttribute(n,"data-row-index",`${s}`),this.domService.setAttribute(n,"data-area",`${i}`),r){const d=this.domService.createText(r);this.domService.appendChild(n,d)}return this.domService.appendChild(e.child,n),n}addColumnDiv(e,t,s=-1,i=-1,o,r,a="",n,d,h=void 0,c){const S=d==null?void 0:d.treeOptions,f=d==null?void 0:d.showCheckboxWihoutExtraColumn,p=this.domService.createElement("div");this.domService.addClass(p,"ge-table-col-div"),this.domService.addClass(p,`ge-table-col-div-${t.index}`),this.domService.setAttribute(p,"data-col-index",`${t.index}`),this.domService.setAttribute(p,"data-row-index",`${s}`),this.domService.setAttribute(p,"data-area",`${o}`);const m=((t==null?void 0:t.index)??0)%2===0?"even":"odd";if(o==="body"&&r==="center"&&this.domService.addClass(p,`ge-table-column-${m}`),this.domService.setStyle(p,"display","clip"),this.domService.setStyle(p,"position","absolute"),this.domService.setStyle(p,"left",`${t.left}px`),this.domService.setStyle(p,"top",`${t.top}px`),this.domService.setStyle(p,"width",`${t.width}px`),this.domService.setStyle(p,"height",`${t.height}px`),n&&n!=="none"&&(this.domService.addClass(p,"ge-table-col-tree"),this.addArrowDiv(p,n,S,s,i,o)),f&&i===0&&h&&this.addCheckboxToDiv(p,h,o,s),a){const g=n!=="none"&&i===0;this.addLabelDiv(p,a,g,s,i,o)}return c&&this.addSortedIcon(p,c,d==null?void 0:d.sortedOptions,i),this.domService.appendChild(e,p),p}addCheckboxToDiv(e,t,s,i){const o=this.domService.createElement("div"),r=t==="full"?"checked":"";return o.innerHTML=`
2
- <input
3
- type="checkbox"
4
- data-area="${s}"
5
- data-row-index="${i}"
6
- data-input-type="checkbox"
7
- ${r}
8
- class="ge-table-row-checkbox"> `,this.domService.setStyle(o,"display","inline"),this.domService.setStyle(o,"width","inherit"),this.domService.setAttribute(o,"data-row-index",`${i}`),this.domService.appendChild(e,o),o}addLabelDiv(e,t="",s=!1,i=-1,o=-1,r="body"){const a=this.domService.createElement("div");if(this.domService.addClass(a,"ge-table-label-div"),this.domService.setStyle(a,"position","relative"),this.domService.setStyle(a,"background","transparent"),this.domService.setStyle(a,"width","100%"),this.domService.setStyle(a,"height","100%"),this.domService.setAttribute(a,"data-row-index",`${i}`),this.domService.setAttribute(a,"data-col-index",`${o}`),this.domService.setAttribute(a,"data-area",`${r}`),t)if(s){const n=this.domService.createText(t);this.domService.appendChild(a,n)}else{const n=this.domService.createElement("div");this.domService.appendChild(a,n);const d=this.domService.createText(t);this.domService.addClass(n,"ge-table-label"),this.domService.appendChild(n,d),this.domService.setAttribute(n,"data-row-index",`${i}`),this.domService.setAttribute(n,"data-col-index",`${o}`),this.domService.setAttribute(n,"data-area",`${r}`)}return this.domService.appendChild(e,a),a}addSortedIcon(e,t="",s=new he,i=-1){const o=this.domService.createElement("div");this.domService.addClass(o,"ge-table-sorted-icon-div"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,"top","0"),this.domService.setStyle(o,"right","0"),this.domService.setStyle(o,"width","20px"),this.domService.setStyle(o,"background","transparent"),this.domService.setStyle(o,"cursor","pointer"),this.domService.setAttribute(o,"data-col-index",`${i}`),this.domService.setAttribute(o,"data-area","header");let r;t==="asc"?r=s.iconAsc:t==="desc"?r=s.iconDesc:r=s.iconPlaceholder;const a=r.content,n=this.domService.createText(a);this.domService.appendChild(o,n),r.style&&this.applyStyleString(o,r.style);for(const d of r.classes)this.domService.addClass(o,d);return this.domService.appendChild(e,o),o}addArrowDiv(e,t="none",s=new de,i=-1,o=-1,r="body"){const a=this.domService.createElement("div");this.domService.addClass(a,"ge-table-tree-arrow-div"),this.domService.setStyle(a,"display","inline-block"),this.domService.setStyle(a,"position",""),this.domService.setStyle(a,"width","20px"),this.domService.setStyle(a,"background","transparent"),this.domService.setStyle(a,"cursor","pointer"),this.domService.setAttribute(a,"data-row-index",`${i}`),this.domService.setAttribute(a,"data-col-index",`${o}`),this.domService.setAttribute(a,"data-area",`${r}`);let n;t==="expanded"?n=s.arrowExpanded:t==="collapsed"?n=s.arrowCollapsed:n=s.arrowPlaceholder;const d=n.content,h=this.domService.createText(d);this.domService.appendChild(a,h),n.style&&this.applyStyleString(a,n.style);for(const c of n.classes)this.domService.addClass(a,c);return this.domService.appendChild(e,a),a}addColumnBorderDivs(e,t,s,i,o){if(e.verticalBorderVisible){const r=`ge-table-${i}-${o}-vertical-border`;this.addVerticalBorder(s,t,r)}if(e.horizontalBorderVisible){const r=`ge-table-${i}-${o}-horizontal-border`;this.addHorizontalBorder(s,t,r)}return t}addHorizontalBorder(e,t,s="ge-table-body-center-horizontal-border"){const i=this.domService.createElement("div");return this.domService.addClass(i,s),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${e.left}px`),this.domService.setStyle(i,"top",`${e.top}px`),this.domService.setStyle(i,"width",`${e.width}px`),this.domService.setStyle(i,"height","1px"),this.domService.appendChild(t,i),i}addFocusBorderDivs(e,t,s){let i=this.domService.createElement("div");return this.domService.addClass(i,"ge-table-focus-border"),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left}px`),this.domService.setStyle(i,"top",`${t.top}px`),this.domService.setStyle(i,"width","1px"),this.domService.setStyle(i,"height",`${t.height}px`),this.applyStyle(i,s),this.domService.appendChild(e,i),i=this.domService.createElement("div"),this.domService.addClass(i,"ge-table-focus-border"),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left+t.width-1}px`),this.domService.setStyle(i,"top",`${t.top}px`),this.domService.setStyle(i,"width","1px"),this.domService.setStyle(i,"height",`${t.height}px`),this.applyStyle(i,s),this.domService.appendChild(e,i),i=this.domService.createElement("div"),this.domService.addClass(i,"ge-table-focus-border"),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left}px`),this.domService.setStyle(i,"top",`${t.top}px`),this.domService.setStyle(i,"width",`${t.width}px`),this.domService.setStyle(i,"height","1px"),this.applyStyle(i,s),this.domService.appendChild(e,i),i=this.domService.createElement("div"),this.domService.addClass(i,"ge-table-focus-border"),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left}px`),this.domService.setStyle(i,"top",`${t.top+t.height-1}px`),this.domService.setStyle(i,"width",`${t.width}px`),this.domService.setStyle(i,"height","1px"),this.applyStyle(i,s),this.domService.appendChild(e,i),e}addVerticalBorder(e,t,s="ge-table-body-center-vertical-border"){const i=this.domService.createElement("div");return this.domService.addClass(i,s),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${e.left}px`),this.domService.setStyle(i,"top",`${e.top}px`),this.domService.setStyle(i,"width","1px"),this.domService.setStyle(i,"height",`${e.height}px`),this.domService.appendChild(t,i),i}addDiv(e,t,s=""){const i=this.domService.createElement("div");return s&&this.domService.addClass(i,s),this.domService.setStyle(i,"display","clip"),this.domService.setStyle(i,"position","absolute"),this.domService.setStyle(i,"left",`${t.left}px`),this.domService.setStyle(i,"top",`${t.top}px`),this.domService.setStyle(i,"width",`${t.width}px`),this.domService.setStyle(i,"height",`${t.height}px`),this.domService.appendChild(e,i),i}applyStyleString(e,t){const s=t.split(";").map(i=>i.trim()).filter(i=>i);for(const i of s){const[o,r]=i.split(":");this.domService.setStyle(e,o.trim(),r.trim())}}getDivOrCreateDiv(e,t){let s=t.cache[e];return s?(s.innerText="",s):(s=this.domService.createElement("div"),t.cache[e]=s,s)}}const q=l=>l==="header"?"header":l==="footer"?"footer":"body";class $e{constructor(e,t){if(this.rowIdx=-1,this.colIdx=-1,this.action=null,this.inputType=null,this.className="",e!==null&&(e instanceof HTMLDivElement||e instanceof HTMLSpanElement||e instanceof HTMLInputElement)){this.className=e.className,this.action=e.getAttribute("data-ge-action"),this.inputType=e.getAttribute("data-input-type"),this.rowIdx=Number(e.getAttribute("data-row-index")),this.colIdx=Number(e.getAttribute("data-col-index"));const s=e.getAttribute("data-area");if(s&&(this.areaIdent=q(s),this.areaModel=t.tableModel.getAreaModel(this.areaIdent),this.row=this.areaModel.getRowByIndex(this.rowIdx)),e instanceof HTMLInputElement){const i=e;this.value=i.value}}}}class _e{constructor(e){this.tableScope=e,this.expandedAll=!0,this.mouseDown=!1,this.dragging=!1,this.tableScope.hostElement.addEventListener("click",this.onHostElementClicked.bind(this)),this.tableScope.hostElement.addEventListener("dblclick",this.onHostElementDblClicked.bind(this)),this.tableScope.hostElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.tableScope.hostElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.tableScope.hostElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.tableScope.hostElement.addEventListener("contextmenu",this.onContextmenu.bind(this)),this.tableScope.hostElement._MouseHandler="true",this.tableScope.scrollViewport.addEventListener("scroll",this.tableScope.adjustAfterScrolling.bind(this.tableScope)),[window,this.tableScope.hostElement].forEach(t=>t.addEventListener("resize",this.tableScope.adjustContainersAndRows.bind(this.tableScope)))}onContextmenu(e){this.mouseEvent=e;const t=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.contextmenu(t)}onHostElementClicked(e){const t=new $e(e.target,this.tableScope);if(t.action==="toggleExpandCollapseAll")this.expandedAll=!this.expandedAll,this.tableScope.toggleExpandCollapseAll(this.expandedAll),e.preventDefault(),e.stopPropagation();else if(t.inputType==="checkbox"&&t.areaIdent)this.tableScope.toggleRowCheckbox(t.rowIdx,t.colIdx,t.areaIdent),e.preventDefault(),e.stopPropagation();else if(K(t.row)&&t.areaModel){const s=t.colIdx===this.getArrowColumnIndex()&&e.altKey,i=t.className.includes("ge-table-tree-arrow-div");if(console.info(i,s),s||i){e.preventDefault(),e.stopPropagation();const o=t.row;o.expanded=!o.expanded,"recalcVisibleTreeRows"in t.areaModel&&t.areaModel.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(o)}}if(t.areaIdent==="body"&&this.tableScope.tableOptions.getFocusModel){const s=this.tableScope.tableOptions.getFocusModel();s==null||s.clear(),s==null||s.setFocus(t.rowIdx,t.colIdx)}this.publishGeMouseEvent(e,1)}onHostElementDblClicked(e){if(e.target instanceof HTMLElement){const t=e.target,s=t.getAttribute("data-area"),i=q(s),o=Number(t.getAttribute("data-row-index")),r=Number(t.getAttribute("data-col-index")),a=this.tableScope.tableModel.getAreaModel(i);if(s&&i==="header")this.tableScope.tableModel.isSortable(r)&&(this.tableScope.clearSelection(),this.tableScope.onHeaderDblClicked(e,o,r));else if(t.getAttribute("data-row-index")){const n=a.getRowByIndex(o);if(s&&i==="body"&&a.isEditable(o,r)&&(this.tableScope.clearSelection(),this.tableScope.initRenderEditor(o,r)),K(n)&&r===this.getArrowColumnIndex()){e.preventDefault(),e.stopPropagation();const d=n;d.expanded=!d.expanded,"recalcVisibleTreeRows"in a&&a.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(d)}}}this.publishGeMouseEvent(e,2)}publishGeMouseEvent(e,t){var s;this.mouseEvent=e,this.geMouseEventOld=(s=this.geMouseEvent)==null?void 0:s.clone(),this.geMouseEvent=this.tableScope.createGeMouseEvent(e),this.geMouseEvent&&(this.geMouseEvent.clickCount=t),this.tableScope.onMouseClicked(this.geMouseEvent,this.geMouseEventOld)}updateCollapsedExpandedState(e){var s,i,o,r,a;const t=(i=(s=this.tableScope.tableOptions)==null?void 0:s.autoRestoreOptions)==null?void 0:i.getRowId;if(t){const n=(o=this.tableScope.storeStateCollapsedExpandService)==null?void 0:o.collapsedExpandedStateGet().mode,d=n==="collapsed"&&!e.expanded||n==="expanded"&&e.expanded,h=n==="collapsed"&&e.expanded||n==="expanded"&&!e.expanded,c=t(e.data);d?(r=this.tableScope.storeStateCollapsedExpandService)==null||r.collapsedStateIdsPush(c):h&&((a=this.tableScope.storeStateCollapsedExpandService)==null||a.collapsedStateIdsRemove(c))}}getArrowColumnIndex(){return this.tableScope.tableModel.isRowCheckboxVisible()?1:0}onMouseDown(e){this.mouseEvent=e,this.startMouseEvent=this.tableScope.createGeMouseEvent(this.mouseEvent),this.tableScope.onMouseDown(this.startMouseEvent),this.mouseDown=!0}onMouseMove(e){this.mouseEvent=e,this.mouseDown?(this.dragging=!0,requestAnimationFrame(this.mouseDraggingOnFrame.bind(this))):requestAnimationFrame(this.mouseMoveOnFrame.bind(this))}onMouseUp(e){this.mouseEvent=e,this.dragging&&requestAnimationFrame(this.mouseDraggingEndOnFrame.bind(this)),this.mouseDown=!1,this.dragging=!1}mouseDraggingOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingOnFrame(t)}}mouseDraggingEndOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingEndOnFrame(t)}}mouseMoveOnFrame(){if(this.mouseEvent){const e=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.mouseMove(e)}}}class Be{constructor(e){this.tableScope=e}updateCells(e,t=!1){this.tableScope.updateCells(e,t)}externalFilterChanged(){this.tableScope.externalFilterChanged()}scrollToPixel(e=0,t=0){this.tableScope.scrollToPixel(e,t)}scrollToIndex(e=0,t=0){this.tableScope.scrollToIndex(e,t)}setHeaderVisible(e=!0){}setColumnVisible(e,t=!0){}isColumnVisible(e){return!0}isHeaderVisible(){return!0}setFooterVisible(e=!0){}isFooterVisible(){return!0}repaint(){this.tableScope.repaint()}}class U{constructor(e){this.getStorageKeyFn=e}autoConvertMapToObject(e){const t={};if(e instanceof Map){const s=e;for(const i of[...s]){const[o,r]=i;t[o]=r}}return t}checkAndPersistItem(e,t){const s=this.getStorageKeyFn;if(s){const i=s();if(i){const o=i+e;if((t+"").includes("Map")){const r=this.autoConvertMapToObject(t);this.persistItem(o,r)}else this.persistItem(o,t)}}}persistItem(e,t){t?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}loadFromLocalStorage(e){const t=localStorage.getItem(e);return t?JSON.parse(t):null}}class We extends U{constructor(e){super(e),this.SCROLL_STATE="scrollState",this.scrollOffset=[0,0],this.load()}getScrollOffset(){return this.scrollOffset}updateScrollOffset(e){this.scrollOffset=e,this.checkAndPersistItem(this.SCROLL_STATE,this.scrollOffset)}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const s=t+this.SCROLL_STATE;let i=this.loadFromLocalStorage(s);this.scrollOffset=i||[0,0]}}}}class Pe{constructor(e="collapsed",t=[],s=!1,i=!1){this.mode=e,this.rowIds=t,this.allCollapsed=s,this.allExpanded=i}}class He extends U{constructor(e){super(e),this.COLLAPSED_EXPANDED_STATE="collapsedExpandedState",this.collapsedExpandedState=new Pe,this.load()}collapsedExpandedStateGet(){return this.collapsedExpandedState}collapsedExpandedStateIncludes(e){return this.collapsedExpandedState.rowIds.includes(e)}collapsedStateIdsPush(e){this.collapsedExpandedState.rowIds.includes(e)||(this.collapsedExpandedState.rowIds.push(e),this.collapsedExpandedState.allCollapsed=!1,this.collapsedExpandedState.allExpanded=!1,this.persist())}collapsedStateIdsRemove(e){const t=this.collapsedExpandedState.rowIds.indexOf(e);t!==-1&&(this.collapsedExpandedState.rowIds.splice(t,1),this.collapsedExpandedState.allCollapsed=!1,this.collapsedExpandedState.allExpanded=!1,this.persist())}collapsedStateAll(e){this.collapsedExpandedState.rowIds=[],this.collapsedExpandedState.mode=e?"collapsed":"expanded",this.collapsedExpandedState.allCollapsed=!e,this.collapsedExpandedState.allExpanded=e,this.persist()}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const s=t+this.COLLAPSED_EXPANDED_STATE,i=this.loadFromLocalStorage(s);i&&(this.collapsedExpandedState=i)}}}persist(){this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE,this.collapsedExpandedState)}}class ke extends U{constructor(e){super(e),this.SORTING_STATE="sortingState",this.sortItems=[],this.load()}getSortItems(){return this.sortItems}setSortItems(e){this.sortItems=e,this.checkAndPersistItem(this.SORTING_STATE,this.sortItems)}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const s=t+this.SORTING_STATE;let i=this.loadFromLocalStorage(s);this.sortItems=i||[]}}}}class T{constructor(e=0,t=0,s=0,i=0,o){this.left=e,this.width=t,this.height=s,this.top=i,this.index=o}}class Ve{constructor(e,t,s,i){this.hostElement=e,this.tableModel=t,this.dom=s,this.tableOptions=i,this.scrollTop=0,this.areaBodyWestGeo=new T,this.areaBodyCenterGeo=new T,this.areaBodyEastGeo=new T;const o=this.hostElement;o.innerText="",this.dom.setAttribute(o,"tabindex","0"),this.dom.setStyle(this.dom.addClass("ge-table",o),"position","relative"),this.hoverRow=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-hover-row",o)),this.hoverColumn=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-hover-column",o)),this.areaHeaderWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-west",o,"header","west"))),this.areaHeaderCenter=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-center",o,"header","center"))),this.areaHeaderEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-header ge-table-header-east",o,"body","east"))),this.areaBodyWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-body ge-table-body-west",o,"body","west"))),this.areaBodyEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-body ge-table-body-east",o,"body","east"))),this.areaFooterWest=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-west",o,"footer","west"))),this.areaFooterCenter=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-center",o,"footer","center"))),this.areaFooterEast=s.appendRelativeChildDiv(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-footer ge-table-footer-east",o,"footer","east"))),this.scrollViewport=s.applyStyleOverflowAuto(this.tableOptions.overflowX??"auto",this.tableOptions.overflowY??"auto",s.applyStyleNoPadding(s.applyStylePosistionAbsolute(s.createAreaDivWithClass("ge-table-scroll-viewport",o,"body","center")))),this.contentWrapperDiv=s.applyStyleNoPadding(s.applyStylePosistionRelative(s.createDivWithClass("ge-table-scroll-content-wrapper",this.scrollViewport))),this.contentDiv=s.applyStyleNoPadding(s.applyStylePosistionRelative(s.createDivWithClass("ge-table-scroll-content",this.contentWrapperDiv))),this.areaBodyCenter=s.appendRelativeChildDiv(s.createDivWithClass("ge-table-body-center",this.contentDiv)),this.borderHeaderBottom=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-header-border",o)),this.borderFixedWest=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-west-fixed-column-border",o)),this.borderFixedEast=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-east-fixed-column-border",o)),this.borderFooterTop=s.applyStylePosistionAbsolute(s.createDivWithClass("ge-table-footer-border",o))}adjustContainersAndRows(){const e=this.tableModel.getPadding(),t=this.hostElement.clientWidth,s=this.hostElement.clientHeight;this.dom.applyStyle(this.scrollViewport,{width:`${t-e.left}px`,height:`${s-e.top}px`,top:`${e.top}px`,left:`${e.left}px`}),this.scrollTop=this.scrollViewport.scrollTop,this.dom.applyStyle(this.contentDiv,{width:`${this.scrollViewport.clientWidth}px`,height:`${this.scrollViewport.clientHeight}px`,top:`${this.scrollTop}px`,left:`${this.scrollViewport.scrollLeft}px`}),this.areaBodyWestGeo.width=e.left,this.areaBodyWestGeo.height=s-e.top-e.bottom,this.areaBodyWestGeo.top=e.top,this.areaBodyWestGeo.left=0,this.dom.applyStyleInPx(this.areaBodyWest.parent,this.areaBodyWestGeo),this.tableOptions.fixedWestSeparatorBorderVisible&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedWest,{width:"1px",height:`${this.areaBodyWestGeo.height}px`,top:`${this.areaBodyWestGeo.top}px`,left:`${this.areaBodyWestGeo.width}px`})):this.dom.applyDisplayNoneStyle(this.borderFixedWest),this.areaBodyEastGeo.width=e.right,this.areaBodyEastGeo.height=s-e.top-e.bottom,this.areaBodyEastGeo.top=e.top,this.areaBodyEastGeo.left=t-e.right,this.dom.applyStyleInPx(this.areaBodyEast.parent,this.areaBodyEastGeo),this.tableOptions.fixedEastSeparatorBorderVisible&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedEast,{width:"1px",height:`${this.areaBodyEastGeo.height}px`,top:`${this.areaBodyEastGeo.top}px`,left:`${this.areaBodyEastGeo.left}px`})):this.dom.applyDisplayNoneStyle(this.borderFixedEast),this.areaBodyCenterGeo.width=t-e.left-e.right,this.areaBodyCenterGeo.height=s-e.top-e.bottom,this.areaBodyCenterGeo.top=0,this.areaBodyCenterGeo.left=0,this.dom.applyStyleInPx(this.areaBodyCenter.parent,this.areaBodyCenterGeo),this.dom.applyStyle(this.areaHeaderCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.top}px`,top:"0",left:`${e.left}px`}),this.dom.applyStyle(this.areaHeaderWest.parent,{width:`${e.left}px`,height:`${e.top}px`,top:"0",left:"0"}),this.dom.applyStyle(this.areaHeaderEast.parent,{width:`${e.right}px`,height:`${e.top}px`,top:"0",left:`${t-e.right}px`}),this.tableOptions.headerSeparatorBorderVisible&&this.tableModel.isHeaderVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderHeaderBottom,{width:`${t}px`,height:"1px",top:`${e.top}px`,left:"0px"})):this.dom.applyDisplayNoneStyle(this.borderHeaderBottom),this.dom.applyStyle(this.areaFooterWest.parent,{width:`${e.left}px`,height:`${e.bottom}px`,top:`${s-e.bottom}px`,left:"0"}),this.dom.applyStyle(this.areaFooterCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.bottom}px`,top:`${s-e.bottom}px`,left:`${e.left}px`}),this.dom.applyStyle(this.areaFooterEast.parent,{width:`${e.right}px`,height:`${e.bottom}px`,top:`${s-e.bottom}px`,left:`${t-e.right}px`}),this.tableOptions.footerSeparatorBorderVisible&&this.tableModel.isFooterVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFooterTop,{width:`${t}px`,height:"1px",top:`${s-e.bottom}px`,left:"0px"})):this.dom.applyDisplayNoneStyle(this.borderFooterTop),this.adjustAfterScrolling()}adjustAfterScrolling(){}resetSizeOfWrapperDiv(){const e=`${this.tableModel.getContentWidthInPixel()}px`,t=`${this.tableModel.getContentHeightInPixel()+1}px`;this.dom.setStyle(this.contentWrapperDiv,"width",e),this.dom.setStyle(this.contentWrapperDiv,"height",t)}}class M{constructor(e,t,s,i,o=!1){this.r1=e,this.c1=t,this.r2=s,this.c2=i,this.gammaRange=o}static create(e){return e.gammaRange===void 0&&(e.gammaRange=!1),new M(e.rowIndex1,e.columnIndex1,e.rowIndex2,e.columnIndex2,e.gammaRange)}static singleCell(e,t){return new M(e,t,e,t)}static singleRow(e){return new M(e,0,e,Number.MAX_SAFE_INTEGER)}static singleColumn(e){return new M(0,e,Number.MAX_SAFE_INTEGER,e)}isInRange(e,t){return e>=this.r1&&e<=this.r2&&t>=this.c1&&t<=this.c2}}class Ge{constructor(e,t){this.tableModel=e,this.areaModel=t,this.colAndRowspanRanges=void 0}init(){if(this.areaModel.getMaxColspan()<2&&this.areaModel.getMaxRowspan()<2)return;this.colAndRowspanRanges=[];const e=this.areaModel.getRowCount(),t=this.tableModel.getColumnCount();for(let s=0;s<e;s++)for(let i=0;i<t;i++){let o=this.areaModel.getColspanAt(s,i),r=this.areaModel.getRowspanAt(s,i);if(o>1||r>1){o===0&&(o=1),r===0&&(r=1);const a=this.areaModel.hasOwnProperty("gammaCells");this.colAndRowspanRanges.push(new M(s,i,s+r-1,i+o-1,a))}}}getRanges(){return this.colAndRowspanRanges?this.colAndRowspanRanges:[]}isInRange(e,t){if(this.colAndRowspanRanges){for(const s of this.colAndRowspanRanges)if(s.isInRange(e,t))return!0}return!1}}class Ne{constructor(e,t,s){this.header=e,this.body=t,this.footer=s}}class je extends Ve{constructor(e,t,s,i){var r,a;super(e,t,s,i),this.scrollLeft=0,this.scrollViewportLeft=0,this.scrollFactorY=0,this.scrollFactorX=0,this.cleanupFunctions={header:[],body:[],footer:[]},this.tree=!1,this.colAndRowspanModels=new Ne,this.firstVisibleRowIndex=-1,this.draggingTargetColumnIndex=-1,this.removables=[],this.editing=!1,this.tableModel.getSelectionModel?this.getSelectionModel=this.tableModel.getSelectionModel:(r=this.tableOptions)!=null&&r.getSelectionModel&&(this.getSelectionModel=this.tableOptions.getSelectionModel),(a=this.tableOptions)!=null&&a.getFocusModel&&(this.getFocusModel=this.tableOptions.getFocusModel),X(t.getAreaModel("body"))&&(this.tree=!0),["header","body","footer"].forEach(n=>{var d;this.colAndRowspanModels[n]=new Ge(t,t.getAreaModel(n)),(d=this.colAndRowspanModels[n])==null||d.init()})}isEditing(){return this.editing}resetEditorRenderer(){this.editorRenderer=void 0,this.editorRendererRow=-1,this.editorRendererColumn=-1,this.editing=!1}clearSelection(){if(this.getSelectionModel){const e=this.getSelectionModel();e==null||e.clear()}}initRenderEditor(e,t){var i;let s=(i=this.tableModel.getColumnDef(t))==null?void 0:i.getEditRenderer;if(s||(s=this.tableOptions.getEditRenderer),s)if(this.editorRenderer=s(e,t),this.editorRenderer){this.editorRendererRow=e,this.editorRendererColumn=t,this.editing=!0,this.repaint();const o=document.querySelector("input.ge-table-cell-editor-input");o&&o.focus()}else this.resetEditorRenderer()}repaint(){this.adjustAfterScrolling()}adjustAfterScrolling(){var e;for(const t of this.removables)t.remove();this.hideHoverRow(),this.hideHoverColumn(),this.scrollTop=this.scrollViewport.scrollTop,this.scrollLeft=this.scrollViewport.scrollLeft,this.debounce(this.checkForScrollPosSaving.bind(this)),this.scrollFactorY=this.scrollTop/(this.scrollViewport.scrollHeight-this.scrollViewport.clientHeight),this.scrollFactorX=this.scrollLeft/(this.scrollViewport.scrollWidth-this.scrollViewport.clientWidth),isNaN(this.scrollFactorY)&&(this.scrollFactorY=0),isNaN(this.scrollFactorX)&&(this.scrollFactorX=0),this.adjustBody(),this.adjustArea("footer"),this.adjustArea("header"),this.tableOptions.tableTopBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,0),this.hostElement,"ge-table-border")),this.tableOptions.tableBottomBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,this.hostElement.clientHeight-1),this.hostElement,"ge-table-border")),this.tableModel.getFixedLeftColumnCount()>0&&this.removables.push(this.dom.addVerticalBorder(new T(this.areaBodyWest.child.clientWidth,1,this.hostElement.clientHeight,0),this.hostElement,"ge-table-body-west-vertical-border")),((e=this.tableModel.getAreaModel("header"))==null?void 0:e.getRowCount())>0&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,this.areaHeaderCenter.child.clientHeight),this.hostElement,"ge-table-body-west-vertical-border"))}checkForScrollPosSaving(){var e,t;this.storeScrollPosStateService&&((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreScrollPosition)&&this.storeScrollPosStateService.updateScrollOffset([this.scrollLeft,this.scrollTop])}updateCells(e,t=!1){e.forEach(s=>{this.tableModel.getAreaModel(s.area).setValue(s.rowIndex,s.columnIndex,s.value),t||this.rerenderCellContent(s)}),t&&this.repaint()}getAreaAndSideIdentByAttr(e){if(e){const t=this.getStringByAttr(e,"data-area"),s=this.getStringByAttr(e,"data-side");if(s&&t)return[t,s]}return[void 0,void 0]}getArea(e,t){if(e==="header"){if(t==="west")return this.areaHeaderWest;if(t==="center")return this.areaHeaderCenter;if(t==="east")return this.areaHeaderEast}else if(e==="body"){if(t==="west")return this.areaBodyWest;if(t==="center")return this.areaBodyCenter;if(t==="east")return this.areaBodyEast}else if(e==="footer"){if(t==="west")return this.areaFooterWest;if(t==="center")return this.areaFooterCenter;if(t==="east")return this.areaFooterEast}throw Error(`Wrong area identifier: row:${e}, col:${t}`)}adjustBody(){const e=this.areaBodyCenterGeo.height-this.tableModel.getContentHeightInPixel(),t=this.scrollFactorY*e;this.dom.setStyle(this.contentDiv,"top",`${this.scrollTop}px`),this.dom.setStyle(this.contentDiv,"left",`${this.scrollViewport.scrollLeft}px`),this.adjustArea("body",t)}getNumberByAttr(e,t){var s;if(e){const i=(s=e.closest("["+t+"]"))==null?void 0:s.getAttribute(t);if(i)return Number(i)}return-1}getStringByAttr(e,t){var s;if(e){const i=(s=e.closest("["+t+"]"))==null?void 0:s.getAttribute(t);if(i)return i}return""}adjustArea(e,t=0){var g;const s=this.getArea(e,"west"),i=this.getArea(e,"center"),o=this.getArea(e,"east"),r=i.child.clientHeight;s.child.innerText="",i.child.innerText="",o.child.innerText="";const a=0,n=this.areaBodyCenterGeo.width,d=this.tableModel.getPadding(),h=this.tableModel.getAreaModel(e),c=h.getRowCount();for(;this.cleanupFunctions[e].length;){const u=this.cleanupFunctions[e].shift();u&&u()}let S=t;const f=this.tableModel.getColumnCount(),p=this.tableModel.getFixedRightColumnCount(),m=this.tableModel.getFixedLeftColumnCount();for(let u=0;u<c;u++){const w=S,x=u===c-1,C=this.tableModel.getRowHeight(e,u);if(w+C>0){this.firstVisibleRowIndex=u;let y={left:a,width:n,height:C,top:w,index:u},v=this.dom.addRowDiv(i,y,u,e,"center");const E=m;if(this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"center",areaModel:h,geo:y,parent:v,rowIndex:u,columnIndexStart:E,columnIndexEnd:f-p-1,verticalFixed:!1,lastRowOfModel:x}),d.left>0&&(y={left:a,width:this.areaBodyWestGeo.width,height:C,top:w,index:u},v=this.dom.addRowDiv(s,y,u,e,"west"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"west",areaModel:h,geo:y,parent:v,rowIndex:u,columnIndexStart:0,columnIndexEnd:E-1,verticalFixed:!0,lastRowOfModel:x})),d.right>0&&(y={left:a,width:this.areaBodyEastGeo.width,height:C,top:w,index:u},v=this.dom.addRowDiv(o,y,u,e,"east"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"east",areaModel:h,geo:y,parent:v,rowIndex:u,columnIndexStart:f-p,columnIndexEnd:f-1,verticalFixed:!0,lastRowOfModel:x})),e==="header"&&this.tree&&u===c-1){const A=this.dom.applyStyle(this.dom.setAttribute(this.dom.addDiv(v,new T(16,20,20,8)),"data-ge-action","toggleExpandCollapseAll"),{cursor:"pointer"}),R=this.tableOptions.treeOptions.arrowExpandCollapseAll;if(R){const W=this.dom.domService.createText(R.content);this.dom.domService.appendChild(A,W),R.style&&this.dom.applyStyleString(A,R.style)}}}if(S=S+C,S>r)break}if(this.colAndRowspanModels&&this.colAndRowspanModels[e]){const u=((g=this.colAndRowspanModels[e])==null?void 0:g.getRanges())??[];if(u.length)for(const w of u){let x=0,C=i.child,y="center";if(w.c1<m)C=s.child,y="west";else if(p>0&&w.c1>=f-p)C=o.child,y="east";else{const v=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();x=this.scrollFactorX*v-this.areaBodyWestGeo.width,y="center"}this.drawBigCell(w,x,t,h,C,y)}}}drawBigCell(e,t,s,i,o,r){const a=s+this.getRowHeights(0,e.r1-1,i).reduce((g,u)=>g+u,0),n=this.tableModel.getColumnCount(),d=this.tableModel.getFixedRightColumnCount();let h=0;d>0&&e.c1>=n-d&&(h=n-d);const c=t+this.getColumnWidths(h,e.c1-1).reduce((g,u)=>g+u,0),S=this.getRowHeights(e.r1,e.r2,i).reduce((g,u)=>g+u,0),f=this.getColumnWidths(e.c1,e.c2).reduce((g,u)=>g+u,0);let p=!1;const m=this.getSelectionModel?this.getSelectionModel():void 0;m&&(p=m.getSelectionCount(e.r1,e.c1)>0),e.gammaRange?(console.info("TODO here",e),this.renderCell({areaModel:i,areaIdent:i.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:c,top:a,width:f,height:S,parent:o,cellSelected:p,lastRowOfModel:!0,gammaRange:e.gammaRange})):this.renderCell({areaModel:i,areaIdent:i.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:c,top:a,width:f,height:S,parent:o,cellSelected:p,lastRowOfModel:!0,gammaRange:e.gammaRange}),i.areaIdent==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:e.r1,columnIndex:e.c1,cellLeft:c,cellTop:a,cellWidth:f,cellHeight:S,parent:o})}findRowOfImportantRowspanCell(e,t,s){const i=e.getMaxRowspan();for(let o=t-1;o>-1;o--){const r=e.getRowspanAt(o,s);if(r>1&&o+r+1>=t)return o;if(t-o>i)return-1}return-1}adjustColumnsToRowParent({areaIdent:e,sideIdent:t,areaModel:s,geo:i,parent:o,rowIndex:r,columnIndexStart:a,columnIndexEnd:n,verticalFixed:d=!1,lastRowOfModel:h=!1}){var m;this.scrollViewportLeft=this.scrollViewport.scrollLeft;let c=0;if(!d){const g=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();c=this.scrollFactorX*g}const S=0,f=!!(e==="body"&&t);let p=c;for(let g=a;g<=n;g++){const u=p,w=this.tableModel.getColumnWidth(g);if(w>0&&u+w>0){let x=i.height;const C=s.getRowspanAt(r,g),y=s.getColspanAt(r,g);C>1&&(x=this.getRowHeights(r,r+C-1,s).reduce((A,R)=>A+R,0));let v=w;y>1&&(v=this.getColumnWidths(g,g+y-1).reduce((A,R)=>A+R,0));let E=!1;if(this.colAndRowspanModels&&this.colAndRowspanModels[e]&&(m=this.colAndRowspanModels[e])!=null&&m.isInRange(r,g)&&(E=!0),this.draggingTargetColumnIndex===g&&e!=="header"){this.renderDragTargetDiv(o,u,S,v,x);const A={left:u,top:S,width:v,height:x};this.dom.addColumnBorderDivs(this.tableOptions,o,A,e,t)}else{const A=this.renderSelectedBackgroundDiv(E,f,t,s,r,g,o,u,S,v,x);E||this.renderCell({areaModel:s,areaIdent:e,sideIdent:t,rowIndex:r,columnIndex:g,left:u,top:S,width:v,height:x,parent:o,cellSelected:A,lastRowOfModel:h,gammaRange:!0}),e==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:r,columnIndex:g,cellLeft:u,cellTop:S,cellWidth:v,cellHeight:x,parent:o})}}if(p=p+w,p>this.areaBodyCenterGeo.width)break}this.tableOptions.verticalBorderVisible&&this.dom.addVerticalBorder(new T(p-1,1,i.height,0),o)}getTreeArrowColumnIndex(){return this.tableOptions.showCheckboxWihoutExtraColumn?0:this.tableModel.isRowCheckboxVisible()?1:0}addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:i,index:o,left:r,width:a,height:n,top:d,parent:h,lastRowOfModel:c,gammaRange:S}){var ee;const p=this.editorRenderer&&this.editorRendererRow===i&&this.editorRendererColumn===o?this.editorRenderer:e.getCellRenderer(i,o),m={left:r,width:a,height:n,top:d,index:o},g=e.getRowByIndex(i);let u="none";if(o===this.getTreeArrowColumnIndex()&&K(g)){const b=g;(ee=b.children)!=null&&ee.length?b.expanded?u="expanded":u="collapsed":u="hidden"}let x;if(t==="header"){const b=this.tableModel.getColumnDef(o);(!(b!=null&&b.sortIconVisible)||b!=null&&b.sortIconVisible())&&(x=b==null?void 0:b.sortState)}const C=e.getValueAt(i,o),y=p?"":`${C}`,v=e.isRowChecked(i),E=this.dom.addColumnDiv(h,m,i,o,t,s,y,u,this.tableOptions,v,x),A=e.getTooltipAt(i,o);A&&this.dom.setAttribute(E,"title",A);const R=this.tableModel.getColumnDef(o);R&&R.classes[t]&&this.dom.addClasses(R.classes[t],E);let W;p&&(W=p.render(E,i,o,t,e,C,this.dom.domService));const Z=e.getCustomClassesAt(i,o);if(Z.length&&this.dom.addClasses(Z,E),this.dom.addColumnBorderDivs(this.tableOptions,h,m,t,s),c&&this.dom.addHorizontalBorder({left:r,width:a,height:n,top:d+n},h),this.getFocusModel&&t==="body"){const b=this.getFocusModel();b!=null&&b.hasFocus(i,o)&&this.dom.addFocusBorderDivs(h,m,{})}t==="header"&&this.dom.setAttribute(E,"data-ge-action","drag-column");const H=e.getCustomStyleAt(i,o);if(H)for(const b in H)this.dom.setStyle(E,b,H[b]);return[E,W]}applyCssClasses(e,t={}){e&&Object.entries(t).forEach(([s,i])=>{i?this.dom.addClass(s,e):this.dom.removeClass(s,e)})}rerenderCellContent({area:e,rowIndex:t,columnIndex:s,value:i,cssClasses:o}){const r=this.tableModel.getAreaModel(e),a='div[data-col-index="'+s+'"][data-row-index="'+t+'"][data-area="'+e+'"]',n=document.querySelector(a);if(n){let d;const c=this.editorRenderer&&this.editorRendererRow===t&&this.editorRendererColumn===s?this.editorRenderer:r.getCellRenderer(t,s);if(n.innerText="",this.applyCssClasses(n,o),c)d=c.render(n,t,s,e,r,i,this.dom.domService),d&&this.cleanupFunctions[e].push(d);else{const p=`${i}`;this.dom.addLabelDiv(n,p,!1,t,s,e)}const S=r.getCustomClassesAt(t,s);S.length&&this.dom.addClasses(S,n);const f=r.getCustomStyleAt(t,s);if(f)for(const p in f)this.dom.setStyle(n,p,f[p])}}getColumnWidths(e,t){const s=[];for(let i=e;i<=t;i++)s.push(this.tableModel.getColumnWidth(i));return s}getRowHeights(e,t,s){const i=[];for(let o=e;o<=t;o++)i.push(s.getRowHeight(o));return i}adjustHoverRows(e){if(this.tableOptions.hoverRowVisible&&e.rowIndex>-1){const t=this.hostElement.clientWidth,s=this.tableModel.getAreaModel("body").getRowHeight(e.rowIndex),i=e.rowTop+this.areaHeaderCenter.parent.clientHeight-this.scrollTop;this.dom.applyStyle(this.hoverRow,{left:"0",top:i+"px",width:t+"px",height:s+"px",display:"block"})}else this.hideHoverRow()}hideHoverRow(){this.dom.applyStyle(this.hoverRow,{display:"none"})}adjustHoverColumns(e){if(this.tableOptions.hoverColumnVisible&&e.rowIndex>-1){const t=this.hostElement.clientHeight,s=this.tableModel.getColumnWidth(e.columnIndex),i=this.areaBodyWestGeo.width,o=e.columnLeft+this.tableModel.getPadding().left-this.scrollLeft-i;this.dom.applyStyle(this.hoverColumn,{left:o+"px",top:"0px",width:s+"px",height:t+"px",display:"block"})}else this.hideHoverColumn()}hideHoverColumn(){this.dom.applyStyle(this.hoverColumn,{display:"none"})}debounce(e,t=1e3){this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(e.bind(this),t)}renderDragTargetDiv(e,t,s,i,o){const r=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass("ge-table-drop-zone",e));return this.dom.setStyle(r,"left",`${t}px`),this.dom.setStyle(r,"top",`${s}px`),this.dom.setStyle(r,"width",`${i}px`),this.dom.setStyle(r,"height",`${o}px`),r}renderSelectedBackgroundDiv(e,t,s,i,o,r,a,n,d,h,c){let S=!1;if(!e&&t&&i.isSelectable(o,r)&&this.getSelectionModel){const f=this.getSelectionModel();if(f){const p=f.getSelectionCount(o,r);S=p>0;for(let m=0;m<p;m++){const g=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(`ge-table-${i.areaIdent}-${s}-selected-range`,a));this.dom.setStyle(g,"left",`${n}px`),this.dom.setStyle(g,"top",`${d}px`),this.dom.setStyle(g,"width",`${h}px`),this.dom.setStyle(g,"height",`${c}px`)}}}return S}renderCell({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:i,columnIndex:o,left:r,top:a,width:n,height:d,parent:h,cellSelected:c,lastRowOfModel:S,gammaRange:f}){const[p,m]=this.addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:s,rowIndex:i,index:o,left:r,width:n,height:d,top:a,parent:h,lastRowOfModel:S,gammaRange:f});c&&this.dom.addClass(`ge-table-${t}-${s}-selected-range`,p),m&&this.cleanupFunctions[t].push(m)}renderHeaderCellResizeHandle({rowIndex:e,columnIndex:t,cellLeft:s,cellTop:i,cellWidth:o,cellHeight:r,parent:a}){const n=this.dom.domService,d=this.tableOptions.columnResizeHandleWidthInPx??2,h=n.createElement("div");n.setAttribute(h,"data-col-index",`${t}`),n.setAttribute(h,"data-row-index",`${e}`),n.setAttribute(h,"data-area","header"),n.setAttribute(h,"data-ge-action","resize-column"),n.addClass(h,"ge-table-column-resize-handle"),n.setStyle(h,"display","clip"),n.setStyle(h,"position","absolute"),n.setStyle(h,"cursor","col-resize"),n.setStyle(h,"left",`${s+o-d}px`),n.setStyle(h,"top",`${i}px`),n.setStyle(h,"width",`${d}px`),n.setStyle(h,"height",`${r}px`),n.appendChild(a,h)}}class Ke{constructor(e,t){this.columnIndex=e,this.sortState=t}}class Xe{constructor(e){this.tableScope=e,this.tableScope.hostElement.addEventListener("change",this.onHostElementChanged.bind(this))}onHostElementChanged(e){if(e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLTextAreaElement){const t=e.target,s=t.getAttribute("data-area"),i=t.getAttribute("data-row-index"),o=t.getAttribute("data-col-index");if(s&&i&&o){const r=q(s),a=Number(i),n=Number(o);this.tableScope.updateModelValueAfterEdit(r,a,n,t.value)}}}}class ze{constructor(e=-1,t=-1){this.rowIndex=e,this.columnIndex=t}}class J{constructor(e){this.cells=e}static createSingle(e,t){return new J([new ze(e,t)])}}class Ye{constructor(e){var t,s;this.tableScope=e,(t=this.tableScope.tableOptions)!=null&&t.getSelectionModel&&(this.getSelectionModel=this.tableScope.tableOptions.getSelectionModel),(s=this.tableScope.tableOptions)!=null&&s.getFocusModel&&(this.getFocusModel=this.tableScope.tableOptions.getFocusModel)}onMouseClicked(e,t){var o,r,a,n,d,h,c;let s=!1,i=!1;if(this.getSelectionModel&&this.getFocusModel){const S=this.getSelectionModel(),f=this.getFocusModel();S&&f&&(f.hasFocus(e.rowIndex,e.columnIndex)||(f.setFocus(e.rowIndex,e.columnIndex),s=!0),(o=e.originalEvent)!=null&&o.shiftKey||S.hasSelection()&&(S.clear(),s=!0),(r=e.originalEvent)!=null&&r.shiftKey&&this.previousEvt?(S.addSelection(this.createRangeByEvents(e,this.previousEvt)),i=!0,s=!0):(a=e.originalEvent)!=null&&a.ctrlKey||(n=e.originalEvent)!=null&&n.metaKey?(S.addSelection(M.singleCell(e.rowIndex,e.columnIndex)),i=!0,s=!0):(d=e.originalEvent)!=null&&d.altKey&&((h=e.originalEvent)!=null&&h.ctrlKey||(c=e.originalEvent)!=null&&c.metaKey)&&(S.removeSelection(M.singleCell(e.rowIndex,e.columnIndex)),i=!0,s=!0))}return i?this.previousEvt=void 0:this.previousEvt=e==null?void 0:e.clone(),s}onActionTriggered(e){if(this.getSelectionModel&&this.getFocusModel){const t=this.getSelectionModel(),s=this.getFocusModel();if(t&&s){if(e==="SELECT_ALL")return t.selectAll(),this.tableScope.repaint(),!0;if(e==="DESELECT_ALL")return t.clear(),this.tableScope.repaint(),!0;if(e==="TOGGLE_SELECTION"){const[i,o]=s.getFocus();return t.togglePoint(i,o),this.tableScope.repaint(),!0}}}return!1}createRangeByEvents(e,t){t||(t=e);const s=Math.min(e.rowIndex,t==null?void 0:t.rowIndex),i=Math.max(e.rowIndex,t==null?void 0:t.rowIndex),o=Math.min(e.columnIndex,t==null?void 0:t.columnIndex),r=Math.max(e.columnIndex,t==null?void 0:t.columnIndex);return M.create({rowIndex1:s,columnIndex1:o,rowIndex2:i,columnIndex2:r})}}class qe{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","ctrl+a":"SELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+x":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","cmd -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT"}}}class Ue{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","cmd+a":"SELECT_ALL","ctrl+a":"SELECT_ALL","cmd+x":"DESELECT_ALL","cmd+shift+a":"DESELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","ctrl -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT"}}}class Je{constructor(e){this.tableScope=e,this.shortcutActionIdMapping={},this.listener=[],this.listener.push(e),this.init()}addListener(e){this.listener.includes(e)||this.listener.push(e)}init(){this.isMacintosh()?Object.assign(this.shortcutActionIdMapping,new Ue().get()):Object.assign(this.shortcutActionIdMapping,new qe().get()),Object.assign(this.shortcutActionIdMapping,this.tableScope.tableOptions.shortcutActionIdMapping),this.isDebug()&&console.debug("ShortcutService",this.shortcutActionIdMapping),this.tableScope.hostElement.addEventListener("keydown",this.onKeyDown.bind(this))}isMacintosh(){return navigator.platform.indexOf("Mac")>-1}isDebug(){return this.isLocalhost()}isLocalhost(){return location.hostname==="localhost"||location.hostname==="127.0.0.1"}onKeyDown(e){const t=this.findEnty(e);t&&this.emit(t)&&(e.preventDefault(),e.stopPropagation())}emit(e){this.isDebug()&&console.debug("ShortcutService emit:",e);let t=!1;for(const s of this.listener)s.onActionTriggered(e)&&(t=!0);return t}findEnty(e){const t=this.getTokenByEvent(e);this.isDebug()&&console.debug("ShortcutService tokens:",t);for(const s in this.shortcutActionIdMapping){const i=s.replace(/opt/g,"alt").replace(/cmd/g,"meta").split(/[\+ ]/g).sort();if(this.areTokensEquals(t,i))return this.shortcutActionIdMapping[s]}}areTokensEquals(e,t){if(e.length!==t.length||e.length===0)return!1;for(let s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}getTokenByEvent(e){const t=[];return e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),e.code&&t.push(e.code.toLowerCase().replace(/key/g,"")),t.sort()}}class oe{onCheckboxChanged(e){}onContextmenu(e){}onModelChanged(e){}onMouseClicked(e){}onMouseDragging(e){}onMouseDraggingEnd(e){}onMouseMoved(e){}}class ce{setStyle(e,t,s){return e.style[t]=s,e}appendText(e,t){const s=this.createText(t);return this.appendChild(e,s),s}addClass(e,t){return t.includes(" ")?t.split(" ").forEach(s=>e.classList.add(s)):e.classList.add(t),e}removeClass(e,t){return t.includes(" ")?t.split(" ").forEach(s=>e.classList.remove(s)):e.classList.remove(t),e}appendChild(e,t){e.appendChild(t)}createElement(e){return document.createElement(e)}createText(e){return document.createTextNode(e)}setAttribute(e,t,s){e.setAttribute(t,s)}}class Qe{render(e,t,s,i,o,r,a){if(o.isEditable(t,s)){a.addClass(e,"ge-table-row-input-div");const n=o.getValueAt(t,s);e.innerHTML=`
9
- <input
10
- type="text"
11
- value="${n}"
12
- autofocus
13
- onfocus="this.setSelectionRange(0, this.value.length)"
14
- data-listen="change"
15
- data-area="${i}"
16
- data-row-index="${t}"
17
- data-col-index="${s}"
18
- data-input-type="text"
19
- style="width:calc(100% - 8px);height:100%;border:0;padding:0 0 0 8px;"
20
- class="ge-table-cell-editor-input">`}}}class Ze{constructor(e="none",t="single"){this.selectionType=e,this.selectionMode=t,this.ranges=[],this.negativeRanges=[],this.allSelected=!1}getSelectionCount(e,t){let s=0;for(const i of this.ranges)i.isInRange(e,t)&&s++;return this.allSelected&&s++,this.isInNegativeRange(e,t)&&(s=0),s}isInNegativeRange(e,t){for(const s of this.negativeRanges)if(s.isInRange(e,t))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1}hasSelection(){return!!this.ranges.length}selectAll(){this.allSelected=!0}addSelection(e){this.addRange(e)}removeSelection(e){if(this.selectionType==="none")return;let t=e;this.selectionType==="row"?t=M.singleRow(e.r1):this.selectionType==="column"&&(t=M.singleColumn(e.c1)),this.negativeRanges.push(t)}togglePoint(e,t){this.getSelectionCount(e,t)>0?this.removeSelection(M.singleCell(e,t)):this.addSelection(M.singleCell(e,t))}addRange(e){this.selectionType!=="none"&&(this.allSelected=!1,this.selectionMode==="single"&&(this.ranges=[]),this.selectionType==="row"?(e.c1=0,e.c2=Number.MAX_SAFE_INTEGER):this.selectionType==="column"?(e.r1=0,e.r2=Number.MAX_SAFE_INTEGER):this.selectionType==="cell"?(e.r2=e.r1,e.c2=e.c1):this.selectionType,this.ranges.push(e))}}class et{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1}setFocus(e,t){(this.rowIndex!==e||this.columnIndex!==t)&&(this.rowIndex=e,this.columnIndex=t,this.changed=!0)}hasFocus(e,t){return this.rowIndex===e&&this.columnIndex===t}getFocus(){return[this.rowIndex,this.columnIndex]}}const tt=new Ze,st=new et("cell");class pe{constructor(){this.overflowX="auto",this.overflowY="auto",this.horizontalBorderVisible=!0,this.verticalBorderVisible=!0,this.footerSeparatorBorderVisible=!0,this.headerSeparatorBorderVisible=!0,this.fixedEastSeparatorBorderVisible=!0,this.fixedWestSeparatorBorderVisible=!0,this.tableTopBorderVisible=!0,this.tableBottomBorderVisible=!0,this.hoverRowVisible=!0,this.hoverColumnVisible=!0,this.columnsResizable=!0,this.columnsDraggable=!0,this.columnResizeHandleWidthInPx=4,this.defaultRowHeights={header:34,body:34,footer:34},this.footerVerticalSeparator=!1,this.headerToggleExpandCollapseIcons=!1,this.headerVerticalSeparator=!1,this.treeOptions=new de,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new he,this.sortOrder=["asc","desc"],this.getEditRenderer=(e,t)=>new Qe,this.getSelectionModel=()=>tt,this.getFocusModel=()=>st}}class Q extends je{constructor(e,t,s,i,o){var r;if(super(e,t,new Le(s),i),this.eventListener=o,this.licenseManager=D.getInstance(),this.selectionService=new Ye(this),this.api=new Be(this),this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,o||(this.eventListener=new oe),(r=this.tableOptions)!=null&&r.autoRestoreOptions){const a=this.tableOptions.autoRestoreOptions,n=a.getStorageKeyFn;n&&(a.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new We(n)),a.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new He(n)),a.autoRestoreSortingState&&(this.storeSortingService=new ke(n)))}this.mouseHandler=new _e(this),this.inputHandler=new Xe(this),this.shortcutService=new Je(this),this.shortcutService.addListener(this.selectionService)}static create(e,t,s=new pe,i=new oe,o=new ce){return new Q(e,t,o,s,i)}onActionTriggered(e){if(e==="NAVIGATE_DOWN"&&this.changeFocusCell(0,1)||e==="NAVIGATE_UP"&&this.changeFocusCell(0,-1)||e==="NAVIGATE_LEFT"&&this.changeFocusCell(-1,0)||e==="NAVIGATE_RIGHT"&&this.changeFocusCell(1,0))return!0;if(e==="START_EDITING"&&this.getFocusModel){const t=this.getFocusModel();if(t){const[s,i]=t.getFocus();this.tableModel.getBodyModel().isEditable(s,i)&&(this.clearSelection(),this.initRenderEditor(s,i))}return!0}return!1}updateModelValueAfterEdit(e,t,s,i){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,s,i)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(J.createSingle(t,s)),this.hostElement.focus())}getApi(){return this.api}firstInit(){var e;return this.tableModel.init(),(e=this.tableOptions)!=null&&e.externalFilterFunction&&this.externalFilterChanged(!1),this.autoRestoreCollapsedExpandedState(),this.autoRestoreSortingState(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.autoRestoreScrollPosition(),this}createGeMouseEvent(e){const t=new Y;if(t.originalEvent=e,e){const s=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(s),t.rowIndex=this.getNumberByAttr(s,"data-row-index"),t.columnIndex=this.getNumberByAttr(s,"data-col-index"),t.action=this.getStringByAttr(s,"data-ge-action"),t.areaIdent){const i=this.tableModel.getAreaModel(t.areaIdent);t.rowTop=i.getYPosByRowIndex(t.rowIndex)}if(t.columnLeft=this.tableModel.getXPosByColumnIndex(t.columnIndex),e.ctrlKey&&e.altKey){const i=e.clientY-this.hostElement.offsetTop-this.areaHeaderCenter.parent.clientHeight,o=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(o,i)}}return t}onMouseDown(e){e.columnIndex>-1&&e.action&&["resize-column","drag-column"].includes(e.action)&&(this.mouseStartWidth=this.tableModel.getColumnWidth(e.columnIndex),this.mouseStartAction=e.action,this.mouseStartColumnIndex=e.columnIndex,this.mouseStartAction==="drag-column"&&(this.dragFrom=this.mouseStartColumnIndex))}mouseDraggingOnFrame(e){this.eventListener.onMouseDragging(e),this.mouseEvent=e,this.mouseStartColumnIndex>-1&&this.mouseStartAction==="resize-column"&&this.tableOptions.columnsResizable?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&e.columnIndex>-1&&this.tableOptions.columnsDraggable&&(this.draggingTargetColumnIndex=e.columnIndex,this.dragTo=this.draggingTargetColumnIndex,this.dragFrom>-1&&this.dragTo>-1&&this.dragFrom!==this.dragTo&&(this.tableModel.changeColumnOrder(this.dragFrom,this.dragTo),this.dragFrom=this.dragTo,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()),this.repaint())}mouseDraggingEndOnFrame(e){this.eventListener.onMouseDraggingEnd(e),this.draggingTargetColumnIndex=-1,this.mouseStartAction==="resize-column"?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&this.repaint(),this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.mouseStartAction=""}mouseMove(e){this.eventListener.onMouseMoved(e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var s;const t=this.tableModel.getBodyModel();X(t)&&(t.toggleExpandCollapseAll(e),this.repaint(),(s=this.storeStateCollapsedExpandService)==null||s.collapsedStateAll(e))}toggleRowCheckbox(e,t,s){var n;const i=this.tableModel.getAreaModel(s),o=i.isRowChecked(e),r=o===void 0||o==="semi"||o==="none";i.setRowChecked(e,r),this.repaint();const a=(n=i.rowSelectionModel)==null?void 0:n.getCheckedRows();this.eventListener.onCheckboxChanged(a||[])}onMouseClicked(e,t){let s=this.selectionService.onMouseClicked(e,t);if(!s&&this.getFocusModel){const i=this.getFocusModel();i&&(s=i.hasChanged(),i.clearChanged(),s&&this.resetEditorRenderer())}this.eventListener.onMouseClicked(e),s&&this.debounce(this.repaint.bind(this),10)}externalFilterChanged(e=!0){const t=this.tableOptions.externalFilterFunction;t&&(e&&this.clearSelectionModel(),this.tableModel.externalFilterChanged(t),this.scrollViewport.scrollTo(0,0),this.tableModel.recalcHeightAndPadding(),this.resetSizeOfWrapperDiv(),this.repaint())}onHeaderDblClicked(e,t,s){var o,r;const i=this.tableModel.getColumnDef(s);if(i!=null&&i.sortable&&i.sortable()){e.preventDefault(),e.stopPropagation();const a=i.sortStatesOrder?i.sortStatesOrder:this.tableOptions.sortOrder,n=i.sortState??"",d=a[(a.indexOf(n)+1)%a.length],h=new Ke(s,d);this.tableModel.doSort([h])&&((o=this.tableModel.getColumnDefs())==null||o.forEach(S=>S.sortState=""),i.sortState=d),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([h])}}changeFocusCell(e,t){if(!this.isEditing()&&this.getFocusModel){const s=this.getFocusModel();if(s){const[i,o]=s.getFocus();return s.setFocus(i+t,o+e),this.repaint(),!0}}return!1}resizeColumn(e){this.tableModel.setColumnWidth(this.mouseStartColumnIndex,this.mouseStartWidth+e.draggingX),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}clearSelectionModel(){var e;this.getSelectionModel&&((e=this.getSelectionModel())==null||e.clear())}debugOnce(e,t){var s;console.clear(),console.info("this.hostElement.offsetTop",this.hostElement.offsetTop),console.info("this.hostElement.scrollHeight",this.hostElement.scrollHeight),console.info("this.scrollViewportTop",this.scrollTop),console.info("this.areaHeaderCenter.parent.clientHeight",this.areaHeaderCenter.parent.clientHeight),console.info("bodyY",t),console.info("bodyX",e),console.info("rows",this.firstVisibleRowIndex),console.info(""),console.info("this.tableModel",this.tableModel),console.info(""),console.info("this.mouseMoveEvent.clientX",(s=this.mouseHandler.mouseEvent)==null?void 0:s.clientX),console.info("this.hostElement.offsetLeft",this.hostElement.offsetLeft),console.info("this.areaBodyWestGeo.width",this.areaBodyWestGeo.width)}autoRestoreScrollPosition(){var e;if((e=this.tableOptions)!=null&&e.autoRestoreOptions&&this.storeScrollPosStateService&&this.tableOptions.autoRestoreOptions.autoRestoreScrollPosition){const s=this.storeScrollPosStateService.getScrollOffset();s&&this.scrollViewport.scrollTo(...s)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const s=this.storeSortingService.getSortItems();s!=null&&s.length&&this.tableModel.getBodyModel().doSort(s)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const s=this.tableOptions.autoRestoreOptions,i=s.getRowId;if(s.autoRestoreCollapsedExpandedState&&i){const o=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(X(r)){const a=r,n=r.getRowCount();for(let d=0;d<n;d++){const h=r.getRowByIndex(d);if(h)if(o.allExpanded)h.expanded=!0;else if(o.allCollapsed)h.expanded=!1;else{const c=i(h.data);o.mode==="expanded"?h.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(c):o.mode==="collapsed"&&(h.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(c))}}a.recalcVisibleTreeRows()}}}}scrollToPixel(e,t){this.scrollViewport.scrollTo(e,t)}scrollToIndex(e,t){const i=this.tableModel.getAreaModel("body").getYPosByRowIndex(t);this.scrollToPixel(0,i)}}function it(l){let e;return{c(){e=be("div"),ye(e,"class","ge-table"),_(e,"width","100%"),_(e,"height","100%"),_(e,"background-color","transparent"),_(e,"padding","0"),_(e,"margin","0")},m(t,s){me(t,e,s),l[4](e)},p:L,i:L,o:L,d(t){t&&ne(e),l[4](null)}}}function ot(l,e,t){let{tableModel:s}=e,{tableOptions:i=new pe}=e,{licenseKey:o}=e,r;const a=te.createEventDispatcher();te.onMount(()=>{const d={onCheckboxChanged:c=>{a("checkboxChanged",c)},onContextmenu:c=>{a("contextmenu",c)},onModelChanged:c=>{a("modelChanged",c)},onMouseClicked:c=>{a("mouseClicked",c)},onMouseDragging:c=>{a("mouseDragging",c)},onMouseDraggingEnd:c=>{a("mouseDraggingEnd",c)},onMouseMoved:c=>{a("mouseMoved",c)}},h=new Q(r,s,new ce,i,d);h.firstInit(),a("tableReady",h.getApi()),o&&D.getInstance().setLicenseKey(o)});function n(d){G[d?"unshift":"push"](()=>{r=d,t(0,r)})}return l.$$set=d=>{"tableModel"in d&&t(1,s=d.tableModel),"tableOptions"in d&&t(2,i=d.tableOptions),"licenseKey"in d&&t(3,o=d.licenseKey)},[r,s,i,o,n]}class lt extends Fe{constructor(e){super(),Ie(this,e,ot,it,ge,{tableModel:1,tableOptions:2,licenseKey:3})}}class rt{constructor(e){this.Component=e}render(e,t,s,i,o,r,a){const n=new this.Component({target:e,props:{cellDiv:e,rowIndex:t,columnIndex:s,areaIdent:i,areaModel:o,cellValue:r}});return()=>{n.$destroy()}}}exports.ComponentRendererWrapper=rt;exports.GuiexpertTable=lt;