@mborecki/crossword 0.2.1 → 0.3.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.
@@ -2155,10 +2155,32 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
2155
2155
  return propValue === "false" ? false : propValue === "" || !!propValue;
2156
2156
  }
2157
2157
  }
2158
+ if (propType & 1 /* String */) {
2159
+ return String(propValue);
2160
+ }
2158
2161
  return propValue;
2159
2162
  }
2160
2163
  return propValue;
2161
2164
  };
2165
+ var getElement = (ref) => {
2166
+ var _a;
2167
+ return (_a = getHostRef(ref)) == null ? void 0 : _a.$hostElement$ ;
2168
+ };
2169
+
2170
+ // src/runtime/event-emitter.ts
2171
+ var createEvent = (ref, name, flags) => {
2172
+ const elm = getElement(ref);
2173
+ return {
2174
+ emit: (detail) => {
2175
+ return emitEvent(elm, name, {
2176
+ bubbles: true,
2177
+ composed: true,
2178
+ cancelable: true,
2179
+ detail
2180
+ });
2181
+ }
2182
+ };
2183
+ };
2162
2184
  var emitEvent = (elm, name, opts) => {
2163
2185
  const ev = plt.ce(name, opts);
2164
2186
  elm.dispatchEvent(ev);
@@ -3213,6 +3235,7 @@ function transformTag(tag) {
3213
3235
  }
3214
3236
 
3215
3237
  exports.bootstrapLazy = bootstrapLazy;
3238
+ exports.createEvent = createEvent;
3216
3239
  exports.forceUpdate = forceUpdate;
3217
3240
  exports.h = h;
3218
3241
  exports.promiseResolve = promiseResolve;
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BlTGwvVC.js');
3
+ var index = require('./index-rgQMtYdn.js');
4
4
  var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
5
 
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"],"hWords":[32],"vWords":[32],"currentClueId":[32],"currentClue":[32],"isFocused":[32],"selectedCell":[32],"specialBorders":[32],"specialCells":[32],"labels":[32],"boardWidth":[32],"boardHeight":[32],"cells":[32],"initGame":[64],"checkAnswer":[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"],"hWords":[32],"vWords":[32],"currentClueId":[32],"currentClue":[32],"isFocused":[32],"selectedCell":[32],"specialBorders":[32],"specialCells":[32],"labels":[32],"boardWidth":[32],"boardHeight":[32],"cells":[32],"initGame":[64],"checkAnswer":[64],"selectClue":[64]},null,{"data":[{"watchData":0}]}]]]], options);
10
10
  };
11
11
 
12
12
  exports.setNonce = index.setNonce;
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BlTGwvVC.js');
3
+ var index = require('./index-rgQMtYdn.js');
4
4
  var index$1 = require('./index-CEGyCfpa.js');
5
5
 
