react-graph-grid 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +4 -0
  2. package/{src/css → dist}/default.css +2 -1
  3. package/dist/index.esm.js +21 -0
  4. package/dist/index.js +56 -0
  5. package/dist/index10.esm.js +3844 -0
  6. package/dist/index10.js +3848 -0
  7. package/dist/index11.esm.js +4121 -0
  8. package/dist/index11.js +4125 -0
  9. package/dist/index12.esm.js +5238 -0
  10. package/dist/index12.js +5242 -0
  11. package/dist/index13.esm.js +5466 -0
  12. package/dist/index13.js +5470 -0
  13. package/dist/index14.esm.js +22 -0
  14. package/dist/index14.js +26 -0
  15. package/dist/index15.esm.js +402 -0
  16. package/dist/index15.js +403 -0
  17. package/dist/index16.esm.js +507 -0
  18. package/dist/index16.js +507 -0
  19. package/dist/index17.esm.js +256 -0
  20. package/dist/index17.js +257 -0
  21. package/dist/index18.esm.js +261 -0
  22. package/dist/index18.js +263 -0
  23. package/dist/index19.esm.js +623 -0
  24. package/dist/index19.js +624 -0
  25. package/dist/index2.esm.js +6 -0
  26. package/dist/index2.js +2 -0
  27. package/dist/index20.esm.js +219 -0
  28. package/dist/index20.js +220 -0
  29. package/dist/index21.esm.js +298 -0
  30. package/dist/index21.js +299 -0
  31. package/dist/index22.esm.js +662 -0
  32. package/dist/index22.js +663 -0
  33. package/dist/index23.esm.js +340 -0
  34. package/dist/index23.js +341 -0
  35. package/dist/index24.esm.js +269 -0
  36. package/dist/index24.js +270 -0
  37. package/dist/index25.esm.js +600 -0
  38. package/dist/index25.js +601 -0
  39. package/dist/index26.esm.js +245 -0
  40. package/dist/index26.js +246 -0
  41. package/dist/index27.esm.js +136 -0
  42. package/dist/index27.js +137 -0
  43. package/dist/index28.esm.js +70 -0
  44. package/dist/index28.js +70 -0
  45. package/dist/index29.esm.js +748 -0
  46. package/dist/index29.js +748 -0
  47. package/dist/index30.esm.js +363 -0
  48. package/dist/index30.js +363 -0
  49. package/dist/index4.esm.js +27 -0
  50. package/dist/index4.js +27 -0
  51. package/dist/index5.esm.js +35 -0
  52. package/dist/index5.js +39 -0
  53. package/dist/index6.esm.js +200 -0
  54. package/dist/index6.js +204 -0
  55. package/dist/index7.esm.js +9 -0
  56. package/dist/index7.js +13 -0
  57. package/dist/index8.esm.js +65 -0
  58. package/dist/index8.js +68 -0
  59. package/dist/index9.esm.js +102 -0
  60. package/dist/index9.js +103 -0
  61. package/package.json +6 -3
  62. package/eslint.config.js +0 -29
  63. package/index.html +0 -13
  64. package/index.js +0 -19
  65. package/npm.aps +0 -0
  66. package/src/Base.jsx +0 -81
  67. package/src/Card.jsx +0 -333
  68. package/src/Dropdown.jsx +0 -339
  69. package/src/FieldEdit.jsx +0 -376
  70. package/src/Graph.jsx +0 -482
  71. package/src/Grid.jsx +0 -887
  72. package/src/GridCD.jsx +0 -180
  73. package/src/GridDB.jsx +0 -897
  74. package/src/GridFE.jsx +0 -753
  75. package/src/GridFL.jsx +0 -468
  76. package/src/GridGR.jsx +0 -311
  77. package/src/GridPK.jsx +0 -414
  78. package/src/Modal.jsx +0 -511
  79. package/src/Overlay.jsx +0 -140
  80. package/src/Tests/DebugApp.jsx +0 -334
  81. package/src/Tests/TestData.jsx +0 -251
  82. package/src/Themes/DefaultGridTheme.jsx +0 -36
  83. package/src/Themes/Images.jsx +0 -438
  84. package/src/Themes/Translate.jsx +0 -76
  85. package/src/css/default_.css +0 -945
  86. package/src/main.jsx +0 -10
  87. package/vite.config.js +0 -14
  88. /package/{public → dist}/IM.svg +0 -0
