@harmonics/lattice-ui 0.5.1 → 0.7.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,6 +1,6 @@
1
1
  import { LatticeElement } from "./host";
2
2
  export declare const ICON_TAG = "lattice-icon";
3
- export declare const ICON_NAMES: readonly ["shears", "done"];
3
+ export declare const ICON_NAMES: readonly ["shears", "done", "note", "turn", "glue", "apart", "bin"];
4
4
  export type IconName = (typeof ICON_NAMES)[number];
5
5
  export declare class LatticeIcon extends LatticeElement {
6
6
  static readonly observedAttributes: string[];
@@ -7,7 +7,7 @@ export { FACES } from "../faceLattice";
7
7
  export type { Part } from "../hexes";
8
8
  export { FACE_TAG, MOODS } from "./face";
9
9
  export { ICON_NAMES, ICON_TAG, type IconName } from "./icon";
10
- export { SHAPE_TAG } from "./shape";
10
+ export { type LatticeShapeEventMap, type PressDetail, SHAPE_TAG } from "./shape";
11
11
  export { SHAPE_NAMES, type ShapeName, TONES } from "./shapes";
12
12
  export { SHEARS_TAG, type StrokePoint } from "./shears";
13
13
  export { SKY_TAG } from "./sky";
@@ -1,7 +1,22 @@
1
- import type { Part } from "../hexes";
1
+ import { type Part } from "../hexes";
2
2
  import { LatticeElement } from "./host";
3
3
  import { type ShapeName } from "./shapes";
4
4
  export declare const SHAPE_TAG = "lattice-shape";
5
+ /** What a press says: which shape, and its parts. */
6
+ export interface PressDetail {
7
+ shape: ShapeName;
8
+ parts: Part[];
9
+ }
10
+ /** The shape's own events, for `addEventListener`. */
11
+ export interface LatticeShapeEventMap extends HTMLElementEventMap {
12
+ press: CustomEvent<PressDetail>;
13
+ }
14
+ export interface LatticeShape {
15
+ addEventListener<K extends keyof LatticeShapeEventMap>(type: K, listener: (this: LatticeShape, event: LatticeShapeEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
16
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
17
+ removeEventListener<K extends keyof LatticeShapeEventMap>(type: K, listener: (this: LatticeShape, event: LatticeShapeEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
18
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
19
+ }
5
20
  export declare class LatticeShape extends LatticeElement {
6
21
  static readonly observedAttributes: string[];
7
22
  private readonly shapeSignal;
@@ -10,6 +25,10 @@ export declare class LatticeShape extends LatticeElement {
10
25
  private readonly liftSignal;
11
26
  private readonly scaleSignal;
12
27
  private readonly labelSignal;
28
+ private readonly pressableSignal;
29
+ /** Unset until the page makes it a toggle: only then does it say `aria-pressed`. */
30
+ private readonly pressedSignal;
31
+ private readonly disabledSignal;
13
32
  get shape(): ShapeName;
14
33
  set shape(name: string);
15
34
  private made;
@@ -24,10 +43,23 @@ export declare class LatticeShape extends LatticeElement {
24
43
  set scale(scale: number | string);
25
44
  get label(): string;
26
45
  set label(label: string);
46
+ /** A button shaped like itself. Kept as the attribute too, which its look is styled by. */
47
+ get pressable(): boolean;
48
+ set pressable(pressable: boolean | string | null);
49
+ /** Pressed, as a toggle; false when the page has not made it one. */
50
+ get pressed(): boolean;
51
+ set pressed(pressed: boolean | string | null | undefined);
52
+ get disabled(): boolean;
53
+ set disabled(disabled: boolean | string | null);
27
54
  attributeChangedCallback(name: string, _: string | null, value: string | null): void;
55
+ /**
56
+ * As a button: its role, its place in the tab order (unless the page gave it one), its name and
57
+ * states, on the element itself, where a screen reader and the Tab key find them.
58
+ */
59
+ private beAButton;
28
60
  }
29
61
  /**
30
- * Register `<lattice-shape>` once, or as `name` (a tag of your own, when another library holds this
31
- * one); a second call, or a call on a server, does nothing.
62
+ * Register `<lattice-shape>` once, or as `name` (a tag of your own, when another library holds
63
+ * this one); a second call, or a call on a server, does nothing.
32
64
  */
33
65
  export declare const defineLatticeShape: (name?: string) => void;
@@ -1,4 +1,5 @@
1
- import type { HexSky, IconName, LatticeFace, LatticeIcon, LatticeShape, Part, ShapeName, ShearsPadElement, StrokeDetail, StrokeEndDetail } from "./index";
1
+ import type { BoardChangeDetail, BoardPiece, LatticeBoard } from "./board-entry";
2
+ import type { HexSky, IconName, LatticeFace, LatticeIcon, LatticeShape, Part, PressDetail, ShapeName, ShearsPadElement, StrokeDetail, StrokeEndDetail } from "./index";
2
3
  declare module "solid-js" {
3
4
  namespace JSX {
4
5
  interface IntrinsicElements {
@@ -25,6 +26,9 @@ declare module "solid-js" {
25
26
  lift?: number | string;
26
27
  scale?: number | string;
27
28
  label?: string;
29
+ pressable?: boolean;
30
+ pressed?: boolean;
31
+ disabled?: boolean;
28
32
  };
29
33
  "shears-pad": JSX.HTMLAttributes<ShearsPadElement> & {
30
34
  disabled?: boolean;
@@ -33,11 +37,23 @@ declare module "solid-js" {
33
37
  name?: IconName;
34
38
  label?: string;
35
39
  };
40
+ "lattice-board": JSX.HTMLAttributes<LatticeBoard> & {
41
+ tray?: boolean;
42
+ scale?: number | string;
43
+ label?: string;
44
+ };
36
45
  }
37
46
  interface ExplicitProperties {
38
47
  parts: Part[] | string;
48
+ pieces: BoardPiece[] | string;
49
+ fixed: BoardPiece[];
39
50
  }
40
51
  interface CustomEvents {
52
+ change: CustomEvent<BoardChangeDetail>;
53
+ catch: CustomEvent<{
54
+ id: string;
55
+ }>;
56
+ press: CustomEvent<PressDetail>;
41
57
  stroke: CustomEvent<StrokeDetail>;
42
58
  strokeend: CustomEvent<StrokeEndDetail>;
43
59
  }