@m2c2kit/addons 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Scott T. Yabiku
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -19,4 +19,4 @@ This package contains additions to m2c2kit core functionally, such as buttons, g
19
19
  - [Website](https://m2c2-project.github.io/m2c2kit/)
20
20
  - [Live Examples](https://m2c2-project.github.io/m2c2kit/docs/category/examples)
21
21
  - [Getting Started](https://m2c2-project.github.io/m2c2kit/docs/getting-started)
22
- - [Interactive Tutorial](https://m2c2-project.github.io/m2c2kit/docs/tutorial-fundamentals/fundamentals)
22
+ - [Interactive Tutorials](https://m2c2-project.github.io/m2c2kit/docs/category/tutorials)
package/dist/index.d.ts CHANGED
@@ -30,7 +30,7 @@ declare class Grid extends Composite {
30
30
  cellWidth: number;
31
31
  cellHeight: number;
32
32
  gridChildren: GridChild[];
33
- private gridBackground?;
33
+ private _gridBackground?;
34
34
  /**
35
35
  * A rectangular grid that supports placement of entities within the grid's
36
36
  * cells.
@@ -43,6 +43,8 @@ declare class Grid extends Composite {
43
43
  */
44
44
  constructor(options: GridOptions);
45
45
  initialize(): void;
46
+ private get gridBackground();
47
+ private set gridBackground(value);
46
48
  dispose(): void;
47
49
  /**
48
50
  * Duplicates an entity using deep copy.
@@ -60,7 +62,6 @@ declare class Grid extends Composite {
60
62
  warmup(canvas: Canvas): void;
61
63
  /**
62
64
  * Removes all children from the grid, but retains grid lines.
63
- *
64
65
  */
65
66
  removeAllChildren(): void;
66
67
  /**
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ class Grid extends Composite {
48
48
  __publicField$3(this, "cellWidth");
49
49
  __publicField$3(this, "cellHeight");
50
50
  __publicField$3(this, "gridChildren", new Array());
51
- __publicField$3(this, "gridBackground");
51
+ __publicField$3(this, "_gridBackground");
52
52
  if (options.size) {
53
53
  this.size = options.size;
54
54
  } else {
@@ -137,6 +137,15 @@ class Grid extends Composite {
137
137
  }
138
138
  this.needsInitialization = false;
139
139
  }
140
+ get gridBackground() {
141
+ if (!this._gridBackground) {
142
+ throw new Error("gridBackground is null or undefined");
143
+ }
144
+ return this._gridBackground;
145
+ }
146
+ set gridBackground(gridBackground) {
147
+ this._gridBackground = gridBackground;
148
+ }
140
149
  // all entities that make up grid are added as children, so they
141
150
  // have their own dispose methods
142
151
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -185,17 +194,18 @@ class Grid extends Composite {
185
194
  }
186
195
  // override Entity.RemoveAllChildren() so that when RemoveAllChildren() is called on a Grid,
187
196
  // it removes only entities added to the grid cells (what we call grid children), not the grid lines!
188
- // note: when we upgrade to typescript 4.3+, we can mark this with override keyword to make intention explicit
189
197
  /**
190
198
  * Removes all children from the grid, but retains grid lines.
191
- *
192
199
  */
193
200
  removeAllChildren() {
194
201
  if (this.gridChildren.length === 0) {
195
202
  return;
196
203
  }
197
204
  while (this.gridChildren.length) {
198
- this.gridChildren.pop();
205
+ const gridChild = this.gridChildren.pop();
206
+ if (gridChild) {
207
+ this.gridBackground.removeChild(gridChild.entity);
208
+ }
199
209
  }
200
210
  this.needsInitialization = true;
201
211
  }
@@ -222,8 +232,17 @@ class Grid extends Composite {
222
232
  * @param column - column position within grid at which to remove children; zero-based indexing
223
233
  */
224
234
  removeAllAtCell(row, column) {
235
+ const gridChildrenToRemove = this.gridChildren.filter(
236
+ (gridChild) => gridChild.row === row && gridChild.column === column
237
+ );
238
+ if (gridChildrenToRemove.length === 0) {
239
+ return;
240
+ }
241
+ this.gridBackground.removeChildren(
242
+ gridChildrenToRemove.map((gridChild) => gridChild.entity)
243
+ );
225
244
  this.gridChildren = this.gridChildren.filter(
226
- (gridChild) => gridChild.row != row && gridChild.column != column
245
+ (gridChild) => gridChild.row !== row && gridChild.column !== column
227
246
  );
228
247
  this.needsInitialization = true;
229
248
  }
@@ -235,9 +254,6 @@ class Grid extends Composite {
235
254
  * @param entity - entity to remove
236
255
  */
237
256
  removeChild(entity) {
238
- if (!this.gridBackground) {
239
- throw new Error("gridBackground is null or undefined");
240
- }
241
257
  this.gridBackground.removeChild(entity);
242
258
  this.gridChildren = this.gridChildren.filter(
243
259
  (gridChild) => gridChild.entity != entity
@@ -1311,5 +1327,7 @@ class Instructions extends Story {
1311
1327
  }
1312
1328
  }
1313
1329
 
1330
+ console.log("\u26AA @m2c2kit/addons version 0.3.9 (03abb9e7)");
1331
+
1314
1332
  export { Button, Dialog, DialogResult, Grid, Instructions, VirtualKeyboard };
1315
1333
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@m2c2kit/addons",
3
- "version": "0.3.7",
4
- "description": "Additions to m2c2kit core functionalty, such as button, grid, and instructions",
3
+ "version": "0.3.9",
4
+ "description": "Additions to m2c2kit core functionality, such as button, grid, and instructions",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {
@@ -15,20 +15,33 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "build": "npm run clean && tsc --build && rollup -c",
18
- "clean": "rimraf build build-nobundler build-umd dist .rollup.cache tsconfig.tsbuildinfo",
18
+ "clean": "rimraf build build-nobundler dist .rollup.cache tsconfig.tsbuildinfo",
19
19
  "test": "echo \"Error: no test specified\" && exit 1"
20
20
  },
21
21
  "license": "MIT",
22
+ "author": {
23
+ "name": "Scott T. Yabiku",
24
+ "email": "syabiku@gmail.com"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/m2c2-project/m2c2kit.git",
29
+ "directory": "packages/addons"
30
+ },
31
+ "homepage": "https://m2c2-project.github.io/m2c2kit",
22
32
  "dependencies": {
23
33
  "@m2c2kit/core": "^0.3.6"
24
34
  },
25
35
  "devDependencies": {
26
- "@rollup/plugin-babel": "6.0.3",
36
+ "@rollup/plugin-replace": "5.0.2",
27
37
  "rimraf": "5.0.1",
28
- "rollup": "3.25.1",
38
+ "rollup": "3.25.3",
29
39
  "rollup-plugin-copy": "3.4.0",
30
40
  "rollup-plugin-dts": "5.3.0",
31
41
  "rollup-plugin-esbuild": "5.0.0",
32
- "typescript": "5.1.3"
42
+ "typescript": "5.1.6"
43
+ },
44
+ "engines": {
45
+ "node": ">=18"
33
46
  }
34
47
  }