@@ -0,0 +1,219 @@
1
+ import { NodeStatus } from "./index8.esm.js";
2
+ import { GraphClass } from "./index18.esm.js";
3
+ import { GridClass } from "./index19.esm.js";
4
+ import { useEffect, useState } from "react";
5
+ function GridGR(props) {
6
+ let grid = null;
7
+ const [gridState, setState] = useState({
8
+ grid,
9
+ ind: 0
10
+ });
11
+ grid = gridState.grid;
12
+ let needGetRows = false;
13
+ if (!grid || grid.uid !== props.uid && props.uid != null) {
14
+ grid = null;
15
+ if (props.findGrid) grid = props.findGrid(props);
16
+ grid = grid || new GridGRClass(props);
17
+ needGetRows = !props.noAutoRefresh && !props.parentGrids;
18
+ }
19
+ if (props.init) props.init(grid);
20
+ grid.refreshState = function() {
21
+ setState({
22
+ grid,
23
+ ind: grid.stateind++
24
+ });
25
+ };
26
+ grid._waitingRows = needGetRows && (grid.rows.length <= 0 || grid.columns.length <= 0);
27
+ useEffect(() => {
28
+ grid.setupEvents(grid);
29
+ if (grid._waitingRows) grid.getRows({
30
+ filters: grid.collectFilters(),
31
+ grid
32
+ }).then((rows) => {
33
+ grid.rows = rows;
34
+ grid.afterGetRows();
35
+ grid.refreshState();
36
+ }).finally(() => {
37
+ grid._waitingRows = false;
38
+ grid.refreshState();
39
+ });
40
+ else if (grid.columns.length <= 0 && grid.getColumns) grid.prepareColumns().then(() => grid.refreshState());
41
+ return () => {
42
+ grid.clearEvents();
43
+ };
44
+ }, [grid]);
45
+ return grid.render();
46
+ }
47
+ var GridGRClass = class extends GridClass {
48
+ constructor(props) {
49
+ super(props);
50
+ const grid = this;
51
+ if (props.entity) grid.entity = props.entity;
52
+ if (props.applyConnection) grid.applyConnection = props.applyConnection;
53
+ if (!props.graph && (props.parentGrids || props.uid)) {
54
+ grid.graphUid = props.graphUid || "defaultGraphUID";
55
+ grid.parentGrids = props.parentGrids;
56
+ window._graphDict = window._graphDict || {};
57
+ window._graphDict[grid.graphUid] = window._graphDict[grid.graphUid] || new GraphClass();
58
+ const graph = window._graphDict[grid.graphUid];
59
+ while (graph.nodesDict[GridClass._seq]) GridClass._seq++;
60
+ grid.id = GridClass._seq++;
61
+ grid.graph = graph;
62
+ graph.uid = grid.graphUid;
63
+ grid.parents = [];
64
+ grid.children = [];
65
+ if (props.parentGrids) grid.graph.needCheckIntegrity = true;
66
+ grid.uid = props.uid != null ? props.uid : grid.id;
67
+ graph.nodeCount++;
68
+ graph.nodesDict[grid.uid] = grid;
69
+ } else grid.uid = props.uid != null ? props.uid : grid.id;
70
+ }
71
+ log(message, pref) {
72
+ const grid = this;
73
+ pref = pref || `grid#${grid.uid ? grid.id + "(" + grid.uid + ")" : grid.id} ${grid.title || ""}`;
74
+ super.log(`${pref}: ` + message, " ");
75
+ }
76
+ clearEvents() {
77
+ const grid = this;
78
+ super.clearEvents();
79
+ if (window._graphDict && grid.graphUid) {
80
+ grid.log(" delete graph");
81
+ delete window._graphDict[grid.graphUid];
82
+ }
83
+ }
84
+ connectToParents(noDetectCycles) {
85
+ const grid = this;
86
+ const graph = grid.graph;
87
+ grid.connectedToParents = true;
88
+ graph.waveCache = {};
89
+ if (!grid.parentGrids) return;
90
+ const parentUids = "," + grid.parentGrids + ",";
91
+ for (let uid in graph.nodesDict) {
92
+ if (uid === grid.uid) continue;
93
+ let parentGrid = graph.nodesDict[uid];
94
+ if (parentUids.indexOf(parentGrid.uid) <= 0) continue;
95
+ const link = {
96
+ parent: parentGrid,
97
+ child: grid
98
+ };
99
+ const lkey = grid.id + "_" + parentGrid.id;
100
+ graph.linksDict[lkey] = link;
101
+ grid.parents.push(parentGrid.uid);
102
+ parentGrid.children.push(grid.uid);
103
+ }
104
+ if (!noDetectCycles) graph.markCycles();
105
+ }
106
+ applyConnection(link) {
107
+ if (!link.parent || !link.parent.rows) return "";
108
+ return link.parent.selectedValue();
109
+ }
110
+ getEntity() {
111
+ const grid = this;
112
+ return grid.entity || "grid_" + (grid.uid || grid.id);
113
+ }
114
+ onSelectedRowChanged(e) {
115
+ super.onSelectedRowChanged(e);
116
+ const grid = this;
117
+ const graph = grid.graph;
118
+ if (graph && (!graph._isMakingWave || e.source == "rowClick")) {
119
+ if (!grid.connectedToParents) grid.connectToParents();
120
+ if (graph.needCheckIntegrity) grid.checkGraphIntegrity();
121
+ if (graph.checkNeedTriggerWave && !graph.checkNeedTriggerWave(grid)) return;
122
+ graph.triggerWave({
123
+ nodes: [grid],
124
+ withStartNodes: false
125
+ });
126
+ }
127
+ }
128
+ checkGraphIntegrity() {
129
+ const grid = this;
130
+ const graph = grid.graph;
131
+ graph.needCheckIntegrity = false;
132
+ for (let uid in graph.nodesDict) {
133
+ if (uid === grid.id) continue;
134
+ let node = graph.nodesDict[uid];
135
+ if (!node.connectedToParents) node.connectToParents();
136
+ }
137
+ let link;
138
+ for (let lkey in graph.linksDict) {
139
+ link = graph.linksDict[lkey];
140
+ if (!link || !graph.nodesDict[link.parent.uid] || !graph.nodesDict[link.child.uid]) delete graph.linksDict[lkey];
141
+ }
142
+ }
143
+ collectFilters() {
144
+ const grid = this;
145
+ const filters = [];
146
+ if (grid.parentGrids && !grid.connectedToParents) return ["1=2"];
147
+ if (!grid.parents || grid.parents.length <= 0) return filters;
148
+ for (let uid of grid.parents) {
149
+ let link = grid.graph.linksDict[grid.id + "_" + grid.graph.nodesDict[uid].id];
150
+ let filter = grid.applyConnection(link);
151
+ if (filter == null || filter === "") continue;
152
+ let fo = {
153
+ type: "graphLink",
154
+ filter
155
+ };
156
+ filters.push(fo);
157
+ }
158
+ return filters;
159
+ }
160
+ skipOnWaveVisit() {
161
+ return false;
162
+ }
163
+ visitByWave(e) {
164
+ const grid = this;
165
+ return new Promise(function(resolve) {
166
+ if (grid.skipOnWaveVisit(e)) {
167
+ resolve(e);
168
+ return;
169
+ }
170
+ grid._waitingRows = true;
171
+ grid.getRows({
172
+ filters: grid.collectFilters(),
173
+ grid
174
+ }).then((rows) => {
175
+ grid.rows = rows;
176
+ grid.afterGetRows(e);
177
+ resolve(e);
178
+ grid.refreshState();
179
+ }).finally(() => {
180
+ grid._waitingRows = false;
181
+ grid.refreshState();
182
+ });
183
+ });
184
+ }
185
+ visitByWaveAlt(e) {
186
+ const grid = this;
187
+ return new Promise(function(resolve) {
188
+ if (grid.skipOnWaveVisit(e)) {
189
+ resolve(e);
190
+ return;
191
+ }
192
+ grid.selectedRowIndex = 0;
193
+ grid._waitingRows = true;
194
+ grid.refreshState();
195
+ grid.getRows({
196
+ filters: grid.collectFilters(),
197
+ grid
198
+ }).then((rows) => {
199
+ grid.rows = rows;
200
+ grid.afterGetRows(e);
201
+ resolve(e);
202
+ grid.refreshState();
203
+ }).finally(() => {
204
+ grid._waitingRows = false;
205
+ grid.refreshState();
206
+ });
207
+ });
208
+ }
209
+ hasVisibleParentGrids() {
210
+ const grid = this;
211
+ if (!grid.graph) return false;
212
+ for (let puid of grid.parents) {
213
+ let pnode = grid.graph.nodesDict[puid];
214
+ if (pnode.visible !== false && pnode.status === NodeStatus.grid) return true;
215
+ }
216
+ return false;
217
+ }
218
+ };
219
+ export { GridGR, GridGRClass };
@@ -0,0 +1,220 @@
1
+ const require_Base = require("./index8.js");
2
+ const require_Graph = require("./index18.js");
3
+ const require_Grid = require("./index19.js");
4
+ let react = require("react");
5
+ function GridGR(props) {
6
+ let grid = null;
7
+ const [gridState, setState] = (0, react.useState)({
8
+ grid,
9
+ ind: 0
10
+ });
11
+ grid = gridState.grid;
12
+ let needGetRows = false;
13
+ if (!grid || grid.uid !== props.uid && props.uid != null) {
14
+ grid = null;
15
+ if (props.findGrid) grid = props.findGrid(props);
16
+ grid = grid || new GridGRClass(props);
17
+ needGetRows = !props.noAutoRefresh && !props.parentGrids;
18
+ }
19
+ if (props.init) props.init(grid);
20
+ grid.refreshState = function() {
21
+ setState({
22
+ grid,
23
+ ind: grid.stateind++
24
+ });
25
+ };
26
+ grid._waitingRows = needGetRows && (grid.rows.length <= 0 || grid.columns.length <= 0);
27
+ (0, react.useEffect)(() => {
28
+ grid.setupEvents(grid);
29
+ if (grid._waitingRows) grid.getRows({
30
+ filters: grid.collectFilters(),
31
+ grid
32
+ }).then((rows) => {
33
+ grid.rows = rows;
34
+ grid.afterGetRows();
35
+ grid.refreshState();
36
+ }).finally(() => {
37
+ grid._waitingRows = false;
38
+ grid.refreshState();
39
+ });
40
+ else if (grid.columns.length <= 0 && grid.getColumns) grid.prepareColumns().then(() => grid.refreshState());
41
+ return () => {
42
+ grid.clearEvents();
43
+ };
44
+ }, [grid]);
45
+ return grid.render();
46
+ }
47
+ var GridGRClass = class extends require_Grid.GridClass {
48
+ constructor(props) {
49
+ super(props);
50
+ const grid = this;
51
+ if (props.entity) grid.entity = props.entity;
52
+ if (props.applyConnection) grid.applyConnection = props.applyConnection;
53
+ if (!props.graph && (props.parentGrids || props.uid)) {
54
+ grid.graphUid = props.graphUid || "defaultGraphUID";
55
+ grid.parentGrids = props.parentGrids;
56
+ window._graphDict = window._graphDict || {};
57
+ window._graphDict[grid.graphUid] = window._graphDict[grid.graphUid] || new require_Graph.GraphClass();
58
+ const graph = window._graphDict[grid.graphUid];
59
+ while (graph.nodesDict[require_Grid.GridClass._seq]) require_Grid.GridClass._seq++;
60
+ grid.id = require_Grid.GridClass._seq++;
61
+ grid.graph = graph;
62
+ graph.uid = grid.graphUid;
63
+ grid.parents = [];
64
+ grid.children = [];
65
+ if (props.parentGrids) grid.graph.needCheckIntegrity = true;
66
+ grid.uid = props.uid != null ? props.uid : grid.id;
67
+ graph.nodeCount++;
68
+ graph.nodesDict[grid.uid] = grid;
69
+ } else grid.uid = props.uid != null ? props.uid : grid.id;
70
+ }
71
+ log(message, pref) {
72
+ const grid = this;
73
+ pref = pref || `grid#${grid.uid ? grid.id + "(" + grid.uid + ")" : grid.id} ${grid.title || ""}`;
74
+ super.log(`${pref}: ` + message, " ");
75
+ }
76
+ clearEvents() {
77
+ const grid = this;
78
+ super.clearEvents();
79
+ if (window._graphDict && grid.graphUid) {
80
+ grid.log(" delete graph");
81
+ delete window._graphDict[grid.graphUid];
82
+ }
83
+ }
84
+ connectToParents(noDetectCycles) {
85
+ const grid = this;
86
+ const graph = grid.graph;
87
+ grid.connectedToParents = true;
88
+ graph.waveCache = {};
89
+ if (!grid.parentGrids) return;
90
+ const parentUids = "," + grid.parentGrids + ",";
91
+ for (let uid in graph.nodesDict) {
92
+ if (uid === grid.uid) continue;
93
+ let parentGrid = graph.nodesDict[uid];
94
+ if (parentUids.indexOf(parentGrid.uid) <= 0) continue;
95
+ const link = {
96
+ parent: parentGrid,
97
+ child: grid
98
+ };
99
+ const lkey = grid.id + "_" + parentGrid.id;
100
+ graph.linksDict[lkey] = link;
101
+ grid.parents.push(parentGrid.uid);
102
+ parentGrid.children.push(grid.uid);
103
+ }
104
+ if (!noDetectCycles) graph.markCycles();
105
+ }
106
+ applyConnection(link) {
107
+ if (!link.parent || !link.parent.rows) return "";
108
+ return link.parent.selectedValue();
109
+ }
110
+ getEntity() {
111
+ const grid = this;
112
+ return grid.entity || "grid_" + (grid.uid || grid.id);
113
+ }
114
+ onSelectedRowChanged(e) {
115
+ super.onSelectedRowChanged(e);
116
+ const grid = this;
117
+ const graph = grid.graph;
118
+ if (graph && (!graph._isMakingWave || e.source == "rowClick")) {
119
+ if (!grid.connectedToParents) grid.connectToParents();
120
+ if (graph.needCheckIntegrity) grid.checkGraphIntegrity();
121
+ if (graph.checkNeedTriggerWave && !graph.checkNeedTriggerWave(grid)) return;
122
+ graph.triggerWave({
123
+ nodes: [grid],
124
+ withStartNodes: false
125
+ });
126
+ }
127
+ }
128
+ checkGraphIntegrity() {
129
+ const grid = this;
130
+ const graph = grid.graph;
131
+ graph.needCheckIntegrity = false;
132
+ for (let uid in graph.nodesDict) {
133
+ if (uid === grid.id) continue;
134
+ let node = graph.nodesDict[uid];
135
+ if (!node.connectedToParents) node.connectToParents();
136
+ }
137
+ let link;
138
+ for (let lkey in graph.linksDict) {
139
+ link = graph.linksDict[lkey];
140
+ if (!link || !graph.nodesDict[link.parent.uid] || !graph.nodesDict[link.child.uid]) delete graph.linksDict[lkey];
141
+ }
142
+ }
143
+ collectFilters() {
144
+ const grid = this;
145
+ const filters = [];
146
+ if (grid.parentGrids && !grid.connectedToParents) return ["1=2"];
147
+ if (!grid.parents || grid.parents.length <= 0) return filters;
148
+ for (let uid of grid.parents) {
149
+ let link = grid.graph.linksDict[grid.id + "_" + grid.graph.nodesDict[uid].id];
150
+ let filter = grid.applyConnection(link);
151
+ if (filter == null || filter === "") continue;
152
+ let fo = {
153
+ type: "graphLink",
154
+ filter
155
+ };
156
+ filters.push(fo);
157
+ }
158
+ return filters;
159
+ }
160
+ skipOnWaveVisit() {
161
+ return false;
162
+ }
163
+ visitByWave(e) {
164
+ const grid = this;
165
+ return new Promise(function(resolve) {
166
+ if (grid.skipOnWaveVisit(e)) {
167
+ resolve(e);
168
+ return;
169
+ }
170
+ grid._waitingRows = true;
171
+ grid.getRows({
172
+ filters: grid.collectFilters(),
173
+ grid
174
+ }).then((rows) => {
175
+ grid.rows = rows;
176
+ grid.afterGetRows(e);
177
+ resolve(e);
178
+ grid.refreshState();
179
+ }).finally(() => {
180
+ grid._waitingRows = false;
181
+ grid.refreshState();
182
+ });
183
+ });
184
+ }
185
+ visitByWaveAlt(e) {
186
+ const grid = this;
187
+ return new Promise(function(resolve) {
188
+ if (grid.skipOnWaveVisit(e)) {
189
+ resolve(e);
190
+ return;
191
+ }
192
+ grid.selectedRowIndex = 0;
193
+ grid._waitingRows = true;
194
+ grid.refreshState();
195
+ grid.getRows({
196
+ filters: grid.collectFilters(),
197
+ grid
198
+ }).then((rows) => {
199
+ grid.rows = rows;
200
+ grid.afterGetRows(e);
201
+ resolve(e);
202
+ grid.refreshState();
203
+ }).finally(() => {
204
+ grid._waitingRows = false;
205
+ grid.refreshState();
206
+ });
207
+ });
208
+ }
209
+ hasVisibleParentGrids() {
210
+ const grid = this;
211
+ if (!grid.graph) return false;
212
+ for (let puid of grid.parents) {
213
+ let pnode = grid.graph.nodesDict[puid];
214
+ if (pnode.visible !== false && pnode.status === require_Base.NodeStatus.grid) return true;
215
+ }
216
+ return false;
217
+ }
218
+ };
219
+ exports.GridGR = GridGR;
220
+ exports.GridGRClass = GridGRClass;