@weasel-js/forge 1.11.0 → 1.11.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/README.md +2 -1
- package/dist/{FrameController-BRhShqut.d.ts → FrameController-Cj_i-Rdk.d.ts} +18 -10
- package/dist/{chunk-R5F44ECM.js → chunk-BKPDKUDN.js} +13 -12
- package/dist/chunk-BKPDKUDN.js.map +1 -0
- package/dist/{chunk-J3GYSNCK.js → chunk-FZNABWJC.js} +12 -15
- package/dist/chunk-FZNABWJC.js.map +1 -0
- package/dist/{chunk-2OJAV522.js → chunk-GH5RE5X5.js} +2 -2
- package/dist/chunk-GH5RE5X5.js.map +1 -0
- package/dist/{chunk-NVNTQ4AT.js → chunk-JTCUIJPZ.js} +87 -5
- package/dist/chunk-JTCUIJPZ.js.map +1 -0
- package/dist/{chunk-SQ4KCIEH.js → chunk-KEQBGDUZ.js} +3 -3
- package/dist/{chunk-SQ4KCIEH.js.map → chunk-KEQBGDUZ.js.map} +1 -1
- package/dist/{chunk-DPTECNYC.js → chunk-LTTEILXY.js} +3 -3
- package/dist/{chunk-DPTECNYC.js.map → chunk-LTTEILXY.js.map} +1 -1
- package/dist/{config-BwScQukB.d.ts → config-DN6IaNf6.d.ts} +3 -3
- package/dist/csf/preview-api.js +2 -2
- package/dist/frame/index.css +1 -0
- package/dist/frame/index.css.map +1 -1
- package/dist/frame/index.d.ts +2 -2
- package/dist/frame/index.js +10 -11
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/shell/index.css +15 -6
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +5 -13
- package/dist/shell/index.js +104 -32
- package/dist/shell/index.js.map +1 -1
- package/dist/test/index.d.ts +2 -4
- package/dist/test/index.js +9 -11
- package/dist/test/index.js.map +1 -1
- package/dist/vite/index.js +14 -5
- package/dist/vite/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-2OJAV522.js.map +0 -1
- package/dist/chunk-J3GYSNCK.js.map +0 -1
- package/dist/chunk-NVNTQ4AT.js.map +0 -1
- package/dist/chunk-R5F44ECM.js.map +0 -1
package/dist/shell/index.js
CHANGED
|
@@ -1,38 +1,55 @@
|
|
|
1
|
-
import { parseRoute, formatRoute, paramsToKnobs, knobPaths, sameKnob, knobsToParams, PLAYHEAD_PARAM, reservedParams } from '../chunk-
|
|
1
|
+
import { parseRoute, formatRoute, paramsToKnobs, knobPaths, sameKnob, knobsToParams, PLAYHEAD_PARAM, reservedParams } from '../chunk-LTTEILXY.js';
|
|
2
2
|
import { DEFAULT_TITLE } from '../chunk-5DXUNLV2.js';
|
|
3
|
-
import { TITLE_LIBRARIES, isIndexId, indexId, indexEntries, librariesFrom, LibrariesContext, createKitRoot, schemaFromDescription, LibraryBadge, openChannel, IndexPage } from '../chunk-
|
|
3
|
+
import { TITLE_LIBRARIES, isIndexId, indexId, indexEntries, librariesFrom, LibrariesContext, createKitRoot, schemaFromDescription, LibraryBadge, openChannel, IndexPage } from '../chunk-BKPDKUDN.js';
|
|
4
4
|
import { isGallery } from '../chunk-WEQSLPKT.js';
|
|
5
|
-
import { useTrialFrame, createTrialFrames, createTrialClocks, StoryGlobalsContext, TrialFramesContext, TrialClocksContext, StoryTrial, useCssOverrides, useTrialClock, TrialHost } from '../chunk-
|
|
6
|
-
export { StoryGlobalsContext, StoryTrial, TrialFramesContext, TrialHost, useTrialFrame } from '../chunk-
|
|
5
|
+
import { useTrialFrame, createTrialFrames, createTrialClocks, StoryGlobalsContext, TrialFramesContext, TrialClocksContext, StoryTrial, useCssOverrides, useTrialClock, TrialHost } from '../chunk-FZNABWJC.js';
|
|
6
|
+
export { StoryGlobalsContext, StoryTrial, TrialFramesContext, TrialHost, useTrialFrame } from '../chunk-FZNABWJC.js';
|
|
7
7
|
import { labGlobals, withGlobals, followApp, storyConfig, GLOBALS_KEY, effectiveGlobals, PLAYHEAD_KEY, labOptions, isGlobalsPath } from '../chunk-7BQPHMA2.js';
|
|
8
|
-
import { loadStories, indexRenderOf, useNearViewport, IN_VIEW_MARGIN } from '../chunk-
|
|
8
|
+
import { loadStories, indexRenderOf, useNearViewport, IN_VIEW_MARGIN } from '../chunk-JTCUIJPZ.js';
|
|
9
9
|
import '../chunk-L5XM5VKB.js';
|
|
10
10
|
import '../chunk-ZAWXMUGZ.js';
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import { stableStringify, PORT_HANDOFF, FRAME_HELLO, PROTOCOL_VERSION } from '../chunk-
|
|
11
|
+
import '../chunk-KEQBGDUZ.js';
|
|
12
|
+
import { stableStringify, PORT_HANDOFF, FRAME_HELLO, PROTOCOL_VERSION } from '../chunk-GH5RE5X5.js';
|
|
13
13
|
import { useTrialId, Button, Lab, useLabContext, TrialIdContext, usePersistedState, Select, useTrialState, ToggleBar as ToggleBar$1, Input, TokenPanel, inferTokenType, refitScale } from '@weasel-js/labkit';
|
|
14
14
|
import num from '@weasel-js/theme/numeric.module.css';
|
|
15
15
|
import { createContext, useState, useRef, useCallback, useEffect, useMemo, useLayoutEffect, useId, useContext, Fragment as Fragment$1, useSyncExternalStore } from 'react';
|
|
16
16
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
17
17
|
import { createEmitter } from '@weasel-js/registry';
|
|
18
18
|
import { f, valueAtPath, isConfigBranch } from '@weasel-js/labkit/config';
|
|
19
|
-
import {
|
|
19
|
+
import { Slider } from '@weasel-js/ui/components/Slider';
|
|
20
|
+
import { Transport } from '@weasel-js/ui/components/Timeline';
|
|
20
21
|
import { TOKEN_MANIFEST, themeAxes, weaselTheme, THEME_SOURCES, resolveTheme, isColorModePreference, isByAxis } from '@weasel-js/theme';
|
|
21
22
|
import { scale, httpThemeApi } from '@weasel-js/theme/engine';
|
|
22
23
|
import { useLatest, historyKey, createHistory, swapOp, isPlainObject } from '@weasel-js/core';
|
|
24
|
+
import { Button as Button$1 } from '@weasel-js/ui/components/Button';
|
|
25
|
+
import { Checkbox } from '@weasel-js/ui/components/Checkbox';
|
|
26
|
+
import { Icon } from '@weasel-js/ui/components/Icon';
|
|
27
|
+
import { ToggleBar } from '@weasel-js/ui/components/ToggleBar';
|
|
28
|
+
import { TOKEN_CATEGORIES } from '@weasel-js/ui/components/TokenPanel';
|
|
23
29
|
import { useResolvedColorMode } from '@weasel-js/theme/react';
|
|
30
|
+
import { formatShortcut } from '@weasel-js/ui/components/ToolPalette';
|
|
31
|
+
import { Dialog } from '@weasel-js/ui/components/Dialog';
|
|
32
|
+
import { Callout } from '@weasel-js/ui/components/Callout';
|
|
24
33
|
import { pref } from '@weasel-js/prefs';
|
|
34
|
+
import { DisclosureMark } from '@weasel-js/ui/components/Disclosure';
|
|
25
35
|
|
|
26
|
-
function
|
|
27
|
-
|
|
36
|
+
function pointAt(point, nodes) {
|
|
37
|
+
const enter = (event) => {
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
point(nodes);
|
|
40
|
+
};
|
|
41
|
+
return { onMouseOver: enter, onFocus: enter, onMouseLeave: () => point(null), onBlur: () => point(null) };
|
|
42
|
+
}
|
|
43
|
+
function Finding({ finding, point }) {
|
|
44
|
+
return /* @__PURE__ */ jsxs("li", { className: "fg-a11y__finding", ...pointAt(point, finding.nodes), children: [
|
|
28
45
|
/* @__PURE__ */ jsxs("p", { className: "fg-a11y__help", children: [
|
|
29
46
|
/* @__PURE__ */ jsx("a", { href: finding.helpUrl, target: "_blank", rel: "noreferrer", children: finding.help }),
|
|
30
47
|
finding.impact ? /* @__PURE__ */ jsx("span", { className: "fg-a11y__impact", "data-impact": finding.impact, children: finding.impact }) : null
|
|
31
48
|
] }),
|
|
32
|
-
/* @__PURE__ */ jsx("ul", { className: "fg-a11y__nodes", children: finding.nodes.map((node) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("code", { children: node.target.join(" ") }) }, `${finding.id}:${node.target.join(",")}`)) })
|
|
49
|
+
/* @__PURE__ */ jsx("ul", { className: "fg-a11y__nodes", children: finding.nodes.map((node) => /* @__PURE__ */ jsx("li", { ...pointAt(point, [node]), children: /* @__PURE__ */ jsx("code", { children: node.target.join(" ") }) }, `${finding.id}:${node.target.join(",")}`)) })
|
|
33
50
|
] });
|
|
34
51
|
}
|
|
35
|
-
function Findings({ title, findings }) {
|
|
52
|
+
function Findings({ title, findings, point }) {
|
|
36
53
|
if (findings.length === 0) return null;
|
|
37
54
|
return /* @__PURE__ */ jsxs("section", { className: "fg-a11y__group", children: [
|
|
38
55
|
/* @__PURE__ */ jsxs("h3", { className: `fg-a11y__group-title ${num.numeric}`, children: [
|
|
@@ -41,7 +58,7 @@ function Findings({ title, findings }) {
|
|
|
41
58
|
findings.length,
|
|
42
59
|
")"
|
|
43
60
|
] }),
|
|
44
|
-
/* @__PURE__ */ jsx("ul", { className: "fg-a11y__findings", children: findings.map((finding) => /* @__PURE__ */ jsx(Finding, { finding }, finding.id)) })
|
|
61
|
+
/* @__PURE__ */ jsx("ul", { className: "fg-a11y__findings", children: findings.map((finding) => /* @__PURE__ */ jsx(Finding, { finding, point }, finding.id)) })
|
|
45
62
|
] });
|
|
46
63
|
}
|
|
47
64
|
function A11yPanel() {
|
|
@@ -60,6 +77,13 @@ function A11yPanel() {
|
|
|
60
77
|
ran.current = audit;
|
|
61
78
|
start(audit);
|
|
62
79
|
}, [audit, start]);
|
|
80
|
+
const send = frame.send;
|
|
81
|
+
const [pointed, setPointed] = useState(null);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (!send || !pointed) return;
|
|
84
|
+
send({ type: "a11y.highlight", targets: pointed.map((node) => node.target) });
|
|
85
|
+
return () => send({ type: "a11y.highlight", targets: [] });
|
|
86
|
+
}, [send, pointed]);
|
|
63
87
|
const rerun = () => {
|
|
64
88
|
if (audit) start(audit);
|
|
65
89
|
};
|
|
@@ -82,8 +106,8 @@ function A11yPanel() {
|
|
|
82
106
|
outcome.report.passes,
|
|
83
107
|
" passes"
|
|
84
108
|
] }),
|
|
85
|
-
/* @__PURE__ */ jsx(Findings, { title: "Violations", findings: outcome.report.violations }),
|
|
86
|
-
/* @__PURE__ */ jsx(Findings, { title: "Needs review", findings: outcome.report.incomplete })
|
|
109
|
+
/* @__PURE__ */ jsx(Findings, { title: "Violations", findings: outcome.report.violations, point: setPointed }),
|
|
110
|
+
/* @__PURE__ */ jsx(Findings, { title: "Needs review", findings: outcome.report.incomplete, point: setPointed })
|
|
87
111
|
] }) : null
|
|
88
112
|
] });
|
|
89
113
|
}
|
|
@@ -954,6 +978,29 @@ var CSS_VARS_SECTION = {
|
|
|
954
978
|
region: "aside",
|
|
955
979
|
item: { title: "CSS Vars", actions: /* @__PURE__ */ jsx(SectionJump, {}), fill: true, body: /* @__PURE__ */ jsx(FocusedCssVars, {}) }
|
|
956
980
|
};
|
|
981
|
+
|
|
982
|
+
// src/shell/cssVars/cssVarsChrome.ts
|
|
983
|
+
var RECORD = "fg-css-vars-shown";
|
|
984
|
+
function cssVarsChrome(shown, toggle) {
|
|
985
|
+
return [
|
|
986
|
+
{
|
|
987
|
+
id: "fg-css-vars-toggle",
|
|
988
|
+
region: "header",
|
|
989
|
+
group: "story",
|
|
990
|
+
item: { icon: (
|
|
991
|
+
/* @icon */
|
|
992
|
+
"ui:typeBraces"
|
|
993
|
+
), label: "CSS Vars panel", pressed: shown, onActivate: toggle }
|
|
994
|
+
},
|
|
995
|
+
...shown ? [CSS_VARS_SECTION] : []
|
|
996
|
+
];
|
|
997
|
+
}
|
|
998
|
+
function CssVarsChrome({ onChrome }) {
|
|
999
|
+
const [shown, setShown] = usePersistedState(RECORD, false, { scope: "lab" });
|
|
1000
|
+
const chrome = useMemo(() => cssVarsChrome(shown, () => setShown((was) => !was)), [shown, setShown]);
|
|
1001
|
+
useEffect(() => onChrome(chrome), [chrome, onChrome]);
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
957
1004
|
var KEYS = { kind: "key", key: "i", mods: { mod: true } };
|
|
958
1005
|
function infoItem(open) {
|
|
959
1006
|
return {
|
|
@@ -1206,9 +1253,9 @@ function RoutePlayhead() {
|
|
|
1206
1253
|
if (!trial || route === null) return null;
|
|
1207
1254
|
return /* @__PURE__ */ jsx(PlayheadSync, { trialId: trial.id, route, appliedRef: applied }, `${trial.id} ${route}`);
|
|
1208
1255
|
}
|
|
1209
|
-
var
|
|
1256
|
+
var RECORD2 = "fg-globals";
|
|
1210
1257
|
function useLabGlobals(declarations) {
|
|
1211
|
-
const [stored, setStored] = usePersistedState(
|
|
1258
|
+
const [stored, setStored] = usePersistedState(RECORD2, null, { scope: "lab" });
|
|
1212
1259
|
const values = useMemo(() => labGlobals(declarations, stored), [declarations, stored]);
|
|
1213
1260
|
const set = useCallback(
|
|
1214
1261
|
(key, value) => setStored((prev) => ({ ...labGlobals(declarations, prev), [key]: value })),
|
|
@@ -1510,14 +1557,27 @@ function filterComponents(rows, query) {
|
|
|
1510
1557
|
}
|
|
1511
1558
|
return out;
|
|
1512
1559
|
}
|
|
1560
|
+
function parentOf(row, byPath) {
|
|
1561
|
+
const segments = row.path.split("/");
|
|
1562
|
+
for (let take = segments.length - 1; take > 0; take--) {
|
|
1563
|
+
const parent = byPath.get(segments.slice(0, take).join("/"));
|
|
1564
|
+
if (parent && parent.library === row.library) return parent;
|
|
1565
|
+
}
|
|
1566
|
+
return void 0;
|
|
1567
|
+
}
|
|
1513
1568
|
function componentNodes(rows) {
|
|
1514
1569
|
const root = [];
|
|
1515
1570
|
const folders = /* @__PURE__ */ new Map();
|
|
1571
|
+
const byPath = new Map(rows.map((row) => [row.path, row]));
|
|
1572
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
1573
|
+
const subs = /* @__PURE__ */ new Map();
|
|
1574
|
+
for (const row of rows) subs.set(row.path, []);
|
|
1516
1575
|
for (const row of rows) {
|
|
1517
|
-
const
|
|
1576
|
+
const parent = parentOf(row, byPath);
|
|
1518
1577
|
const title = row.path.split("/");
|
|
1519
|
-
|
|
1520
|
-
let
|
|
1578
|
+
const labels = parent ? title.slice(parent.path.split("/").length) : row.label.split("/");
|
|
1579
|
+
let siblings = parent ? subs.get(parent.path) : root;
|
|
1580
|
+
let tag = parent ? void 0 : row.library;
|
|
1521
1581
|
for (let i = 0; i < labels.length - 1; i++) {
|
|
1522
1582
|
const path = title.slice(0, title.length - labels.length + i + 1).join("/");
|
|
1523
1583
|
let folder = folders.get(path);
|
|
@@ -1529,14 +1589,22 @@ function componentNodes(rows) {
|
|
|
1529
1589
|
siblings = folder.children;
|
|
1530
1590
|
tag = void 0;
|
|
1531
1591
|
}
|
|
1532
|
-
|
|
1592
|
+
const node = {
|
|
1533
1593
|
kind: "folder",
|
|
1534
1594
|
label: labels[labels.length - 1],
|
|
1535
1595
|
path: row.path,
|
|
1536
1596
|
tag,
|
|
1537
1597
|
...row.index ? { index: row.index } : {},
|
|
1538
|
-
children:
|
|
1539
|
-
}
|
|
1598
|
+
children: []
|
|
1599
|
+
};
|
|
1600
|
+
nodes.set(row.path, node);
|
|
1601
|
+
siblings.push(node);
|
|
1602
|
+
}
|
|
1603
|
+
for (const row of rows) {
|
|
1604
|
+
nodes.get(row.path).children = [
|
|
1605
|
+
...subs.get(row.path),
|
|
1606
|
+
...row.entries.map((entry) => ({ kind: "story", entry }))
|
|
1607
|
+
];
|
|
1540
1608
|
}
|
|
1541
1609
|
return foldGalleries(root);
|
|
1542
1610
|
}
|
|
@@ -2391,6 +2459,12 @@ function useDocumentTitle(title) {
|
|
|
2391
2459
|
document.title = title;
|
|
2392
2460
|
}, [title]);
|
|
2393
2461
|
}
|
|
2462
|
+
function NoStories({ stories }) {
|
|
2463
|
+
return /* @__PURE__ */ jsxs("div", { className: "fg-empty", children: [
|
|
2464
|
+
/* @__PURE__ */ jsx("p", { className: "fg-empty__title", children: "No stories found" }),
|
|
2465
|
+
stories.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "fg-empty__globs", "aria-label": "Story globs", children: stories.map((glob) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("code", { children: glob }) }, glob)) }) : null
|
|
2466
|
+
] });
|
|
2467
|
+
}
|
|
2394
2468
|
function Workshop({ index, frameUrl, importers, setup, changes, config, stories = [], storageKey, storage, dependencies }) {
|
|
2395
2469
|
const declarations = config?.globals ?? NO_DECLARATIONS;
|
|
2396
2470
|
const title = config?.title ?? DEFAULT_TITLE;
|
|
@@ -2435,25 +2509,22 @@ function Workshop({ index, frameUrl, importers, setup, changes, config, stories
|
|
|
2435
2509
|
[]
|
|
2436
2510
|
);
|
|
2437
2511
|
const infoCommand = useMemo(() => infoItem(() => setInfoOpen(true)), []);
|
|
2512
|
+
const showsCssVars = config?.cssVars !== false;
|
|
2513
|
+
const [cssVarsChrome2, setCssVarsChrome] = useState([]);
|
|
2438
2514
|
const labChrome = useMemo(
|
|
2439
2515
|
() => [
|
|
2440
2516
|
{ id: "fg-stories", region: "sidebar", render: (ctx) => /* @__PURE__ */ jsx(StoryTree, { ctx, index }) },
|
|
2441
|
-
...
|
|
2517
|
+
...showsCssVars ? cssVarsChrome2 : [],
|
|
2442
2518
|
A11Y_SECTION,
|
|
2443
2519
|
...Object.keys(declarations).length > 0 ? [{ id: "fg-globals", region: "header", render: () => /* @__PURE__ */ jsx(GlobalsToolbar, { declarations }) }] : [],
|
|
2444
2520
|
{ id: "fg-info", region: "header", group: "story", item: infoCommand },
|
|
2445
2521
|
...config?.labChrome ?? []
|
|
2446
2522
|
],
|
|
2447
|
-
[index, infoCommand, declarations,
|
|
2523
|
+
[index, infoCommand, declarations, showsCssVars, cssVarsChrome2, config?.labChrome]
|
|
2448
2524
|
);
|
|
2449
2525
|
const [menus, setMenus] = useState();
|
|
2450
2526
|
const first = index[0];
|
|
2451
|
-
if (!first) {
|
|
2452
|
-
return /* @__PURE__ */ jsxs("div", { className: "fg-empty", children: [
|
|
2453
|
-
/* @__PURE__ */ jsx("p", { className: "fg-empty__title", children: "No stories found" }),
|
|
2454
|
-
stories.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "fg-empty__globs", "aria-label": "Story globs", children: stories.map((glob) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("code", { children: glob }) }, glob)) }) : null
|
|
2455
|
-
] });
|
|
2456
|
-
}
|
|
2527
|
+
if (!first) return /* @__PURE__ */ jsx(NoStories, { stories });
|
|
2457
2528
|
return /* @__PURE__ */ jsx(LibrariesContext.Provider, { value: libraries, children: /* @__PURE__ */ jsx(StoryGlobalsContext.Provider, { value: labValues, children: /* @__PURE__ */ jsx(DependenciesContext.Provider, { value: dependencies ?? null, children: /* @__PURE__ */ jsx(FramePoolContext.Provider, { value: pool, children: /* @__PURE__ */ jsx(TrialFramesContext.Provider, { value: frames, children: /* @__PURE__ */ jsx(TrialClocksContext.Provider, { value: clocks, children: /* @__PURE__ */ jsxs(
|
|
2458
2529
|
Lab,
|
|
2459
2530
|
{
|
|
@@ -2484,7 +2555,8 @@ function Workshop({ index, frameUrl, importers, setup, changes, config, stories
|
|
|
2484
2555
|
}
|
|
2485
2556
|
),
|
|
2486
2557
|
/* @__PURE__ */ jsx(LabGlobals, { declarations, onChange: reportLabValues }),
|
|
2487
|
-
/* @__PURE__ */ jsx(GlobalsMenus, { declarations, onMenus: setMenus })
|
|
2558
|
+
/* @__PURE__ */ jsx(GlobalsMenus, { declarations, onMenus: setMenus }),
|
|
2559
|
+
showsCssVars ? /* @__PURE__ */ jsx(CssVarsChrome, { onChrome: setCssVarsChrome }) : null
|
|
2488
2560
|
]
|
|
2489
2561
|
}
|
|
2490
2562
|
) }) }) }) }) }) });
|