strata-react 2.1.14 → 2.1.16
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/README.md +8 -1
- package/UPGRADING.md +4 -0
- package/dist/index.d.ts +50 -1
- package/dist/index.js +385 -15
- package/dist/index.js.map +1 -1
- package/dist/{run-D_Ic1jE7.js → run-C3RjrKWa.js} +76 -5
- package/dist/run-C3RjrKWa.js.map +1 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.d.ts +8 -1
- package/dist/visual.js +2 -2
- package/package.json +1 -1
- package/dist/run-D_Ic1jE7.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -9906,7 +9906,7 @@ function useObjectUrl(data, type) {
|
|
|
9906
9906
|
}
|
|
9907
9907
|
|
|
9908
9908
|
// src/components/pixel-image.tsx
|
|
9909
|
-
const sizeOf = (p) => p.image ? {
|
|
9909
|
+
const sizeOf$1 = (p) => p.image ? {
|
|
9910
9910
|
width: p.image.width,
|
|
9911
9911
|
height: p.image.height,
|
|
9912
9912
|
data: p.image.data
|
|
@@ -9922,7 +9922,7 @@ function pixelZoom(width, height, zoom = "fit", maxSize = 512) {
|
|
|
9922
9922
|
}
|
|
9923
9923
|
/** A decoded RGBA picture on a canvas at a whole-number zoom with square pixels, a checkerboard behind clear pixels, named with its size. */
|
|
9924
9924
|
function PixelImage({ label, zoom = "fit", maxSize = 512, className, ...source }) {
|
|
9925
|
-
const { width, height, data } = sizeOf(source);
|
|
9925
|
+
const { width, height, data } = sizeOf$1(source);
|
|
9926
9926
|
const canvas = React.useRef(null);
|
|
9927
9927
|
const complete = data.length === width * height * 4 && width > 0 && height > 0;
|
|
9928
9928
|
const scale = pixelZoom(width, height, zoom, maxSize);
|
|
@@ -21623,9 +21623,9 @@ const HANDLE_AT = {
|
|
|
21623
21623
|
sw: "left-0 bottom-0 -translate-x-1/2 translate-y-1/2",
|
|
21624
21624
|
w: "left-0 top-1/2 -translate-x-1/2 -translate-y-1/2"
|
|
21625
21625
|
};
|
|
21626
|
-
const round = (n) => format.integer(Math.round(n));
|
|
21626
|
+
const round$1 = (n) => format.integer(Math.round(n));
|
|
21627
21627
|
/** A window said in words. */
|
|
21628
|
-
const describeRegion = (r) => `${r.label}: ${round(r.w)} wide by ${round(r.h)} high, ${round(r.x)} across and ${round(r.y)} down`;
|
|
21628
|
+
const describeRegion = (r) => `${r.label}: ${round$1(r.w)} wide by ${round$1(r.h)} high, ${round$1(r.x)} across and ${round$1(r.y)} down`;
|
|
21629
21629
|
/** Draw and move one or two named windows on a picture, with pointer, keyboard and numbers kept in step; aspect and bounds hold through all three; two windows make a from/to move with a Watch preview. */
|
|
21630
21630
|
function RegionEditor({ label, children, size, regions, onChange, selectedId, onSelectedChange, aspect, min, bounds, step, onDraw, mode = "single", onPreview, duration = 1500, easing = "ease-in-out", fields = true, unit = "px", defaults, angle = 0, onAngleChange, guide, spreadLabels = {
|
|
21631
21631
|
one: "Page",
|
|
@@ -21826,7 +21826,7 @@ function RegionEditor({ label, children, size, regions, onChange, selectedId, on
|
|
|
21826
21826
|
...regions[1],
|
|
21827
21827
|
...moved[1]
|
|
21828
21828
|
}]);
|
|
21829
|
-
setSaid(`Gutter at ${round(gutterOf(moved[0], moved[1]))}: ${spreadLabels.left} ${round(moved[0].w)} wide, ${spreadLabels.right} ${round(moved[1].w)} wide`);
|
|
21829
|
+
setSaid(`Gutter at ${round$1(gutterOf(moved[0], moved[1]))}: ${spreadLabels.left} ${round$1(moved[0].w)} wide, ${spreadLabels.right} ${round$1(moved[1].w)} wide`);
|
|
21830
21830
|
}
|
|
21831
21831
|
};
|
|
21832
21832
|
const split = () => {
|
|
@@ -23004,7 +23004,7 @@ function Row$1({ level, children }) {
|
|
|
23004
23004
|
children
|
|
23005
23005
|
});
|
|
23006
23006
|
}
|
|
23007
|
-
function Node$
|
|
23007
|
+
function Node$2({ node }) {
|
|
23008
23008
|
const c = useCtx();
|
|
23009
23009
|
const key = c.nodeKey(node);
|
|
23010
23010
|
c.nodes.set(key, node);
|
|
@@ -23095,7 +23095,7 @@ function ClosedChild({ id }) {
|
|
|
23095
23095
|
}
|
|
23096
23096
|
function Nodes({ nodes }) {
|
|
23097
23097
|
const c = useCtx();
|
|
23098
|
-
return /* @__PURE__ */ jsx(Fragment, { children: c.sorted(nodes).map((n) => /* @__PURE__ */ jsx(Node$
|
|
23098
|
+
return /* @__PURE__ */ jsx(Fragment, { children: c.sorted(nodes).map((n) => /* @__PURE__ */ jsx(Node$2, { node: n }, c.nodeKey(n))) });
|
|
23099
23099
|
}
|
|
23100
23100
|
function Children({ node }) {
|
|
23101
23101
|
const c = useCtx();
|
|
@@ -23406,6 +23406,154 @@ function Tree({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderN
|
|
|
23406
23406
|
});
|
|
23407
23407
|
}
|
|
23408
23408
|
|
|
23409
|
+
// src/components/json-view.tsx
|
|
23410
|
+
const kindOf = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v === "object" ? "object" : typeof v === "string" ? "string" : typeof v === "number" ? "number" : typeof v === "boolean" ? "boolean" : "other";
|
|
23411
|
+
const entriesOf = (v) => Array.isArray(v) ? v.map((x, i) => [String(i), x]) : v !== null && typeof v === "object" ? Object.entries(v) : [];
|
|
23412
|
+
const isBranch = (v) => entriesOf(v).length > 0;
|
|
23413
|
+
const child = (path, key) => `${path}/${key.replaceAll("~", "~0").replaceAll("/", "~1")}`;
|
|
23414
|
+
/** Every branch's path under `value` down to `depth` levels (all of them with `Infinity`): what `JsonView` opens at first, and what "Expand all" opens. */
|
|
23415
|
+
function jsonBranchPaths(value, depth = Infinity, path = "") {
|
|
23416
|
+
if (!isBranch(value) || depth <= 0) return [];
|
|
23417
|
+
return [path, ...entriesOf(value).flatMap(([k, v]) => jsonBranchPaths(v, depth - 1, child(path, k)))];
|
|
23418
|
+
}
|
|
23419
|
+
function Scalar({ value }) {
|
|
23420
|
+
const kind = kindOf(value);
|
|
23421
|
+
if (kind === "string") return /* @__PURE__ */ jsxs("span", {
|
|
23422
|
+
className: "whitespace-pre-wrap break-words text-success",
|
|
23423
|
+
children: [
|
|
23424
|
+
/* @__PURE__ */ jsx("span", {
|
|
23425
|
+
className: "text-muted-foreground",
|
|
23426
|
+
children: "\""
|
|
23427
|
+
}),
|
|
23428
|
+
value,
|
|
23429
|
+
/* @__PURE__ */ jsx("span", {
|
|
23430
|
+
className: "text-muted-foreground",
|
|
23431
|
+
children: "\""
|
|
23432
|
+
})
|
|
23433
|
+
]
|
|
23434
|
+
});
|
|
23435
|
+
if (kind === "number") return /* @__PURE__ */ jsx("span", {
|
|
23436
|
+
className: "text-info tabular-nums",
|
|
23437
|
+
children: String(value)
|
|
23438
|
+
});
|
|
23439
|
+
if (kind === "boolean") return /* @__PURE__ */ jsx("span", {
|
|
23440
|
+
className: "text-primary",
|
|
23441
|
+
children: String(value)
|
|
23442
|
+
});
|
|
23443
|
+
if (kind === "null") return /* @__PURE__ */ jsx("span", {
|
|
23444
|
+
className: "italic text-muted-foreground",
|
|
23445
|
+
children: "null"
|
|
23446
|
+
});
|
|
23447
|
+
if (kind === "array") return /* @__PURE__ */ jsx("span", {
|
|
23448
|
+
className: "text-muted-foreground",
|
|
23449
|
+
children: "[]"
|
|
23450
|
+
});
|
|
23451
|
+
if (kind === "object") return /* @__PURE__ */ jsx("span", {
|
|
23452
|
+
className: "text-muted-foreground",
|
|
23453
|
+
children: "{}"
|
|
23454
|
+
});
|
|
23455
|
+
return /* @__PURE__ */ jsx("span", {
|
|
23456
|
+
className: "italic text-muted-foreground",
|
|
23457
|
+
children: String(value)
|
|
23458
|
+
});
|
|
23459
|
+
}
|
|
23460
|
+
const sizeOf = (v) => {
|
|
23461
|
+
const n = entriesOf(v).length;
|
|
23462
|
+
return Array.isArray(v) ? format.count(n, "item") : format.count(n, "key");
|
|
23463
|
+
};
|
|
23464
|
+
function Node$1({ name, value, path, index }) {
|
|
23465
|
+
const branch = isBranch(value);
|
|
23466
|
+
const array = Array.isArray(value);
|
|
23467
|
+
const text = kindOf(value) === "string" ? value : branch ? sizeOf(value) : String(value);
|
|
23468
|
+
return /* @__PURE__ */ jsxs(TreeItem, {
|
|
23469
|
+
id: path,
|
|
23470
|
+
textValue: `${name} ${text}`.trim(),
|
|
23471
|
+
className: "outline-none",
|
|
23472
|
+
children: [/* @__PURE__ */ jsx(TreeItemContent, { children: ({ level, isExpanded, isFocusVisible }) => /* @__PURE__ */ jsxs("div", {
|
|
23473
|
+
className: cn("flex min-h-(--control-h-sm) min-w-0 items-start gap-1 rounded-control py-1 pr-2 font-mono type-body-sm hover:bg-muted", isFocusVisible && "outline-2 -outline-offset-2 outline-ring"),
|
|
23474
|
+
style: { paddingInlineStart: `${(level - 1) * 1.25}rem` },
|
|
23475
|
+
children: [branch ? /* @__PURE__ */ jsx(Button$1, {
|
|
23476
|
+
slot: "chevron",
|
|
23477
|
+
"aria-label": isExpanded ? `Close ${name}` : `Open ${name}`,
|
|
23478
|
+
className: "grid size-5 shrink-0 place-items-center rounded-control text-muted-foreground",
|
|
23479
|
+
children: /* @__PURE__ */ jsx(ChevronRight, {
|
|
23480
|
+
"aria-hidden": true,
|
|
23481
|
+
className: cn("size-4", isExpanded && "rotate-90")
|
|
23482
|
+
})
|
|
23483
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
23484
|
+
"aria-hidden": true,
|
|
23485
|
+
className: "size-5 shrink-0"
|
|
23486
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
23487
|
+
className: "min-w-0 flex-1",
|
|
23488
|
+
children: [
|
|
23489
|
+
/* @__PURE__ */ jsx("span", {
|
|
23490
|
+
className: index ? "text-muted-foreground" : "font-medium text-foreground",
|
|
23491
|
+
children: name
|
|
23492
|
+
}),
|
|
23493
|
+
/* @__PURE__ */ jsx("span", {
|
|
23494
|
+
className: "text-muted-foreground",
|
|
23495
|
+
children: ": "
|
|
23496
|
+
}),
|
|
23497
|
+
branch ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23498
|
+
/* @__PURE__ */ jsx("span", {
|
|
23499
|
+
className: "text-muted-foreground",
|
|
23500
|
+
children: array ? isExpanded ? "[" : "[…]" : isExpanded ? "{" : "{…}"
|
|
23501
|
+
}),
|
|
23502
|
+
" ",
|
|
23503
|
+
/* @__PURE__ */ jsx("span", {
|
|
23504
|
+
className: "font-sans type-caption text-muted-foreground",
|
|
23505
|
+
children: sizeOf(value)
|
|
23506
|
+
})
|
|
23507
|
+
] }) : /* @__PURE__ */ jsx(Scalar, { value })
|
|
23508
|
+
]
|
|
23509
|
+
})]
|
|
23510
|
+
}) }), branch && entriesOf(value).map(([k, v]) => /* @__PURE__ */ jsx(Node$1, {
|
|
23511
|
+
name: k,
|
|
23512
|
+
value: v,
|
|
23513
|
+
path: child(path, k),
|
|
23514
|
+
index: array
|
|
23515
|
+
}, k))]
|
|
23516
|
+
});
|
|
23517
|
+
}
|
|
23518
|
+
/** Any JSON value as a tree: objects and arrays open and close (arrows, type-ahead, Expand all / Collapse all), values coloured by type with theme roles, long strings wrapped. The fallback for a value an app cannot show in its own words. */
|
|
23519
|
+
function JsonView({ value, label, openDepth = 2, expanded: given, rootName = "value", height = "32rem", className }) {
|
|
23520
|
+
const [initial] = React.useState(() => given ? [] : jsonBranchPaths(value, openDepth));
|
|
23521
|
+
const own = useExpanded({ initial });
|
|
23522
|
+
const expanded = given ?? own;
|
|
23523
|
+
const branch = isBranch(value);
|
|
23524
|
+
const all = React.useMemo(() => jsonBranchPaths(value), [value]);
|
|
23525
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
23526
|
+
className: cn("grid min-w-0 gap-1", className),
|
|
23527
|
+
children: [branch && /* @__PURE__ */ jsxs("div", {
|
|
23528
|
+
className: "flex items-center gap-1",
|
|
23529
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
23530
|
+
size: "sm",
|
|
23531
|
+
variant: "ghost",
|
|
23532
|
+
onPress: () => expanded.onChange(new Set(all)),
|
|
23533
|
+
children: "Expand all"
|
|
23534
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
23535
|
+
size: "sm",
|
|
23536
|
+
variant: "ghost",
|
|
23537
|
+
onPress: () => expanded.onChange(/* @__PURE__ */ new Set()),
|
|
23538
|
+
children: "Collapse all"
|
|
23539
|
+
})]
|
|
23540
|
+
}), /* @__PURE__ */ jsx(Tree$1, {
|
|
23541
|
+
"aria-label": label,
|
|
23542
|
+
expandedKeys: expanded.expanded,
|
|
23543
|
+
onExpandedChange: (keys) => expanded.onChange(new Set([...keys].map(String))),
|
|
23544
|
+
className: "min-w-0 overflow-y-auto rounded-control bg-surface-sunken p-1 outline-none",
|
|
23545
|
+
style: { maxHeight: height },
|
|
23546
|
+
"data-strata-scroll": "",
|
|
23547
|
+
children: /* @__PURE__ */ jsx(Node$1, {
|
|
23548
|
+
name: rootName,
|
|
23549
|
+
value,
|
|
23550
|
+
path: "",
|
|
23551
|
+
index: false
|
|
23552
|
+
})
|
|
23553
|
+
})]
|
|
23554
|
+
});
|
|
23555
|
+
}
|
|
23556
|
+
|
|
23409
23557
|
// src/components/folder-picker.tsx
|
|
23410
23558
|
const SEP = "/";
|
|
23411
23559
|
const parts = (path) => path.split(SEP).filter(Boolean);
|
|
@@ -23758,7 +23906,7 @@ const MINUTE_WORDS = {
|
|
|
23758
23906
|
20: "twenty",
|
|
23759
23907
|
25: "twenty-five"
|
|
23760
23908
|
};
|
|
23761
|
-
const NUMBER_WORDS = [
|
|
23909
|
+
const NUMBER_WORDS$1 = [
|
|
23762
23910
|
"",
|
|
23763
23911
|
"one",
|
|
23764
23912
|
"two",
|
|
@@ -23783,8 +23931,8 @@ const NUMBER_WORDS = [
|
|
|
23783
23931
|
];
|
|
23784
23932
|
/** "one" to "twenty-nine", for the minutes said as a number ("seven minutes past three"). */
|
|
23785
23933
|
function minuteWord(n) {
|
|
23786
|
-
if (n <= 20) return NUMBER_WORDS[n] ?? String(n);
|
|
23787
|
-
return `twenty-${NUMBER_WORDS[n - 20]}`;
|
|
23934
|
+
if (n <= 20) return NUMBER_WORDS$1[n] ?? String(n);
|
|
23935
|
+
return `twenty-${NUMBER_WORDS$1[n - 20]}`;
|
|
23788
23936
|
}
|
|
23789
23937
|
/** The part of the day a 24-hour time falls in, as `clockWords` says it with `dayPart`. */
|
|
23790
23938
|
function dayPart(hours) {
|
|
@@ -23836,7 +23984,7 @@ const ROMAN = [
|
|
|
23836
23984
|
function romanHour(n) {
|
|
23837
23985
|
return ROMAN[(n % 12 + 12) % 12];
|
|
23838
23986
|
}
|
|
23839
|
-
const C = 100;
|
|
23987
|
+
const C$1 = 100;
|
|
23840
23988
|
/** A point `r` from the centre at `deg` clockwise from 12. */
|
|
23841
23989
|
function at(deg, r) {
|
|
23842
23990
|
const a = (deg - 90) * Math.PI / 180;
|
|
@@ -23856,7 +24004,7 @@ function handAngles(hours, minutes, seconds = 0) {
|
|
|
23856
24004
|
};
|
|
23857
24005
|
}
|
|
23858
24006
|
/** Points along a hand drawn pointing at 12, `from` below the centre to `to` above it, as an SVG polygon. */
|
|
23859
|
-
const poly = (pts) => pts.map(([x, y]) => `${100 + x},${100 - y}`).join(" ");
|
|
24007
|
+
const poly$1 = (pts) => pts.map(([x, y]) => `${100 + x},${100 - y}`).join(" ");
|
|
23860
24008
|
/** One hand drawn pointing at 12 (the group around it turns it): its shape by style, ink by role. */
|
|
23861
24009
|
function handShape(style, which) {
|
|
23862
24010
|
const hour = which === "hour";
|
|
@@ -23883,7 +24031,7 @@ function handShape(style, which) {
|
|
|
23883
24031
|
3.25
|
|
23884
24032
|
];
|
|
23885
24033
|
return /* @__PURE__ */ jsx("polygon", {
|
|
23886
|
-
points: poly([
|
|
24034
|
+
points: poly$1([
|
|
23887
24035
|
[-base, -tail],
|
|
23888
24036
|
[base, -tail],
|
|
23889
24037
|
[end, tip],
|
|
@@ -23926,7 +24074,7 @@ function handShape(style, which) {
|
|
|
23926
24074
|
case "sword": {
|
|
23927
24075
|
const [len, w] = hour ? [46, 6] : [74, 4.5];
|
|
23928
24076
|
return /* @__PURE__ */ jsx("polygon", {
|
|
23929
|
-
points: poly([
|
|
24077
|
+
points: poly$1([
|
|
23930
24078
|
[0, -12],
|
|
23931
24079
|
[w, len * .3],
|
|
23932
24080
|
[0, len],
|
|
@@ -24490,6 +24638,228 @@ function DigitalClock({ hours, minutes, seconds, hour12 = true, period = false,
|
|
|
24490
24638
|
});
|
|
24491
24639
|
}
|
|
24492
24640
|
|
|
24641
|
+
// src/components/fraction-shape.tsx
|
|
24642
|
+
/** Every outline, in the order a gallery shows them. */
|
|
24643
|
+
const FRACTION_OUTLINES = [
|
|
24644
|
+
"circle",
|
|
24645
|
+
"square",
|
|
24646
|
+
"rectangle",
|
|
24647
|
+
"triangle"
|
|
24648
|
+
];
|
|
24649
|
+
const R = 92;
|
|
24650
|
+
const C = 100;
|
|
24651
|
+
const RECT = {
|
|
24652
|
+
x: 6,
|
|
24653
|
+
y: 35,
|
|
24654
|
+
w: 188,
|
|
24655
|
+
h: 130
|
|
24656
|
+
};
|
|
24657
|
+
const SQUARE = {
|
|
24658
|
+
x: 8,
|
|
24659
|
+
y: 8,
|
|
24660
|
+
w: 184,
|
|
24661
|
+
h: 184
|
|
24662
|
+
};
|
|
24663
|
+
const TRIANGLE = [
|
|
24664
|
+
[100, 10],
|
|
24665
|
+
[192, 182],
|
|
24666
|
+
[8, 182]
|
|
24667
|
+
];
|
|
24668
|
+
const poly = (points) => `M${points.map(([x, y]) => `${round(x)} ${round(y)}`).join(" L")} Z`;
|
|
24669
|
+
const round = (n) => Math.round(n * 100) / 100;
|
|
24670
|
+
const mid = (a, b) => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
|
|
24671
|
+
const lerp = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
24672
|
+
/** Cut points from 0 to 1: equal, or (unequal) each part one size bigger than the one before. */
|
|
24673
|
+
function stops(parts, unequal) {
|
|
24674
|
+
const sizes = Array.from({ length: parts }, (_, i) => unequal ? i + 1 : 1);
|
|
24675
|
+
const total = sizes.reduce((a, b) => a + b, 0);
|
|
24676
|
+
const out = [0];
|
|
24677
|
+
for (const s of sizes) out.push(out[out.length - 1] + s / total);
|
|
24678
|
+
out[out.length - 1] = 1;
|
|
24679
|
+
return out;
|
|
24680
|
+
}
|
|
24681
|
+
function slices(parts, unequal) {
|
|
24682
|
+
if (parts === 1) return [`M8 ${C} A${R} ${R} 0 1 1 192 ${C} A${R} ${R} 0 1 1 8 ${C} Z`];
|
|
24683
|
+
const at = (t) => [C + R * Math.sin(t * 2 * Math.PI), C - R * Math.cos(t * 2 * Math.PI)];
|
|
24684
|
+
const s = stops(parts, unequal);
|
|
24685
|
+
return s.slice(1).map((end, i) => {
|
|
24686
|
+
const [x0, y0] = at(s[i]);
|
|
24687
|
+
const [x1, y1] = at(end);
|
|
24688
|
+
const large = end - s[i] > .5 ? 1 : 0;
|
|
24689
|
+
return `M${C} ${C} L${round(x0)} ${round(y0)} A${R} ${R} 0 ${large} 1 ${round(x1)} ${round(y1)} Z`;
|
|
24690
|
+
});
|
|
24691
|
+
}
|
|
24692
|
+
function boxParts(box, parts, cut) {
|
|
24693
|
+
const { x, y, w, h } = box;
|
|
24694
|
+
const corners = [
|
|
24695
|
+
[x, y],
|
|
24696
|
+
[x + w, y],
|
|
24697
|
+
[x + w, y + h],
|
|
24698
|
+
[x, y + h]
|
|
24699
|
+
];
|
|
24700
|
+
if (cut === "diagonal" && (parts === 2 || parts === 4)) {
|
|
24701
|
+
if (parts === 2) return [poly([
|
|
24702
|
+
corners[0],
|
|
24703
|
+
corners[1],
|
|
24704
|
+
corners[2]
|
|
24705
|
+
]), poly([
|
|
24706
|
+
corners[0],
|
|
24707
|
+
corners[2],
|
|
24708
|
+
corners[3]
|
|
24709
|
+
])];
|
|
24710
|
+
const centre = [x + w / 2, y + h / 2];
|
|
24711
|
+
return corners.map((p, i) => poly([
|
|
24712
|
+
p,
|
|
24713
|
+
corners[(i + 1) % 4],
|
|
24714
|
+
centre
|
|
24715
|
+
]));
|
|
24716
|
+
}
|
|
24717
|
+
if (cut === "grid" && parts === 4) {
|
|
24718
|
+
const cx = x + w / 2;
|
|
24719
|
+
const cy = y + h / 2;
|
|
24720
|
+
return [
|
|
24721
|
+
poly([
|
|
24722
|
+
[x, y],
|
|
24723
|
+
[cx, y],
|
|
24724
|
+
[cx, cy],
|
|
24725
|
+
[x, cy]
|
|
24726
|
+
]),
|
|
24727
|
+
poly([
|
|
24728
|
+
[cx, y],
|
|
24729
|
+
[x + w, y],
|
|
24730
|
+
[x + w, cy],
|
|
24731
|
+
[cx, cy]
|
|
24732
|
+
]),
|
|
24733
|
+
poly([
|
|
24734
|
+
[cx, cy],
|
|
24735
|
+
[x + w, cy],
|
|
24736
|
+
[x + w, y + h],
|
|
24737
|
+
[cx, y + h]
|
|
24738
|
+
]),
|
|
24739
|
+
poly([
|
|
24740
|
+
[x, cy],
|
|
24741
|
+
[cx, cy],
|
|
24742
|
+
[cx, y + h],
|
|
24743
|
+
[x, y + h]
|
|
24744
|
+
])
|
|
24745
|
+
];
|
|
24746
|
+
}
|
|
24747
|
+
const s = stops(parts, cut === "unequal");
|
|
24748
|
+
return s.slice(1).map((end, i) => cut === "rows" ? poly([
|
|
24749
|
+
[x, y + h * s[i]],
|
|
24750
|
+
[x + w, y + h * s[i]],
|
|
24751
|
+
[x + w, y + h * end],
|
|
24752
|
+
[x, y + h * end]
|
|
24753
|
+
]) : poly([
|
|
24754
|
+
[x + w * s[i], y],
|
|
24755
|
+
[x + w * end, y],
|
|
24756
|
+
[x + w * end, y + h],
|
|
24757
|
+
[x + w * s[i], y + h]
|
|
24758
|
+
]));
|
|
24759
|
+
}
|
|
24760
|
+
function triangleParts(parts, cut) {
|
|
24761
|
+
const [top, right, left] = TRIANGLE;
|
|
24762
|
+
if (parts === 4 && cut !== "unequal" && cut !== "strips") {
|
|
24763
|
+
const a = mid(top, right);
|
|
24764
|
+
const b = mid(right, left);
|
|
24765
|
+
const c = mid(left, top);
|
|
24766
|
+
return [
|
|
24767
|
+
poly([
|
|
24768
|
+
top,
|
|
24769
|
+
a,
|
|
24770
|
+
c
|
|
24771
|
+
]),
|
|
24772
|
+
poly([
|
|
24773
|
+
a,
|
|
24774
|
+
right,
|
|
24775
|
+
b
|
|
24776
|
+
]),
|
|
24777
|
+
poly([
|
|
24778
|
+
c,
|
|
24779
|
+
b,
|
|
24780
|
+
left
|
|
24781
|
+
]),
|
|
24782
|
+
poly([
|
|
24783
|
+
a,
|
|
24784
|
+
b,
|
|
24785
|
+
c
|
|
24786
|
+
])
|
|
24787
|
+
];
|
|
24788
|
+
}
|
|
24789
|
+
const s = stops(parts, cut === "unequal");
|
|
24790
|
+
return s.slice(1).map((end, i) => poly([
|
|
24791
|
+
top,
|
|
24792
|
+
lerp(left, right, s[i]),
|
|
24793
|
+
lerp(left, right, end)
|
|
24794
|
+
]));
|
|
24795
|
+
}
|
|
24796
|
+
/** The parts of a shape as SVG paths in a 200 by 200 view, in the order `shaded` counts them. */
|
|
24797
|
+
function fractionParts(shape, parts, cut = "strips") {
|
|
24798
|
+
if (!Number.isInteger(parts) || parts < 1 || parts > 8) throw new RangeError(`parts must be 1 to 8, not ${parts}`);
|
|
24799
|
+
if (shape === "circle") return slices(parts, cut === "unequal");
|
|
24800
|
+
if (shape === "triangle") return triangleParts(parts, cut);
|
|
24801
|
+
return boxParts(shape === "square" ? SQUARE : RECT, parts, cut);
|
|
24802
|
+
}
|
|
24803
|
+
const NUMBER_WORDS = [
|
|
24804
|
+
"zero",
|
|
24805
|
+
"one",
|
|
24806
|
+
"two",
|
|
24807
|
+
"three",
|
|
24808
|
+
"four",
|
|
24809
|
+
"five",
|
|
24810
|
+
"six",
|
|
24811
|
+
"seven",
|
|
24812
|
+
"eight"
|
|
24813
|
+
];
|
|
24814
|
+
const PART_NAMES = {
|
|
24815
|
+
2: ["half", "halves"],
|
|
24816
|
+
3: ["third", "thirds"],
|
|
24817
|
+
4: ["quarter", "quarters"],
|
|
24818
|
+
5: ["fifth", "fifths"],
|
|
24819
|
+
6: ["sixth", "sixths"],
|
|
24820
|
+
7: ["seventh", "sevenths"],
|
|
24821
|
+
8: ["eighth", "eighths"]
|
|
24822
|
+
};
|
|
24823
|
+
/**
|
|
24824
|
+
* A fraction as it is said: "one half", "three quarters", "two thirds". A whole is "one whole" ("two halves" is still
|
|
24825
|
+
* a whole, so `fractionWords(2, 2)` is "two halves"); 0 is "none".
|
|
24826
|
+
*/
|
|
24827
|
+
function fractionWords(shaded, parts) {
|
|
24828
|
+
if (shaded === 0) return "none";
|
|
24829
|
+
if (parts === 1) return "one whole";
|
|
24830
|
+
const [one, many] = PART_NAMES[parts] ?? [`part of ${parts}`, `parts of ${parts}`];
|
|
24831
|
+
return `${NUMBER_WORDS[shaded] ?? String(shaded)} ${shaded === 1 ? one : many}`;
|
|
24832
|
+
}
|
|
24833
|
+
const OUTLINE_WORDS = {
|
|
24834
|
+
circle: "A circle",
|
|
24835
|
+
square: "A square",
|
|
24836
|
+
rectangle: "A rectangle",
|
|
24837
|
+
triangle: "A triangle"
|
|
24838
|
+
};
|
|
24839
|
+
/** A shape cut into parts, some of them shaded: the picture of a fraction (a half, a quarter, and not a half). */
|
|
24840
|
+
function FractionShape({ shape, parts, shaded, cut = "strips", label, className }) {
|
|
24841
|
+
const paths = fractionParts(shape, parts, cut);
|
|
24842
|
+
const lit = new Set(typeof shaded === "number" ? paths.map((_, i) => i).slice(0, shaded) : shaded);
|
|
24843
|
+
const equal = cut === "unequal" && parts > 1 ? "unequal" : "equal";
|
|
24844
|
+
const said = label ?? `${OUTLINE_WORDS[shape]} cut into ${parts} ${equal} part${parts === 1 ? "" : "s"}, ${lit.size} shaded`;
|
|
24845
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
24846
|
+
viewBox: "0 0 200 200",
|
|
24847
|
+
role: "img",
|
|
24848
|
+
"aria-label": said,
|
|
24849
|
+
className: cn("block aspect-square w-full", className),
|
|
24850
|
+
children: /* @__PURE__ */ jsx("g", {
|
|
24851
|
+
strokeWidth: 3,
|
|
24852
|
+
strokeLinejoin: "round",
|
|
24853
|
+
className: "stroke-foreground",
|
|
24854
|
+
children: paths.map((d, i) => /* @__PURE__ */ jsx("path", {
|
|
24855
|
+
d,
|
|
24856
|
+
"data-shaded": lit.has(i) || void 0,
|
|
24857
|
+
className: lit.has(i) ? "fill-primary" : "fill-card"
|
|
24858
|
+
}, i))
|
|
24859
|
+
})
|
|
24860
|
+
});
|
|
24861
|
+
}
|
|
24862
|
+
|
|
24493
24863
|
// src/components/clock.tsx
|
|
24494
24864
|
/** Every face `Clock` draws: the analogue faces, then the digital ones. */
|
|
24495
24865
|
const CLOCK_STYLES = [...CLOCK_FACE_STYLES, ...DIGITAL_CLOCK_STYLES];
|
|
@@ -24742,5 +25112,5 @@ function SetClock({ value, onChange, step = 5, geared = true, face = "teaching",
|
|
|
24742
25112
|
});
|
|
24743
25113
|
}
|
|
24744
25114
|
|
|
24745
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BRUSHES, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, CLOCK_FACE_STYLES, CLOCK_STYLES, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, Clock, ClockFace, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Concealed, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DIGITAL_CLOCK_STYLES, DataTable, DataView$1 as DataView, Density, Dialog, DigitalClock, Disclosure, Done, DragSource, DrawingLayer, DrawingToolbar, EditListPlayer, EmptyState, EventLog, FIT, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, Glimpse, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RangeSlider, RateChoice, ReadAlong, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SayPicture, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SetClock, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, applyOp, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, clockParts, clockWords, cn, colorSchemeScript, commandShortcut, continues, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, currentOf, curvePoints, dayPart, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, digitalTime, diskThresholds, drawRect, drawingToSvg, ease, editTimeOf, editTimes, emptyDrawing, encodeWav, errorPayload, explainMicrophoneError, feedbackMarker, fetchJson, fieldErrorsOf, filterMarkup, findPage, fitPoints, fitRect, followAim, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, hitsStroke, hourAt, inkMatch, inputLevelThresholds, invertOp, isDigitalStyle, isDoubtful, isRefusal, isReservedChord, isSpeaking, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, mediaStatRows, minutesAt, moveGutter, moveMinuteHand, movePoints, moveRect, newStrokeId, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, pointsBox, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, replay, resample, resamplePeaks, rescaleDrawing, resizeRect, rgbaToBlob, rmsDb, romanHour, safeHref, sayPosition, serialiseSort, settleCut, simplifyPoints, skipAction, smoothPath, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepMinuteHand, stepOnGrid, stopSpeaking, strokeAt, strokeBox, strokeShape, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useCountdown, useDifference, useDrawing, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useReadAloud, useRebindableShortcuts, useRecorder, useReserve, useRevealed, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeaking, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, widthsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
25115
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BRUSHES, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, CLOCK_FACE_STYLES, CLOCK_STYLES, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, Clock, ClockFace, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Concealed, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DIGITAL_CLOCK_STYLES, DataTable, DataView$1 as DataView, Density, Dialog, DigitalClock, Disclosure, Done, DragSource, DrawingLayer, DrawingToolbar, EditListPlayer, EmptyState, EventLog, FIT, FRACTION_OUTLINES, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FractionShape, FullscreenFrame, Glimpse, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, JsonView, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RangeSlider, RateChoice, ReadAlong, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SayPicture, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SetClock, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, applyOp, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, clockParts, clockWords, cn, colorSchemeScript, commandShortcut, continues, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, currentOf, curvePoints, dayPart, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, digitalTime, diskThresholds, drawRect, drawingToSvg, ease, editTimeOf, editTimes, emptyDrawing, encodeWav, errorPayload, explainMicrophoneError, feedbackMarker, fetchJson, fieldErrorsOf, filterMarkup, findPage, fitPoints, fitRect, followAim, format, formatChord, fractionParts, fractionWords, frameAt, gainToVolume, geo, gridPoints, gutterOf, hitsStroke, hourAt, inkMatch, inputLevelThresholds, invertOp, isDigitalStyle, isDoubtful, isRefusal, isReservedChord, isSpeaking, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, jsonBranchPaths, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, mediaStatRows, minutesAt, moveGutter, moveMinuteHand, movePoints, moveRect, newStrokeId, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, pointsBox, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, replay, resample, resamplePeaks, rescaleDrawing, resizeRect, rgbaToBlob, rmsDb, romanHour, safeHref, sayPosition, serialiseSort, settleCut, simplifyPoints, skipAction, smoothPath, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepMinuteHand, stepOnGrid, stopSpeaking, strokeAt, strokeBox, strokeShape, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useCountdown, useDifference, useDrawing, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useReadAloud, useRebindableShortcuts, useRecorder, useReserve, useRevealed, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeaking, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, widthsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
24746
25116
|
//# sourceMappingURL=index.js.map
|