@m2c2kit/addons 0.3.10 → 0.3.11
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/dist/index.d.ts +1 -1
- package/dist/index.js +115 -215
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -603,4 +603,4 @@ declare class Instructions extends Story {
|
|
|
603
603
|
static Create(options: InstructionsOptions): Array<Scene>;
|
|
604
604
|
}
|
|
605
605
|
|
|
606
|
-
export { Button, ButtonOptions, Dialog, DialogEvent, DialogOptions, DialogResult, DrawPad, DrawPadEvent, DrawPadEventType, DrawPadItem, DrawPadItemEvent, DrawPadItemEventType, DrawPadOptions, DrawPadStroke, Grid, GridOptions, InstructionScene, Instructions, InstructionsOptions, KeyConfiguration, KeyTapMetadata, StrokeInteraction, VirtualKeyboard, VirtualKeyboardEvent, VirtualKeyboardOptions, VirtualKeyboardRow };
|
|
606
|
+
export { Button, type ButtonOptions, Dialog, type DialogEvent, type DialogOptions, DialogResult, DrawPad, type DrawPadEvent, DrawPadEventType, type DrawPadItem, type DrawPadItemEvent, DrawPadItemEventType, type DrawPadOptions, type DrawPadStroke, Grid, type GridOptions, type InstructionScene, Instructions, type InstructionsOptions, type KeyConfiguration, type KeyTapMetadata, type StrokeInteraction, VirtualKeyboard, type VirtualKeyboardEvent, type VirtualKeyboardOptions, type VirtualKeyboardRow };
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,5 @@
|
|
|
1
1
|
import { Composite, WebColors, Shape, Label, CanvasKitHelpers, EventType, MutablePath, Easings, Story, Transition, TransitionDirection, LabelHorizontalAlignmentMode, Scene, Dimensions, Sprite } from '@m2c2kit/core';
|
|
2
2
|
|
|
3
|
-
var __defProp$4 = Object.defineProperty;
|
|
4
|
-
var __defProps$1 = Object.defineProperties;
|
|
5
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
6
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues$1 = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
13
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols$1)
|
|
15
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
16
|
-
if (__propIsEnum$1.call(b, prop))
|
|
17
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
22
|
-
var __publicField$4 = (obj, key, value) => {
|
|
23
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
-
return value;
|
|
25
|
-
};
|
|
26
3
|
class Grid extends Composite {
|
|
27
4
|
/**
|
|
28
5
|
* A rectangular grid that supports placement of entities within the grid's
|
|
@@ -36,19 +13,16 @@ class Grid extends Composite {
|
|
|
36
13
|
*/
|
|
37
14
|
constructor(options) {
|
|
38
15
|
super(options);
|
|
39
|
-
|
|
16
|
+
this.compositeType = "grid";
|
|
40
17
|
// Grid options
|
|
41
18
|
// TODO: make getter, setter for these so they can be changed after initial construction
|
|
42
|
-
|
|
43
|
-
|
|
19
|
+
this.rows = 0;
|
|
20
|
+
this.columns = 0;
|
|
44
21
|
// default Grid is: transparent gray, red lines, line width 1
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
__publicField$4(this, "cellHeight");
|
|
50
|
-
__publicField$4(this, "gridChildren", new Array());
|
|
51
|
-
__publicField$4(this, "_gridBackground");
|
|
22
|
+
this.gridBackgroundColor = [0, 0, 233, 0.25];
|
|
23
|
+
this.gridLineColor = WebColors.Red;
|
|
24
|
+
this.gridLineWidth = 1;
|
|
25
|
+
this.gridChildren = new Array();
|
|
52
26
|
if (options.size) {
|
|
53
27
|
this.size = options.size;
|
|
54
28
|
} else {
|
|
@@ -162,7 +136,9 @@ class Grid extends Composite {
|
|
|
162
136
|
* provided, name will be the new uuid
|
|
163
137
|
*/
|
|
164
138
|
duplicate(newName) {
|
|
165
|
-
const dest = new Grid(
|
|
139
|
+
const dest = new Grid({
|
|
140
|
+
...this.getEntityOptions(),
|
|
141
|
+
...this.getDrawableOptions(),
|
|
166
142
|
rows: this.rows,
|
|
167
143
|
columns: this.columns,
|
|
168
144
|
size: this.size,
|
|
@@ -170,7 +146,7 @@ class Grid extends Composite {
|
|
|
170
146
|
gridLineWidth: this.gridLineWidth,
|
|
171
147
|
gridLineColor: this.gridLineColor,
|
|
172
148
|
name: newName
|
|
173
|
-
})
|
|
149
|
+
});
|
|
174
150
|
if (this.children.length > 0) {
|
|
175
151
|
dest.children = this.children.map((child) => {
|
|
176
152
|
const clonedChild = child.duplicate();
|
|
@@ -262,29 +238,6 @@ class Grid extends Composite {
|
|
|
262
238
|
}
|
|
263
239
|
}
|
|
264
240
|
|
|
265
|
-
var __defProp$3 = Object.defineProperty;
|
|
266
|
-
var __defProps = Object.defineProperties;
|
|
267
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
268
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
269
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
270
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
271
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
272
|
-
var __spreadValues = (a, b) => {
|
|
273
|
-
for (var prop in b || (b = {}))
|
|
274
|
-
if (__hasOwnProp.call(b, prop))
|
|
275
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
276
|
-
if (__getOwnPropSymbols)
|
|
277
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
278
|
-
if (__propIsEnum.call(b, prop))
|
|
279
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
280
|
-
}
|
|
281
|
-
return a;
|
|
282
|
-
};
|
|
283
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
284
|
-
var __publicField$3 = (obj, key, value) => {
|
|
285
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
286
|
-
return value;
|
|
287
|
-
};
|
|
288
241
|
class Button extends Composite {
|
|
289
242
|
// todo: add getters/setters so button can respond to changes in its options
|
|
290
243
|
// todo: add default "behaviors" (?) like button click animation?
|
|
@@ -299,15 +252,14 @@ class Button extends Composite {
|
|
|
299
252
|
*/
|
|
300
253
|
constructor(options) {
|
|
301
254
|
super(options);
|
|
302
|
-
|
|
255
|
+
this.compositeType = "button";
|
|
303
256
|
// Button options
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
__publicField$3(this, "backgroundPaint");
|
|
257
|
+
this._backgroundColor = WebColors.Black;
|
|
258
|
+
this.size = { width: 200, height: 50 };
|
|
259
|
+
this.cornerRadius = 9;
|
|
260
|
+
this.fontSize = 20;
|
|
261
|
+
this.text = "";
|
|
262
|
+
this._fontColor = WebColors.White;
|
|
311
263
|
if (options.text) {
|
|
312
264
|
this.text = options.text;
|
|
313
265
|
}
|
|
@@ -381,13 +333,16 @@ class Button extends Composite {
|
|
|
381
333
|
* provided, name will be the new uuid
|
|
382
334
|
*/
|
|
383
335
|
duplicate(newName) {
|
|
384
|
-
const dest = new Button(
|
|
336
|
+
const dest = new Button({
|
|
337
|
+
...this.getEntityOptions(),
|
|
338
|
+
...this.getDrawableOptions(),
|
|
339
|
+
...this.getTextOptions(),
|
|
385
340
|
size: this.size,
|
|
386
341
|
cornerRadius: this.cornerRadius,
|
|
387
342
|
backgroundColor: this.backgroundColor,
|
|
388
343
|
fontColor: this.fontColor,
|
|
389
344
|
name: newName
|
|
390
|
-
})
|
|
345
|
+
});
|
|
391
346
|
if (this.children.length > 0) {
|
|
392
347
|
dest.children = this.children.map((child) => {
|
|
393
348
|
const clonedChild = child.duplicate();
|
|
@@ -411,12 +366,6 @@ class Button extends Composite {
|
|
|
411
366
|
}
|
|
412
367
|
}
|
|
413
368
|
|
|
414
|
-
var __defProp$2 = Object.defineProperty;
|
|
415
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
416
|
-
var __publicField$2 = (obj, key, value) => {
|
|
417
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
418
|
-
return value;
|
|
419
|
-
};
|
|
420
369
|
var DialogResult = /* @__PURE__ */ ((DialogResult2) => {
|
|
421
370
|
DialogResult2["Dismiss"] = "Dismiss";
|
|
422
371
|
DialogResult2["Positive"] = "Positive";
|
|
@@ -428,17 +377,16 @@ class Dialog extends Composite {
|
|
|
428
377
|
// todo: add default "behaviors" (?) like button click animation?
|
|
429
378
|
constructor(options) {
|
|
430
379
|
super(options);
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
__publicField$2(this, "backgroundPaint");
|
|
380
|
+
this.compositeType = "dialog";
|
|
381
|
+
this._backgroundColor = WebColors.White;
|
|
382
|
+
this.cornerRadius = 9;
|
|
383
|
+
this.overlayAlpha = 0.5;
|
|
384
|
+
this.contentText = "";
|
|
385
|
+
this.positiveButtonText = "";
|
|
386
|
+
this.negativeButtonText = "";
|
|
387
|
+
this.zPosition = Number.MAX_VALUE;
|
|
388
|
+
this.hidden = true;
|
|
389
|
+
this._fontColor = WebColors.White;
|
|
442
390
|
if (!options) {
|
|
443
391
|
return;
|
|
444
392
|
}
|
|
@@ -626,12 +574,6 @@ class Dialog extends Composite {
|
|
|
626
574
|
}
|
|
627
575
|
}
|
|
628
576
|
|
|
629
|
-
var __defProp$1 = Object.defineProperty;
|
|
630
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
631
|
-
var __publicField$1 = (obj, key, value) => {
|
|
632
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
633
|
-
return value;
|
|
634
|
-
};
|
|
635
577
|
const DrawPadEventType = {
|
|
636
578
|
StrokeStart: "StrokeStart",
|
|
637
579
|
StrokeMove: "StrokeMove",
|
|
@@ -652,26 +594,21 @@ class DrawPad extends Composite {
|
|
|
652
594
|
*/
|
|
653
595
|
constructor(options) {
|
|
654
596
|
super(options);
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
/** The lines that are drawn */
|
|
667
|
-
__publicField$1(this, "drawShape");
|
|
668
|
-
__publicField$1(this, "isDrawingPointerDown", false);
|
|
669
|
-
__publicField$1(this, "pointerIsDownAndPointerLeftDrawAreaWhenDown", false);
|
|
670
|
-
__publicField$1(this, "currentStrokesNotAllowed", false);
|
|
597
|
+
this.compositeType = "DrawPad";
|
|
598
|
+
this.resumeDrawingOnReturn = false;
|
|
599
|
+
this.continuousDrawingOnly = false;
|
|
600
|
+
this._backgroundColor = [0, 0, 0, 0];
|
|
601
|
+
this._borderColor = WebColors.Black;
|
|
602
|
+
this._borderWidth = 1;
|
|
603
|
+
this._lineColor = WebColors.Red;
|
|
604
|
+
this._lineWidth = 1;
|
|
605
|
+
this.isDrawingPointerDown = false;
|
|
606
|
+
this.pointerIsDownAndPointerLeftDrawAreaWhenDown = false;
|
|
607
|
+
this.currentStrokesNotAllowed = false;
|
|
671
608
|
/** Array of strokes created on the DrawPad, with position and timestamps
|
|
672
609
|
* of all interactions with each DrawPadStroke.
|
|
673
610
|
*/
|
|
674
|
-
|
|
611
|
+
this.strokes = new Array();
|
|
675
612
|
if (options.isUserInteractionEnabled === void 0) {
|
|
676
613
|
this.isUserInteractionEnabled = true;
|
|
677
614
|
}
|
|
@@ -712,9 +649,9 @@ class DrawPad extends Composite {
|
|
|
712
649
|
initializeDrawShape() {
|
|
713
650
|
if (!this.drawShape) {
|
|
714
651
|
const mutablePath = new MutablePath();
|
|
715
|
-
mutablePath.size = this.size;
|
|
716
652
|
this.drawShape = new Shape({
|
|
717
|
-
path: mutablePath
|
|
653
|
+
path: mutablePath,
|
|
654
|
+
size: this.size
|
|
718
655
|
});
|
|
719
656
|
this.addChild(this.drawShape);
|
|
720
657
|
}
|
|
@@ -1141,12 +1078,6 @@ class DrawPad extends Composite {
|
|
|
1141
1078
|
}
|
|
1142
1079
|
}
|
|
1143
1080
|
|
|
1144
|
-
var __defProp = Object.defineProperty;
|
|
1145
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1146
|
-
var __publicField = (obj, key, value) => {
|
|
1147
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1148
|
-
return value;
|
|
1149
|
-
};
|
|
1150
1081
|
class VirtualKeyboard extends Composite {
|
|
1151
1082
|
/**
|
|
1152
1083
|
* An on-screen keyboard that can be used to enter text.
|
|
@@ -1154,31 +1085,15 @@ class VirtualKeyboard extends Composite {
|
|
|
1154
1085
|
* @param options - {@link VirtualKeyboardOptions}
|
|
1155
1086
|
*/
|
|
1156
1087
|
constructor(options) {
|
|
1157
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
1158
1088
|
super(options);
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
__publicField(this, "keyHorizontalPaddingPercent");
|
|
1162
|
-
__publicField(this, "keyVerticalPaddingPercent");
|
|
1163
|
-
__publicField(this, "rowsConfiguration", new Array());
|
|
1164
|
-
__publicField(this, "keysPerRow");
|
|
1165
|
-
__publicField(this, "fontSize");
|
|
1166
|
-
__publicField(this, "fontNames");
|
|
1167
|
-
__publicField(this, "hiddenKeys");
|
|
1168
|
-
__publicField(this, "capitalLettersOnly");
|
|
1169
|
-
__publicField(this, "keyColor");
|
|
1170
|
-
__publicField(this, "keyDownColor");
|
|
1171
|
-
__publicField(this, "specialKeyDownColor");
|
|
1172
|
-
__publicField(this, "backgroundColor");
|
|
1173
|
-
__publicField(this, "showKeyDownPreview");
|
|
1174
|
-
__publicField(this, "shiftActivated", false);
|
|
1175
|
-
__publicField(this, "shiftKeyShape");
|
|
1089
|
+
this.rowsConfiguration = new Array();
|
|
1090
|
+
this.shiftActivated = false;
|
|
1176
1091
|
this.size = options.size;
|
|
1177
|
-
this.position =
|
|
1178
|
-
this.keyboardHorizontalPaddingPercent =
|
|
1179
|
-
this.keyboardVerticalPaddingPercent =
|
|
1180
|
-
this.keyHorizontalPaddingPercent =
|
|
1181
|
-
this.keyVerticalPaddingPercent =
|
|
1092
|
+
this.position = options.position ?? { x: 0, y: 0 };
|
|
1093
|
+
this.keyboardHorizontalPaddingPercent = options.keyboardHorizontalPaddingPercent ?? 0.02;
|
|
1094
|
+
this.keyboardVerticalPaddingPercent = options.keyboardVerticalPaddingPercent ?? 0.025;
|
|
1095
|
+
this.keyHorizontalPaddingPercent = options.keyHorizontalPaddingPercent ?? 0.1;
|
|
1096
|
+
this.keyVerticalPaddingPercent = options.keyVerticalPaddingPercent ?? 0.1;
|
|
1182
1097
|
if (options.rows !== void 0) {
|
|
1183
1098
|
this.rowsConfiguration = options.rows.map((row) => {
|
|
1184
1099
|
const internalRow = row.map((key) => {
|
|
@@ -1196,19 +1111,18 @@ class VirtualKeyboard extends Composite {
|
|
|
1196
1111
|
return internalRow;
|
|
1197
1112
|
});
|
|
1198
1113
|
}
|
|
1199
|
-
this.keysPerRow =
|
|
1200
|
-
this.fontSize =
|
|
1114
|
+
this.keysPerRow = options.keysPerRow ?? NaN;
|
|
1115
|
+
this.fontSize = options.fontSize ?? NaN;
|
|
1201
1116
|
this.fontNames = options.fontNames;
|
|
1202
|
-
this.hiddenKeys =
|
|
1203
|
-
this.capitalLettersOnly =
|
|
1204
|
-
this.keyColor =
|
|
1205
|
-
this.keyDownColor =
|
|
1206
|
-
this.specialKeyDownColor =
|
|
1207
|
-
this.backgroundColor =
|
|
1208
|
-
this.showKeyDownPreview =
|
|
1117
|
+
this.hiddenKeys = options.hiddenKeys ?? "";
|
|
1118
|
+
this.capitalLettersOnly = options.capitalLettersOnly ?? false;
|
|
1119
|
+
this.keyColor = options.keyColor ?? WebColors.White;
|
|
1120
|
+
this.keyDownColor = options.keyDownColor ?? WebColors.Transparent;
|
|
1121
|
+
this.specialKeyDownColor = options.specialKeyDownColor ?? WebColors.LightSteelBlue;
|
|
1122
|
+
this.backgroundColor = options.backgroundColor ?? [242, 240, 244, 1];
|
|
1123
|
+
this.showKeyDownPreview = options.showKeyDownPreview ?? true;
|
|
1209
1124
|
}
|
|
1210
1125
|
initialize() {
|
|
1211
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1212
1126
|
if (this.rowsConfiguration.length === 0) {
|
|
1213
1127
|
const numKeys = [
|
|
1214
1128
|
["1", "!"],
|
|
@@ -1248,7 +1162,7 @@ class VirtualKeyboard extends Composite {
|
|
|
1248
1162
|
const shiftArrowShapeOptions = {
|
|
1249
1163
|
path: {
|
|
1250
1164
|
// Public Domain from https://www.freesvg.org
|
|
1251
|
-
|
|
1165
|
+
pathString: "m288-6.6849e-14 -288 288h144v288h288v-288h144l-288-288z",
|
|
1252
1166
|
width: 24
|
|
1253
1167
|
},
|
|
1254
1168
|
lineWidth: 2,
|
|
@@ -1258,7 +1172,7 @@ class VirtualKeyboard extends Composite {
|
|
|
1258
1172
|
const backspaceShapeOptions = {
|
|
1259
1173
|
path: {
|
|
1260
1174
|
// CC0 from https://www.svgrepo.com
|
|
1261
|
-
|
|
1175
|
+
pathString: "M10.625 5.09 0 22.09l10.625 17H44.18v-34H10.625zm31.555 32H11.734l-9.375-15 9.375-15H42.18v30zm-23.293-6.293 7.293-7.293 7.293 7.293 1.414-1.414-7.293-7.293 7.293-7.293-1.414-1.414-7.293 7.293-7.293-7.293-1.414 1.414 7.293 7.293-7.293 7.293",
|
|
1262
1176
|
width: 24
|
|
1263
1177
|
},
|
|
1264
1178
|
lineWidth: 1,
|
|
@@ -1309,7 +1223,6 @@ class VirtualKeyboard extends Composite {
|
|
|
1309
1223
|
this.addChild(keyboardRectangle);
|
|
1310
1224
|
const rows = this.rowsConfiguration.map((row) => {
|
|
1311
1225
|
return row.map((key) => {
|
|
1312
|
-
var _a2, _b2, _c2, _d2;
|
|
1313
1226
|
let widthRatio = 1;
|
|
1314
1227
|
const heightRatio = 1;
|
|
1315
1228
|
let code;
|
|
@@ -1331,11 +1244,11 @@ class VirtualKeyboard extends Composite {
|
|
|
1331
1244
|
labelShifted = key[1];
|
|
1332
1245
|
} else {
|
|
1333
1246
|
code = key.code;
|
|
1334
|
-
label =
|
|
1335
|
-
labelShifted =
|
|
1336
|
-
widthRatio =
|
|
1247
|
+
label = key.labelText ?? "";
|
|
1248
|
+
labelShifted = key.labelTextShifted ?? label;
|
|
1249
|
+
widthRatio = key.widthRatio ?? 1;
|
|
1337
1250
|
keyIcon = key.keyIcon;
|
|
1338
|
-
isShift =
|
|
1251
|
+
isShift = key.isShift ?? false;
|
|
1339
1252
|
}
|
|
1340
1253
|
return {
|
|
1341
1254
|
widthRatio,
|
|
@@ -1352,17 +1265,14 @@ class VirtualKeyboard extends Composite {
|
|
|
1352
1265
|
x: -keyboardRectangle.size.width / 2,
|
|
1353
1266
|
y: -keyboardRectangle.size.height / 2
|
|
1354
1267
|
};
|
|
1355
|
-
const keyboardVerticalPadding = (
|
|
1356
|
-
const keyboardHorizontalPadding = (
|
|
1268
|
+
const keyboardVerticalPadding = (this.keyboardVerticalPaddingPercent ?? 0.025) * this.size.height;
|
|
1269
|
+
const keyboardHorizontalPadding = (this.keyboardHorizontalPaddingPercent ?? 0.02) * this.size.width;
|
|
1357
1270
|
const keyBoxHeight = (this.size.height - 2 * keyboardVerticalPadding) / rows.length;
|
|
1358
1271
|
const keyBoxWidth = (this.size.width - 2 * keyboardHorizontalPadding) / this.keysPerRow;
|
|
1359
1272
|
for (let r = 0; r < rows.length; r++) {
|
|
1360
1273
|
const row = rows[r];
|
|
1361
1274
|
const rowSumKeyWidths = row.reduce(
|
|
1362
|
-
(sum, key) =>
|
|
1363
|
-
var _a2;
|
|
1364
|
-
return sum + ((_a2 = key.widthRatio) != null ? _a2 : 1);
|
|
1365
|
-
},
|
|
1275
|
+
(sum, key) => sum + (key.widthRatio ?? 1),
|
|
1366
1276
|
0
|
|
1367
1277
|
);
|
|
1368
1278
|
let extraPadding = 0;
|
|
@@ -1371,17 +1281,14 @@ class VirtualKeyboard extends Composite {
|
|
|
1371
1281
|
}
|
|
1372
1282
|
for (let k = 0; k < row.length; k++) {
|
|
1373
1283
|
const key = row[k];
|
|
1374
|
-
if (
|
|
1284
|
+
if (this.hiddenKeys?.split(",").map((s) => s.trim()).includes(key.code)) {
|
|
1375
1285
|
continue;
|
|
1376
1286
|
}
|
|
1377
|
-
const keyBoxWidthsSoFar = row.slice(0, k).reduce((sum, key2) =>
|
|
1378
|
-
var _a2;
|
|
1379
|
-
return sum + ((_a2 = key2.widthRatio) != null ? _a2 : 1);
|
|
1380
|
-
}, 0) * keyBoxWidth;
|
|
1287
|
+
const keyBoxWidthsSoFar = row.slice(0, k).reduce((sum, key2) => sum + (key2.widthRatio ?? 1), 0) * keyBoxWidth;
|
|
1381
1288
|
const keyBox = new Shape({
|
|
1382
1289
|
rect: {
|
|
1383
1290
|
size: {
|
|
1384
|
-
width: keyBoxWidth * (
|
|
1291
|
+
width: keyBoxWidth * (key.widthRatio ?? 1),
|
|
1385
1292
|
height: keyBoxHeight
|
|
1386
1293
|
}
|
|
1387
1294
|
},
|
|
@@ -1389,12 +1296,12 @@ class VirtualKeyboard extends Composite {
|
|
|
1389
1296
|
strokeColor: WebColors.Transparent,
|
|
1390
1297
|
lineWidth: 1,
|
|
1391
1298
|
position: {
|
|
1392
|
-
x: extraPadding + keyboardOrigin.x + keyboardHorizontalPadding + keyBoxWidthsSoFar + (
|
|
1299
|
+
x: extraPadding + keyboardOrigin.x + keyboardHorizontalPadding + keyBoxWidthsSoFar + (key.widthRatio ?? 1) * keyBoxWidth / 2,
|
|
1393
1300
|
y: keyboardOrigin.y + keyboardVerticalPadding + r * keyBoxHeight + keyBoxHeight / 2
|
|
1394
1301
|
}
|
|
1395
1302
|
});
|
|
1396
|
-
const keyWidth = keyBoxWidth * (
|
|
1397
|
-
const keyHeight = keyBoxHeight - (
|
|
1303
|
+
const keyWidth = keyBoxWidth * (key.widthRatio ?? 1) - 2 * this.keyHorizontalPaddingPercent * keyBoxWidth;
|
|
1304
|
+
const keyHeight = keyBoxHeight - (key.heightRatio ?? 1) - 2 * this.keyVerticalPaddingPercent * keyBoxHeight;
|
|
1398
1305
|
const keyShape = new Shape({
|
|
1399
1306
|
rect: { size: { width: keyWidth, height: keyHeight } },
|
|
1400
1307
|
cornerRadius: 4,
|
|
@@ -1404,7 +1311,6 @@ class VirtualKeyboard extends Composite {
|
|
|
1404
1311
|
});
|
|
1405
1312
|
keyBox.addChild(keyShape);
|
|
1406
1313
|
keyShape.onTapUp((tapEvent) => {
|
|
1407
|
-
var _a2, _b2;
|
|
1408
1314
|
let keyAsString = "";
|
|
1409
1315
|
if (!key.isShift) {
|
|
1410
1316
|
if (this.shiftActivated) {
|
|
@@ -1416,14 +1322,13 @@ class VirtualKeyboard extends Composite {
|
|
|
1416
1322
|
}
|
|
1417
1323
|
}
|
|
1418
1324
|
rows.flatMap((k2) => k2).forEach((k2) => {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
k2.keyLabel.text = (_b3 = k2.labelText) != null ? _b3 : "";
|
|
1325
|
+
if (k2.keyLabel?.text !== void 0) {
|
|
1326
|
+
k2.keyLabel.text = k2.labelText ?? "";
|
|
1422
1327
|
}
|
|
1423
1328
|
});
|
|
1424
|
-
keyAsString =
|
|
1329
|
+
keyAsString = key.labelTextShifted ?? key.code;
|
|
1425
1330
|
} else {
|
|
1426
|
-
keyAsString =
|
|
1331
|
+
keyAsString = key.labelText ?? key.code;
|
|
1427
1332
|
}
|
|
1428
1333
|
if (key.code === " " || key.code === "Backspace") {
|
|
1429
1334
|
keyAsString = key.code;
|
|
@@ -1460,7 +1365,6 @@ class VirtualKeyboard extends Composite {
|
|
|
1460
1365
|
}
|
|
1461
1366
|
});
|
|
1462
1367
|
keyShape.onTapDown((tapEvent) => {
|
|
1463
|
-
var _a2, _b2, _c2, _d2;
|
|
1464
1368
|
if (key.isShift) {
|
|
1465
1369
|
this.shiftActivated = !this.shiftActivated;
|
|
1466
1370
|
if (this.shiftActivated) {
|
|
@@ -1469,9 +1373,8 @@ class VirtualKeyboard extends Composite {
|
|
|
1469
1373
|
key.keyIcon.fillColor = WebColors.Black;
|
|
1470
1374
|
}
|
|
1471
1375
|
rows.flatMap((k2) => k2).forEach((k2) => {
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
k2.keyLabel.text = (_c3 = (_b3 = k2.labelTextShifted) != null ? _b3 : k2.labelText) != null ? _c3 : "";
|
|
1376
|
+
if (k2.keyLabel?.text !== void 0) {
|
|
1377
|
+
k2.keyLabel.text = k2.labelTextShifted ?? k2.labelText ?? "";
|
|
1475
1378
|
}
|
|
1476
1379
|
});
|
|
1477
1380
|
} else {
|
|
@@ -1480,9 +1383,8 @@ class VirtualKeyboard extends Composite {
|
|
|
1480
1383
|
key.keyIcon.fillColor = WebColors.Transparent;
|
|
1481
1384
|
}
|
|
1482
1385
|
rows.flatMap((k2) => k2).forEach((k2) => {
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
k2.keyLabel.text = (_b3 = k2.labelText) != null ? _b3 : "";
|
|
1386
|
+
if (k2.keyLabel?.text !== void 0) {
|
|
1387
|
+
k2.keyLabel.text = k2.labelText ?? "";
|
|
1486
1388
|
}
|
|
1487
1389
|
});
|
|
1488
1390
|
}
|
|
@@ -1498,15 +1400,15 @@ class VirtualKeyboard extends Composite {
|
|
|
1498
1400
|
letterCircle.position.x = keyBox.position.x;
|
|
1499
1401
|
letterCircle.position.y = keyBox.position.y - keyHeight * 1.2;
|
|
1500
1402
|
if (this.shiftActivated) {
|
|
1501
|
-
letterCircleLabel.text =
|
|
1403
|
+
letterCircleLabel.text = key.labelTextShifted ?? key.code;
|
|
1502
1404
|
} else {
|
|
1503
|
-
letterCircleLabel.text =
|
|
1405
|
+
letterCircleLabel.text = key.labelText ?? key.code;
|
|
1504
1406
|
}
|
|
1505
1407
|
}
|
|
1506
1408
|
if (this.shiftActivated) {
|
|
1507
|
-
keyAsString =
|
|
1409
|
+
keyAsString = key.labelTextShifted ?? key.code;
|
|
1508
1410
|
} else {
|
|
1509
|
-
keyAsString =
|
|
1411
|
+
keyAsString = key.labelText ?? key.code;
|
|
1510
1412
|
}
|
|
1511
1413
|
}
|
|
1512
1414
|
if (this.eventListeners.length > 0) {
|
|
@@ -1645,38 +1547,37 @@ class Instructions extends Story {
|
|
|
1645
1547
|
static Create(options) {
|
|
1646
1548
|
const scenes = new Array();
|
|
1647
1549
|
options.instructionScenes.forEach((s, i) => {
|
|
1648
|
-
|
|
1649
|
-
const nextSceneTransition = (_b = (_a = s.nextSceneTransition) != null ? _a : options.nextSceneTransition) != null ? _b : Transition.slide({
|
|
1550
|
+
const nextSceneTransition = s.nextSceneTransition ?? options.nextSceneTransition ?? Transition.slide({
|
|
1650
1551
|
direction: TransitionDirection.Left,
|
|
1651
1552
|
duration: SCENE_TRANSITION_DURATION,
|
|
1652
1553
|
easing: SCENE_TRANSITION_EASING
|
|
1653
1554
|
});
|
|
1654
|
-
const backSceneTransition =
|
|
1555
|
+
const backSceneTransition = s.backSceneTransition ?? options.backSceneTransition ?? Transition.slide({
|
|
1655
1556
|
direction: TransitionDirection.Right,
|
|
1656
1557
|
duration: SCENE_TRANSITION_DURATION,
|
|
1657
1558
|
easing: SCENE_TRANSITION_EASING
|
|
1658
1559
|
});
|
|
1659
|
-
const backButtonText =
|
|
1660
|
-
const nextButtonText =
|
|
1661
|
-
const backButtonWidth =
|
|
1662
|
-
const nextButtonWidth =
|
|
1663
|
-
const backButtonHeight =
|
|
1664
|
-
const nextButtonHeight =
|
|
1665
|
-
const backgroundColor =
|
|
1666
|
-
const imageAboveText =
|
|
1667
|
-
const imageMarginTop =
|
|
1668
|
-
const imageMarginBottom =
|
|
1669
|
-
const textMarginStart =
|
|
1670
|
-
const textMarginEnd =
|
|
1671
|
-
const textAlignmentMode =
|
|
1672
|
-
const textFontSize =
|
|
1673
|
-
const titleFontSize =
|
|
1674
|
-
const titleMarginTop =
|
|
1675
|
-
const backButtonBackgroundColor =
|
|
1676
|
-
const backButtonFontColor =
|
|
1677
|
-
const nextButtonBackgroundColor =
|
|
1678
|
-
const nextButtonFontColor =
|
|
1679
|
-
const sceneNamePrefix =
|
|
1560
|
+
const backButtonText = s.backButtonText ?? options.backButtonText ?? "Back";
|
|
1561
|
+
const nextButtonText = s.nextButtonText ?? options.nextButtonText ?? "Next";
|
|
1562
|
+
const backButtonWidth = s.backButtonWidth ?? options.backButtonWidth ?? 125;
|
|
1563
|
+
const nextButtonWidth = s.nextButtonWidth ?? options.nextButtonWidth ?? 125;
|
|
1564
|
+
const backButtonHeight = s.backButtonHeight ?? options.backButtonHeight ?? 50;
|
|
1565
|
+
const nextButtonHeight = s.nextButtonHeight ?? options.nextButtonHeight ?? 50;
|
|
1566
|
+
const backgroundColor = s.backgroundColor ?? options.backgroundColor;
|
|
1567
|
+
const imageAboveText = s.imageAboveText ?? true;
|
|
1568
|
+
const imageMarginTop = s.imageMarginTop ?? 0;
|
|
1569
|
+
const imageMarginBottom = s.imageMarginBottom ?? 0;
|
|
1570
|
+
const textMarginStart = s.textMarginStart ?? 48;
|
|
1571
|
+
const textMarginEnd = s.textMarginEnd ?? 48;
|
|
1572
|
+
const textAlignmentMode = s.textAlignmentMode ?? LabelHorizontalAlignmentMode.Left;
|
|
1573
|
+
const textFontSize = s.textFontSize ?? 16;
|
|
1574
|
+
const titleFontSize = s.titleFontSize ?? 16;
|
|
1575
|
+
const titleMarginTop = s.titleMarginTop ?? 48;
|
|
1576
|
+
const backButtonBackgroundColor = s.backButtonBackgroundColor ?? options.backButtonBackgroundColor ?? WebColors.Black;
|
|
1577
|
+
const backButtonFontColor = s.backButtonFontColor ?? options.backButtonFontColor ?? WebColors.White;
|
|
1578
|
+
const nextButtonBackgroundColor = s.nextButtonBackgroundColor ?? options.nextButtonBackgroundColor ?? WebColors.Black;
|
|
1579
|
+
const nextButtonFontColor = s.nextButtonFontColor ?? options.nextButtonFontColor ?? WebColors.White;
|
|
1580
|
+
const sceneNamePrefix = options.sceneNamePrefix ?? "instructions";
|
|
1680
1581
|
const scene = new Scene({
|
|
1681
1582
|
name: sceneNamePrefix + "-" + (i + 1).toString().padStart(2, "0"),
|
|
1682
1583
|
backgroundColor
|
|
@@ -1806,9 +1707,8 @@ class Instructions extends Story {
|
|
|
1806
1707
|
} else {
|
|
1807
1708
|
if (options.postInstructionsScene !== void 0) {
|
|
1808
1709
|
nextButton.onTapDown(() => {
|
|
1809
|
-
var _a2;
|
|
1810
1710
|
scene.game.presentScene(
|
|
1811
|
-
|
|
1711
|
+
options.postInstructionsScene ?? "",
|
|
1812
1712
|
nextSceneTransition
|
|
1813
1713
|
);
|
|
1814
1714
|
});
|
|
@@ -1842,7 +1742,7 @@ class Instructions extends Story {
|
|
|
1842
1742
|
}
|
|
1843
1743
|
}
|
|
1844
1744
|
|
|
1845
|
-
console.log("\u26AA @m2c2kit/addons version 0.3.
|
|
1745
|
+
console.log("\u26AA @m2c2kit/addons version 0.3.11 (60325bea)");
|
|
1846
1746
|
|
|
1847
1747
|
export { Button, Dialog, DialogResult, DrawPad, DrawPadEventType, DrawPadItemEventType, Grid, Instructions, VirtualKeyboard };
|
|
1848
1748
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m2c2kit/addons",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
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",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://m2c2-project.github.io/m2c2kit",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@m2c2kit/core": "^0.3.
|
|
33
|
+
"@m2c2kit/core": "^0.3.14"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@rollup/plugin-replace": "5.0.
|
|
37
|
-
"rimraf": "5.0.
|
|
38
|
-
"rollup": "
|
|
39
|
-
"rollup-plugin-copy": "3.
|
|
40
|
-
"rollup-plugin-dts": "
|
|
41
|
-
"rollup-plugin-esbuild": "
|
|
42
|
-
"typescript": "5.
|
|
36
|
+
"@rollup/plugin-replace": "5.0.5",
|
|
37
|
+
"rimraf": "5.0.5",
|
|
38
|
+
"rollup": "4.6.1",
|
|
39
|
+
"rollup-plugin-copy": "3.5.0",
|
|
40
|
+
"rollup-plugin-dts": "6.1.0",
|
|
41
|
+
"rollup-plugin-esbuild": "6.1.0",
|
|
42
|
+
"typescript": "5.3.2"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=18"
|