@devtime-ltd/ui-bench 0.0.0-stage → 0.1.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.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +247 -2
  3. package/dist/cjs/UiBench.js +67 -0
  4. package/dist/cjs/UiBench.native.js +77 -0
  5. package/dist/cjs/core/controller.js +147 -0
  6. package/dist/cjs/core/entry.js +35 -0
  7. package/dist/cjs/core/fixtures.js +102 -0
  8. package/dist/cjs/core/fragment.js +107 -0
  9. package/dist/cjs/core/inputs.js +83 -0
  10. package/dist/cjs/core/prefs.js +76 -0
  11. package/dist/cjs/core/props.js +16 -0
  12. package/dist/cjs/core/stage.js +129 -0
  13. package/dist/cjs/core/viewports.js +49 -0
  14. package/dist/cjs/dom/ControlBar.js +34 -0
  15. package/dist/cjs/dom/FixturePicker.js +105 -0
  16. package/dist/cjs/dom/Frame.js +171 -0
  17. package/dist/cjs/dom/InputsPanel.js +47 -0
  18. package/dist/cjs/dom/Landing.js +32 -0
  19. package/dist/cjs/dom/hashUrl.js +35 -0
  20. package/dist/cjs/dom/styles.js +261 -0
  21. package/dist/cjs/index.js +44 -0
  22. package/dist/cjs/native/Box.js +47 -0
  23. package/dist/cjs/native/ControlBar.js +50 -0
  24. package/dist/cjs/native/FixturePicker.js +65 -0
  25. package/dist/cjs/native/InputsPanel.js +67 -0
  26. package/dist/cjs/native/Landing.js +42 -0
  27. package/dist/cjs/native/Triangle.js +43 -0
  28. package/dist/cjs/native/theme.js +49 -0
  29. package/dist/cjs/package.json +1 -0
  30. package/dist/cjs/testing/index.js +59 -0
  31. package/dist/esm/UiBench.d.ts +2 -0
  32. package/dist/esm/UiBench.js +41 -0
  33. package/dist/esm/UiBench.js.map +1 -0
  34. package/dist/esm/UiBench.native.d.ts +2 -0
  35. package/dist/esm/UiBench.native.js +51 -0
  36. package/dist/esm/UiBench.native.js.map +1 -0
  37. package/dist/esm/core/controller.d.ts +43 -0
  38. package/dist/esm/core/controller.js +122 -0
  39. package/dist/esm/core/controller.js.map +1 -0
  40. package/dist/esm/core/entry.d.ts +8 -0
  41. package/dist/esm/core/entry.js +10 -0
  42. package/dist/esm/core/entry.js.map +1 -0
  43. package/dist/esm/core/fixtures.d.ts +27 -0
  44. package/dist/esm/core/fixtures.js +71 -0
  45. package/dist/esm/core/fixtures.js.map +1 -0
  46. package/dist/esm/core/fragment.d.ts +14 -0
  47. package/dist/esm/core/fragment.js +85 -0
  48. package/dist/esm/core/fragment.js.map +1 -0
  49. package/dist/esm/core/inputs.d.ts +30 -0
  50. package/dist/esm/core/inputs.js +52 -0
  51. package/dist/esm/core/inputs.js.map +1 -0
  52. package/dist/esm/core/prefs.d.ts +18 -0
  53. package/dist/esm/core/prefs.js +47 -0
  54. package/dist/esm/core/prefs.js.map +1 -0
  55. package/dist/esm/core/props.d.ts +23 -0
  56. package/dist/esm/core/props.js +2 -0
  57. package/dist/esm/core/props.js.map +1 -0
  58. package/dist/esm/core/stage.d.ts +50 -0
  59. package/dist/esm/core/stage.js +98 -0
  60. package/dist/esm/core/stage.js.map +1 -0
  61. package/dist/esm/core/viewports.d.ts +10 -0
  62. package/dist/esm/core/viewports.js +15 -0
  63. package/dist/esm/core/viewports.js.map +1 -0
  64. package/dist/esm/dom/ControlBar.d.ts +4 -0
  65. package/dist/esm/dom/ControlBar.js +8 -0
  66. package/dist/esm/dom/ControlBar.js.map +1 -0
  67. package/dist/esm/dom/FixturePicker.d.ts +6 -0
  68. package/dist/esm/dom/FixturePicker.js +82 -0
  69. package/dist/esm/dom/FixturePicker.js.map +1 -0
  70. package/dist/esm/dom/Frame.d.ts +9 -0
  71. package/dist/esm/dom/Frame.js +151 -0
  72. package/dist/esm/dom/Frame.js.map +1 -0
  73. package/dist/esm/dom/InputsPanel.d.ts +7 -0
  74. package/dist/esm/dom/InputsPanel.js +21 -0
  75. package/dist/esm/dom/InputsPanel.js.map +1 -0
  76. package/dist/esm/dom/Landing.d.ts +6 -0
  77. package/dist/esm/dom/Landing.js +6 -0
  78. package/dist/esm/dom/Landing.js.map +1 -0
  79. package/dist/esm/dom/hashUrl.d.ts +2 -0
  80. package/dist/esm/dom/hashUrl.js +9 -0
  81. package/dist/esm/dom/hashUrl.js.map +1 -0
  82. package/dist/esm/dom/styles.d.ts +1 -0
  83. package/dist/esm/dom/styles.js +235 -0
  84. package/dist/esm/dom/styles.js.map +1 -0
  85. package/dist/esm/index.d.ts +8 -0
  86. package/dist/esm/index.js +6 -0
  87. package/dist/esm/index.js.map +1 -0
  88. package/dist/esm/native/Box.d.ts +10 -0
  89. package/dist/esm/native/Box.js +21 -0
  90. package/dist/esm/native/Box.js.map +1 -0
  91. package/dist/esm/native/ControlBar.d.ts +5 -0
  92. package/dist/esm/native/ControlBar.js +24 -0
  93. package/dist/esm/native/ControlBar.js.map +1 -0
  94. package/dist/esm/native/FixturePicker.d.ts +6 -0
  95. package/dist/esm/native/FixturePicker.js +39 -0
  96. package/dist/esm/native/FixturePicker.js.map +1 -0
  97. package/dist/esm/native/InputsPanel.d.ts +7 -0
  98. package/dist/esm/native/InputsPanel.js +41 -0
  99. package/dist/esm/native/InputsPanel.js.map +1 -0
  100. package/dist/esm/native/Landing.d.ts +8 -0
  101. package/dist/esm/native/Landing.js +20 -0
  102. package/dist/esm/native/Landing.js.map +1 -0
  103. package/dist/esm/native/Triangle.d.ts +4 -0
  104. package/dist/esm/native/Triangle.js +17 -0
  105. package/dist/esm/native/Triangle.js.map +1 -0
  106. package/dist/esm/native/theme.d.ts +18 -0
  107. package/dist/esm/native/theme.js +19 -0
  108. package/dist/esm/native/theme.js.map +1 -0
  109. package/dist/esm/testing/index.d.ts +21 -0
  110. package/dist/esm/testing/index.js +33 -0
  111. package/dist/esm/testing/index.js.map +1 -0
  112. package/package.json +84 -4
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var FixturePicker_exports = {};
20
+ __export(FixturePicker_exports, {
21
+ FixturePicker: () => FixturePicker
22
+ });
23
+ module.exports = __toCommonJS(FixturePicker_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_react = require("react");
26
+ var import_fixtures = require("../core/fixtures");
27
+ function FixturePicker({ fixtures, selected, onSelect }) {
28
+ const [open, setOpen] = (0, import_react.useState)(false);
29
+ const [query, setQuery] = (0, import_react.useState)("");
30
+ const [active, setActive] = (0, import_react.useState)(0);
31
+ const root = (0, import_react.useRef)(null);
32
+ const matches = (0, import_react.useMemo)(() => (0, import_fixtures.searchFixtures)(fixtures, query), [fixtures, query]);
33
+ const rows = (0, import_react.useMemo)(() => toRows(matches), [matches]);
34
+ const close = () => {
35
+ setOpen(false);
36
+ setQuery("");
37
+ setActive(0);
38
+ };
39
+ const choose = (fixture) => {
40
+ if (!fixture)
41
+ return;
42
+ onSelect(fixture.id);
43
+ close();
44
+ };
45
+ (0, import_react.useEffect)(() => {
46
+ const onKey = (event) => {
47
+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
48
+ event.preventDefault();
49
+ setOpen((was) => !was);
50
+ }
51
+ };
52
+ window.addEventListener("keydown", onKey);
53
+ return () => window.removeEventListener("keydown", onKey);
54
+ }, []);
55
+ (0, import_react.useEffect)(() => {
56
+ if (!open)
57
+ return;
58
+ const onDown = (event) => {
59
+ if (!root.current?.contains(event.target))
60
+ close();
61
+ };
62
+ window.addEventListener("mousedown", onDown);
63
+ return () => window.removeEventListener("mousedown", onDown);
64
+ }, [open]);
65
+ const onSearchKey = (event) => {
66
+ if (event.key === "ArrowDown") {
67
+ event.preventDefault();
68
+ setActive((index) => Math.min(index + 1, matches.length - 1));
69
+ } else if (event.key === "ArrowUp") {
70
+ event.preventDefault();
71
+ setActive((index) => Math.max(index - 1, 0));
72
+ } else if (event.key === "Enter") {
73
+ event.preventDefault();
74
+ choose(matches[active]);
75
+ } else if (event.key === "Escape") {
76
+ event.preventDefault();
77
+ close();
78
+ }
79
+ };
80
+ return (0, import_jsx_runtime.jsxs)("div", { className: "uib-picker", ref: root, children: [(0, import_jsx_runtime.jsxs)("button", { type: "button", className: "uib-box", "aria-haspopup": "listbox", "aria-expanded": open, "data-testid": "fixture-picker", onClick: () => open ? close() : setOpen(true), children: [(0, import_jsx_runtime.jsx)("span", { className: "uib-picker-label", children: selected ? selected.label : "Pick a fixture" }), (0, import_jsx_runtime.jsx)("span", { className: "uib-tri" })] }), open ? (0, import_jsx_runtime.jsxs)("div", { className: "uib-popover", children: [(0, import_jsx_runtime.jsx)("input", { className: "uib-search", autoFocus: true, value: query, placeholder: "Search fixtures", "aria-label": "Search fixtures", "data-testid": "fixture-search", onChange: (event) => {
81
+ setQuery(event.target.value);
82
+ setActive(0);
83
+ }, onKeyDown: onSearchKey }), (0, import_jsx_runtime.jsxs)("div", { className: "uib-list", role: "listbox", "aria-label": "Fixtures", children: [rows.map((row) => row.kind === "group" ? (0, import_jsx_runtime.jsx)("div", { className: "uib-group", children: row.file }, `group:${row.file}`) : (0, import_jsx_runtime.jsx)("button", { type: "button", role: "option", className: "uib-option", "aria-selected": row.fixture.id === selected?.id, "data-active": matches[active]?.id === row.fixture.id, "data-nested": row.nested, "data-fixture": row.fixture.id, ref: matches[active]?.id === row.fixture.id ? scrollIntoView : void 0, onMouseEnter: () => setActive(matches.indexOf(row.fixture)), onClick: () => choose(row.fixture), children: row.text }, row.fixture.id)), matches.length === 0 ? (0, import_jsx_runtime.jsx)("div", { className: "uib-none", children: "No fixtures match." }) : null] })] }) : null] });
84
+ }
85
+ function toRows(fixtures) {
86
+ const rows = [];
87
+ for (const [file, items] of (0, import_fixtures.groupByFile)(fixtures)) {
88
+ const [only] = items;
89
+ if (items.length === 1 && only && only.name === "default") {
90
+ rows.push({ kind: "option", fixture: only, text: file, nested: false });
91
+ continue;
92
+ }
93
+ rows.push({ kind: "group", file });
94
+ for (const fixture of items)
95
+ rows.push({ kind: "option", fixture, text: fixture.name, nested: true });
96
+ }
97
+ return rows;
98
+ }
99
+ function scrollIntoView(element) {
100
+ element?.scrollIntoView?.({ block: "nearest" });
101
+ }
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ FixturePicker
105
+ });
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Frame_exports = {};
20
+ __export(Frame_exports, {
21
+ Frame: () => Frame
22
+ });
23
+ module.exports = __toCommonJS(Frame_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_react = require("react");
26
+ const FALLBACK = { width: 640, height: 480 };
27
+ const SMALLEST = { width: 240, height: 160 };
28
+ const PADDING = 24;
29
+ const HANDLE = 12;
30
+ const BORDER = 1;
31
+ function Frame({ name, size, fragment, frame, onResize }) {
32
+ const address = `${location.pathname}${location.search}#${fragment}`;
33
+ const [initial] = (0, import_react.useState)(address);
34
+ const shown = (0, import_react.useRef)(address);
35
+ const area = (0, import_react.useRef)(null);
36
+ const drag = (0, import_react.useRef)(null);
37
+ const [fitted, setFitted] = (0, import_react.useState)(null);
38
+ const [dragged, setDragged] = (0, import_react.useState)(null);
39
+ const [dragging, setDragging] = (0, import_react.useState)(null);
40
+ const readout = (0, import_react.useRef)(null);
41
+ const readoutTimer = (0, import_react.useRef)(void 0);
42
+ const [readoutAt, setReadoutAt] = (0, import_react.useState)(null);
43
+ const [reading, setReading] = (0, import_react.useState)(false);
44
+ (0, import_react.useEffect)(() => () => clearTimeout(readoutTimer.current), []);
45
+ function showReadout(x, y) {
46
+ clearTimeout(readoutTimer.current);
47
+ const gap = 14;
48
+ const width = readout.current?.offsetWidth ?? 0;
49
+ const height = readout.current?.offsetHeight ?? 0;
50
+ setReadoutAt({
51
+ left: x + gap + width > window.innerWidth ? x - gap - width : x + gap,
52
+ top: y + gap + height > window.innerHeight ? y - gap - height : y + gap
53
+ });
54
+ setReading(true);
55
+ }
56
+ function fadeReadout(after) {
57
+ clearTimeout(readoutTimer.current);
58
+ readoutTimer.current = setTimeout(() => setReading(false), after);
59
+ }
60
+ (0, import_react.useEffect)(() => {
61
+ if (shown.current === address)
62
+ return;
63
+ shown.current = address;
64
+ frame.current?.contentWindow?.location.replace(address);
65
+ }, [address, frame]);
66
+ const unsized = !!onResize && !size;
67
+ (0, import_react.useLayoutEffect)(() => {
68
+ const scroller = area.current?.parentElement;
69
+ const inner2 = frame.current;
70
+ if (!unsized || !scroller || !inner2)
71
+ return;
72
+ const top = inner2.getBoundingClientRect().top - scroller.getBoundingClientRect().top;
73
+ const width = scroller.clientWidth - 2 * (PADDING + HANDLE + BORDER);
74
+ const height = scroller.clientHeight - top - PADDING - HANDLE - 2 * BORDER;
75
+ if (width > 0 && height > 0)
76
+ setFitted(clamp({ width, height }));
77
+ }, [unsized, frame]);
78
+ (0, import_react.useEffect)(() => setDragged(null), [size?.width, size?.height]);
79
+ const current = dragged ?? size ?? fitted ?? FALLBACK;
80
+ function startDrag(axis) {
81
+ return (event) => {
82
+ const inner2 = frame.current;
83
+ if (!inner2)
84
+ return;
85
+ event.preventDefault();
86
+ event.currentTarget.setPointerCapture?.(event.pointerId);
87
+ const rect = inner2.getBoundingClientRect();
88
+ drag.current = { axis, offsetX: event.clientX - rect.right, offsetY: event.clientY - rect.bottom };
89
+ setDragging(axis);
90
+ showReadout(event.clientX, event.clientY);
91
+ };
92
+ }
93
+ function moveDrag(event) {
94
+ const active = drag.current;
95
+ const scroller = area.current?.parentElement;
96
+ const inner2 = frame.current;
97
+ if (!active || !scroller || !inner2)
98
+ return;
99
+ let { width, height } = current;
100
+ if (active.axis !== "y") {
101
+ const edge = event.clientX - active.offsetX;
102
+ const left = scroller.getBoundingClientRect().left;
103
+ const room = scroller.clientWidth - 2 * (PADDING + HANDLE);
104
+ const centred = 2 * (edge - left - scroller.clientWidth / 2);
105
+ const outer = centred <= room ? centred : edge - left - PADDING - HANDLE + scroller.scrollLeft;
106
+ width = outer - 2 * BORDER;
107
+ }
108
+ if (active.axis !== "x") {
109
+ height = event.clientY - active.offsetY - inner2.getBoundingClientRect().top - 2 * BORDER;
110
+ }
111
+ setDragged(clamp({ width, height }));
112
+ showReadout(event.clientX, event.clientY);
113
+ }
114
+ function endDrag() {
115
+ if (!drag.current)
116
+ return;
117
+ drag.current = null;
118
+ setDragging(null);
119
+ fadeReadout(600);
120
+ if (dragged)
121
+ onResize?.(dragged);
122
+ }
123
+ function nudge(axis) {
124
+ return (event) => {
125
+ const step = event.shiftKey ? 1 : 10;
126
+ const change = axis === "x" ? { ArrowLeft: -step, ArrowRight: step }[event.key] : { ArrowUp: -step, ArrowDown: step }[event.key];
127
+ if (!change)
128
+ return;
129
+ event.preventDefault();
130
+ const rect = event.currentTarget.getBoundingClientRect();
131
+ showReadout(Math.min(Math.max(rect.left + rect.width / 2, 0), window.innerWidth), Math.min(Math.max(rect.top + rect.height / 2, 0), window.innerHeight));
132
+ fadeReadout(1e3);
133
+ onResize?.(clamp(axis === "x" ? { width: current.width + change, height: current.height } : { width: current.width, height: current.height + change }));
134
+ };
135
+ }
136
+ const inner = (0, import_jsx_runtime.jsx)("iframe", { ref: frame, className: "uib-frame", title: "Fixture preview", "data-testid": "viewport-frame", src: initial, style: { width: current.width, height: current.height } });
137
+ const handle = { onPointerMove: moveDrag, onPointerUp: endDrag, onPointerCancel: endDrag };
138
+ return (0, import_jsx_runtime.jsxs)("div", { className: "uib-frame-area", ref: area, children: [(0, import_jsx_runtime.jsx)("span", { className: "uib-frame-label", "data-testid": "viewport-size", children: onResize ? (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [name, (0, import_jsx_runtime.jsx)(SizeInput, { label: "Viewport width", testId: "viewport-width", value: current.width, onCommit: (width) => onResize(clamp({ width, height: current.height })) }), "\xD7", (0, import_jsx_runtime.jsx)(SizeInput, { label: "Viewport height", testId: "viewport-height", value: current.height, onCommit: (height) => onResize(clamp({ width: current.width, height })) })] }) : `${name} ${current.width}\xD7${current.height}` }), onResize ? (0, import_jsx_runtime.jsxs)("div", { className: "uib-resizer", "data-dragging": dragging ? true : void 0, children: [inner, (0, import_jsx_runtime.jsx)("div", { className: "uib-handle uib-handle-x", role: "separator", "aria-orientation": "vertical", "aria-label": "Resize width", "aria-valuenow": current.width, tabIndex: 0, "data-testid": "resize-width", "data-active": dragging === "x" ? true : void 0, onPointerDown: startDrag("x"), onKeyDown: nudge("x"), ...handle }), (0, import_jsx_runtime.jsx)("div", { className: "uib-handle uib-handle-y", role: "separator", "aria-orientation": "horizontal", "aria-label": "Resize height", "aria-valuenow": current.height, tabIndex: 0, "data-testid": "resize-height", "data-active": dragging === "y" ? true : void 0, onPointerDown: startDrag("y"), onKeyDown: nudge("y"), ...handle }), (0, import_jsx_runtime.jsx)("div", { className: "uib-handle uib-handle-xy", "data-testid": "resize-both", "data-active": dragging === "xy" ? true : void 0, onPointerDown: startDrag("xy"), ...handle }), (0, import_jsx_runtime.jsxs)("span", { ref: readout, className: "uib-readout", "data-testid": "viewport-readout", "data-shown": reading ? true : void 0, style: readoutAt ?? void 0, children: [current.width, "\xD7", current.height] })] }) : inner] });
139
+ }
140
+ function SizeInput({ label, testId, value, onCommit }) {
141
+ const [draft, setDraft] = (0, import_react.useState)(null);
142
+ function commit() {
143
+ if (draft === null)
144
+ return;
145
+ setDraft(null);
146
+ if (draft !== "" && Number(draft) !== value)
147
+ onCommit(Number(draft));
148
+ }
149
+ return (0, import_jsx_runtime.jsx)("input", { className: "uib-size", type: "text", inputMode: "numeric", "aria-label": label, "data-testid": testId, value: draft ?? String(value), onFocus: (event) => event.currentTarget.select(), onChange: (event) => setDraft(event.target.value.replace(/\D/g, "")), onBlur: commit, onKeyDown: (event) => {
150
+ if (event.key === "Enter")
151
+ commit();
152
+ else if (event.key === "Escape")
153
+ setDraft(null);
154
+ else if (event.key === "ArrowUp" || event.key === "ArrowDown") {
155
+ event.preventDefault();
156
+ const step = (event.shiftKey ? 10 : 1) * (event.key === "ArrowUp" ? 1 : -1);
157
+ setDraft(null);
158
+ onCommit((draft ? Number(draft) : value) + step);
159
+ }
160
+ } });
161
+ }
162
+ function clamp(size) {
163
+ return {
164
+ width: Math.max(SMALLEST.width, Math.round(size.width)),
165
+ height: Math.max(SMALLEST.height, Math.round(size.height))
166
+ };
167
+ }
168
+ // Annotate the CommonJS export names for ESM import in node:
169
+ 0 && (module.exports = {
170
+ Frame
171
+ });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var InputsPanel_exports = {};
20
+ __export(InputsPanel_exports, {
21
+ InputsPanel: () => InputsPanel
22
+ });
23
+ module.exports = __toCommonJS(InputsPanel_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_react = require("react");
26
+ var import_inputs = require("../core/inputs");
27
+ function InputsPanel({ values, changed, onChange, onReset }) {
28
+ const canonical = JSON.stringify(values);
29
+ const [text, setText] = (0, import_react.useState)(() => (0, import_inputs.formatRawInputs)(values));
30
+ const parsed = (0, import_inputs.parseRawInputs)(text);
31
+ (0, import_react.useEffect)(() => {
32
+ setText((current) => {
33
+ const typed = (0, import_inputs.parseRawInputs)(current);
34
+ return typed.ok && JSON.stringify(typed.values) === canonical ? current : (0, import_inputs.formatRawInputs)(JSON.parse(canonical));
35
+ });
36
+ }, [canonical]);
37
+ return (0, import_jsx_runtime.jsxs)("div", { className: "uib-panel", "data-testid": "inputs-panel", children: [(0, import_jsx_runtime.jsxs)("div", { className: "uib-panel-head", children: [(0, import_jsx_runtime.jsx)("span", { className: "uib-panel-title", children: "inputs" }), (0, import_jsx_runtime.jsx)("span", { className: "uib-spacer" }), parsed.ok ? null : (0, import_jsx_runtime.jsx)("span", { className: "uib-panel-error", role: "alert", "data-testid": "inputs-error", children: parsed.message }), (0, import_jsx_runtime.jsx)("button", { type: "button", className: "uib-box", disabled: !changed, onClick: onReset, "data-testid": "inputs-reset", children: "reset" })] }), (0, import_jsx_runtime.jsx)("textarea", { className: "uib-raw", value: text, spellCheck: false, autoCapitalize: "off", autoCorrect: "off", "aria-label": "Fixture inputs as JSON", "aria-invalid": !parsed.ok, "data-testid": "inputs-raw", onChange: (event) => {
38
+ setText(event.target.value);
39
+ const next = (0, import_inputs.parseRawInputs)(event.target.value);
40
+ if (next.ok)
41
+ onChange(next.values);
42
+ } })] });
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ InputsPanel
47
+ });
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Landing_exports = {};
20
+ __export(Landing_exports, {
21
+ Landing: () => Landing
22
+ });
23
+ module.exports = __toCommonJS(Landing_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_fixtures = require("../core/fixtures");
26
+ function Landing({ fixtures, missing, onSelect }) {
27
+ return (0, import_jsx_runtime.jsxs)("div", { className: "uib-landing", "data-testid": "landing", children: [(0, import_jsx_runtime.jsx)("h1", { children: "UI bench" }), missing ? (0, import_jsx_runtime.jsxs)("p", { role: "alert", children: ["No fixture is called ", (0, import_jsx_runtime.jsx)("code", { children: missing }), "."] }) : fixtures.length === 0 ? (0, import_jsx_runtime.jsxs)("p", { children: ["No fixtures yet. Add a ", (0, import_jsx_runtime.jsx)("code", { children: "Name.fixture.tsx" }), " beside a component, with the component (or an object of named variants) as its default export."] }) : (0, import_jsx_runtime.jsxs)("p", { children: [fixtures.length, " ", fixtures.length === 1 ? "fixture" : "fixtures", ". Pick one to render it on its own."] }), (0, import_fixtures.groupByFile)(fixtures).map(([file, items]) => (0, import_jsx_runtime.jsxs)("div", { children: [(0, import_jsx_runtime.jsx)("h2", { children: file }), items.map((fixture) => (0, import_jsx_runtime.jsx)("button", { type: "button", className: "uib-link", "data-fixture": fixture.id, onClick: () => onSelect(fixture.id), children: fixture.name }, fixture.id))] }, file))] });
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ Landing
32
+ });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var hashUrl_exports = {};
20
+ __export(hashUrl_exports, {
21
+ hashUrl: () => hashUrl
22
+ });
23
+ module.exports = __toCommonJS(hashUrl_exports);
24
+ const hashUrl = {
25
+ read: () => location.hash,
26
+ write: (fragment) => history.replaceState(history.state, "", `${location.pathname}${location.search}${fragment ? `#${fragment}` : ""}`),
27
+ subscribe: (listener) => {
28
+ window.addEventListener("hashchange", listener);
29
+ return () => window.removeEventListener("hashchange", listener);
30
+ }
31
+ };
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ hashUrl
35
+ });
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var styles_exports = {};
20
+ __export(styles_exports, {
21
+ CSS: () => CSS
22
+ });
23
+ module.exports = __toCommonJS(styles_exports);
24
+ const CSS = `
25
+ .uib-root, .uib-bare {
26
+ --uib-bar: #050505;
27
+ --uib-bar-fg: #f4f4f4;
28
+ --uib-bar-dim: #a8a8a8;
29
+ --uib-bar-line: #3d3d3d;
30
+ --uib-surround: color-mix(in srgb, var(--uib-bar) 90%, #fff);
31
+ --uib-accent: #ff8844;
32
+ --uib-stage: #ffffff;
33
+ --uib-stage-fg: #16181d;
34
+ --uib-stage-dim: #6b7280;
35
+ --uib-stage-line: #d8dbe2;
36
+ --uib-danger: #c62828;
37
+ position: fixed;
38
+ inset: 0;
39
+ font: 12px/16px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
40
+ background: var(--uib-stage);
41
+ color: var(--uib-stage-fg);
42
+ color-scheme: light;
43
+ }
44
+ .uib-root[data-mode="dark"], .uib-bare[data-mode="dark"] {
45
+ --uib-stage: #101216;
46
+ --uib-stage-fg: #eceef2;
47
+ --uib-stage-dim: #8b93a3;
48
+ --uib-stage-line: #2b303b;
49
+ --uib-danger: #ff8a80;
50
+ color-scheme: dark;
51
+ }
52
+ .uib-root { display: flex; flex-direction: column; }
53
+ .uib-bare { overflow: auto; }
54
+ .uib-root *, .uib-root *::before, .uib-root *::after { box-sizing: border-box; }
55
+ .uib-bar {
56
+ flex: none;
57
+ display: flex;
58
+ align-items: center;
59
+ gap: 8px;
60
+ min-height: 32px;
61
+ padding: 4px 8px;
62
+ background: var(--uib-bar);
63
+ color: var(--uib-bar-fg);
64
+ position: relative;
65
+ z-index: 2;
66
+ }
67
+ .uib-mark { color: var(--uib-accent); font-weight: 700; white-space: nowrap; }
68
+ @media (max-width: 560px) { .uib-mark-rest { display: none; } }
69
+ .uib-spacer { flex: 1; }
70
+ .uib-box {
71
+ appearance: none;
72
+ display: inline-flex;
73
+ align-items: center;
74
+ gap: 6px;
75
+ height: 22px;
76
+ margin: 0;
77
+ padding: 0 8px;
78
+ border: 1px solid var(--uib-bar-line);
79
+ border-radius: 0;
80
+ background: transparent;
81
+ color: inherit;
82
+ font: inherit;
83
+ cursor: pointer;
84
+ white-space: nowrap;
85
+ }
86
+ .uib-box:hover, .uib-box:focus-visible { border-color: var(--uib-accent); outline: none; }
87
+ .uib-box:disabled { opacity: 0.4; cursor: default; border-color: var(--uib-bar-line); }
88
+ .uib-box[aria-pressed="true"] { border-color: var(--uib-accent); color: var(--uib-accent); }
89
+ .uib-box-accent { border-color: var(--uib-accent); color: var(--uib-accent); }
90
+ .uib-box option { color: initial; }
91
+ .uib-tri { flex: none; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
92
+ .uib-root[data-edge="bottom"] .uib-tri { border-bottom: 5px solid currentColor; }
93
+ .uib-root[data-edge="top"] .uib-tri { border-top: 5px solid currentColor; }
94
+ .uib-select { position: relative; display: inline-flex; }
95
+ .uib-select > .uib-box { padding-right: 22px; }
96
+ .uib-select > .uib-tri { position: absolute; right: 8px; top: 50%; margin-top: -2.5px; pointer-events: none; }
97
+ .uib-picker { position: relative; min-width: 0; }
98
+ .uib-picker > .uib-box { max-width: 50vw; }
99
+ .uib-picker-label { overflow: hidden; text-overflow: ellipsis; }
100
+ .uib-popover {
101
+ position: absolute;
102
+ left: 0;
103
+ width: min(360px, 90vw);
104
+ max-height: min(60vh, 480px);
105
+ display: flex;
106
+ flex-direction: column;
107
+ background: var(--uib-bar);
108
+ border: 1px solid var(--uib-bar-line);
109
+ }
110
+ .uib-root[data-edge="bottom"] .uib-popover { bottom: 28px; }
111
+ .uib-root[data-edge="top"] .uib-popover { top: 28px; }
112
+ .uib-search {
113
+ flex: none;
114
+ margin: 0;
115
+ padding: 8px;
116
+ border: 0;
117
+ border-bottom: 1px solid var(--uib-bar-line);
118
+ border-radius: 0;
119
+ background: transparent;
120
+ color: inherit;
121
+ font: inherit;
122
+ outline: none;
123
+ }
124
+ .uib-search::placeholder { color: var(--uib-bar-dim); }
125
+ .uib-list { overflow: auto; padding: 4px 0; }
126
+ .uib-group { padding: 6px 8px 2px; color: var(--uib-bar-dim); }
127
+ .uib-option {
128
+ appearance: none;
129
+ display: block;
130
+ width: 100%;
131
+ margin: 0;
132
+ padding: 4px 8px;
133
+ border: 0;
134
+ border-radius: 0;
135
+ background: transparent;
136
+ color: inherit;
137
+ font: inherit;
138
+ text-align: left;
139
+ cursor: pointer;
140
+ }
141
+ .uib-option[data-nested="true"] { padding-left: 20px; }
142
+ .uib-option[data-active="true"] { background: var(--uib-bar-line); }
143
+ .uib-option[aria-selected="true"] { color: var(--uib-accent); }
144
+ .uib-none { padding: 8px; color: var(--uib-bar-dim); }
145
+ .uib-panel {
146
+ flex: none;
147
+ display: flex;
148
+ flex-direction: column;
149
+ gap: 6px;
150
+ padding: 8px;
151
+ background: var(--uib-bar);
152
+ color: var(--uib-bar-fg);
153
+ border-top: 1px solid var(--uib-bar-line);
154
+ border-bottom: 1px solid var(--uib-bar-line);
155
+ }
156
+ .uib-panel-head { display: flex; align-items: center; gap: 8px; }
157
+ .uib-panel-title { color: var(--uib-bar-dim); }
158
+ .uib-raw {
159
+ width: 100%;
160
+ min-height: 96px;
161
+ max-height: 40vh;
162
+ margin: 0;
163
+ padding: 8px;
164
+ border: 1px solid var(--uib-bar-line);
165
+ border-radius: 0;
166
+ background: transparent;
167
+ color: inherit;
168
+ font: inherit;
169
+ resize: vertical;
170
+ outline: none;
171
+ }
172
+ .uib-raw:focus { border-color: var(--uib-accent); }
173
+ .uib-raw[aria-invalid="true"] { border-color: var(--uib-danger); }
174
+ .uib-panel-error { color: #ff8a80; }
175
+ .uib-area { flex: 1; min-height: 0; overflow: auto; position: relative; }
176
+ .uib-area[data-framed="true"] { background: var(--uib-surround); }
177
+ .uib-stage-padded { padding: 24px; }
178
+ .uib-stage-full { display: flex; flex-direction: column; min-height: 100%; }
179
+ .uib-error { color: var(--uib-danger); white-space: pre-wrap; margin: 0; font: inherit; }
180
+ .uib-dim { color: var(--uib-stage-dim); }
181
+ .uib-frame-area {
182
+ min-width: min-content;
183
+ min-height: 100%;
184
+ display: flex;
185
+ flex-direction: column;
186
+ align-items: center;
187
+ gap: 8px;
188
+ padding: 16px 24px 24px;
189
+ }
190
+ .uib-frame-label { display: flex; align-items: center; gap: 6px; min-height: 20px; color: var(--uib-bar-dim); }
191
+ .uib-size {
192
+ width: 6ch;
193
+ height: 20px;
194
+ margin: 0;
195
+ padding: 0 4px;
196
+ border: 1px solid var(--uib-bar-line);
197
+ border-radius: 0;
198
+ background: transparent;
199
+ color: var(--uib-bar-fg);
200
+ font: inherit;
201
+ text-align: center;
202
+ outline: none;
203
+ }
204
+ .uib-size:hover, .uib-size:focus { border-color: var(--uib-accent); }
205
+ .uib-frame { flex: none; box-sizing: content-box; border: 1px solid var(--uib-bar-line); background: var(--uib-stage); }
206
+ .uib-resizer {
207
+ flex: none;
208
+ display: grid;
209
+ grid-template-columns: auto 12px;
210
+ grid-template-rows: auto 12px;
211
+ margin-left: 12px;
212
+ }
213
+ .uib-resizer[data-dragging] .uib-frame { pointer-events: none; }
214
+ .uib-handle { position: relative; background: var(--uib-bar-line); touch-action: none; outline: none; }
215
+ .uib-handle:hover, .uib-handle:focus-visible, .uib-handle[data-active] { background: var(--uib-accent); }
216
+ .uib-handle::after { content: ""; position: absolute; inset: 0; margin: auto; background: var(--uib-bar); }
217
+ .uib-handle-x { cursor: ew-resize; }
218
+ .uib-handle-x::after { width: 2px; height: 32px; }
219
+ .uib-handle-y { cursor: ns-resize; }
220
+ .uib-handle-y::after { width: 32px; height: 2px; }
221
+ .uib-handle-xy { cursor: nwse-resize; }
222
+ .uib-handle-xy::after { width: 4px; height: 4px; }
223
+ .uib-readout {
224
+ position: fixed;
225
+ z-index: 3;
226
+ padding: 2px 6px;
227
+ background: var(--uib-bar);
228
+ color: var(--uib-bar-fg);
229
+ border: 1px solid var(--uib-accent);
230
+ white-space: nowrap;
231
+ pointer-events: none;
232
+ opacity: 0;
233
+ transition: opacity 0.25s;
234
+ }
235
+ .uib-readout[data-shown] { opacity: 1; transition-duration: 0.08s; }
236
+ .uib-landing { max-width: 560px; margin: 0 auto; padding: 48px 24px; }
237
+ .uib-landing h1 { margin: 0 0 4px; font: inherit; font-weight: 700; }
238
+ .uib-landing p { margin: 0 0 24px; color: var(--uib-stage-dim); }
239
+ .uib-landing h2 { margin: 16px 0 4px; font: inherit; color: var(--uib-stage-dim); }
240
+ .uib-landing code { font: inherit; color: var(--uib-stage-fg); }
241
+ .uib-link {
242
+ appearance: none;
243
+ display: block;
244
+ margin: 0;
245
+ padding: 3px 0;
246
+ border: 0;
247
+ background: transparent;
248
+ color: inherit;
249
+ font: inherit;
250
+ text-align: left;
251
+ cursor: pointer;
252
+ }
253
+ .uib-link:hover, .uib-link:focus-visible { text-decoration: underline; outline: none; }
254
+ .uib-restore { position: absolute; right: 0; z-index: 2; background: var(--uib-bar); color: var(--uib-bar-fg); padding: 4px; display: flex; align-items: center; }
255
+ .uib-root[data-edge="bottom"] .uib-restore { bottom: 24px; }
256
+ .uib-root[data-edge="top"] .uib-restore { top: 24px; }
257
+ `;
258
+ // Annotate the CommonJS export names for ESM import in node:
259
+ 0 && (module.exports = {
260
+ CSS
261
+ });