@mborecki/crossword 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mb-crossword.cjs.entry.js +58 -34
- package/dist/cjs/mb-crossword.cjs.js +1 -1
- package/dist/collection/components/crossword/mb-crossword.js +85 -37
- package/dist/components/mb-crossword.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mb-crossword.entry.js +58 -34
- package/dist/esm/mb-crossword.js +1 -1
- package/dist/mb-crossword/mb-crossword.esm.js +1 -1
- package/dist/mb-crossword/{p-a8347a29.entry.js → p-bd24da56.entry.js} +1 -1
- package/dist/types/components/crossword/mb-crossword.d.ts +5 -5
- package/dist/types/components.d.ts +11 -1
- package/package.json +1 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
|
6
6
|
const defineCustomElements = async (win, options) => {
|
|
7
7
|
if (typeof window === 'undefined') return undefined;
|
|
8
8
|
await appGlobals.globalScripts();
|
|
9
|
-
return index.bootstrapLazy([["mb-crossword.cjs",[[529,"mb-crossword",{"init":[4],"data":[16],"showCluePreview":[4,"show-clue-preview"],"clueListStyle":[1,"clue-list-style"],"hWords":[32],"vWords":[32],"currentClueId":[32],"currentClue":[32],"isFocused":[32],"selectedCell":[32],"specialBorders":[32],"specialCells":[32],"labels":[32],"boardWidth":[32],"boardHeight":[32],"cells":[32],"floatingPreviewHackParams":[32],"initGame":[64],"checkAnswer":[64],"selectClue":[64]},null,{"data":[{"watchData":0}]}]]]], options);
|
|
9
|
+
return index.bootstrapLazy([["mb-crossword.cjs",[[529,"mb-crossword",{"init":[4],"data":[16],"showCluePreview":[4,"show-clue-preview"],"clueListStyle":[1,"clue-list-style"],"compareFunction":[16],"hWords":[32],"vWords":[32],"currentClueId":[32],"currentClue":[32],"isFocused":[32],"selectedCell":[32],"specialBorders":[32],"specialCells":[32],"labels":[32],"boardWidth":[32],"boardHeight":[32],"cells":[32],"floatingPreviewHackParams":[32],"initGame":[64],"checkAnswer":[64],"selectClue":[64]},null,{"data":[{"watchData":0}]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -67,6 +67,7 @@ const MBCrossword = class {
|
|
|
67
67
|
data;
|
|
68
68
|
showCluePreview = true;
|
|
69
69
|
clueListStyle = 'ol';
|
|
70
|
+
compareFunction = (a, b) => { return a === b; };
|
|
70
71
|
clueSelected;
|
|
71
72
|
textInput;
|
|
72
73
|
hWords = [];
|
|
@@ -81,7 +82,7 @@ const MBCrossword = class {
|
|
|
81
82
|
if (this.init && this.data) {
|
|
82
83
|
this.initGame();
|
|
83
84
|
}
|
|
84
|
-
if (this.useStickyBottomHack && typeof window !== 'undefined') {
|
|
85
|
+
if (this.useStickyBottomHack && typeof window !== 'undefined' && window.visualViewport) {
|
|
85
86
|
window.visualViewport.addEventListener('resize', this.updateFloatingPreview.bind(this), { signal: this.abortController.signal });
|
|
86
87
|
window.visualViewport.addEventListener('scroll', this.updateFloatingPreview.bind(this), { signal: this.abortController.signal });
|
|
87
88
|
this.updateFloatingPreview();
|
|
@@ -126,7 +127,7 @@ const MBCrossword = class {
|
|
|
126
127
|
}
|
|
127
128
|
async checkAnswer() {
|
|
128
129
|
const cells = this.cells.filter(c => !c.isBlocked);
|
|
129
|
-
return cells.every(c => c.value
|
|
130
|
+
return cells.every(c => this.compareFunction(c.value, c.answer));
|
|
130
131
|
}
|
|
131
132
|
specialBorders = [];
|
|
132
133
|
specialCells = [];
|
|
@@ -140,11 +141,13 @@ const MBCrossword = class {
|
|
|
140
141
|
offsetTop: 0
|
|
141
142
|
};
|
|
142
143
|
updateFloatingPreview(_event) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
if (window.visualViewport) {
|
|
145
|
+
this.floatingPreviewHackParams = {
|
|
146
|
+
...this.floatingPreviewHackParams,
|
|
147
|
+
height: window.visualViewport.height,
|
|
148
|
+
offsetTop: window.visualViewport.offsetTop
|
|
149
|
+
};
|
|
150
|
+
}
|
|
148
151
|
}
|
|
149
152
|
buildBoard() {
|
|
150
153
|
let boardWidth = 0;
|
|
@@ -316,29 +319,64 @@ const MBCrossword = class {
|
|
|
316
319
|
onFocusOut() {
|
|
317
320
|
this.isFocused = false;
|
|
318
321
|
}
|
|
319
|
-
async selectClue(id,
|
|
322
|
+
async selectClue(id, cell = null) {
|
|
320
323
|
if (!id)
|
|
321
324
|
return;
|
|
322
|
-
|
|
323
|
-
const clue = this.allWords.find(w => w.id === id);
|
|
325
|
+
const clue = this.getClueById(id);
|
|
324
326
|
if (!clue) {
|
|
325
327
|
this.currentClueId = null;
|
|
326
328
|
this.currentClue = null;
|
|
329
|
+
return;
|
|
327
330
|
}
|
|
331
|
+
this.currentClueId = id;
|
|
328
332
|
this.currentClue = clue;
|
|
329
333
|
const selectCell = [clue.x, clue.y];
|
|
330
|
-
if (
|
|
331
|
-
if (
|
|
332
|
-
selectCell[1] =
|
|
334
|
+
if (cell && clue.orientation === 'vertical') {
|
|
335
|
+
if (cell.y >= clue.y && cell.y < clue.y + clue.word.length) {
|
|
336
|
+
selectCell[1] = cell.y;
|
|
333
337
|
}
|
|
334
338
|
}
|
|
335
|
-
if (
|
|
336
|
-
if (
|
|
337
|
-
selectCell[0] =
|
|
339
|
+
if (cell && clue.orientation === 'horizontal') {
|
|
340
|
+
if (cell.x >= clue.x && cell.x < clue.x + clue.word.length) {
|
|
341
|
+
selectCell[0] = cell.x;
|
|
338
342
|
}
|
|
339
343
|
}
|
|
340
344
|
this.selectCellByXY(index$1.Vec2.from(selectCell));
|
|
341
345
|
}
|
|
346
|
+
selectClueFromCell(cell) {
|
|
347
|
+
const clue = this.getClueByXV(cell);
|
|
348
|
+
if (!clue)
|
|
349
|
+
return;
|
|
350
|
+
const preview = this.getCluePreview(clue);
|
|
351
|
+
console.log('selectClueFromCell', cell, clue, preview);
|
|
352
|
+
if (preview.replaceAll('_', '').length === 0) {
|
|
353
|
+
this.selectClue(clue.id, index$1.Vec2.from(clue));
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
this.selectClue(clue.id, cell);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
selectClueByXY(v) {
|
|
360
|
+
const clue = this.getClueByXV(v);
|
|
361
|
+
if (!clue)
|
|
362
|
+
return;
|
|
363
|
+
this.selectClue(clue.id, v);
|
|
364
|
+
}
|
|
365
|
+
getClueByXV(v) {
|
|
366
|
+
const clues = this.allWords.filter(w => this.isInClue(v, w));
|
|
367
|
+
console.log('getClueXY', clues);
|
|
368
|
+
if (!clues.length) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (this.selectedCell && clues.length === 2 && v.eq(index$1.Vec2.from(this.selectedCell))) {
|
|
372
|
+
const betterClue = clues.find(c => c.orientation !== this.currentClue?.orientation);
|
|
373
|
+
return betterClue ?? clues[0];
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
const betterClue = clues.find(c => c.orientation === this.currentClue?.orientation);
|
|
377
|
+
return betterClue ?? clues[0];
|
|
378
|
+
}
|
|
379
|
+
}
|
|
342
380
|
selectCellByXY(v) {
|
|
343
381
|
const selectCellIndex = index$1.indexFromXY(v, this.boardWidth);
|
|
344
382
|
this.selectedCell = this.cells[selectCellIndex] ?? null;
|
|
@@ -370,20 +408,6 @@ const MBCrossword = class {
|
|
|
370
408
|
const cell = this.cells[index$1.indexFromXY(v, this.boardWidth)];
|
|
371
409
|
return cell?.isBlocked ?? true;
|
|
372
410
|
}
|
|
373
|
-
selectClueByXY(v) {
|
|
374
|
-
const clues = this.allWords.filter(w => this.isInClue(v, w));
|
|
375
|
-
if (!clues.length) {
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
if (this.selectedCell && clues.length === 2 && v.eq(index$1.Vec2.from(this.selectedCell))) {
|
|
379
|
-
const betterClue = clues.find(c => c.orientation !== this.currentClue?.orientation);
|
|
380
|
-
this.selectClue(betterClue?.id ?? clues[0].id, { row: v.y, col: v.x });
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
const betterClue = clues.find(c => c.orientation === this.currentClue?.orientation);
|
|
384
|
-
this.selectClue(betterClue?.id ?? clues[0].id, { row: v.y, col: v.x });
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
411
|
getCluePreview(clue) {
|
|
388
412
|
if (!clue)
|
|
389
413
|
return '_';
|
|
@@ -442,14 +466,14 @@ const MBCrossword = class {
|
|
|
442
466
|
const hideList = this.clueListStyle === 'none';
|
|
443
467
|
const twoLists = hasHWords && hasVWords;
|
|
444
468
|
const showFloatingClue = this.isFocused && this.currentClue && this.bowserParser.isPlatform('mobile');
|
|
445
|
-
return index.h("div", { key: '
|
|
469
|
+
return index.h("div", { key: '6fed5a87911f7be97155b1f0f854266ffc618f7d', part: "main", class: {
|
|
446
470
|
"--focused": this.isFocused,
|
|
447
471
|
"--only-board": hideList,
|
|
448
472
|
"--sticky-bottom-hack": this.useStickyBottomHack
|
|
449
473
|
}, onFocusin: this.onFocusin.bind(this), onFocusout: this.onFocusOut.bind(this), onClick: () => {
|
|
450
474
|
this.textInput.blur();
|
|
451
475
|
this.textInput.focus();
|
|
452
|
-
} }, index.h("input", { key: '
|
|
476
|
+
} }, index.h("input", { key: 'bffd1c704603b35b54f59c35092edb984a7adccb', type: "text", class: "dummy", ref: (el) => this.textInput = el, onKeyDown: this.onKeyPress.bind(this), onInput: this.onInput.bind(this) }), hideList ? '' : index.h("div", { part: "clues", class: {
|
|
453
477
|
twoLists,
|
|
454
478
|
oneList: !twoLists
|
|
455
479
|
} }, hasHWords ? index.h(ClueList, { type: this.clueListStyle }, this.hWords.map(w => {
|
|
@@ -458,7 +482,7 @@ const MBCrossword = class {
|
|
|
458
482
|
})) : '', hasVWords ? index.h(ClueList, { type: this.clueListStyle }, this.vWords.map(w => {
|
|
459
483
|
const isCurrent = w.id === this.currentClueId;
|
|
460
484
|
return index.h(Clue, { showPreview: this.showCluePreview, preview: this.getCluePreview(w), word: w, isCurrent: isCurrent, onPointerDown: () => this.selectClue(w.id), tagName: this.clueListStyle === 'ol' ? 'li' : undefined });
|
|
461
|
-
})) : ''), index.h("div", { key: '
|
|
485
|
+
})) : ''), index.h("div", { key: '9842d788d6e6a8df712c025474303ad0b0cf4f4b', part: "board", style: {
|
|
462
486
|
'--board-width': `${this.boardWidth}`,
|
|
463
487
|
'grid-template-columns': `repeat(${this.boardWidth}, 1fr)`,
|
|
464
488
|
aspectRatio: `${this.boardWidth / this.boardHeight}`
|
|
@@ -466,7 +490,7 @@ const MBCrossword = class {
|
|
|
466
490
|
const isInCurrentClue = this.isInClue(cell);
|
|
467
491
|
const isSelected = this.isSelectedCell(cell);
|
|
468
492
|
const isSpecial = this.specialCells.some(c => c.x === cell.x && c.y === cell.y);
|
|
469
|
-
return index.h(Cell, { isSpecial: isSpecial, onPointerDown: () => this.
|
|
493
|
+
return index.h(Cell, { isSpecial: isSpecial, onPointerDown: () => this.selectClueFromCell(index$1.Vec2.from(cell)), isInCurrentClue: isInCurrentClue, isSelected: isSelected, data: cell });
|
|
470
494
|
}), this.specialBorders.map((b, index$1) => {
|
|
471
495
|
return index.h("div", { key: index$1, part: "special-border", class: {
|
|
472
496
|
'top': Boolean(b.border & 0x1000),
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["mb-crossword.cjs",[[529,"mb-crossword",{"init":[4],"data":[16],"showCluePreview":[4,"show-clue-preview"],"clueListStyle":[1,"clue-list-style"],"hWords":[32],"vWords":[32],"currentClueId":[32],"currentClue":[32],"isFocused":[32],"selectedCell":[32],"specialBorders":[32],"specialCells":[32],"labels":[32],"boardWidth":[32],"boardHeight":[32],"cells":[32],"floatingPreviewHackParams":[32],"initGame":[64],"checkAnswer":[64],"selectClue":[64]},null,{"data":[{"watchData":0}]}]]]], options);
|
|
22
|
+
return index.bootstrapLazy([["mb-crossword.cjs",[[529,"mb-crossword",{"init":[4],"data":[16],"showCluePreview":[4,"show-clue-preview"],"clueListStyle":[1,"clue-list-style"],"compareFunction":[16],"hWords":[32],"vWords":[32],"currentClueId":[32],"currentClue":[32],"isFocused":[32],"selectedCell":[32],"specialBorders":[32],"specialCells":[32],"labels":[32],"boardWidth":[32],"boardHeight":[32],"cells":[32],"floatingPreviewHackParams":[32],"initGame":[64],"checkAnswer":[64],"selectClue":[64]},null,{"data":[{"watchData":0}]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -10,6 +10,7 @@ export class MBCrossword {
|
|
|
10
10
|
data;
|
|
11
11
|
showCluePreview = true;
|
|
12
12
|
clueListStyle = 'ol';
|
|
13
|
+
compareFunction = (a, b) => { return a === b; };
|
|
13
14
|
clueSelected;
|
|
14
15
|
textInput;
|
|
15
16
|
hWords = [];
|
|
@@ -24,7 +25,7 @@ export class MBCrossword {
|
|
|
24
25
|
if (this.init && this.data) {
|
|
25
26
|
this.initGame();
|
|
26
27
|
}
|
|
27
|
-
if (this.useStickyBottomHack && typeof window !== 'undefined') {
|
|
28
|
+
if (this.useStickyBottomHack && typeof window !== 'undefined' && window.visualViewport) {
|
|
28
29
|
window.visualViewport.addEventListener('resize', this.updateFloatingPreview.bind(this), { signal: this.abortController.signal });
|
|
29
30
|
window.visualViewport.addEventListener('scroll', this.updateFloatingPreview.bind(this), { signal: this.abortController.signal });
|
|
30
31
|
this.updateFloatingPreview();
|
|
@@ -69,7 +70,7 @@ export class MBCrossword {
|
|
|
69
70
|
}
|
|
70
71
|
async checkAnswer() {
|
|
71
72
|
const cells = this.cells.filter(c => !c.isBlocked);
|
|
72
|
-
return cells.every(c => c.value
|
|
73
|
+
return cells.every(c => this.compareFunction(c.value, c.answer));
|
|
73
74
|
}
|
|
74
75
|
specialBorders = [];
|
|
75
76
|
specialCells = [];
|
|
@@ -83,11 +84,13 @@ export class MBCrossword {
|
|
|
83
84
|
offsetTop: 0
|
|
84
85
|
};
|
|
85
86
|
updateFloatingPreview(_event) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
if (window.visualViewport) {
|
|
88
|
+
this.floatingPreviewHackParams = {
|
|
89
|
+
...this.floatingPreviewHackParams,
|
|
90
|
+
height: window.visualViewport.height,
|
|
91
|
+
offsetTop: window.visualViewport.offsetTop
|
|
92
|
+
};
|
|
93
|
+
}
|
|
91
94
|
}
|
|
92
95
|
buildBoard() {
|
|
93
96
|
let boardWidth = 0;
|
|
@@ -259,29 +262,64 @@ export class MBCrossword {
|
|
|
259
262
|
onFocusOut() {
|
|
260
263
|
this.isFocused = false;
|
|
261
264
|
}
|
|
262
|
-
async selectClue(id,
|
|
265
|
+
async selectClue(id, cell = null) {
|
|
263
266
|
if (!id)
|
|
264
267
|
return;
|
|
265
|
-
|
|
266
|
-
const clue = this.allWords.find(w => w.id === id);
|
|
268
|
+
const clue = this.getClueById(id);
|
|
267
269
|
if (!clue) {
|
|
268
270
|
this.currentClueId = null;
|
|
269
271
|
this.currentClue = null;
|
|
272
|
+
return;
|
|
270
273
|
}
|
|
274
|
+
this.currentClueId = id;
|
|
271
275
|
this.currentClue = clue;
|
|
272
276
|
const selectCell = [clue.x, clue.y];
|
|
273
|
-
if (
|
|
274
|
-
if (
|
|
275
|
-
selectCell[1] =
|
|
277
|
+
if (cell && clue.orientation === 'vertical') {
|
|
278
|
+
if (cell.y >= clue.y && cell.y < clue.y + clue.word.length) {
|
|
279
|
+
selectCell[1] = cell.y;
|
|
276
280
|
}
|
|
277
281
|
}
|
|
278
|
-
if (
|
|
279
|
-
if (
|
|
280
|
-
selectCell[0] =
|
|
282
|
+
if (cell && clue.orientation === 'horizontal') {
|
|
283
|
+
if (cell.x >= clue.x && cell.x < clue.x + clue.word.length) {
|
|
284
|
+
selectCell[0] = cell.x;
|
|
281
285
|
}
|
|
282
286
|
}
|
|
283
287
|
this.selectCellByXY(Vec2.from(selectCell));
|
|
284
288
|
}
|
|
289
|
+
selectClueFromCell(cell) {
|
|
290
|
+
const clue = this.getClueByXV(cell);
|
|
291
|
+
if (!clue)
|
|
292
|
+
return;
|
|
293
|
+
const preview = this.getCluePreview(clue);
|
|
294
|
+
console.log('selectClueFromCell', cell, clue, preview);
|
|
295
|
+
if (preview.replaceAll('_', '').length === 0) {
|
|
296
|
+
this.selectClue(clue.id, Vec2.from(clue));
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
this.selectClue(clue.id, cell);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
selectClueByXY(v) {
|
|
303
|
+
const clue = this.getClueByXV(v);
|
|
304
|
+
if (!clue)
|
|
305
|
+
return;
|
|
306
|
+
this.selectClue(clue.id, v);
|
|
307
|
+
}
|
|
308
|
+
getClueByXV(v) {
|
|
309
|
+
const clues = this.allWords.filter(w => this.isInClue(v, w));
|
|
310
|
+
console.log('getClueXY', clues);
|
|
311
|
+
if (!clues.length) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (this.selectedCell && clues.length === 2 && v.eq(Vec2.from(this.selectedCell))) {
|
|
315
|
+
const betterClue = clues.find(c => c.orientation !== this.currentClue?.orientation);
|
|
316
|
+
return betterClue ?? clues[0];
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
const betterClue = clues.find(c => c.orientation === this.currentClue?.orientation);
|
|
320
|
+
return betterClue ?? clues[0];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
285
323
|
selectCellByXY(v) {
|
|
286
324
|
const selectCellIndex = indexFromXY(v, this.boardWidth);
|
|
287
325
|
this.selectedCell = this.cells[selectCellIndex] ?? null;
|
|
@@ -313,20 +351,6 @@ export class MBCrossword {
|
|
|
313
351
|
const cell = this.cells[indexFromXY(v, this.boardWidth)];
|
|
314
352
|
return cell?.isBlocked ?? true;
|
|
315
353
|
}
|
|
316
|
-
selectClueByXY(v) {
|
|
317
|
-
const clues = this.allWords.filter(w => this.isInClue(v, w));
|
|
318
|
-
if (!clues.length) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
if (this.selectedCell && clues.length === 2 && v.eq(Vec2.from(this.selectedCell))) {
|
|
322
|
-
const betterClue = clues.find(c => c.orientation !== this.currentClue?.orientation);
|
|
323
|
-
this.selectClue(betterClue?.id ?? clues[0].id, { row: v.y, col: v.x });
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
const betterClue = clues.find(c => c.orientation === this.currentClue?.orientation);
|
|
327
|
-
this.selectClue(betterClue?.id ?? clues[0].id, { row: v.y, col: v.x });
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
354
|
getCluePreview(clue) {
|
|
331
355
|
if (!clue)
|
|
332
356
|
return '_';
|
|
@@ -385,14 +409,14 @@ export class MBCrossword {
|
|
|
385
409
|
const hideList = this.clueListStyle === 'none';
|
|
386
410
|
const twoLists = hasHWords && hasVWords;
|
|
387
411
|
const showFloatingClue = this.isFocused && this.currentClue && this.bowserParser.isPlatform('mobile');
|
|
388
|
-
return h("div", { key: '
|
|
412
|
+
return h("div", { key: '6fed5a87911f7be97155b1f0f854266ffc618f7d', part: "main", class: {
|
|
389
413
|
"--focused": this.isFocused,
|
|
390
414
|
"--only-board": hideList,
|
|
391
415
|
"--sticky-bottom-hack": this.useStickyBottomHack
|
|
392
416
|
}, onFocusin: this.onFocusin.bind(this), onFocusout: this.onFocusOut.bind(this), onClick: () => {
|
|
393
417
|
this.textInput.blur();
|
|
394
418
|
this.textInput.focus();
|
|
395
|
-
} }, h("input", { key: '
|
|
419
|
+
} }, h("input", { key: 'bffd1c704603b35b54f59c35092edb984a7adccb', type: "text", class: "dummy", ref: (el) => this.textInput = el, onKeyDown: this.onKeyPress.bind(this), onInput: this.onInput.bind(this) }), hideList ? '' : h("div", { part: "clues", class: {
|
|
396
420
|
twoLists,
|
|
397
421
|
oneList: !twoLists
|
|
398
422
|
} }, hasHWords ? h(ClueList, { type: this.clueListStyle }, this.hWords.map(w => {
|
|
@@ -401,7 +425,7 @@ export class MBCrossword {
|
|
|
401
425
|
})) : '', hasVWords ? h(ClueList, { type: this.clueListStyle }, this.vWords.map(w => {
|
|
402
426
|
const isCurrent = w.id === this.currentClueId;
|
|
403
427
|
return h(Clue, { showPreview: this.showCluePreview, preview: this.getCluePreview(w), word: w, isCurrent: isCurrent, onPointerDown: () => this.selectClue(w.id), tagName: this.clueListStyle === 'ol' ? 'li' : undefined });
|
|
404
|
-
})) : ''), h("div", { key: '
|
|
428
|
+
})) : ''), h("div", { key: '9842d788d6e6a8df712c025474303ad0b0cf4f4b', part: "board", style: {
|
|
405
429
|
'--board-width': `${this.boardWidth}`,
|
|
406
430
|
'grid-template-columns': `repeat(${this.boardWidth}, 1fr)`,
|
|
407
431
|
aspectRatio: `${this.boardWidth / this.boardHeight}`
|
|
@@ -409,7 +433,7 @@ export class MBCrossword {
|
|
|
409
433
|
const isInCurrentClue = this.isInClue(cell);
|
|
410
434
|
const isSelected = this.isSelectedCell(cell);
|
|
411
435
|
const isSpecial = this.specialCells.some(c => c.x === cell.x && c.y === cell.y);
|
|
412
|
-
return h(Cell, { isSpecial: isSpecial, onPointerDown: () => this.
|
|
436
|
+
return h(Cell, { isSpecial: isSpecial, onPointerDown: () => this.selectClueFromCell(Vec2.from(cell)), isInCurrentClue: isInCurrentClue, isSelected: isSelected, data: cell });
|
|
413
437
|
}), this.specialBorders.map((b, index) => {
|
|
414
438
|
return h("div", { key: index, part: "special-border", class: {
|
|
415
439
|
'top': Boolean(b.border & 0x1000),
|
|
@@ -530,6 +554,24 @@ export class MBCrossword {
|
|
|
530
554
|
"reflect": false,
|
|
531
555
|
"attribute": "clue-list-style",
|
|
532
556
|
"defaultValue": "'ol'"
|
|
557
|
+
},
|
|
558
|
+
"compareFunction": {
|
|
559
|
+
"type": "unknown",
|
|
560
|
+
"mutable": false,
|
|
561
|
+
"complexType": {
|
|
562
|
+
"original": "(a: string, b: string) => boolean",
|
|
563
|
+
"resolved": "(a: string, b: string) => boolean",
|
|
564
|
+
"references": {}
|
|
565
|
+
},
|
|
566
|
+
"required": false,
|
|
567
|
+
"optional": false,
|
|
568
|
+
"docs": {
|
|
569
|
+
"tags": [],
|
|
570
|
+
"text": ""
|
|
571
|
+
},
|
|
572
|
+
"getter": false,
|
|
573
|
+
"setter": false,
|
|
574
|
+
"defaultValue": "(a,b) => {return a === b}"
|
|
533
575
|
}
|
|
534
576
|
};
|
|
535
577
|
}
|
|
@@ -616,20 +658,26 @@ export class MBCrossword {
|
|
|
616
658
|
},
|
|
617
659
|
"selectClue": {
|
|
618
660
|
"complexType": {
|
|
619
|
-
"signature": "(id: string,
|
|
661
|
+
"signature": "(id: string, cell?: Vec2 | null) => Promise<void>",
|
|
620
662
|
"parameters": [{
|
|
621
663
|
"name": "id",
|
|
622
664
|
"type": "string",
|
|
623
665
|
"docs": ""
|
|
624
666
|
}, {
|
|
625
|
-
"name": "
|
|
626
|
-
"type": "
|
|
667
|
+
"name": "cell",
|
|
668
|
+
"type": "Vec2",
|
|
627
669
|
"docs": ""
|
|
628
670
|
}],
|
|
629
671
|
"references": {
|
|
630
672
|
"Promise": {
|
|
631
673
|
"location": "global",
|
|
632
674
|
"id": "global::Promise"
|
|
675
|
+
},
|
|
676
|
+
"Vec2": {
|
|
677
|
+
"location": "import",
|
|
678
|
+
"path": "@mb-puzzle/vec2",
|
|
679
|
+
"id": "../../shared/vec2/src/vec2.ts::Vec2",
|
|
680
|
+
"referenceLocation": "Vec2"
|
|
633
681
|
}
|
|
634
682
|
},
|
|
635
683
|
"return": "Promise<void>"
|