6
- function Clue({ isCurrent, word, onPointerDown, preview, showPreview }) {
7
- return index.h("p", { onPointerDown: onPointerDown, part: "clue", class: {
6
+ function Clue({ isCurrent, word, onPointerDown, preview, showPreview, tagName }) {
7
+ const Tag = tagName ?? 'div';
8
+ return index.h(Tag, { onPointerDown: onPointerDown, part: "clue", class: {
8
9
  "--current": isCurrent
9
10
  } }, word.clue, showPreview && index.h("span", { class: "preview" }, preview));
10
11
  }
@@ -22,15 +23,29 @@ function Cell({ data, isInCurrentClue, isSelected, isSpecial, onPointerDown }) {
22
23
  } }, index.h("div", { class: "_inner", style: { position: 'absolute', width: '100%' } }, data.value));
23
24
  }
24
25
 
25
- const mbCrosswordCss = () => `*[part=main]{position:relative;display:grid;grid-template-areas:"board" "clues";grid-template-columns:1fr}@media (min-width: 768px){*[part=main]{grid-template-areas:"clues board" "clues .";grid-template-columns:1fr 1fr}}*[part=main].--focused{background:lightgrey}*[part=main] input.dummy{pointer-events:none;opacity:0.2;z-index:100;grid-area:board;border:none;outline:none}[part=clues]{grid-area:clues;display:grid;grid-template-columns:1fr 1fr;gap:16px}[part=clues].oneList{grid-template-columns:1fr}[part=clue].--current{background:var(--clue-current-background, lightcyan);position:sticky;bottom:0;left:0;right:0}[part=clue] .preview{font-weight:bold;letter-spacing:0.2em;text-align:center;display:block;text-transform:uppercase}[part=board]{grid-area:board;display:block;position:relative;container-type:size;background:var(--board-background, darkgoldenrod);--cell-border-width:2px;--cell-width-temp:calc((100cqw - var(--cell-border-width)) / var(--board-width, 10));--cell-width:var(--cell-width-temp);--cell-width:round(var(--cell-width-temp), 1px)}[part=cell]{display:block;color:var(--cell-color, #11138d);width:calc(var(--cell-width) - var(--cell-border-width));aspect-ratio:1;background:var(--cell-background, #d9d9d9);position:absolute;container-type:size;top:calc(var(--y, 0) * var(--cell-width));left:calc(var(--x, 0) * var(--cell-width));border:var(--cell-border-width) solid var(--cell-border-color, red)}[part=cell].--alt{background:var(--cell-background-alt, #999)}[part=cell].--in-current-clue{box-shadow:inset 0 0 2px 2px var(--cell-selected-background, lightblue)}[part=cell].--selected{background:var(--cell-selected-background, lightblue)}[part=cell].--special{background:var(--cell-special-background, lightgreen)}[part=cell] ._inner{position:absolute;top:0;left:0;right:0;bottom:0;display:grid;place-content:center;text-transform:uppercase;font-size:80cqh}[part=preview]{display:none}[part=special-border]{display:block;background:black;position:absolute;z-index:100;--s-border:max(2px, var(--cell-border-width))}[part=special-border].left,[part=special-border].right{width:var(--s-border);height:calc(var(--cell-width) - var(--cell-border-width));top:calc(var(--y, 0) * var(--cell-width) + var(--cell-border-width))}[part=special-border].left{left:calc(var(--x, 0) * var(--cell-width) - var(--s-border) / 2)}[part=special-border].right{left:calc((var(--x, 0) + 1) * var(--cell-width) - var(--s-border) / 2)}[part=special-border].top,[part=special-border].bottom{width:calc(var(--cell-width) - var(--cell-border-width));height:var(--s-border);left:calc(var(--x, 0) * var(--cell-width) + var(--cell-border-width))}[part=special-border].top{top:calc(var(--y, 0) * var(--cell-width))}[part=special-border].bottom{top:calc((var(--y, 0) + 1) * var(--cell-width))}[part=label]{display:grid;position:absolute;container-type:size;top:calc(var(--y, 0) * var(--cell-width));left:calc(var(--x, 0) * var(--cell-width));width:calc(var(--cell-width) - var(--cell-border-width));aspect-ratio:1;border:var(--cell-border-width) solid transparent;--label-place-content:center end}[part=label] ._inner{position:absolute;top:var(--label-padding, 10cqh);left:var(--label-padding, 10cqh);right:var(--label-padding, 10cqh);bottom:var(--label-padding, 10cqh);display:grid;place-content:var(--label-place-content, center);text-transform:uppercase;font-size:var(--label-font-size, 60cqh)}`;
26
+ const ClueList = ({ type }, children) => {
27
+ if (type === 'p') {
28
+ return index.h("p", { part: "clue-list" }, children.map((child, index$1) => {
29
+ return index.h("p", { key: index$1 }, child);
30
+ }));
31
+ }
32
+ if (type === 'ol') {
33
+ return index.h("ol", { part: "clue-list" }, children);
34
+ }
35
+ };
36
+
37
+ const mbCrosswordCss = () => `*[part=main]{position:relative;display:grid;grid-template-areas:"board" "clues";grid-template-columns:1fr}@media (min-width: 768px){*[part=main]{grid-template-areas:"clues board" "clues .";grid-template-columns:1fr 1fr}*[part=main].--only-board{grid-template-columns:1fr;grid-template-areas:"board"}}*[part=main].--focused{background:lightgrey}*[part=main] input.dummy{pointer-events:none;opacity:0.2;z-index:100;grid-area:board;border:none;outline:none}[part=clues]{grid-area:clues;display:grid;grid-template-columns:1fr 1fr;gap:16px}[part=clues].oneList{grid-template-columns:1fr}[part=clue-list]{margin:0;padding:0}[part=clue].--current{background:var(--clue-current-background, lightcyan);position:sticky;bottom:0;left:0;right:0}[part=clue] .preview{font-weight:bold;letter-spacing:0.2em;text-align:center;display:block;text-transform:uppercase}li[part=clue]{--_clue-padding:var(--clue-padding, .5em);border-radius:var(--clue-radius, 0.5em);padding:var(--_clue-padding);list-style-position:inside;padding-left:calc(1em + var(--_clue-padding));text-indent:-1em;margin:0}[part=board]{grid-area:board;display:block;position:relative;container-type:size;background:var(--board-background, darkgoldenrod);--_cell-border-width:var(--cell-border-width, 2px);--cell-width-temp:calc((100cqw - var(--_cell-border-width)) / var(--board-width, 10));--cell-width:var(--cell-width-temp);--cell-width:round(var(--cell-width-temp), 1px)}[part=cell]{display:block;color:var(--cell-color, #11138d);width:calc(var(--cell-width) - var(--_cell-border-width));aspect-ratio:1;background:var(--cell-background, #d9d9d9);position:absolute;container-type:size;top:calc(var(--y, 0) * var(--cell-width));left:calc(var(--x, 0) * var(--cell-width));border:var(--_cell-border-width) solid var(--cell-border-color, red)}[part=cell].--alt{background:var(--cell-background-alt, #999)}[part=cell].--in-current-clue{box-shadow:inset 0 0 2px 2px var(--cell-selected-background, lightblue)}[part=cell].--selected{background:var(--cell-selected-background, lightblue)}[part=cell].--special{background:var(--cell-special-background, lightgreen)}[part=cell].--special.--selected:before{content:"";background:var(--cell-selected-background, lightblue);position:absolute;top:0;left:0;right:0;bottom:0;clip-path:polygon(100% 0, 100% 100%, 50% 100%)}[part=cell] ._inner{position:absolute;top:0;left:0;right:0;bottom:0;display:grid;place-content:center;text-transform:uppercase;font-size:80cqh}[part=preview]{display:none}[part=special-border]{display:block;background:black;position:absolute;z-index:100;--s-border:max(2px, var(--_cell-border-width))}[part=special-border].left,[part=special-border].right{width:var(--s-border);height:calc(var(--cell-width) - var(--_cell-border-width));top:calc(var(--y, 0) * var(--cell-width) + var(--_cell-border-width))}[part=special-border].left{left:calc(var(--x, 0) * var(--cell-width) - var(--s-border) / 2)}[part=special-border].right{left:calc((var(--x, 0) + 1) * var(--cell-width) - var(--s-border) / 2)}[part=special-border].top,[part=special-border].bottom{width:calc(var(--cell-width) - var(--_cell-border-width));height:var(--s-border);left:calc(var(--x, 0) * var(--cell-width) + var(--_cell-border-width))}[part=special-border].top{top:calc(var(--y, 0) * var(--cell-width))}[part=special-border].bottom{top:calc((var(--y, 0) + 1) * var(--cell-width))}[part=label]{display:grid;position:absolute;container-type:size;top:calc(var(--y, 0) * var(--cell-width));left:calc(var(--x, 0) * var(--cell-width));width:calc(var(--cell-width) - var(--_cell-border-width));aspect-ratio:1;border:var(--_cell-border-width) solid transparent;--label-place-content:center end}[part=label] ._inner{position:absolute;top:var(--label-padding, 10cqh);left:var(--label-padding, 10cqh);right:var(--label-padding, 10cqh);bottom:var(--label-padding, 10cqh);display:grid;place-content:var(--label-place-content, center);text-transform:uppercase;font-size:var(--label-font-size, 60cqh)}`;
26
38
 
27
39
  const MBCrossword = class {
28
40
  constructor(hostRef) {
29
41
  index.registerInstance(this, hostRef);
42
+ this.clueSelected = index.createEvent(this, "clueSelected");
30
43
  }
31
44
  init = true;
32
45
  data;
33
46
  showCluePreview = true;
47
+ clueListStyle = 'ol';
48
+ clueSelected;
34
49
  textInput;
35
50
  hWords = [];
36
51
  vWords = [];
@@ -263,7 +278,7 @@ const MBCrossword = class {
263
278
  onFocusOut() {
264
279
  this.isFocused = false;
265
280
  }
266
- selectClue(id, { row, col } = {}) {
281
+ async selectClue(id, { row, col } = {}) {
267
282
  if (!id)
268
283
  return;
269
284
  this.currentClueId = id;
@@ -386,18 +401,21 @@ const MBCrossword = class {
386
401
  render() {
387
402
  const hasVWords = Boolean(this.vWords.length);
388
403
  const hasHWords = Boolean(this.hWords.length);
404
+ const hideList = this.clueListStyle === 'none';
389
405
  const twoLists = hasHWords && hasVWords;
390
- return index.h("div", { key: '87d88806305c6102eeb76c3984d4b9c2ad2d9759', part: "main", class: {
391
- "--focused": this.isFocused
392
- }, onFocusin: this.onFocusin.bind(this), onFocusout: this.onFocusOut.bind(this) }, index.h("input", { key: '49cdb053a4d2c4ad2c7eb881488b18c68e31fe65', type: "text", class: "dummy", ref: (el) => this.textInput = el, onKeyDown: this.onKeyPress.bind(this), onInput: this.onInput.bind(this) }), index.h("div", { key: '0ca71a907f70e17a6d2d10bff9462bd0b2284007', part: "clues", class: {
393
- twoLists, oneList: !twoLists
394
- } }, hasHWords ? index.h("div", { part: "clue-list" }, this.hWords.map(w => {
406
+ return index.h("div", { key: '0aa26f6435a57c206eba0d518313d6248d922eaa', part: "main", class: {
407
+ "--focused": this.isFocused,
408
+ "--only-board": hideList
409
+ }, onFocusin: this.onFocusin.bind(this), onFocusout: this.onFocusOut.bind(this) }, index.h("input", { key: 'e15789ff3feb48df30117b501b440142ba3eccf7', 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: {
410
+ twoLists,
411
+ oneList: !twoLists
412
+ } }, hasHWords ? index.h(ClueList, { type: this.clueListStyle }, this.hWords.map(w => {
395
413
  const isCurrent = w.id === this.currentClueId;
396
- return index.h(Clue, { showPreview: this.showCluePreview, preview: this.getCluePreview(w), word: w, isCurrent: isCurrent, onPointerDown: () => this.selectClue(w.id) });
397
- })) : '', hasVWords ? index.h("div", { part: "clue-list" }, this.vWords.map(w => {
414
+ 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 });
415
+ })) : '', hasVWords ? index.h(ClueList, { type: this.clueListStyle }, this.vWords.map(w => {
398
416
  const isCurrent = w.id === this.currentClueId;
399
- return index.h(Clue, { showPreview: this.showCluePreview, preview: this.getCluePreview(w), word: w, isCurrent: isCurrent, onPointerDown: () => this.selectClue(w.id) });
400
- })) : ''), index.h("div", { key: 'ea16dca25fe7884d25f9748f98740ad83e25293e', part: "board", style: {
417
+ 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 });
418
+ })) : ''), index.h("div", { key: '08ffd76832a1c9c9dfddf8424e9e014d104444a0', part: "board", style: {
401
419
  '--board-width': `${this.boardWidth}`,
402
420
  'grid-template-columns': `repeat(${this.boardWidth}, 1fr)`,
403
421
  aspectRatio: `${this.boardWidth / this.boardHeight}`
@@ -421,7 +439,7 @@ const MBCrossword = class {
421
439
  "--x": `${label.x}`,
422
440
  "--y": `${label.y}`
423
441
  }, onPointerDown: () => this.selectClue(label.clueId) }, index.h("div", { class: "_inner" }, label.text));
424
- })), index.h("div", { key: 'd391413e7be3dee148f2f5e6d8fbf22742278a0c', part: "preview" }, "Tu bedzie podgl\u0105d: ", this.currentClueId));
442
+ })));
425
443
  }
