@harmonics/lattice-ui 0.4.0 → 0.5.1
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/CHANGELOG.md +27 -0
- package/README.md +40 -5
- package/dist/define.js +1 -1
- package/dist/{elements-BJBhL4LI.js → elements-Ka2LbDpP.js} +304 -246
- package/dist/{hexes-DN9eyQho.js → hexes-B4uCADpF.js} +84 -38
- package/dist/hexes.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/elements/face.d.ts +5 -2
- package/dist/types/elements/hexes.d.ts +1 -1
- package/dist/types/elements/host.d.ts +5 -2
- package/dist/types/elements/icon.d.ts +5 -2
- package/dist/types/elements/index.d.ts +2 -8
- package/dist/types/elements/shape.d.ts +7 -3
- package/dist/types/elements/shears.d.ts +24 -2
- package/dist/types/elements/sky.d.ts +8 -2
- package/dist/types/elements/solid.d.ts +3 -4
- package/package.json +4 -1
- package/react.d.ts +9 -3
|
@@ -252,8 +252,8 @@ function M(e, t, n) {
|
|
|
252
252
|
};
|
|
253
253
|
return i.reduce((e, t) => a(t) < a(e) ? t : e);
|
|
254
254
|
}
|
|
255
|
-
var
|
|
256
|
-
function
|
|
255
|
+
var ee = (e) => e * e * (3 - 2 * e);
|
|
256
|
+
function te(e, t, i, a) {
|
|
257
257
|
let s = (E(e) ? r : n) * j.reach;
|
|
258
258
|
if (a) {
|
|
259
259
|
let e = o(a);
|
|
@@ -273,7 +273,7 @@ function P(e, t, i, a) {
|
|
|
273
273
|
pull: 1,
|
|
274
274
|
held: c
|
|
275
275
|
};
|
|
276
|
-
let f = u >= s ? 0 : 1 -
|
|
276
|
+
let f = u >= s ? 0 : 1 - ee((u - d) / (s - d)), p = f * j.lean;
|
|
277
277
|
return {
|
|
278
278
|
step: c,
|
|
279
279
|
x: t + (l.x - t) * p,
|
|
@@ -282,7 +282,7 @@ function P(e, t, i, a) {
|
|
|
282
282
|
held: void 0
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
|
-
function
|
|
285
|
+
function N(e, t = .12) {
|
|
286
286
|
let n = (t) => `translate(${e.x * t}px, ${e.y * t}px)`;
|
|
287
287
|
return [
|
|
288
288
|
{
|
|
@@ -306,7 +306,7 @@ function F(e, t = .12) {
|
|
|
306
306
|
}
|
|
307
307
|
];
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function P(e, t) {
|
|
310
310
|
return (E(e) ? {
|
|
311
311
|
ArrowRight: {
|
|
312
312
|
i: -1,
|
|
@@ -343,11 +343,11 @@ function I(e, t) {
|
|
|
343
343
|
}
|
|
344
344
|
})[t];
|
|
345
345
|
}
|
|
346
|
-
var
|
|
346
|
+
var F = (e) => ({
|
|
347
347
|
i: e.i + e.j,
|
|
348
348
|
j: -e.i + 0
|
|
349
349
|
});
|
|
350
|
-
function
|
|
350
|
+
function I(e) {
|
|
351
351
|
let t = Math.min(...e.map((e) => e.i)), n = e.filter((e) => e.i === t);
|
|
352
352
|
return n.length === 2 ? {
|
|
353
353
|
i: t,
|
|
@@ -359,20 +359,20 @@ function R(e) {
|
|
|
359
359
|
k: 1
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function L(e, t) {
|
|
363
363
|
let n = (t % 6 + 6) % 6, r = e.pivot, i = (e) => {
|
|
364
364
|
let t = {
|
|
365
365
|
i: e.i - r.i,
|
|
366
366
|
j: e.j - r.j
|
|
367
367
|
};
|
|
368
|
-
for (let e = 0; e < n; e++) t =
|
|
368
|
+
for (let e = 0; e < n; e++) t = F(t);
|
|
369
369
|
return {
|
|
370
370
|
i: t.i + r.i,
|
|
371
371
|
j: t.j + r.j
|
|
372
372
|
};
|
|
373
373
|
}, a = e.parts.map((e) => e.kind === "tri" ? {
|
|
374
374
|
...e,
|
|
375
|
-
at:
|
|
375
|
+
at: I(c(e.at).map(i))
|
|
376
376
|
} : {
|
|
377
377
|
...e,
|
|
378
378
|
at: f(i(d(e.at)))
|
|
@@ -382,25 +382,25 @@ function z(e, t) {
|
|
|
382
382
|
parts: a
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
var
|
|
386
|
-
function
|
|
385
|
+
var R = (e) => s(e.pivot);
|
|
386
|
+
function z(e) {
|
|
387
387
|
let t = e.flatMap(y).flatMap((e) => c(e).map(s)), n = {
|
|
388
388
|
x: t.reduce((e, t) => e + t.x, 0) / t.length,
|
|
389
389
|
y: t.reduce((e, t) => e + t.y, 0) / t.length
|
|
390
390
|
};
|
|
391
391
|
return e.some((e) => e.kind === "cell") ? d(l(n.x, n.y)) : u(n.x, n.y);
|
|
392
392
|
}
|
|
393
|
-
var
|
|
393
|
+
var B = (e, t) => ({
|
|
394
394
|
id: e,
|
|
395
395
|
parts: t,
|
|
396
|
-
pivot:
|
|
396
|
+
pivot: z(t)
|
|
397
397
|
});
|
|
398
|
-
function
|
|
398
|
+
function V(e, t) {
|
|
399
399
|
let n = t instanceof Set ? t : new Set(t.map(h));
|
|
400
400
|
return e.some((e) => m(e).some((e) => n.has(h(e))));
|
|
401
401
|
}
|
|
402
|
-
var
|
|
403
|
-
function
|
|
402
|
+
var H = (e, t) => S(e).length <= S(t).length ? V(S(e), C(t)) : V(S(t), C(e));
|
|
403
|
+
function U(e, t) {
|
|
404
404
|
let n = C(t), r = [];
|
|
405
405
|
for (let t of S(e)) for (let e of m(t)) {
|
|
406
406
|
if (!n.has(h(e))) continue;
|
|
@@ -409,7 +409,7 @@ function G(e, t) {
|
|
|
409
409
|
}
|
|
410
410
|
return r;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function W(e) {
|
|
413
413
|
let t = /* @__PURE__ */ new Map();
|
|
414
414
|
e.parts.forEach((e, n) => {
|
|
415
415
|
for (let r of y(e)) t.set(h(r), n);
|
|
@@ -430,31 +430,31 @@ function K(e) {
|
|
|
430
430
|
}
|
|
431
431
|
return n;
|
|
432
432
|
}
|
|
433
|
-
function
|
|
434
|
-
let n = t.filter((t) => t.id !== e.id &&
|
|
433
|
+
function G(e, t) {
|
|
434
|
+
let n = t.filter((t) => t.id !== e.id && H(e, t)), r = [...e.parts, ...n.flatMap((e) => e.parts)];
|
|
435
435
|
return {
|
|
436
|
-
piece:
|
|
436
|
+
piece: B(e.id, r),
|
|
437
437
|
absorbed: n.map((e) => e.id)
|
|
438
438
|
};
|
|
439
439
|
}
|
|
440
|
-
function
|
|
440
|
+
function K(e, t) {
|
|
441
441
|
let n = [...e], r = [];
|
|
442
442
|
for (; n.length > 0;) {
|
|
443
443
|
let e = [n.shift()];
|
|
444
444
|
for (let t = 0; t < e.length; t++) {
|
|
445
445
|
let r = y(e[t]);
|
|
446
|
-
for (let t = n.length - 1; t >= 0; t--)
|
|
446
|
+
for (let t = n.length - 1; t >= 0; t--) V(r, y(n[t])) && e.push(...n.splice(t, 1));
|
|
447
447
|
}
|
|
448
|
-
r.push(
|
|
448
|
+
r.push(B(t(), e));
|
|
449
449
|
}
|
|
450
450
|
return r;
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function q(e, t, n) {
|
|
453
453
|
let r = e.parts[t], i = e.parts.filter((e, n) => n !== t);
|
|
454
|
-
return [
|
|
454
|
+
return [B(n(), [r]), ...K(i, n)];
|
|
455
455
|
}
|
|
456
|
-
var
|
|
457
|
-
function
|
|
456
|
+
var J = (e, t) => e.parts.map((e) => B(t(), [e]));
|
|
457
|
+
function Y(e) {
|
|
458
458
|
return E(e) ? [
|
|
459
459
|
{
|
|
460
460
|
i: -1,
|
|
@@ -507,8 +507,8 @@ function Z(e) {
|
|
|
507
507
|
}
|
|
508
508
|
];
|
|
509
509
|
}
|
|
510
|
-
function
|
|
511
|
-
let s =
|
|
510
|
+
function X(e, t, n, r = [], i = 6, a = () => !0) {
|
|
511
|
+
let s = Y(e), c = /* @__PURE__ */ new Set(["0,0"]), l = [{
|
|
512
512
|
i: 0,
|
|
513
513
|
j: 0
|
|
514
514
|
}];
|
|
@@ -530,8 +530,8 @@ function Q(e, t, n, r = [], i = 6, a = () => !0) {
|
|
|
530
530
|
l = u;
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
var
|
|
534
|
-
function
|
|
533
|
+
var Z = (e) => o(e);
|
|
534
|
+
function ne(e) {
|
|
535
535
|
let t = new Set(S(e).map(h)), n = [];
|
|
536
536
|
for (let r of S(e)) for (let e of m(r)) {
|
|
537
537
|
if (t.has(h(e))) continue;
|
|
@@ -540,15 +540,15 @@ function ee(e) {
|
|
|
540
540
|
}
|
|
541
541
|
return n;
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function re(e, t, n, r, i) {
|
|
544
544
|
let a = l(t, n);
|
|
545
|
-
if (e === "cell") return
|
|
545
|
+
if (e === "cell") return B(i, [{
|
|
546
546
|
kind: e,
|
|
547
547
|
at: a,
|
|
548
548
|
tone: r
|
|
549
549
|
}]);
|
|
550
550
|
let { i: o, j: s } = d(a);
|
|
551
|
-
return
|
|
551
|
+
return B(i, [{
|
|
552
552
|
kind: e,
|
|
553
553
|
at: {
|
|
554
554
|
i: o - 1,
|
|
@@ -558,7 +558,7 @@ function te(e, t, n, r, i) {
|
|
|
558
558
|
tone: r
|
|
559
559
|
}]);
|
|
560
560
|
}
|
|
561
|
-
function
|
|
561
|
+
function ie(e, t) {
|
|
562
562
|
let n = (e) => Math.round(e * 100) / 100, o = (e) => `M${e.map((e) => `${n(e.x)} ${n(e.y)}`).join("L")}Z`, l = (e) => ({
|
|
563
563
|
x: e.x,
|
|
564
564
|
y: e.y - t
|
|
@@ -617,8 +617,54 @@ function ne(e, t) {
|
|
|
617
617
|
kind: e.kind,
|
|
618
618
|
d: e.d.join("")
|
|
619
619
|
})),
|
|
620
|
-
seams:
|
|
620
|
+
seams: W(e).map(([e, r]) => `M${n(e.x)} ${n(e.y - t)}L${n(r.x)} ${n(r.y - t)}`).join("")
|
|
621
621
|
};
|
|
622
622
|
}
|
|
623
|
+
function Q(e, t, n, r) {
|
|
624
|
+
let i = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), a = i(n, r, e), o = i(n, r, t), s = i(e, t, n), c = i(e, t, r);
|
|
625
|
+
return a * o < 0 && s * c < 0;
|
|
626
|
+
}
|
|
627
|
+
function $(e, t) {
|
|
628
|
+
let n = 0;
|
|
629
|
+
for (let r = 1; r < e.length; r++) {
|
|
630
|
+
let i = e[r - 1], a = e[r];
|
|
631
|
+
for (let e = 0; e < t.length; e++) Q(i, a, t[e], t[(e + 1) % t.length]) && n++;
|
|
632
|
+
if (n >= 2) return !0;
|
|
633
|
+
}
|
|
634
|
+
return !1;
|
|
635
|
+
}
|
|
636
|
+
function ae(e, t, n = 0) {
|
|
637
|
+
let { x: o, y: s } = a(t);
|
|
638
|
+
return $(e, [
|
|
639
|
+
{
|
|
640
|
+
x: o + i,
|
|
641
|
+
y: s - n
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
x: o + r,
|
|
645
|
+
y: s + 22 - n
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
x: o + r,
|
|
649
|
+
y: s + 66 - n
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
x: o + i,
|
|
653
|
+
y: s + 88 - n
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
x: o,
|
|
657
|
+
y: s + 66 - n
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
x: o,
|
|
661
|
+
y: s + 22 - n
|
|
662
|
+
}
|
|
663
|
+
]);
|
|
664
|
+
}
|
|
665
|
+
function oe(e, t) {
|
|
666
|
+
for (let n = 1; n < e.length; n++) for (let r = 1; r < t.length; r++) if (Q(e[n - 1], e[n], t[r - 1], t[r])) return !0;
|
|
667
|
+
return !1;
|
|
668
|
+
}
|
|
623
669
|
//#endregion
|
|
624
|
-
export {
|
|
670
|
+
export { p as A, W as C, P as D, N as E, re as M, e as N, Z as O, t as P, _ as S, A as T, X as _, s as a, R as b, ae as c, T as d, ie as f, D as g, te as h, u as i, L as j, H as k, oe as l, l as m, J as n, c as o, G as p, a as r, S as s, j as t, $ as u, ne as v, U as w, q as x, B as y };
|
package/dist/hexes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as MAGNET, n as apart, r as boxOf, i as cornerAt, a as cornerOf, o as cornersOf, s as covered, c as
|
|
1
|
+
export { t as MAGNET, n as apart, r as boxOf, i as cornerAt, a as cornerOf, o as cornersOf, s as covered, c as crossesCell, l as crossesLine, u as crossesRing, d as fits, p as glued, m as hexAt, h as magnetOf, g as moved, _ as nearestFit, v as outlineOf, y as pieceOf, b as pivotPoint, x as pulledOff, S as screenArea, C as seamsOf, w as sharedSides, T as snapDelta, E as snapFrames, D as stepFor, O as stepOnScreen, k as touching, A as trisOf, j as turned, M as unitAt } from "./hexes-B4uCADpF.js";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { x as FACES, _ as FACE_TAG, n as HexSky, p as ICON_NAMES, m as ICON_TAG, v as LatticeFace, h as LatticeIcon, c as LatticeShape, y as MOODS, d as SHAPE_NAMES, l as SHAPE_TAG, a as SHEARS_TAG, r as SKY_TAG, o as ShearsPadElement, f as TONES, i as defineHexSky, t as defineLatticeElements, b as defineLatticeFace, g as defineLatticeIcon, u as defineLatticeShape, s as defineShearsPad } from "./elements-
|
|
1
|
+
export { x as FACES, _ as FACE_TAG, n as HexSky, p as ICON_NAMES, m as ICON_TAG, v as LatticeFace, h as LatticeIcon, c as LatticeShape, y as MOODS, d as SHAPE_NAMES, l as SHAPE_TAG, a as SHEARS_TAG, r as SKY_TAG, o as ShearsPadElement, f as TONES, i as defineHexSky, t as defineLatticeElements, b as defineLatticeFace, g as defineLatticeIcon, u as defineLatticeShape, s as defineShearsPad } from "./elements-Ka2LbDpP.js";
|
|
@@ -28,5 +28,8 @@ export declare class LatticeFace extends LatticeElement {
|
|
|
28
28
|
set decorative(decorative: boolean | string | null);
|
|
29
29
|
attributeChangedCallback(name: string, _: string | null, value: string | null): void;
|
|
30
30
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Register `<lattice-face>` once, or as `name` (a tag of your own, when another library holds this
|
|
33
|
+
* one); a second call, or a call on a server, does nothing.
|
|
34
|
+
*/
|
|
35
|
+
export declare const defineLatticeFace: (name?: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type Area, apart, boxOf, type Corner, cornerAt, cornerOf, cornersOf, covered, fits, glued, type Hex, hexAt, MAGNET, type Magnet, magnetOf, moved, nearestFit, outlineOf, type Part, type Piece, pieceOf, pivotPoint, pulledOff, screenArea, seamsOf, sharedSides, snapDelta, snapFrames, stepFor, stepOnScreen, type Tri, touching, trisOf, turned, unitAt, } from "../hexes";
|
|
1
|
+
export { type Area, apart, boxOf, type Corner, cornerAt, cornerOf, cornersOf, covered, crossesCell, crossesLine, crossesRing, fits, glued, type Hex, hexAt, MAGNET, type Magnet, magnetOf, moved, nearestFit, outlineOf, type Part, type Piece, pieceOf, pivotPoint, pulledOff, screenArea, seamsOf, sharedSides, snapDelta, snapFrames, stepFor, stepOnScreen, type Tri, touching, trisOf, turned, unitAt, } from "../hexes";
|
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
declare const HostElement: typeof HTMLElement;
|
|
6
6
|
/** One stylesheet per kind of element, made the first time one is shown and shared after. */
|
|
7
7
|
export declare function sheetOf(css: string): () => CSSStyleSheet;
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Register an element once, in a browser, as `name` (its own `tag` by default); a second call, or
|
|
10
|
+
* a call on a server, does nothing. A name another element already holds is left to it, and said.
|
|
11
|
+
*/
|
|
12
|
+
export declare function define(tag: string, element: CustomElementConstructor, name?: string): void;
|
|
10
13
|
/** A whole number from an attribute or a property, or `fallback` when it is not one. */
|
|
11
14
|
export declare const numberOf: (value: unknown, fallback: number) => number;
|
|
12
15
|
/** Whether a boolean attribute or property is on: present, and not "false". */
|
|
@@ -12,5 +12,8 @@ export declare class LatticeIcon extends LatticeElement {
|
|
|
12
12
|
set label(label: string);
|
|
13
13
|
attributeChangedCallback(name: string, _: string | null, value: string | null): void;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Register `<lattice-icon>` once, or as `name` (a tag of your own, when another library holds this
|
|
17
|
+
* one); a second call, or a call on a server, does nothing.
|
|
18
|
+
*/
|
|
19
|
+
export declare const defineLatticeIcon: (name?: string) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineLatticeFace, LatticeFace } from "./face";
|
|
2
2
|
import { defineLatticeIcon, LatticeIcon } from "./icon";
|
|
3
3
|
import { defineLatticeShape, LatticeShape } from "./shape";
|
|
4
|
-
import { defineShearsPad, ShearsPadElement, type StrokeDetail } from "./shears";
|
|
4
|
+
import { defineShearsPad, ShearsPadElement, type ShearsPadEventMap, type StrokeDetail, type StrokeEndDetail } from "./shears";
|
|
5
5
|
import { defineHexSky, HexSky } from "./sky";
|
|
6
6
|
export { FACES } from "../faceLattice";
|
|
7
7
|
export type { Part } from "../hexes";
|
|
@@ -11,7 +11,7 @@ export { 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";
|
|
14
|
-
export { defineHexSky, defineLatticeFace, defineLatticeIcon, defineLatticeShape, defineShearsPad, HexSky, LatticeFace, LatticeIcon, LatticeShape, ShearsPadElement, type StrokeDetail, };
|
|
14
|
+
export { defineHexSky, defineLatticeFace, defineLatticeIcon, defineLatticeShape, defineShearsPad, HexSky, LatticeFace, LatticeIcon, LatticeShape, ShearsPadElement, type ShearsPadEventMap, type StrokeDetail, type StrokeEndDetail, };
|
|
15
15
|
/** Register every element once; a second call, or a call on a server, does nothing. */
|
|
16
16
|
export declare function defineLatticeElements(): void;
|
|
17
17
|
declare global {
|
|
@@ -22,10 +22,4 @@ declare global {
|
|
|
22
22
|
"shears-pad": ShearsPadElement;
|
|
23
23
|
"lattice-icon": LatticeIcon;
|
|
24
24
|
}
|
|
25
|
-
interface HTMLElementEventMap {
|
|
26
|
-
stroke: CustomEvent<StrokeDetail>;
|
|
27
|
-
strokeend: CustomEvent<{
|
|
28
|
-
points: StrokeDetail["points"];
|
|
29
|
-
}>;
|
|
30
|
-
}
|
|
31
25
|
}
|
|
@@ -12,7 +12,8 @@ export declare class LatticeShape extends LatticeElement {
|
|
|
12
12
|
private readonly labelSignal;
|
|
13
13
|
get shape(): ShapeName;
|
|
14
14
|
set shape(name: string);
|
|
15
|
-
|
|
15
|
+
private made;
|
|
16
|
+
/** The parts drawn: those given, or the shape's; the same array until an input changes. */
|
|
16
17
|
get parts(): Part[];
|
|
17
18
|
set parts(parts: unknown);
|
|
18
19
|
get tone(): number;
|
|
@@ -25,5 +26,8 @@ export declare class LatticeShape extends LatticeElement {
|
|
|
25
26
|
set label(label: string);
|
|
26
27
|
attributeChangedCallback(name: string, _: string | null, value: string | null): void;
|
|
27
28
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
29
|
+
/**
|
|
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.
|
|
32
|
+
*/
|
|
33
|
+
export declare const defineLatticeShape: (name?: string) => void;
|
|
@@ -6,9 +6,28 @@ export type StrokePoint = {
|
|
|
6
6
|
y: number;
|
|
7
7
|
};
|
|
8
8
|
export interface StrokeDetail {
|
|
9
|
+
/** The stroke so far, a copy of its own. */
|
|
9
10
|
points: StrokePoint[];
|
|
11
|
+
/** The newest point, the last of `points`. */
|
|
12
|
+
point: StrokePoint;
|
|
10
13
|
fresh: boolean;
|
|
11
14
|
}
|
|
15
|
+
export interface StrokeEndDetail {
|
|
16
|
+
points: StrokePoint[];
|
|
17
|
+
/** The stroke was cut short instead of lifted. */
|
|
18
|
+
cancelled: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** The pad's own events, for `addEventListener`. */
|
|
21
|
+
export interface ShearsPadEventMap extends HTMLElementEventMap {
|
|
22
|
+
stroke: CustomEvent<StrokeDetail>;
|
|
23
|
+
strokeend: CustomEvent<StrokeEndDetail>;
|
|
24
|
+
}
|
|
25
|
+
export interface ShearsPadElement {
|
|
26
|
+
addEventListener<K extends keyof ShearsPadEventMap>(type: K, listener: (this: ShearsPadElement, event: ShearsPadEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
27
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
28
|
+
removeEventListener<K extends keyof ShearsPadEventMap>(type: K, listener: (this: ShearsPadElement, event: ShearsPadEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
29
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
30
|
+
}
|
|
12
31
|
export declare class ShearsPadElement extends LatticeElement {
|
|
13
32
|
static readonly observedAttributes: string[];
|
|
14
33
|
private readonly disabledSignal;
|
|
@@ -16,5 +35,8 @@ export declare class ShearsPadElement extends LatticeElement {
|
|
|
16
35
|
set disabled(disabled: boolean | string | null);
|
|
17
36
|
attributeChangedCallback(_: string, __: string | null, value: string | null): void;
|
|
18
37
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Register `<shears-pad>` once, or as `name` (a tag of your own, when another library holds this
|
|
40
|
+
* one); a second call, or a call on a server, does nothing.
|
|
41
|
+
*/
|
|
42
|
+
export declare const defineShearsPad: (name?: string) => void;
|
|
@@ -3,11 +3,14 @@ export declare const SKY_TAG = "hex-sky";
|
|
|
3
3
|
export declare class HexSky extends LatticeElement {
|
|
4
4
|
static readonly observedAttributes: string[];
|
|
5
5
|
private readonly kindSignal;
|
|
6
|
+
private readonly orientSignal;
|
|
6
7
|
private readonly scaleSignal;
|
|
7
8
|
private readonly xSignal;
|
|
8
9
|
private readonly ySignal;
|
|
9
10
|
get kind(): "sky" | "earth";
|
|
10
11
|
set kind(kind: string);
|
|
12
|
+
get orient(): "pointy" | "flat";
|
|
13
|
+
set orient(orient: string);
|
|
11
14
|
get scale(): number;
|
|
12
15
|
set scale(scale: number | string);
|
|
13
16
|
get x(): number;
|
|
@@ -16,5 +19,8 @@ export declare class HexSky extends LatticeElement {
|
|
|
16
19
|
set y(y: number | string);
|
|
17
20
|
attributeChangedCallback(name: string, _: string | null, value: string | null): void;
|
|
18
21
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Register `<hex-sky>` once, or as `name` (a tag of your own, when another library holds this
|
|
24
|
+
* one); a second call, or a call on a server, does nothing.
|
|
25
|
+
*/
|
|
26
|
+
export declare const defineHexSky: (name?: string) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HexSky, IconName, LatticeFace, LatticeIcon, LatticeShape, Part, ShapeName, ShearsPadElement, StrokeDetail,
|
|
1
|
+
import type { HexSky, IconName, LatticeFace, LatticeIcon, LatticeShape, Part, ShapeName, ShearsPadElement, StrokeDetail, StrokeEndDetail } from "./index";
|
|
2
2
|
declare module "solid-js" {
|
|
3
3
|
namespace JSX {
|
|
4
4
|
interface IntrinsicElements {
|
|
@@ -13,6 +13,7 @@ declare module "solid-js" {
|
|
|
13
13
|
};
|
|
14
14
|
"hex-sky": JSX.HTMLAttributes<HexSky> & {
|
|
15
15
|
kind?: "sky" | "earth";
|
|
16
|
+
orient?: "pointy" | "flat";
|
|
16
17
|
scale?: number | string;
|
|
17
18
|
x?: number | string;
|
|
18
19
|
y?: number | string;
|
|
@@ -38,9 +39,7 @@ declare module "solid-js" {
|
|
|
38
39
|
}
|
|
39
40
|
interface CustomEvents {
|
|
40
41
|
stroke: CustomEvent<StrokeDetail>;
|
|
41
|
-
strokeend: CustomEvent<
|
|
42
|
-
points: StrokePoint[];
|
|
43
|
-
}>;
|
|
42
|
+
strokeend: CustomEvent<StrokeEndDetail>;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harmonics/lattice-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "The Harmonics tree's look as Custom Elements: a lattice face, the hexagon sky, raised lattice shapes, a shears cut gesture and two marks. Any page, any framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"prepublishOnly": "cd .. && bun run kit"
|
|
9
|
+
},
|
|
7
10
|
"sideEffects": [
|
|
8
11
|
"./dist/define.js"
|
|
9
12
|
],
|
package/react.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
ShapeName,
|
|
12
12
|
ShearsPadElement,
|
|
13
13
|
StrokeDetail,
|
|
14
|
-
|
|
14
|
+
StrokeEndDetail,
|
|
15
15
|
} from "./dist/types/elements/index";
|
|
16
16
|
|
|
17
17
|
type Base<E> = DetailedHTMLProps<HTMLAttributes<E>, E>;
|
|
@@ -28,7 +28,13 @@ declare module "react" {
|
|
|
28
28
|
label?: string;
|
|
29
29
|
decorative?: boolean;
|
|
30
30
|
};
|
|
31
|
-
"hex-sky": Base<HexSky> & {
|
|
31
|
+
"hex-sky": Base<HexSky> & {
|
|
32
|
+
kind?: "sky" | "earth";
|
|
33
|
+
orient?: "pointy" | "flat";
|
|
34
|
+
scale?: number;
|
|
35
|
+
x?: number;
|
|
36
|
+
y?: number;
|
|
37
|
+
};
|
|
32
38
|
"lattice-shape": Base<LatticeShape> & {
|
|
33
39
|
shape?: ShapeName;
|
|
34
40
|
parts?: Part[] | string;
|
|
@@ -40,7 +46,7 @@ declare module "react" {
|
|
|
40
46
|
"shears-pad": Base<ShearsPadElement> & {
|
|
41
47
|
disabled?: boolean;
|
|
42
48
|
onstroke?: (event: CustomEvent<StrokeDetail>) => void;
|
|
43
|
-
onstrokeend?: (event: CustomEvent<
|
|
49
|
+
onstrokeend?: (event: CustomEvent<StrokeEndDetail>) => void;
|
|
44
50
|
};
|
|
45
51
|
"lattice-icon": Base<LatticeIcon> & { name?: IconName; label?: string };
|
|
46
52
|
}
|