basalt-ui 2.8.1 → 2.9.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/AGENTS.md +2 -2
- package/CHANGELOG.md +33 -0
- package/MIGRATING.md +81 -27
- package/README.md +7 -8
- package/agent/rules/basalt-controls.md +1 -1
- package/agent/rules/basalt-state.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/templates/AGENTS-block.md.tpl +2 -2
- package/configs/oxlint-plugin.js +25 -68
- package/configs/oxlint-plugin.test.ts +19 -27
- package/configs/oxlint.json +4 -0
- package/dist/charts/BandStrip.d.ts +1 -1
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +1 -10
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +2 -9
- package/dist/charts/band-fold.d.ts +15 -0
- package/dist/charts/band-fold.d.ts.map +1 -0
- package/dist/charts/band-fold.js +19 -0
- package/dist/charts/index.d.ts +1 -0
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/index.js +3 -1
- package/dist/cli/audit-allows.d.ts.map +1 -1
- package/dist/cli/audit-allows.js +1 -1
- package/dist/cli/check-theme.d.ts.map +1 -1
- package/dist/cli/check-theme.js +4 -1
- package/dist/cli/config.d.ts +14 -4
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +7 -2
- package/dist/cli/doctor-upgrade.d.ts +9 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +14 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +10 -12
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +2 -3
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +4 -2
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +6 -0
- package/dist/cli/install-root.d.ts +10 -0
- package/dist/cli/install-root.d.ts.map +1 -0
- package/dist/cli/install-root.js +32 -0
- package/dist/cli/router-wiring.d.ts +4 -2
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +2 -0
- package/dist/cli/sync.d.ts +0 -2
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +19 -15
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +1 -6
- package/dist/common/errors.d.ts +1 -6
- package/dist/common/errors.d.ts.map +1 -1
- package/dist/common/errors.js +0 -7
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +1 -9
- package/dist/common/props.d.ts +2 -2
- package/dist/common/vx-family.d.ts +1 -1
- package/dist/content/toc-click-pin.d.ts +45 -0
- package/dist/content/toc-click-pin.d.ts.map +1 -0
- package/dist/content/toc-click-pin.js +111 -0
- package/dist/content/toc-spy.d.ts +25 -0
- package/dist/content/toc-spy.d.ts.map +1 -0
- package/dist/content/toc-spy.js +43 -0
- package/dist/content/toc.d.ts +1 -4
- package/dist/content/toc.d.ts.map +1 -1
- package/dist/content/toc.js +38 -49
- package/dist/controls/number-filter.d.ts.map +1 -1
- package/dist/controls/number-filter.js +1 -1
- package/dist/dashboard/index.d.ts +1 -1
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +1 -3
- package/dist/dashboard/section.d.ts +10 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +20 -3
- package/dist/dashboard/stat-card.d.ts +2 -8
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +1 -1
- package/dist/guard/index.d.ts +13 -9
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +74 -37
- package/dist/guard/types.d.ts +8 -7
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/vx-names.d.ts +1 -1
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +1 -33
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/router-tanstack/search-store.d.ts +1 -11
- package/dist/router-tanstack/search-store.d.ts.map +1 -1
- package/dist/router-tanstack/search-store.js +1 -2
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +3 -0
- package/dist/shell/nav-types.d.ts +1 -1
- package/dist/shell/page-bar.d.ts +6 -0
- package/dist/shell/page-bar.d.ts.map +1 -1
- package/dist/shell/page-bar.js +12 -2
- package/dist/state/fields.d.ts +1 -1
- package/dist/state/fields.d.ts.map +1 -1
- package/dist/state/fields.js +3 -1
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +5 -11
- package/dist/table/data-table.d.ts +2 -2
- package/dist/tokens/core.d.ts +0 -10
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -44
- package/llms.txt +24 -8
- package/package.json +8 -5
- package/src/charts/BandStrip.tsx +4 -16
- package/src/charts/MirroredBars.tsx +2 -11
- package/src/charts/band-fold.ts +26 -0
- package/src/charts/index.ts +1 -0
- package/src/cli/audit-allows.ts +1 -3
- package/src/cli/check-theme.ts +7 -1
- package/src/cli/config.ts +21 -5
- package/src/cli/doctor-upgrade.ts +23 -1
- package/src/cli/doctor.ts +10 -17
- package/src/cli/help.ts +1 -4
- package/src/cli/index.ts +9 -6
- package/src/cli/init.ts +7 -0
- package/src/cli/install-root.ts +40 -0
- package/src/cli/router-wiring.ts +6 -2
- package/src/cli/sync.ts +28 -17
- package/src/cli/tokens-css.ts +0 -5
- package/src/common/errors.ts +1 -18
- package/src/common/index.ts +1 -8
- package/src/common/props.ts +2 -2
- package/src/common/vx-family.ts +1 -1
- package/src/content/toc-click-pin.ts +156 -0
- package/src/content/toc-spy.ts +61 -0
- package/src/content/toc.tsx +47 -95
- package/src/controls/form-layout.tsx +1 -1
- package/src/controls/number-filter.tsx +6 -1
- package/src/dashboard/index.ts +1 -6
- package/src/dashboard/section.tsx +39 -8
- package/src/dashboard/stat-card.tsx +4 -11
- package/src/guard/index.ts +114 -89
- package/src/guard/types.ts +8 -7
- package/src/guard/vx-names.ts +1 -33
- package/src/index.ts +1 -2
- package/src/router-tanstack/search-store.ts +2 -14
- package/src/shell/index.tsx +2 -0
- package/src/shell/nav-types.ts +1 -1
- package/src/shell/page-bar.tsx +21 -2
- package/src/state/fields.ts +7 -2
- package/src/surfaces.ts +5 -11
- package/src/table/data-table.tsx +2 -2
- package/src/tokens/core.ts +6 -67
- package/dist/tokens.css +0 -331
package/dist/cli/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import { guardHook } from "./guard-hook.js";
|
|
|
20
20
|
import { COMMAND_OPTIONS, USAGE, unknownFlag } from "./help.js";
|
|
21
21
|
import { init } from "./init.js";
|
|
22
22
|
import { sync } from "./sync.js";
|
|
23
|
-
import { CODE_ROUTED_NOTE, routerSeedSkip } from "./router-wiring.js";
|
|
23
|
+
import { CODE_ROUTED_NOTE, SHELL_LESS_NOTE, routerSeedSkip } from "./router-wiring.js";
|
|
24
24
|
import { hasDependency, readIfExists, readPackageJson } from "./source-text.js";
|
|
25
25
|
import { fontsCss, normalizeColorFunctions, tokensCss } from "./tokens-css.js";
|
|
26
26
|
import { DEFAULT_ROOT, exemptRulePaths, resolveRoots } from "./config.js";
|
|
@@ -348,11 +348,13 @@ function routerSeedDests(appRel) {
|
|
|
348
348
|
}
|
|
349
349
|
const START_APP_NOTE = "TanStack Start app \u2014 no main.tsx/nav.tsx/__root.tsx seeded (Start owns the router); render <BasaltProvider><Outlet /></BasaltProvider> in your root route component.";
|
|
350
350
|
function routerSeedPlan(cwd, appRel, tokensOnly = false) {
|
|
351
|
-
const
|
|
351
|
+
const detected = tokensOnly ? null : routerSeedSkip(cwd, appRel);
|
|
352
|
+
const skip = detected ?? (!tokensOnly && readBasaltConfig(cwd).shell === false ? "shell-less" : null);
|
|
352
353
|
return { skip, skipped: new Set(tokensOnly || skip !== null ? routerSeedDests(appRel) : []) };
|
|
353
354
|
}
|
|
354
355
|
function seedSkipNote(skip) {
|
|
355
356
|
if (skip === "start") return START_APP_NOTE;
|
|
357
|
+
if (skip === "shell-less") return SHELL_LESS_NOTE;
|
|
356
358
|
return skip === "code-routed" ? CODE_ROUTED_NOTE : null;
|
|
357
359
|
}
|
|
358
360
|
const appRelative = (root, dir) => relativePosix(root, dir).replace(/^\.\/?/, "");
|
package/dist/cli/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAA;AA6D7D,yGAAyG;AACzG,wBAAgB,IAAI,CAAC,GAAG,GAAE,MAAsB,EAAE,aAAa,GAAE,aAAkB,GAAG,MAAM,CAoM3F"}
|
package/dist/cli/init.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { deriveSpacing } from "../tokens/core.js";
|
|
4
|
+
import { shellConfigError } from "./config.js";
|
|
4
5
|
import {
|
|
5
6
|
MANIFEST_PATH,
|
|
6
7
|
declaredProfile,
|
|
@@ -48,6 +49,11 @@ function init(cwd = process.cwd(), scaffoldFlags = {}) {
|
|
|
48
49
|
`\u26A0 basalt-ui init: basalt-ui does not resolve from ${cwd} or any directory above it \u2014 the seeded \`extends\` paths and CI steps are being written against the repo root by assumption. Install basalt-ui here (or at the repo root) and re-run \`basalt-ui init\` so they resolve.`
|
|
49
50
|
);
|
|
50
51
|
}
|
|
52
|
+
const shellError = shellConfigError(readBasaltConfig(cwd));
|
|
53
|
+
if (shellError !== null) {
|
|
54
|
+
console.error(`\u2716 basalt-ui init: ${shellError}`);
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
51
57
|
const appError = resolvePlacement(cwd).appError;
|
|
52
58
|
if (appError !== null) {
|
|
53
59
|
console.error(`\u2716 basalt-ui init: ${appError}`);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The nearest ANCESTOR of `dir` (exclusive) carrying a basalt manifest, or null. */
|
|
2
|
+
export declare function findManifestAbove(dir: string): string | null;
|
|
3
|
+
/**
|
|
4
|
+
* The install root above `dir`, when `dir` is the APP package of that install: no manifest here,
|
|
5
|
+
* basalt-ui declared here, an ancestor manifest, `resolveAppDir(root)` naming `dir`, and the
|
|
6
|
+
* basalt-ui that resolves from `dir` the same copy (or version) the root uses. Anything else is
|
|
7
|
+
* null — a sub-package with its own basalt-ui is a competing install, not part of the root's.
|
|
8
|
+
*/
|
|
9
|
+
export declare function installRootAbove(dir: string): string | null;
|
|
10
|
+
//# sourceMappingURL=install-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-root.d.ts","sourceRoot":"","sources":["../../src/cli/install-root.ts"],"names":[],"mappings":"AAOA,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQ5D;AAOD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAU3D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { MANIFEST_PATH, findBasaltInstall, resolveAppDir } from "./index.js";
|
|
4
|
+
import { hasDependency } from "./source-text.js";
|
|
5
|
+
function findManifestAbove(dir) {
|
|
6
|
+
let current = resolve(dir, "..");
|
|
7
|
+
for (; ; ) {
|
|
8
|
+
if (existsSync(resolve(current, MANIFEST_PATH))) return current;
|
|
9
|
+
const parent = resolve(current, "..");
|
|
10
|
+
if (parent === current) return null;
|
|
11
|
+
current = parent;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function sameInstall(a, b) {
|
|
15
|
+
if (a === null || b === null) return false;
|
|
16
|
+
return a === b || realpathSync(a) === realpathSync(b);
|
|
17
|
+
}
|
|
18
|
+
function installRootAbove(dir) {
|
|
19
|
+
if (existsSync(resolve(dir, MANIFEST_PATH)) || !hasDependency(dir, "basalt-ui")) return null;
|
|
20
|
+
const root = findManifestAbove(dir);
|
|
21
|
+
if (root === null) return null;
|
|
22
|
+
const app = resolveAppDir(root);
|
|
23
|
+
if ("error" in app || app.dir !== dir) return null;
|
|
24
|
+
const here = findBasaltInstall(dir);
|
|
25
|
+
const there = findBasaltInstall(root);
|
|
26
|
+
const sameVersion = here.version !== null && here.version === there.version;
|
|
27
|
+
return sameInstall(here.dir, there.dir) || sameVersion ? root : null;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
findManifestAbove,
|
|
31
|
+
installRootAbove
|
|
32
|
+
};
|
|
@@ -26,12 +26,14 @@ export declare function isCodeRoutedApp(cwd: string, appRel: string): boolean;
|
|
|
26
26
|
/** A TanStack Start app owns its router, so its router seeds give way to an in-tree `<BasaltProvider>`. */
|
|
27
27
|
export declare function isStartApp(cwd: string, appRel: string): boolean;
|
|
28
28
|
/** Why an app's router seeds are not placed (see `routerSeedSkip`). */
|
|
29
|
-
export type RouterSeedSkip = 'start' | 'code-routed' | null;
|
|
29
|
+
export type RouterSeedSkip = 'start' | 'code-routed' | 'shell-less' | null;
|
|
30
30
|
export declare const CODE_ROUTED_NOTE = "code-routed app (createBasaltRouter, no route-tree plugin or routeTree.gen) \u2014 no main.tsx/nav.tsx/__root.tsx seeded.";
|
|
31
31
|
/**
|
|
32
32
|
* Why an app's router seeds (main/nav/__root) are not placed: `start` (Start owns the router, and
|
|
33
|
-
* wins when both apply) or `code-routed` (no generated tree to assume); null when they are.
|
|
33
|
+
* wins when both apply) or `code-routed` (no generated tree to assume); null when they are. The
|
|
34
|
+
* declared `shell: false` (`shell-less`) is applied by `routerSeedPlan`, which reads the config.
|
|
34
35
|
*/
|
|
35
36
|
export declare function routerSeedSkip(cwd: string, appRel: string): RouterSeedSkip;
|
|
37
|
+
export declare const SHELL_LESS_NOTE = "`basalt.shell: false` \u2014 no main.tsx/nav.tsx/__root.tsx seeded; the app owns its root route (or has none).";
|
|
36
38
|
export {};
|
|
37
39
|
//# sourceMappingURL=router-wiring.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-wiring.d.ts","sourceRoot":"","sources":["../../src/cli/router-wiring.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,QAAQ,EAAE,MAAM,eAAe,CAAA;AAuErE,oGAAoG;AACpG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAEzC;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAqBT;AAED,wHAAwH;AACxH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9C;AAID,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAErD;AAED,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQhE;AAED,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAEnF;AAOD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAMpE;AAED,2GAA2G;AAC3G,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,aAAa,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"router-wiring.d.ts","sourceRoot":"","sources":["../../src/cli/router-wiring.ts"],"names":[],"mappings":"AAOA,OAAO,EAA+B,QAAQ,EAAE,MAAM,eAAe,CAAA;AAuErE,oGAAoG;AACpG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAEzC;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAqBT;AAED,wHAAwH;AACxH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9C;AAID,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAErD;AAED,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQhE;AAED,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAEnF;AAOD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAMpE;AAED,2GAA2G;AAC3G,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,aAAa,GAAG,YAAY,GAAG,IAAI,CAAA;AAE1E,eAAO,MAAM,gBAAgB,8HAC2F,CAAA;AAExH;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAG1E;AAED,eAAO,MAAM,eAAe,mHACiF,CAAA"}
|
|
@@ -102,8 +102,10 @@ function routerSeedSkip(cwd, appRel) {
|
|
|
102
102
|
if (isStartApp(cwd, appRel)) return "start";
|
|
103
103
|
return isCodeRoutedApp(cwd, appRel) ? "code-routed" : null;
|
|
104
104
|
}
|
|
105
|
+
const SHELL_LESS_NOTE = "`basalt.shell: false` \u2014 no main.tsx/nav.tsx/__root.tsx seeded; the app owns its root route (or has none).";
|
|
105
106
|
export {
|
|
106
107
|
CODE_ROUTED_NOTE,
|
|
108
|
+
SHELL_LESS_NOTE,
|
|
107
109
|
appEntry,
|
|
108
110
|
callOf,
|
|
109
111
|
callsIn,
|
package/dist/cli/sync.d.ts
CHANGED
|
@@ -11,8 +11,6 @@ export type SyncOptions = {
|
|
|
11
11
|
* (a package under a configured repo); one text, so neither prescribes a second `init`.
|
|
12
12
|
*/
|
|
13
13
|
export declare function parentInstallAdvice(cwd: string, parent: string, verb: string): string;
|
|
14
|
-
/** The nearest ANCESTOR of `dir` (exclusive) carrying a basalt manifest, or null. */
|
|
15
|
-
export declare function findManifestAbove(dir: string): string | null;
|
|
16
14
|
/**
|
|
17
15
|
* Reconcile managed files with the shipped versions via a sha256 three-way compare.
|
|
18
16
|
*
|
package/dist/cli/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/cli/sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/cli/sync.ts"],"names":[],"mappings":"AA4CA,gGAAgG;AAChG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAGjE;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,mGAAmG;IACnG,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrF;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,WAAgB,EAAE,aAAa,GAAE,MAAsB,GAAG,MAAM,CAoP1F"}
|
package/dist/cli/sync.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { deriveSpacing } from "../tokens/core.js";
|
|
4
|
+
import { shellConfigError } from "./config.js";
|
|
4
5
|
import {
|
|
5
6
|
MANIFEST_PATH,
|
|
6
7
|
basaltPresetEntry,
|
|
@@ -37,6 +38,7 @@ import {
|
|
|
37
38
|
writeFileEnsuringDir,
|
|
38
39
|
writeUnit
|
|
39
40
|
} from "./index.js";
|
|
41
|
+
import { findManifestAbove, installRootAbove } from "./install-root.js";
|
|
40
42
|
function readOxlintPresetPlugins(pkgRoot) {
|
|
41
43
|
const plugins = parseJsonc(readSource(pkgRoot, OXLINT_FILES.preset) ?? "null")?.["plugins"];
|
|
42
44
|
return isStringArray(plugins) ? plugins : [];
|
|
@@ -44,27 +46,29 @@ function readOxlintPresetPlugins(pkgRoot) {
|
|
|
44
46
|
function parentInstallAdvice(cwd, parent, verb) {
|
|
45
47
|
return `This repo's install is at ${relativePosix(cwd, parent)} (${parent}) \u2014 run ${verb} there, or set BASALT_CWD to it.`;
|
|
46
48
|
}
|
|
47
|
-
function findManifestAbove(dir) {
|
|
48
|
-
let current = resolve(dir, "..");
|
|
49
|
-
for (; ; ) {
|
|
50
|
-
if (existsSync(resolve(current, MANIFEST_PATH))) return current;
|
|
51
|
-
const parent = resolve(current, "..");
|
|
52
|
-
if (parent === current) return null;
|
|
53
|
-
current = parent;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
49
|
function sync(opts = {}, invocationCwd = process.cwd()) {
|
|
57
50
|
const syncFlags = opts.flags ?? [];
|
|
58
51
|
if (conflictingProfileFlags("sync", syncFlags)) return 1;
|
|
59
52
|
const project = resolveProjectDir(invocationCwd);
|
|
60
|
-
const cwd = project.dir;
|
|
61
53
|
noteRelocation("sync", project);
|
|
54
|
+
const installAbove = project.relocatedFrom === null ? installRootAbove(project.dir) : null;
|
|
55
|
+
const cwd = installAbove ?? project.dir;
|
|
56
|
+
if (installAbove !== null) {
|
|
57
|
+
console.log(
|
|
58
|
+
`basalt-ui sync: ${project.dir} is a package of the install at ${installAbove}; syncing there.`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
62
61
|
if (declaredProfile(readBasaltConfig(cwd), syncFlags) === "tokens-only") {
|
|
63
62
|
console.log(
|
|
64
63
|
`basalt-ui sync: ${MANIFEST_PATH}: n/a \u2014 a tokens-only consumer has no scaffold to reconcile. The token layer is refreshed by re-running \`basalt-ui tokens:css\`, and \`tokens:css --check\` is its drift gate. Pass --framework to force the full profile.`
|
|
65
64
|
);
|
|
66
65
|
return 0;
|
|
67
66
|
}
|
|
67
|
+
const shellError = shellConfigError(readBasaltConfig(cwd));
|
|
68
|
+
if (shellError !== null) {
|
|
69
|
+
console.error(`\u2716 basalt-ui sync: ${shellError}`);
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
68
72
|
const appError = resolvePlacement(cwd).appError;
|
|
69
73
|
if (appError !== null) {
|
|
70
74
|
console.error(`\u2716 basalt-ui sync: ${appError}`);
|
|
@@ -132,11 +136,12 @@ function sync(opts = {}, invocationCwd = process.cwd()) {
|
|
|
132
136
|
});
|
|
133
137
|
staleForCheck += pruned.removed.length + pruned.drifted.length;
|
|
134
138
|
const isTracked = (d) => manifest.files[d] !== void 0;
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
const retiredBecause = seedSkip === "code-routed" ? "code-routed app" : seedSkip === "shell-less" ? "basalt.shell: false" : null;
|
|
140
|
+
const retiredSeeds = retiredBecause === null ? [] : [...skipped].filter(isTracked);
|
|
141
|
+
if (retiredSeeds.length > 0 && !opts.check) {
|
|
142
|
+
for (const d of retiredSeeds) delete manifest.files[d];
|
|
138
143
|
console.error(
|
|
139
|
-
`\u26A0 basalt-ui sync:
|
|
144
|
+
`\u26A0 basalt-ui sync: ${retiredBecause} \u2014 dropped ${retiredSeeds.join(", ")} from the manifest (any file is yours).`
|
|
140
145
|
);
|
|
141
146
|
}
|
|
142
147
|
const startSkippedSeeds = seedSkip === "start" ? [...skipped] : [];
|
|
@@ -217,7 +222,6 @@ function sync(opts = {}, invocationCwd = process.cwd()) {
|
|
|
217
222
|
return 0;
|
|
218
223
|
}
|
|
219
224
|
export {
|
|
220
|
-
findManifestAbove,
|
|
221
225
|
parentInstallAdvice,
|
|
222
226
|
readOxlintPresetPlugins,
|
|
223
227
|
sync
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens-css.d.ts","sourceRoot":"","sources":["../../src/cli/tokens-css.ts"],"names":[],"mappings":"AAkCA;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK3D;AA4DD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"tokens-css.d.ts","sourceRoot":"","sources":["../../src/cli/tokens-css.ts"],"names":[],"mappings":"AAkCA;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK3D;AA4DD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CAuE9E;AAgBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,CAa7E"}
|
package/dist/cli/tokens-css.js
CHANGED
|
@@ -112,12 +112,7 @@ function tokensCss(flags, cwd = process.cwd()) {
|
|
|
112
112
|
...Object.keys(scheme).length === 0 ? {} : { scheme },
|
|
113
113
|
...defaultScheme === void 0 ? {} : { defaultScheme },
|
|
114
114
|
...flags.includes("--media-fallback") ? { mediaFallback: true } : {},
|
|
115
|
-
...only === void 0 ? {} : { only }
|
|
116
|
-
// The tokens-only consumer is exactly the one who writes these names by hand, so they are also
|
|
117
|
-
// the one who wants the deprecated camelCase aliases gone — and this command is their only
|
|
118
|
-
// entry point. Without the flag the CLI and the API could disagree about what basalt's tokens
|
|
119
|
-
// are, which is the one thing this command is documented never to allow.
|
|
120
|
-
...flags.includes("--no-legacy-aliases") ? { legacyAliases: false } : {}
|
|
115
|
+
...only === void 0 ? {} : { only }
|
|
121
116
|
});
|
|
122
117
|
if (schemeClass !== void 0) {
|
|
123
118
|
css = css.replace(
|
package/dist/common/errors.d.ts
CHANGED
|
@@ -18,16 +18,11 @@ export declare const BASALT_PREFIX = "[basalt]";
|
|
|
18
18
|
export declare function requiredProp(component: string, prop: string, hint?: string): string;
|
|
19
19
|
/** A prop with a closed value set that got something outside it. */
|
|
20
20
|
export declare function oneOf(component: string, prop: string, allowed: readonly string[], got: unknown): string;
|
|
21
|
-
/**
|
|
22
|
-
* A prop still shipped and still working, with a named successor and the version it goes away in.
|
|
23
|
-
* Majors are banned here, so the deprecation notice IS the migration channel.
|
|
24
|
-
*/
|
|
25
|
-
export declare function deprecatedProp(component: string, oldProp: string, newProp: string, removeIn: string, note?: string): string;
|
|
26
21
|
/**
|
|
27
22
|
* A prop the component ACCEPTS, reads nothing from, and cannot report as wrong — because a SECOND
|
|
28
23
|
* prop it was passed alongside decides the same thing and won.
|
|
29
24
|
*
|
|
30
|
-
* Distinct from {@link
|
|
25
|
+
* Distinct from {@link oneOf} (read, and the
|
|
31
26
|
* value is out of range): this one renders something the caller did not ask for and nothing in the
|
|
32
27
|
* type system, the linter or the console says so. A 1.x chart's `height` under `fill` was the
|
|
33
28
|
* reference case — weatherorb passed both for the life of the file and never learnt that eight height
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/common/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,yDAAyD;AACzD,eAAO,MAAM,aAAa,aAAa,CAAA;AAMvC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnF;AAED,oEAAoE;AACpE,wBAAgB,KAAK,CACnB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,GAAG,EAAE,OAAO,GACX,MAAM,CAMR;AAED
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/common/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,yDAAyD;AACzD,eAAO,MAAM,aAAa,aAAa,CAAA;AAMvC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnF;AAED,oEAAoE;AACpE,wBAAgB,KAAK,CACnB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,GAAG,EAAE,OAAO,GACX,MAAM,CAMR;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMvF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAErF;AAED,kGAAkG;AAClG,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED;;kDAEkD;AAClD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK9D;AAOD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI5D;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,SAAwB,GAAG,MAAM,CAKrF"}
|
package/dist/common/errors.js
CHANGED
|
@@ -11,12 +11,6 @@ function oneOf(component, prop, allowed, got) {
|
|
|
11
11
|
`prop "${prop}" must be one of ${allowed.map((value) => `'${value}'`).join(" | ")} \u2014 got ${JSON.stringify(got)}.`
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
|
-
function deprecatedProp(component, oldProp, newProp, removeIn, note) {
|
|
15
|
-
return message(
|
|
16
|
-
component,
|
|
17
|
-
`prop "${oldProp}" is deprecated \u2014 use "${newProp}" instead. "${oldProp}" is removed in ${removeIn}.${note === void 0 ? "" : ` ${note}`}`
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
14
|
function ignoredProp(component, prop, because) {
|
|
21
15
|
return message(component, `prop "${prop}" is ignored because ${because}`);
|
|
22
16
|
}
|
|
@@ -69,7 +63,6 @@ function toErrorMessage(err, fallback = "The request failed.") {
|
|
|
69
63
|
}
|
|
70
64
|
export {
|
|
71
65
|
BASALT_PREFIX,
|
|
72
|
-
deprecatedProp,
|
|
73
66
|
duplicateMount,
|
|
74
67
|
errorStatus,
|
|
75
68
|
ignoredProp,
|
package/dist/common/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
export { type BasaltProps, type SlotClassNames, type SlotStylesProps } from './props.js';
|
|
10
10
|
export { type Tone, type ToneWithNeutral, type Tier, cx } from './props.js';
|
|
11
11
|
export { assignRef, mergeRefs } from './refs.js';
|
|
12
|
-
export { BASALT_PREFIX, requiredProp, oneOf,
|
|
12
|
+
export { BASALT_PREFIX, requiredProp, oneOf, duplicateMount, missingLayer } from './errors.js';
|
|
13
13
|
export { useValidateProps, assertRequiredProps, resetValidatedProps } from './validate.js';
|
|
14
14
|
export { scrollParentOf, SCROLLPORT_ATTRIBUTE } from './scroll-parent.js';
|
|
15
15
|
export { useCoarsePointer } from './use-media-query.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AACrF,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,eAAe,EAAE,KAAK,IAAI,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AACrF,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,eAAe,EAAE,KAAK,IAAI,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AACxE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC3F,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACvF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/common/index.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import {} from "./props.js";
|
|
2
2
|
import { cx } from "./props.js";
|
|
3
3
|
import { assignRef, mergeRefs } from "./refs.js";
|
|
4
|
-
import {
|
|
5
|
-
BASALT_PREFIX,
|
|
6
|
-
requiredProp,
|
|
7
|
-
oneOf,
|
|
8
|
-
deprecatedProp,
|
|
9
|
-
duplicateMount,
|
|
10
|
-
missingLayer
|
|
11
|
-
} from "./errors.js";
|
|
4
|
+
import { BASALT_PREFIX, requiredProp, oneOf, duplicateMount, missingLayer } from "./errors.js";
|
|
12
5
|
import { useValidateProps, assertRequiredProps, resetValidatedProps } from "./validate.js";
|
|
13
6
|
import { scrollParentOf, SCROLLPORT_ATTRIBUTE } from "./scroll-parent.js";
|
|
14
7
|
import { useCoarsePointer } from "./use-media-query.js";
|
|
@@ -22,7 +15,6 @@ export {
|
|
|
22
15
|
assertRequiredProps,
|
|
23
16
|
assignRef,
|
|
24
17
|
cx,
|
|
25
|
-
deprecatedProp,
|
|
26
18
|
duplicateMount,
|
|
27
19
|
mergeRefs,
|
|
28
20
|
missingLayer,
|
package/dist/common/props.d.ts
CHANGED
|
@@ -41,8 +41,8 @@ export interface SlotStylesProps<S extends string> {
|
|
|
41
41
|
readonly classNames?: SlotClassNames<S> | undefined;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* The ONE status vocabulary (audit A13).
|
|
45
|
-
*
|
|
44
|
+
* The ONE status vocabulary (audit A13). Forks exist today — `SidebarBlockTone` is
|
|
45
|
+
* byte-identical to this, `CalloutKind` / `AccountBadgeTone` /
|
|
46
46
|
* `NotificationIntent` each differ — and they stay put for now: an adopter aliases its fork to this
|
|
47
47
|
* type, it does not get renamed out from under a consumer.
|
|
48
48
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A `--vx-*` name's FAMILY — its leading lowercase run: `--vx-surface-bg` → `surface`, `--vx-ink2`
|
|
3
|
-
* → `ink`, `--vx-
|
|
3
|
+
* → `ink`, `--vx-tooltip-bg` → `tooltip`, `--vx-fill-hover-cyan` → `fill`. Dependency-free, because
|
|
4
4
|
* three sides must agree on it byte for byte: the generator that writes `BASALT_VX_FAMILIES`, the
|
|
5
5
|
* guard that judges every name inside one of those families, and the token factories that refuse a
|
|
6
6
|
* consumer name inside one — the refusal is what makes the guard's judgement honest.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long the scroller must be quiet before a pinned click counts as settled: the fallback for a
|
|
3
|
+
* browser without a reliable `scrollend`, and the only signal for a click that needs no scroll.
|
|
4
|
+
*/
|
|
5
|
+
export declare const QUIET_MS = 200;
|
|
6
|
+
/** Scroll movement tolerated while held (sub-pixel offsets, fractional DPR). */
|
|
7
|
+
export declare const HOLD_EPSILON_PX = 2;
|
|
8
|
+
/** The document-level events that mean the reader is about to scroll (or may have). */
|
|
9
|
+
export declare const INTENT_EVENTS: readonly ["wheel", "touchstart", "keydown", "pointerdown"];
|
|
10
|
+
/**
|
|
11
|
+
* Did the reader just do something that scrolls (or may scroll) the page? `link` is the rail link
|
|
12
|
+
* that was activated: pointing at it is the click itself, and Enter on it is not a scroll key.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isScrollIntent(event: Event, link: Element | null): boolean;
|
|
15
|
+
type ClickPinState = {
|
|
16
|
+
readonly kind: 'idle';
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'pinned';
|
|
19
|
+
readonly id: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: 'held';
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly top: number;
|
|
24
|
+
};
|
|
25
|
+
export declare class ClickPin {
|
|
26
|
+
private readonly onIdle;
|
|
27
|
+
private current;
|
|
28
|
+
private stop;
|
|
29
|
+
/** `onIdle` runs when the machine hands the rail back, so the spy can re-resolve. */
|
|
30
|
+
constructor(onIdle: () => void);
|
|
31
|
+
get state(): ClickPinState;
|
|
32
|
+
/** The entry the click owns (pinned or held), or `null` when the spy answers. A pure query. */
|
|
33
|
+
get activeId(): string | null;
|
|
34
|
+
/** `link` is the rail link just activated; `scroller` the element the spy watches (`null` = document). */
|
|
35
|
+
click(id: string, link: Element | null, scroller: HTMLElement | null): void;
|
|
36
|
+
/** Items changed: a click on an id that no longer exists cannot stand. */
|
|
37
|
+
prune(ids: readonly string[]): void;
|
|
38
|
+
release(): void;
|
|
39
|
+
/** Unmount: idle, timer and listeners gone, no callback. */
|
|
40
|
+
dispose(): void;
|
|
41
|
+
}
|
|
42
|
+
/** `onIdle` must be stable (a state setter): it is captured once, at construction. */
|
|
43
|
+
export declare function useClickPin(onIdle: () => void): ClickPin;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=toc-click-pin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc-click-pin.d.ts","sourceRoot":"","sources":["../../src/content/toc-click-pin.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,eAAO,MAAM,QAAQ,MAAM,CAAA;AAC3B,gFAAgF;AAChF,eAAO,MAAM,eAAe,IAAI,CAAA;AAsBhC,uFAAuF;AACvF,eAAO,MAAM,aAAa,4DAA6D,CAAA;AAEvF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,OAAO,CAY1E;AAMD,KAAK,aAAa,GACd;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAExE,qBAAa,QAAQ;IAKP,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJnC,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,IAAI,CAA4B;IAExC,qFAAqF;gBACxD,MAAM,EAAE,MAAM,IAAI;IAE/C,IAAI,KAAK,IAAI,aAAa,CAEzB;IAED,+FAA+F;IAC/F,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;IAED,0GAA0G;IAC1G,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI;IAwC3E,0EAA0E;IAC1E,KAAK,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAInC,OAAO,IAAI,IAAI;IAMf,4DAA4D;IAC5D,OAAO,IAAI,IAAI;CAKhB;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,QAAQ,CAIxD"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
const QUIET_MS = 200;
|
|
3
|
+
const HOLD_EPSILON_PX = 2;
|
|
4
|
+
const SCROLL_KEYS = /* @__PURE__ */ new Set([
|
|
5
|
+
"PageUp",
|
|
6
|
+
"PageDown",
|
|
7
|
+
"Home",
|
|
8
|
+
"End",
|
|
9
|
+
"ArrowUp",
|
|
10
|
+
"ArrowDown",
|
|
11
|
+
" "
|
|
12
|
+
]);
|
|
13
|
+
const isEditable = (event) => event.composedPath().some(
|
|
14
|
+
(node) => node instanceof HTMLElement && (node.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(node.tagName))
|
|
15
|
+
);
|
|
16
|
+
const INTENT_EVENTS = ["wheel", "touchstart", "keydown", "pointerdown"];
|
|
17
|
+
function isScrollIntent(event, link) {
|
|
18
|
+
switch (event.type) {
|
|
19
|
+
case "wheel":
|
|
20
|
+
case "touchstart":
|
|
21
|
+
return true;
|
|
22
|
+
case "pointerdown":
|
|
23
|
+
return !(event.target instanceof Node && link?.contains(event.target));
|
|
24
|
+
case "keydown":
|
|
25
|
+
return event instanceof KeyboardEvent && SCROLL_KEYS.has(event.key) && !isEditable(event);
|
|
26
|
+
default:
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function scrollTopOf(scroller) {
|
|
31
|
+
return scroller ? scroller.scrollTop : window.scrollY;
|
|
32
|
+
}
|
|
33
|
+
class ClickPin {
|
|
34
|
+
/** `onIdle` runs when the machine hands the rail back, so the spy can re-resolve. */
|
|
35
|
+
constructor(onIdle) {
|
|
36
|
+
this.onIdle = onIdle;
|
|
37
|
+
}
|
|
38
|
+
current = { kind: "idle" };
|
|
39
|
+
stop = null;
|
|
40
|
+
get state() {
|
|
41
|
+
return this.current;
|
|
42
|
+
}
|
|
43
|
+
/** The entry the click owns (pinned or held), or `null` when the spy answers. A pure query. */
|
|
44
|
+
get activeId() {
|
|
45
|
+
return this.current.kind === "idle" ? null : this.current.id;
|
|
46
|
+
}
|
|
47
|
+
/** `link` is the rail link just activated; `scroller` the element the spy watches (`null` = document). */
|
|
48
|
+
click(id, link, scroller) {
|
|
49
|
+
this.stop?.();
|
|
50
|
+
this.current = { kind: "pinned", id };
|
|
51
|
+
const target = scroller ?? window;
|
|
52
|
+
let quiet;
|
|
53
|
+
const hold = () => {
|
|
54
|
+
clearTimeout(quiet);
|
|
55
|
+
if (this.current.kind !== "pinned") return;
|
|
56
|
+
this.current = { kind: "held", id, top: scrollTopOf(scroller) };
|
|
57
|
+
};
|
|
58
|
+
const onScroll = () => {
|
|
59
|
+
const state = this.current;
|
|
60
|
+
if (state.kind === "pinned") {
|
|
61
|
+
clearTimeout(quiet);
|
|
62
|
+
quiet = setTimeout(hold, QUIET_MS);
|
|
63
|
+
} else if (state.kind === "held" && Math.abs(scrollTopOf(scroller) - state.top) > HOLD_EPSILON_PX) {
|
|
64
|
+
this.release();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const onIntent = (event) => {
|
|
68
|
+
if (isScrollIntent(event, link)) this.release();
|
|
69
|
+
};
|
|
70
|
+
quiet = setTimeout(hold, QUIET_MS);
|
|
71
|
+
target.addEventListener("scrollend", hold, { once: true });
|
|
72
|
+
target.addEventListener("scroll", onScroll, { passive: true });
|
|
73
|
+
for (const type of INTENT_EVENTS) document.addEventListener(type, onIntent, { capture: true });
|
|
74
|
+
this.stop = () => {
|
|
75
|
+
clearTimeout(quiet);
|
|
76
|
+
target.removeEventListener("scrollend", hold);
|
|
77
|
+
target.removeEventListener("scroll", onScroll);
|
|
78
|
+
for (const type of INTENT_EVENTS) {
|
|
79
|
+
document.removeEventListener(type, onIntent, { capture: true });
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Items changed: a click on an id that no longer exists cannot stand. */
|
|
84
|
+
prune(ids) {
|
|
85
|
+
if (this.current.kind !== "idle" && !ids.includes(this.current.id)) this.release();
|
|
86
|
+
}
|
|
87
|
+
release() {
|
|
88
|
+
if (this.current.kind === "idle") return;
|
|
89
|
+
this.dispose();
|
|
90
|
+
this.onIdle();
|
|
91
|
+
}
|
|
92
|
+
/** Unmount: idle, timer and listeners gone, no callback. */
|
|
93
|
+
dispose() {
|
|
94
|
+
this.stop?.();
|
|
95
|
+
this.stop = null;
|
|
96
|
+
this.current = { kind: "idle" };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function useClickPin(onIdle) {
|
|
100
|
+
const [pin] = useState(() => new ClickPin(onIdle));
|
|
101
|
+
useEffect(() => () => pin.dispose(), [pin]);
|
|
102
|
+
return pin;
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
ClickPin,
|
|
106
|
+
HOLD_EPSILON_PX,
|
|
107
|
+
INTENT_EVENTS,
|
|
108
|
+
QUIET_MS,
|
|
109
|
+
isScrollIntent,
|
|
110
|
+
useClickPin
|
|
111
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** The TOC scroll-spy's pure half: scroll geometry in, the reader's section out. */
|
|
2
|
+
/** Sub-pixel / fractional-DPR slack when asking "is the scrollport at its end". */
|
|
3
|
+
export declare const BOTTOM_EPSILON_PX = 2;
|
|
4
|
+
/** Distance below the scrollport's top where a heading counts as reached (the observer's top inset). */
|
|
5
|
+
export declare const ACTIVATION_TOP_PX = 80;
|
|
6
|
+
/** The observer's band: below the activation line, down to 30% of the scrollport. */
|
|
7
|
+
export declare const OBSERVER_ROOT_MARGIN = "-80px 0px -70% 0px";
|
|
8
|
+
export type ScrollMetrics = {
|
|
9
|
+
readonly top: number;
|
|
10
|
+
readonly scrollTop: number;
|
|
11
|
+
readonly clientHeight: number;
|
|
12
|
+
readonly scrollHeight: number;
|
|
13
|
+
};
|
|
14
|
+
/** The scrollport's geometry; `null` is the document, whose "top" is the viewport's. */
|
|
15
|
+
export declare function scrollMetrics(port: HTMLElement | null): ScrollMetrics;
|
|
16
|
+
/** Is there a scroll range at all? Content that fits has no "top" or "bottom" to be at. */
|
|
17
|
+
export declare function canScroll(m: ScrollMetrics): boolean;
|
|
18
|
+
export declare function isAtBottom(m: ScrollMetrics): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The reader's section. Nothing to scroll: the first heading. At the end: the last (its section may
|
|
21
|
+
* be too short to ever reach the band). Otherwise the topmost heading inside the band, else the last
|
|
22
|
+
* heading at or above the activation line, else the first.
|
|
23
|
+
*/
|
|
24
|
+
export declare function pickActive(elements: readonly HTMLElement[], intersecting: ReadonlySet<string>, m: ScrollMetrics): string | undefined;
|
|
25
|
+
//# sourceMappingURL=toc-spy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc-spy.d.ts","sourceRoot":"","sources":["../../src/content/toc-spy.ts"],"names":[],"mappings":"AAAA,oFAAoF;AAEpF,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAClC,wGAAwG;AACxG,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,qFAAqF;AACrF,eAAO,MAAM,oBAAoB,uBAAyC,CAAA;AAE1E,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC9B,CAAA;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,aAAa,CAerE;AAED,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAEnD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,SAAS,WAAW,EAAE,EAChC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EACjC,CAAC,EAAE,aAAa,GACf,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const BOTTOM_EPSILON_PX = 2;
|
|
2
|
+
const ACTIVATION_TOP_PX = 80;
|
|
3
|
+
const OBSERVER_ROOT_MARGIN = `-${ACTIVATION_TOP_PX}px 0px -70% 0px`;
|
|
4
|
+
function scrollMetrics(port) {
|
|
5
|
+
if (port) {
|
|
6
|
+
return {
|
|
7
|
+
top: port.getBoundingClientRect().top,
|
|
8
|
+
scrollTop: port.scrollTop,
|
|
9
|
+
clientHeight: port.clientHeight,
|
|
10
|
+
scrollHeight: port.scrollHeight
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
top: 0,
|
|
15
|
+
scrollTop: window.scrollY,
|
|
16
|
+
clientHeight: window.innerHeight,
|
|
17
|
+
scrollHeight: document.documentElement.scrollHeight
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function canScroll(m) {
|
|
21
|
+
return m.scrollHeight - m.clientHeight > BOTTOM_EPSILON_PX;
|
|
22
|
+
}
|
|
23
|
+
function isAtBottom(m) {
|
|
24
|
+
return canScroll(m) && m.scrollTop + m.clientHeight >= m.scrollHeight - BOTTOM_EPSILON_PX;
|
|
25
|
+
}
|
|
26
|
+
function pickActive(elements, intersecting, m) {
|
|
27
|
+
if (!canScroll(m)) return elements[0]?.id;
|
|
28
|
+
if (isAtBottom(m)) return elements[elements.length - 1]?.id;
|
|
29
|
+
const topmost = elements.find((el) => intersecting.has(el.id));
|
|
30
|
+
if (topmost) return topmost.id;
|
|
31
|
+
const line = m.top + ACTIVATION_TOP_PX;
|
|
32
|
+
const passed = elements.filter((el) => el.getBoundingClientRect().top <= line);
|
|
33
|
+
return (passed[passed.length - 1] ?? elements[0])?.id;
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
ACTIVATION_TOP_PX,
|
|
37
|
+
BOTTOM_EPSILON_PX,
|
|
38
|
+
OBSERVER_ROOT_MARGIN,
|
|
39
|
+
canScroll,
|
|
40
|
+
isAtBottom,
|
|
41
|
+
pickActive,
|
|
42
|
+
scrollMetrics
|
|
43
|
+
};
|
package/dist/content/toc.d.ts
CHANGED
|
@@ -17,10 +17,7 @@
|
|
|
17
17
|
* a viewport-rooted observer measures the wrong band. `null` means the document scrolls, which is
|
|
18
18
|
* the shell-less case and behaves exactly as before.
|
|
19
19
|
*
|
|
20
|
-
* The active
|
|
21
|
-
* link set that navigates within one page, rather than `"page"`/`"true"`) — both a genuine a11y fix
|
|
22
|
-
* (previously `activeId` drove `classes.active` alone, so a screen reader had no signal at all) and
|
|
23
|
-
* the one DOM-observable hook for `activeId` that does not depend on a CSS Modules class hash.
|
|
20
|
+
* The active item carries `aria-current="location"` (WAI-ARIA APG: a link set within one page).
|
|
24
21
|
*
|
|
25
22
|
* @example
|
|
26
23
|
* import { TableOfContents, headingSlug } from 'basalt-ui/content'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toc.d.ts","sourceRoot":"","sources":["../../src/content/toc.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"toc.d.ts","sourceRoot":"","sources":["../../src/content/toc.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAA;AAQlD,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,oEAAoE;IACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAA;IAC1B,8FAA8F;IAC9F,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACrD,wEAAwE;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAsBD,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,YAAY,EACZ,MAAuB,EACvB,KAAqB,EACrB,UAAU,EACV,SAAS,GACV,EAAE,oBAAoB,sCAuItB"}
|