426
444
  static get delegatesFocus() { return true; }
427
445
  static get watchers() { return {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BlTGwvVC.js');
3
+ var index = require('./index-rgQMtYdn.js');
4
4
  var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
5
 
6
6
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -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"],"hWords":[32],"vWords":[32],"currentClueId":[32],"currentClue":[32],"isFocused":[32],"selectedCell":[32],"specialBorders":[32],"specialCells":[32],"labels":[32],"boardWidth":[32],"boardHeight":[32],"cells":[32],"initGame":[64],"checkAnswer":[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"],"hWords":[32],"vWords":[32],"currentClueId":[32],"currentClue":[32],"isFocused":[32],"selectedCell":[32],"specialBorders":[32],"specialCells":[32],"labels":[32],"boardWidth":[32],"boardHeight":[32],"cells":[32],"initGame":[64],"checkAnswer":[64],"selectClue":[64]},null,{"data":[{"watchData":0}]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -0,0 +1,11 @@
1
+ import { h } from "@stencil/core";
2
+ export const ClueList = ({ type }, children) => {
3
+ if (type === 'p') {
4
+ return h("p", { part: "clue-list" }, children.map((child, index) => {
5
+ return h("p", { key: index }, child);
6
+ }));
7
+ }
8
+ if (type === 'ol') {
9
+ return h("ol", { part: "clue-list" }, children);
10
+ }
11
+ };
@@ -1,6 +1,7 @@
1
1
  import { h } from "@stencil/core";
2
- export function Clue({ isCurrent, word, onPointerDown, preview, showPreview }) {
3
- return h("p", { onPointerDown: onPointerDown, part: "clue", class: {
2
+ export function Clue({ isCurrent, word, onPointerDown, preview, showPreview, tagName }) {
3
+ const Tag = tagName ?? 'div';
4
+ return h(Tag, { onPointerDown: onPointerDown, part: "clue", class: {
4
5
  "--current": isCurrent
5
6
  } }, word.clue, showPreview && h("span", { class: "preview" }, preview));
6
7
  }
@@ -9,6 +9,10 @@
9
9
  grid-template-areas: "clues board" "clues .";
10
10
  grid-template-columns: 1fr 1fr;
11
11
  }
12
+ *[part=main].--only-board {
13
+ grid-template-columns: 1fr;
14
+ grid-template-areas: "board";
15
+ }
12
16
  }
13
17
  *[part=main].--focused {
14
18
  background: lightgrey;
@@ -32,6 +36,11 @@
32
36
  grid-template-columns: 1fr;
33
37
  }
34
38
 
39
+ [part=clue-list] {
40
+ margin: 0;
41
+ padding: 0;
42
+ }
43
+
35
44
  [part=clue].--current {
36
45
  background: var(--clue-current-background, lightcyan);
37
46
  position: sticky;
@@ -47,14 +56,24 @@
47
56
  text-transform: uppercase;
48
57
  }
49
58
 
59
+ li[part=clue] {
60
+ --_clue-padding: var(--clue-padding, .5em);
61
+ border-radius: var(--clue-radius, 0.5em);
62
+ padding: var(--_clue-padding);
63
+ list-style-position: inside;
64
+ padding-left: calc(1em + var(--_clue-padding));
65
+ text-indent: -1em;
66
+ margin: 0;
67
+ }
68
+
50
69
  [part=board] {
51
70
  grid-area: board;
52
71
  display: block;
53
72
  position: relative;
54
73
  container-type: size;
55
74
  background: var(--board-background, darkgoldenrod);
56
- --cell-border-width: 2px;
57
- --cell-width-temp: calc((100cqw - var(--cell-border-width)) / var(--board-width, 10));
75
+ --_cell-border-width: var(--cell-border-width, 2px);
76
+ --cell-width-temp: calc((100cqw - var(--_cell-border-width)) / var(--board-width, 10));
58
77
  --cell-width: var(--cell-width-temp);
59
78
  --cell-width: round(var(--cell-width-temp), 1px);
60
79
  }
@@ -62,14 +81,14 @@
62
81
  [part=cell] {
63
82
  display: block;
64
83
  color: var(--cell-color, #11138d);
65
- width: calc(var(--cell-width) - var(--cell-border-width));
84
+ width: calc(var(--cell-width) - var(--_cell-border-width));
66
85
  aspect-ratio: 1;
67
86
  background: var(--cell-background, #d9d9d9);
68
87
  position: absolute;
69
88
  container-type: size;
70
89
  top: calc(var(--y, 0) * var(--cell-width));
71
90
  left: calc(var(--x, 0) * var(--cell-width));
72
- border: var(--cell-border-width) solid var(--cell-border-color, red);
91
+ border: var(--_cell-border-width) solid var(--cell-border-color, red);
73
92
  }
74
93
  [part=cell].--alt {
75
94
  background: var(--cell-background-alt, #999);
@@ -83,6 +102,16 @@
83
102
  [part=cell].--special {
84
103
  background: var(--cell-special-background, lightgreen);
85
104
  }
105
+ [part=cell].--special.--selected:before {
106
+ content: "";
107
+ background: var(--cell-selected-background, lightblue);
108
+ position: absolute;
109
+ top: 0;
110
+ left: 0;
111
+ right: 0;
112
+ bottom: 0;
113
+ clip-path: polygon(100% 0, 100% 100%, 50% 100%);
114
+ }
86
115
  [part=cell] ._inner {
87
116
  position: absolute;
88
117
  top: 0;
@@ -104,12 +133,12 @@
104
133
  background: black;
105
134
  position: absolute;
106
135
  z-index: 100;
107
- --s-border: max(2px, var(--cell-border-width));
136
+ --s-border: max(2px, var(--_cell-border-width));
108
137
  }
109
138
  [part=special-border].left, [part=special-border].right {
110
139
  width: var(--s-border);
111
- height: calc(var(--cell-width) - var(--cell-border-width));
112
- top: calc(var(--y, 0) * var(--cell-width) + var(--cell-border-width));
140
+ height: calc(var(--cell-width) - var(--_cell-border-width));
141
+ top: calc(var(--y, 0) * var(--cell-width) + var(--_cell-border-width));
113
142
  }
114
143
  [part=special-border].left {
115
144
  left: calc(var(--x, 0) * var(--cell-width) - var(--s-border) / 2);
@@ -118,9 +147,9 @@
118
147
  left: calc((var(--x, 0) + 1) * var(--cell-width) - var(--s-border) / 2);
119
148
  }
120
149
  [part=special-border].top, [part=special-border].bottom {
121
- width: calc(var(--cell-width) - var(--cell-border-width));
150
+ width: calc(var(--cell-width) - var(--_cell-border-width));
122
151
  height: var(--s-border);
123
- left: calc(var(--x, 0) * var(--cell-width) + var(--cell-border-width));
152
+ left: calc(var(--x, 0) * var(--cell-width) + var(--_cell-border-width));
124
153
  }
125
154
  [part=special-border].top {
126
155
  top: calc(var(--y, 0) * var(--cell-width));
@@ -135,9 +164,9 @@
135
164
  container-type: size;
136
165
  top: calc(var(--y, 0) * var(--cell-width));
137
166
  left: calc(var(--x, 0) * var(--cell-width));
138
- width: calc(var(--cell-width) - var(--cell-border-width));
167
+ width: calc(var(--cell-width) - var(--_cell-border-width));
139
168
  aspect-ratio: 1;
140
- border: var(--cell-border-width) solid transparent;
169
+ border: var(--_cell-border-width) solid transparent;
141
170
  --label-place-content: center end;
142
171
  }
143
172
  [part=label] ._inner {
@@ -3,10 +3,13 @@ import { Clue } from "./clue";
3
3
  import { Cell } from "./cell";
4
4
  import { indexFromXY, isInputEventLetter, Vec2fromIndex } from "../../utils/utils";
5
5
  import { Vec2 } from "@mb-puzzle/vec2";
6
+ import { ClueList } from "./clue-list";
6
7
  export class MBCrossword {
7
8
  init = true;
8
9
  data;
9
10
  showCluePreview = true;
11
+ clueListStyle = 'ol';
12
+ clueSelected;
10
13
  textInput;
11
14
  hWords = [];
12
15
  vWords = [];
@@ -239,7 +242,7 @@ export class MBCrossword {
239
242
  onFocusOut() {
240
243
  this.isFocused = false;
241
244
  }
242
- selectClue(id, { row, col } = {}) {
245
+ async selectClue(id, { row, col } = {}) {
243
246
  if (!id)
244
247
  return;
245
248
  this.currentClueId = id;
@@ -362,18 +365,21 @@ export class MBCrossword {
362
365
  render() {
363
366
  const hasVWords = Boolean(this.vWords.length);
364
367
  const hasHWords = Boolean(this.hWords.length);
368
+ const hideList = this.clueListStyle === 'none';
365
369
  const twoLists = hasHWords && hasVWords;
366
- return h("div", { key: '87d88806305c6102eeb76c3984d4b9c2ad2d9759', part: "main", class: {
367
- "--focused": this.isFocused
368
- }, onFocusin: this.onFocusin.bind(this), onFocusout: this.onFocusOut.bind(this) }, h("input", { key: '49cdb053a4d2c4ad2c7eb881488b18c68e31fe65', type: "text", class: "dummy", ref: (el) => this.textInput = el, onKeyDown: this.onKeyPress.bind(this), onInput: this.onInput.bind(this) }), h("div", { key: '0ca71a907f70e17a6d2d10bff9462bd0b2284007', part: "clues", class: {
369
- twoLists, oneList: !twoLists
370
- } }, hasHWords ? h("div", { part: "clue-list" }, this.hWords.map(w => {
370
+ return h("div", { key: '0aa26f6435a57c206eba0d518313d6248d922eaa', part: "main", class: {
371
+ "--focused": this.isFocused,
372
+ "--only-board": hideList
373
+ }, onFocusin: this.onFocusin.bind(this), onFocusout: this.onFocusOut.bind(this) }, h("input", { key: 'e15789ff3feb48df30117b501b440142ba3eccf7', 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: {
374
+ twoLists,
375
+ oneList: !twoLists
376
+ } }, hasHWords ? h(ClueList, { type: this.clueListStyle }, this.hWords.map(w => {
371
377
  const isCurrent = w.id === this.currentClueId;
372
- return h(Clue, { showPreview: this.showCluePreview, preview: this.getCluePreview(w), word: w, isCurrent: isCurrent, onPointerDown: () => this.selectClue(w.id) });
373
- })) : '', hasVWords ? h("div", { part: "clue-list" }, this.vWords.map(w => {
378
+ 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 });
379
+ })) : '', hasVWords ? h(ClueList, { type: this.clueListStyle }, this.vWords.map(w => {
374
380
  const isCurrent = w.id === this.currentClueId;
375
- return h(Clue, { showPreview: this.showCluePreview, preview: this.getCluePreview(w), word: w, isCurrent: isCurrent, onPointerDown: () => this.selectClue(w.id) });
376
- })) : ''), h("div", { key: 'ea16dca25fe7884d25f9748f98740ad83e25293e', part: "board", style: {
381
+ 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 });
382
+ })) : ''), h("div", { key: '08ffd76832a1c9c9dfddf8424e9e014d104444a0', part: "board", style: {
377
383
  '--board-width': `${this.boardWidth}`,
378
384
  'grid-template-columns': `repeat(${this.boardWidth}, 1fr)`,
379
385
  aspectRatio: `${this.boardWidth / this.boardHeight}`
@@ -397,7 +403,7 @@ export class MBCrossword {
397
403
  "--x": `${label.x}`,
398
404
  "--y": `${label.y}`
399
405
  }, onPointerDown: () => this.selectClue(label.clueId) }, h("div", { class: "_inner" }, label.text));
400
- })), h("div", { key: 'd391413e7be3dee148f2f5e6d8fbf22742278a0c', part: "preview" }, "Tu bedzie podgl\u0105d: ", this.currentClueId));
406
+ })));
401
407
  }
402
408
  static get is() { return "mb-crossword"; }
403
409
  static get encapsulation() { return "shadow"; }
@@ -477,6 +483,26 @@ export class MBCrossword {
477
483
  "reflect": false,
478
484
  "attribute": "show-clue-preview",
479
485
  "defaultValue": "true"
486
+ },
487
+ "clueListStyle": {
488
+ "type": "string",
489
+ "mutable": false,
490
+ "complexType": {
491
+ "original": "'p' | 'ol' | 'none'",
492
+ "resolved": "\"none\" | \"ol\" | \"p\"",
493
+ "references": {}
494
+ },
495
+ "required": false,
496
+ "optional": false,
497
+ "docs": {
498
+ "tags": [],
499
+ "text": ""
500
+ },
501
+ "getter": false,
502
+ "setter": false,
503
+ "reflect": false,
504
+ "attribute": "clue-list-style",
505
+ "defaultValue": "'ol'"
480
506
  }
481
507
  };
482
508
  }
@@ -496,6 +522,24 @@ export class MBCrossword {
496
522
  "cells": {}
497
523
  };
498
524
  }
525
+ static get events() {
526
+ return [{
527
+ "method": "clueSelected",
528
+ "name": "clueSelected",
529
+ "bubbles": true,
530
+ "cancelable": true,
531
+ "composed": true,
532
+ "docs": {
533
+ "tags": [],
534
+ "text": ""
535
+ },
536
+ "complexType": {
537
+ "original": "string",
538
+ "resolved": "string",
539
+ "references": {}
540
+ }
541
+ }];
542
+ }
499
543
  static get methods() {
500
544
  return {
501
545
  "initGame": {
@@ -541,6 +585,31 @@ export class MBCrossword {
541
585
  "text": "",
542
586
  "tags": []
543
587
  }
588
+ },
589
+ "selectClue": {
590
+ "complexType": {
591
+ "signature": "(id: string, { row, col }?: { row?: number; col?: number; }) => Promise<void>",
592
+ "parameters": [{
593
+ "name": "id",
594
+ "type": "string",
595
+ "docs": ""
596
+ }, {
597
+ "name": "__1",
598
+ "type": "{ row?: number; col?: number; }",
599
+ "docs": ""
600
+ }],
601
+ "references": {
602
+ "Promise": {
603
+ "location": "global",
604
+ "id": "global::Promise"
605
+ }
606
+ },
607
+ "return": "Promise<void>"
608
+ },
609
+ "docs": {
610
+ "text": "",
611
+ "tags": []
612
+ }
544
613
  }
545
614
  };
546
615
  }