@harmonics/lattice-ui 0.5.1 → 0.6.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.
@@ -0,0 +1,2 @@
1
+ /** What was done to the pieces, as a `change` says it. */
2
+ export type BoardAction = "move" | "turn" | "glue" | "break" | "pull" | "add" | "remove";
@@ -0,0 +1,9 @@
1
+ import { BOARD_TAG, type BoardChangeDetail, type BoardPiece, defineLatticeBoard, LatticeBoard, type LatticeBoardEventMap } from "./board";
2
+ export type { BoardAction } from "../boardTypes";
3
+ export type { Part, Piece } from "../hexes";
4
+ export { BOARD_TAG, type BoardChangeDetail, type BoardPiece, defineLatticeBoard, LatticeBoard, type LatticeBoardEventMap, };
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ "lattice-board": LatticeBoard;
8
+ }
9
+ }
@@ -0,0 +1,59 @@
1
+ import type { BoardAction } from "../boardTypes";
2
+ import { type Part, type Piece } from "../hexes";
3
+ import { LatticeElement } from "./host";
4
+ export declare const BOARD_TAG = "lattice-board";
5
+ /** A piece as a page hands it over: an id of its own (one is made if not) and its parts. */
6
+ export interface BoardPiece {
7
+ id?: string;
8
+ parts: Part[];
9
+ }
10
+ export interface BoardChangeDetail {
11
+ /** The board's pieces now, fixed ones left out. */
12
+ pieces: Piece[];
13
+ action: BoardAction;
14
+ /** The piece acted on ("" when the board itself moved pieces back into view). */
15
+ id: string;
16
+ }
17
+ /** The board's own events, for `addEventListener`. */
18
+ export interface LatticeBoardEventMap extends HTMLElementEventMap {
19
+ change: CustomEvent<BoardChangeDetail>;
20
+ catch: CustomEvent<{
21
+ id: string;
22
+ }>;
23
+ }
24
+ export interface LatticeBoard {
25
+ addEventListener<K extends keyof LatticeBoardEventMap>(type: K, listener: (this: LatticeBoard, event: LatticeBoardEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
26
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
27
+ removeEventListener<K extends keyof LatticeBoardEventMap>(type: K, listener: (this: LatticeBoard, event: LatticeBoardEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
28
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
29
+ }
30
+ export declare class LatticeBoard extends LatticeElement {
31
+ static readonly observedAttributes: string[];
32
+ private readonly givenSignal;
33
+ private readonly fixedSignal;
34
+ private readonly traySignal;
35
+ private readonly scaleSignal;
36
+ private readonly labelSignal;
37
+ /** The board's pieces while it is drawn. */
38
+ private live;
39
+ private made;
40
+ private readonly madeId;
41
+ /** The pieces on the board, fixed ones left out. */
42
+ get pieces(): Piece[];
43
+ set pieces(pieces: unknown);
44
+ /** Pieces drawn flat and in the way, never handled. */
45
+ get fixed(): Piece[];
46
+ set fixed(pieces: unknown);
47
+ get tray(): boolean;
48
+ set tray(tray: boolean | string | null);
49
+ get scale(): number;
50
+ set scale(scale: number | string);
51
+ get label(): string;
52
+ set label(label: string);
53
+ attributeChangedCallback(name: string, _: string | null, value: string | null): void;
54
+ }
55
+ /**
56
+ * Register `<lattice-board>` once, or as `name` (a tag of your own, when another library holds
57
+ * this one); a second call, or a call on a server, does nothing.
58
+ */
59
+ export declare const defineLatticeBoard: (name?: string) => void;
@@ -1,3 +1,4 @@
1
+ import type { BoardChangeDetail, BoardPiece, LatticeBoard } from "./board-entry";
1
2
  import type { HexSky, IconName, LatticeFace, LatticeIcon, LatticeShape, Part, ShapeName, ShearsPadElement, StrokeDetail, StrokeEndDetail } from "./index";
2
3
  declare module "solid-js" {
3
4
  namespace JSX {
@@ -33,11 +34,22 @@ declare module "solid-js" {
33
34
  name?: IconName;
34
35
  label?: string;
35
36
  };
37
+ "lattice-board": JSX.HTMLAttributes<LatticeBoard> & {
38
+ tray?: boolean;
39
+ scale?: number | string;
40
+ label?: string;
41
+ };
36
42
  }
37
43
  interface ExplicitProperties {
38
44
  parts: Part[] | string;
45
+ pieces: BoardPiece[] | string;
46
+ fixed: BoardPiece[];
39
47
  }
40
48
  interface CustomEvents {
49
+ change: CustomEvent<BoardChangeDetail>;
50
+ catch: CustomEvent<{
51
+ id: string;
52
+ }>;
41
53
  stroke: CustomEvent<StrokeDetail>;
42
54
  strokeend: CustomEvent<StrokeEndDetail>;
43
55
  }