@estiva-app/ui 0.59.0 → 0.60.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 (71) hide show
  1. package/dist/AppProvider.d.ts +47 -0
  2. package/dist/AppProvider.d.ts.map +1 -0
  3. package/dist/AppShell.d.ts +6 -2
  4. package/dist/AppShell.d.ts.map +1 -1
  5. package/dist/Avatar.d.ts +1 -1
  6. package/dist/Avatar.d.ts.map +1 -1
  7. package/dist/Chip.d.ts.map +1 -1
  8. package/dist/IconButton.d.ts.map +1 -1
  9. package/dist/InlineChip.d.ts.map +1 -1
  10. package/dist/Link.d.ts +1 -1
  11. package/dist/Link.d.ts.map +1 -1
  12. package/dist/NavItem.d.ts +1 -1
  13. package/dist/NavItem.d.ts.map +1 -1
  14. package/dist/RailItem.d.ts +1 -1
  15. package/dist/RailItem.d.ts.map +1 -1
  16. package/dist/SearchInput.d.ts +3 -3
  17. package/dist/TopBar.d.ts +14 -3
  18. package/dist/TopBar.d.ts.map +1 -1
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +710 -642
  22. package/dist/index.js.map +4 -4
  23. package/dist/registry/{app-LDGOH6UW.js → app-X2GI4WTU.js} +2 -2
  24. package/dist/registry/app.d.ts.map +1 -1
  25. package/dist/registry/{chunk-TQ6UQER3.js → chunk-V67F474L.js} +8 -3
  26. package/dist/registry/chunk-V67F474L.js.map +7 -0
  27. package/dist/registry/cli.js +1 -1
  28. package/dist/registry/index.js +1 -1
  29. package/package.json +1 -1
  30. package/registry.json +87 -9
  31. package/skill/estiva-ui.md +2 -1
  32. package/src/AppProvider.mdx +69 -0
  33. package/src/AppProvider.stories.tsx +60 -0
  34. package/src/AppProvider.test.tsx +152 -0
  35. package/src/AppProvider.tsx +76 -0
  36. package/src/AppShell.mdx +4 -1
  37. package/src/AppShell.stories.tsx +5 -5
  38. package/src/AppShell.tsx +7 -3
  39. package/src/Avatar.tsx +7 -3
  40. package/src/Breadcrumb.mdx +2 -2
  41. package/src/Card.mdx +1 -1
  42. package/src/Chip.mdx +2 -2
  43. package/src/Chip.tsx +3 -1
  44. package/src/IconButton.mdx +2 -2
  45. package/src/IconButton.tsx +4 -1
  46. package/src/InlineChip.mdx +3 -3
  47. package/src/InlineChip.tsx +3 -1
  48. package/src/Link.mdx +5 -3
  49. package/src/Link.tsx +4 -1
  50. package/src/NavItem.mdx +3 -3
  51. package/src/NavItem.tsx +4 -0
  52. package/src/NavTree.mdx +3 -2
  53. package/src/RailItem.mdx +3 -3
  54. package/src/RailItem.tsx +4 -1
  55. package/src/SearchInput.mdx +3 -4
  56. package/src/SearchInput.tsx +3 -3
  57. package/src/Sidebar.mdx +2 -2
  58. package/src/TopBar.mdx +18 -9
  59. package/src/TopBar.stories.tsx +22 -4
  60. package/src/TopBar.test.tsx +97 -0
  61. package/src/TopBar.tsx +45 -4
  62. package/src/index.ts +1 -0
  63. package/src/pages.test.ts +3 -1
  64. package/src/registry/app.test.ts +24 -6
  65. package/src/registry/app.ts +21 -2
  66. package/src/registry/contract.test.ts +1 -1
  67. package/src/registry/gated.test.ts +1 -0
  68. package/src/registry/registry.test.ts +4 -4
  69. package/stories/Choosing.mdx +2 -0
  70. package/dist/registry/chunk-TQ6UQER3.js.map +0 -7
  71. /package/dist/registry/{app-LDGOH6UW.js.map → app-X2GI4WTU.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  buildAppRegistry
4
- } from "./chunk-TQ6UQER3.js";
4
+ } from "./chunk-V67F474L.js";
5
5
  import "./chunk-P55P2QFD.js";
6
6
  import "./chunk-PZO4BVV3.js";
7
7
  export {
8
8
  buildAppRegistry
9
9
  };
10
- //# sourceMappingURL=app-LDGOH6UW.js.map
10
+ //# sourceMappingURL=app-X2GI4WTU.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/registry/app.ts"],"names":[],"mappings":"AAyCA,OAAO,EAAwE,KAAK,QAAQ,EAAsB,MAAM,UAAU,CAAA;AAElI,MAAM,WAAW,eAAe;IAC9B,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oGAAoG;IACpG,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gIAAgI;IAChI,eAAe,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;IACjC,gIAAgI;IAChI,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC/B;AAwQD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,IAAoB,EAAE,IAAI,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAE,eAAoB,GAAG,QAAQ,CA0kBrI"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/registry/app.ts"],"names":[],"mappings":"AAqDA,OAAO,EAAwE,KAAK,QAAQ,EAAsB,MAAM,UAAU,CAAA;AAElI,MAAM,WAAW,eAAe;IAC9B,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oGAAoG;IACpG,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gIAAgI;IAChI,eAAe,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;IACjC,gIAAgI;IAChI,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC/B;AA0QD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,IAAoB,EAAE,IAAI,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAE,eAAoB,GAAG,QAAQ,CA+kBrI"}
@@ -25,7 +25,8 @@ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
25
25
  import { basename, dirname, extname, join, relative, resolve, sep } from "node:path";
26
26
  import ts from "typescript";
27
27
  var WRITABLE = ["reusable", "one-off", "promote-candidate"];
28
- var WRITTEN = /^@registry\s+([a-z-]+)\s*:\s*(.+)$/m;
28
+ var WRITTEN = /^@registry\s+(?!namesake\b)([a-z-]+)\s*:\s*(.+)$/m;
29
+ var NAMESAKE = /^@registry\s+namesake\s*:\s*\S/m;
29
30
  var isStory = (file) => /\.stories\.[cm]?[jt]sx?$/.test(file);
30
31
  var isTest = (file) => /\.(test|spec)\.[cm]?[jt]sx?$/.test(file) || /(^|\/)__(tests|mocks)__\//.test(file);
31
32
  var isPascal = (name) => /^[A-Z][A-Za-z0-9]*$/.test(name) && !/^[A-Z0-9_]+$/.test(name);
@@ -628,6 +629,10 @@ function buildAppRegistry({ root = process.cwd(), repo, packageRegistry, package
628
629
  cls = "promote-candidate";
629
630
  reason = `Used in ${usedIn.length} places, and everything it uses is already in the package.`;
630
631
  }
632
+ const namesake = namesakes.has(p.name) && !(pass && isPackageImport(pass.specifier) && pass.name === p.name) ? p.name : null;
633
+ if (namesake && !(NAMESAKE.test(doc) || onePart && NAMESAKE.test(header))) {
634
+ problems.push(`${p.name} in ${p.file} has the name of the package's ${namesake}. Use the package's, or write why this one is kept: "@registry namesake: <reason>" in its /** \u2026 */ comment.`);
635
+ }
631
636
  const shape = declared ? module.resolve(declared.propsType) : { props: [], variants: [] };
632
637
  const facts_ = {
633
638
  class: cls,
@@ -636,7 +641,7 @@ function buildAppRegistry({ root = process.cwd(), repo, packageRegistry, package
636
641
  handsOn: pass ? isPackageImport(pass.specifier) ? pass.name : `${pass.name} from ${pass.specifier}` : null,
637
642
  usedIn,
638
643
  tiedTo: ties,
639
- packageNamesake: namesakes.has(p.name) && !(pass && isPackageImport(pass.specifier) && pass.name === p.name) ? p.name : null,
644
+ packageNamesake: namesake,
640
645
  defaultExport: p.defaultExport
641
646
  };
642
647
  const found2 = pass ? { docsId: null, storyId: null } : storyOf(p);
@@ -697,4 +702,4 @@ function buildAppRegistry({ root = process.cwd(), repo, packageRegistry, package
697
702
  export {
698
703
  buildAppRegistry
699
704
  };
700
- //# sourceMappingURL=chunk-TQ6UQER3.js.map
705
+ //# sourceMappingURL=chunk-V67F474L.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/registry/app.ts"],
4
+ "sourcesContent": ["/// <reference types=\"node\" />\n/**\n * An app's catalogue (UIG-13): every part in an app's own code, what it is for,\n * where it is used, and which of four kinds it is.\n *\n * **Built fresh, never committed** (Katerina, 18 September 2026). The package is\n * public and Peek and Ship are private, so an app's catalogue lives nowhere but\n * in its own code: `estiva-ui find` and `estiva-ui check` build it each time,\n * which takes about a second, and `estiva-ui build` writes it to a file only\n * when asked. A file that is never kept can never drift.\n *\n * **A file is not a part, and a folder says nothing.** Peek's `components/ui`\n * holds one-line pass-ons beside 187-line components, one file can hold six\n * parts, and a part can draw nothing at all (a provider, a listener). So the\n * target set is every name an app's `.tsx` files export that is a part: a\n * function that draws, or a name drawn as a tag somewhere in the app. The kind\n * is read from the code, and only from the code:\n *\n * - **re-export** \u2014 its file only hands a package part on.\n * - **one-off** \u2014 one file of the app uses it.\n * - **reusable** \u2014 two or more do.\n * - **promote-candidate** \u2014 two or more do, and everything it uses is already in\n * the package, so it could move there as it is. Katerina rules on each.\n * - **unused** \u2014 no file of the app uses it; its stories or tests may.\n *\n * Where the count is wrong \u2014 a general part only one screen uses yet \u2014 a person\n * writes the kind beside the part, with the reason, and the catalogue shows it:\n *\n * /**\n * * A timeline of what happened to a thing.\n * * @registry reusable: general; one screen uses it so far\n * *\\/\n *\n * A part that shares its name with a package part is refused unless the reason\n * it is kept is written beside it, the same way:\n *\n * /**\n * * The package's `Avatar`, handed the picture this app knows about.\n * * @registry namesake: the package cannot know where pictures come from\n * *\\/\n *\n * Peek's own MembersPill stayed in two headers for two days after the package\n * gained one (0.58.0, 6 October) \u2014 built from the package's parts, so no rule\n * saw it (Katerina, 8 October).\n *\n * TypeScript is the app's own install, as it is for the package's builder.\n */\nimport { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'\nimport { basename, dirname, extname, join, relative, resolve, sep } from 'node:path'\nimport ts from 'typescript'\nimport { asBehaviours, baseUiBehaviours, drawnIn, handedOn, isBaseUi, rootsIn, splitTag } from './behaviours'\nimport { firstSentence, isPackageImport, pageOpening, readModule, sanitize, toId, type Resolved } from './build'\nimport { looksOf, parseForLooks } from '../eslint/looks-of'\nimport { SCHEMA_VERSION, type AppFacts, type EntryClass, type FileWithoutPart, type Registry, type RegistryEntry } from './schema'\n\nexport interface AppBuildOptions {\n /** The app's folder: where its `package.json` and `src/` are. Ship's is `web`. */\n root?: string\n /** The name its entries are recorded under \u2014 `peek`, `ship`. Defaults to the app's package name. */\n repo?: string\n /** The package's own catalogue, for the parts an app part shares a name with. Defaults to the one this builder ships beside. */\n packageRegistry?: Registry | null\n /** The packages the package itself depends on. An import of one never ties a part to its app. Defaults to the package's own. */\n packageDependencies?: string[]\n}\n\n/** The kinds a person may write beside a part. A pass-on is a fact about its file; so is being used nowhere. */\nconst WRITABLE: EntryClass[] = ['reusable', 'one-off', 'promote-candidate']\nconst WRITTEN = /^@registry\\s+(?!namesake\\b)([a-z-]+)\\s*:\\s*(.+)$/m\n/** Why a part with a package part's name is kept: `@registry namesake: <reason>`. */\nconst NAMESAKE = /^@registry\\s+namesake\\s*:\\s*\\S/m\n\nconst isStory = (file: string) => /\\.stories\\.[cm]?[jt]sx?$/.test(file)\nconst isTest = (file: string) => /\\.(test|spec)\\.[cm]?[jt]sx?$/.test(file) || /(^|\\/)__(tests|mocks)__\\//.test(file)\nconst isPascal = (name: string) => /^[A-Z][A-Za-z0-9]*$/.test(name) && !/^[A-Z0-9_]+$/.test(name)\n/**\n * What a dynamic `import('./x')` takes from its file. Written as\n * `import('./Settings').then((m) => ({ default: m.SettingsPage }))`, only the names\n * read off the module; otherwise the whole module (`*`), whose default a caller\n * then takes.\n */\nfunction pickedFrom(call: ts.CallExpression): { imported: string; local: string }[] {\n const then = call.parent\n const invoked = then?.parent\n if (then && ts.isPropertyAccessExpression(then) && then.name.text === 'then' && invoked && ts.isCallExpression(invoked)) {\n const callback = invoked.arguments[0]\n const param = callback && (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback)) ? callback.parameters[0]?.name : undefined\n if (param && ts.isIdentifier(param)) {\n const names = new Set<string>()\n const visit = (n: ts.Node) => {\n if (ts.isPropertyAccessExpression(n) && ts.isIdentifier(n.expression) && n.expression.text === param.text) names.add(n.name.text)\n ts.forEachChild(n, visit)\n }\n visit(callback)\n if (names.size) return [...names].map((imported) => ({ imported, local: '(dynamic)' }))\n }\n }\n return [{ imported: '*', local: '(dynamic)' }]\n}\n\n/**\n * `export default memo(TopicRow)`: the default is TopicRow, wrapped. A call on\n * a name, with no function written into it, hands that name out, so the export\n * is read as if it named it \u2014 one part, whose comment and props are its own.\n */\nfunction unwrapDefault<T extends { isDefault: boolean; local: string | null; node: ts.Node | null }>(ex: T): T {\n if (!ex.isDefault || ex.local || !ex.node || !ts.isExpression(ex.node)) return ex\n const name = handedOut(ex.node)\n return name ? { ...ex, local: name, node: null } : ex\n}\n\n/**\n * The name an `export default \u2026` hands out, under whatever it is wrapped in:\n * `memo(forwardRef(Row))`, `Row as ComponentType`, `Row satisfies FC`,\n * `styled(Row)\\`\u2026\\``. `null` when what is exported is written right there.\n */\nfunction handedOut(expression: ts.Expression): string | null {\n let e: ts.Expression = expression\n for (;;) {\n if (ts.isIdentifier(e)) return e.text\n if (ts.isParenthesizedExpression(e) || ts.isAsExpression(e) || ts.isSatisfiesExpression(e) || ts.isNonNullExpression(e) || ts.isTypeAssertionExpression(e)) e = e.expression\n else if (ts.isTaggedTemplateExpression(e)) e = e.tag\n else if (ts.isCallExpression(e) && e.arguments[0] && !e.arguments.some((a) => ts.isArrowFunction(a) || ts.isFunctionExpression(a))) e = e.arguments[0]\n else return null\n }\n}\n\n/** `memo-page` \u2192 `MemoPage`, `topic_view` \u2192 `TopicView`. */\nconst pascalOf = (stem: string) => stem.split(/[^A-Za-z0-9]+/).filter(Boolean).map((word) => word[0].toUpperCase() + word.slice(1)).join('')\n/** A default with no name of its own takes its file's \u2014 or, for `settings/index.tsx`, its folder's. */\nconst defaultNameOf = (file: string) => {\n const stem = basename(file, extname(file))\n return pascalOf(stem === 'index' ? basename(dirname(file)) : stem)\n}\nconst CODE = ['.tsx', '.ts', '.jsx', '.js', '.mts', '.cts']\n\n/** `@scope/name/sub` \u2192 `@scope/name`; `name/sub` \u2192 `name`. */\nfunction packageOf(specifier: string): string {\n const parts = specifier.split('/')\n return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0]\n}\n\n/** What the package this builder belongs to depends on, and its catalogue. Read from beside the builder. */\nfunction packageSelf(): { dependencies: string[]; registry: Registry | null } {\n const at = (rel: string) => new URL(rel, import.meta.url)\n const manifest = JSON.parse(readFileSync(at('../../package.json'), 'utf8')) as { name: string; dependencies?: Record<string, string>; peerDependencies?: Record<string, string> }\n const registryUrl = at('../../registry.json')\n const registry = existsSync(registryUrl) ? (JSON.parse(readFileSync(registryUrl, 'utf8')) as Registry) : null\n return { dependencies: [manifest.name, ...Object.keys(manifest.dependencies ?? {}), ...Object.keys(manifest.peerDependencies ?? {})], registry }\n}\n\n/**\n * The import aliases an app's `tsconfig*.json` files declare \u2014 `@/*` \u2192\n * `<root>/src/*` \u2014 and the `baseUrl` folders a bare `src/Card` is read from.\n */\nfunction readAliases(root: string): { aliases: { prefix: string; target: string }[]; bases: string[] } {\n const aliases: { prefix: string; target: string }[] = []\n const bases: string[] = []\n for (const name of readdirSync(root).filter((file) => /^tsconfig.*\\.json$/.test(file)).sort()) {\n const read = ts.readConfigFile(join(root, name), ts.sys.readFile)\n const options = (read.config?.compilerOptions ?? {}) as { paths?: Record<string, string[]>; baseUrl?: string }\n const base = resolve(root, options.baseUrl ?? '.')\n if (options.baseUrl !== undefined && !bases.includes(base)) bases.push(base)\n for (const [pattern, targets] of Object.entries(options.paths ?? {})) {\n if (!pattern.endsWith('/*') || !targets[0]?.endsWith('/*')) continue\n const prefix = pattern.slice(0, -1)\n if (!aliases.some((alias) => alias.prefix === prefix)) aliases.push({ prefix, target: resolve(base, targets[0].slice(0, -2)) })\n }\n }\n return { aliases, bases }\n}\n\nfunction walk(dir: string): string[] {\n return readdirSync(dir).flatMap((name) => {\n if (name === 'node_modules' || name.startsWith('.')) return []\n const path = join(dir, name)\n return statSync(path).isDirectory() ? walk(path) : [path]\n })\n}\n\n/** One import, re-export or dynamic import of a file, resolved. */\ninterface Link {\n specifier: string\n /** An app code file, relative to the app; `null` for a package; `'?'` for anything else. */\n target: string | null\n /** `imported` name \u2192 local name; `*` for a namespace or a dynamic import. Type-only names are left out. */\n names: { imported: string; local: string }[]\n typeOnly: boolean\n kind: 'import' | 're-export' | 'dynamic'\n}\n\n/** A part a file exports, before anything is known about its use. */\ninterface Found {\n file: string\n /** The name it is exported as; a default export takes its own name, or the file's. */\n name: string\n /** The name it has inside its file, where it has one. */\n local: string | null\n defaultExport: boolean\n /** A pass-on: the package and the name it hands on. */\n from: { specifier: string; name: string } | null\n}\n\n/** Everything one file says, read once. */\ninterface FileFacts {\n file: string\n source: string\n sf: ts.SourceFile\n links: Link[]\n /** `exported name` \u2192 local name, and whether it is the default. */\n exports: { name: string; local: string | null; isDefault: boolean; node: ts.Node | null }[]\n /** Pass-ons and barrel entries: `export { A } from '\u2026'`. */\n reexports: { name: string; source: string; specifier: string; target: string | null }[]\n starFrom: { specifier: string; target: string | null }[]\n /** `export * as Parts from './parts'`: a name that stands for another file's parts. */\n namespaces: { name: string; target: string | null }[]\n /** Every name drawn as a JSX tag in this file. */\n tags: Set<string>\n /** Each imported value name \u2192 where it came from, for `import { X } from '\u2026'` then `export { X }`. */\n bindings: Map<string, { specifier: string; imported: string; target: string | null }>\n}\n\n/** Whether a node draws: JSX, or `createElement` / `createPortal`. */\nfunction draws(node: ts.Node): boolean {\n let found = false\n const visit = (n: ts.Node) => {\n if (found) return\n if (ts.isJsxElement(n) || ts.isJsxSelfClosingElement(n) || ts.isJsxFragment(n)) {\n found = true\n return\n }\n if (ts.isCallExpression(n)) {\n const callee = ts.isPropertyAccessExpression(n.expression) ? n.expression.name.text : ts.isIdentifier(n.expression) ? n.expression.text : ''\n if (callee === 'createElement' || callee === 'createPortal') {\n found = true\n return\n }\n }\n ts.forEachChild(n, visit)\n }\n visit(node)\n return found\n}\n\n/**\n * Whether a file names `local` anywhere but in `home` (its own declaration), its\n * imports and its export lines \u2014 as a tag, a value, or passed along. A property\n * name, an attribute name and a type are not uses of the part.\n */\nfunction mentions(sf: ts.SourceFile, local: string, home: ts.Node | null): boolean {\n let named = false\n const visit = (n: ts.Node) => {\n if (named) return\n if (ts.isIdentifier(n) && n.text === local) {\n const parent = n.parent\n // The name of something else that happens to be spelled the same \u2014 a\n // property of a type or a class, a member, another declaration \u2014 is not the part.\n const declares = (ts.isPropertySignature(parent) || ts.isPropertyDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isMethodSignature(parent) || ts.isGetAccessorDeclaration(parent) || ts.isSetAccessorDeclaration(parent) || ts.isEnumMember(parent) || ts.isVariableDeclaration(parent) || ts.isFunctionDeclaration(parent) || ts.isClassDeclaration(parent) || ts.isParameter(parent) || ts.isBindingElement(parent)) && (parent as { name?: ts.Node }).name === n\n const bindingKey = ts.isBindingElement(parent) && parent.propertyName === n\n const isName = declares || bindingKey || (ts.isPropertyAccessExpression(parent) && parent.name === n) || (ts.isPropertyAssignment(parent) && parent.name === n) || ts.isJsxAttribute(parent) || ts.isExportSpecifier(parent) || ts.isImportSpecifier(parent) || ts.isJsxClosingElement(parent)\n // `SlashMenu.displayName = 'SlashMenu'` sets something on the part; it does not use it.\n const configures = ts.isPropertyAccessExpression(parent) && parent.expression === n && ts.isBinaryExpression(parent.parent) && parent.parent.left === parent && parent.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken\n if (configures) {\n ts.forEachChild(n, visit)\n return\n }\n let inType = false\n for (let a: ts.Node | undefined = parent; a && a !== sf; a = a.parent) if (ts.isTypeNode(a)) inType = true\n if (!isName && !inType && !shadowed(n, local, sf)) named = true\n }\n ts.forEachChild(n, visit)\n }\n for (const s of sf.statements) {\n if (s === home || ts.isExportDeclaration(s) || ts.isImportDeclaration(s)) continue\n // `export default Row`, `memo(forwardRef(Row))`, `Row as ComponentType` hand the\n // part out; they do not use it. Anything else written into the default is code.\n if (ts.isExportAssignment(s) && handedOut(s.expression)) continue\n visit(s)\n }\n return named\n}\n\n/** Whether a binding name \u2014 `Icon`, `{ icon: Icon }`, `[Icon]` \u2014 binds `local`. */\nfunction binds(name: ts.BindingName | undefined, local: string): boolean {\n if (!name) return false\n if (ts.isIdentifier(name)) return name.text === local\n return name.elements.some((element) => !ts.isOmittedExpression(element) && binds(element.name, local))\n}\n\n/**\n * Whether `n` means something declared closer than the file: a parameter\n * (`Item({ icon: Icon }) { return <Icon /> }`), or a constant, function or class\n * of an enclosing block. That `Icon` is not the file's part called Icon.\n */\nfunction shadowed(n: ts.Node, local: string, sf: ts.SourceFile): boolean {\n for (let a: ts.Node | undefined = n.parent; a && a !== sf; a = a.parent) {\n if (ts.isFunctionLike(a)) {\n if (a.parameters.some((p) => binds(p.name, local))) return true\n if ((ts.isFunctionExpression(a) || ts.isClassExpression(a)) && a.name?.text === local) return true\n }\n if (ts.isCatchClause(a) && binds(a.variableDeclaration?.name, local)) return true\n if (ts.isBlock(a) || ts.isModuleBlock(a) || ts.isCaseClause(a) || ts.isDefaultClause(a)) {\n for (const s of a.statements) {\n if (ts.isVariableStatement(s) && s.declarationList.declarations.some((d) => binds(d.name, local))) return true\n if ((ts.isFunctionDeclaration(s) || ts.isClassDeclaration(s)) && s.name?.text === local) return true\n }\n }\n if ((ts.isForStatement(a) || ts.isForOfStatement(a) || ts.isForInStatement(a)) && a.initializer && ts.isVariableDeclarationList(a.initializer) && a.initializer.declarations.some((d) => binds(d.name, local))) return true\n }\n return false\n}\n\n/**\n * The thing a declaration holds, if it is a function, a class, or a call that\n * wraps one (`forwardRef`, `memo`) \u2014 as a constant, or written straight into\n * `export default \u2026`.\n */\nfunction drawingBody(node: ts.Node): ts.Node | null {\n if (ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)) return node\n const init = ts.isVariableDeclaration(node) ? node.initializer : ts.isExpression(node) ? node : undefined\n if (!init) return null\n if (ts.isArrowFunction(init) || ts.isFunctionExpression(init) || ts.isClassExpression(init)) return init\n if (ts.isCallExpression(init)) {\n const callee = init.expression.getText()\n if (/(^|\\.)createContext$/.test(callee)) return null\n if (init.arguments.some((a) => ts.isArrowFunction(a) || ts.isFunctionExpression(a))) return init\n }\n return null\n}\n\n/**\n * Read one app and return its catalogue.\n *\n * Throws on anything it cannot explain, with every problem at once: a part with\n * no purpose, a written kind it does not know. A catalogue that quietly drops\n * what it could not read would answer \"we have nothing for that\" when the\n * truth is \"the builder gave up\".\n */\nexport function buildAppRegistry({ root = process.cwd(), repo, packageRegistry, packageDependencies }: AppBuildOptions = {}): Registry {\n const app = resolve(root)\n const src = join(app, 'src')\n if (!existsSync(src)) throw new Error(`${app} has no src/ folder: estiva-ui reads an app's parts from src/`)\n const manifest = JSON.parse(readFileSync(join(app, 'package.json'), 'utf8')) as { name?: string; version?: string; scripts?: Record<string, string> }\n const self = packageRegistry === undefined || packageDependencies === undefined ? packageSelf() : null\n const theRegistry = packageRegistry === undefined ? (self?.registry ?? null) : packageRegistry\n const allowed = new Set(packageDependencies ?? self?.dependencies ?? [])\n const repoName = repo ?? manifest.name ?? basename(app)\n const { aliases, bases } = readAliases(app)\n const rel = (abs: string) => relative(app, abs).split(sep).join('/')\n\n const files = walk(src)\n .filter((path) => CODE.includes(extname(path)) && !path.endsWith('.d.ts'))\n .map(rel)\n .sort()\n const known = new Set(files)\n\n /** Where an import points: an app code file, a package (`null`), or something else (`'?'`). */\n const resolveSpecifier = (from: string, specifier: string): string | null => {\n let base: string | null = null\n if (specifier.startsWith('.')) base = resolve(app, dirname(from), specifier)\n else {\n const alias = aliases.find((a) => specifier.startsWith(a.prefix))\n if (alias) base = join(alias.target, specifier.slice(alias.prefix.length))\n }\n const lookUp = (at: string): string | null => {\n const stem = at.replace(/\\.(js|jsx)$/, '')\n for (const candidate of [at, ...CODE.map((e) => stem + e), ...CODE.map((e) => join(at, `index${e}`))]) {\n const r = rel(candidate)\n if (known.has(r)) return r\n }\n return null\n }\n if (base === null) {\n // A bare `src/Card` is the app's own when its tsconfig's baseUrl says so; otherwise a package.\n for (const folder of bases) {\n const hit = lookUp(join(folder, specifier))\n if (hit) return hit\n }\n return null\n }\n return lookUp(base) ?? '?'\n }\n\n // \u2500\u2500 Read every file once \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const facts = new Map<string, FileFacts>()\n for (const file of files) {\n const source = readFileSync(join(app, file), 'utf8')\n const sf = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true, /x$/.test(file) ? ts.ScriptKind.TSX : ts.ScriptKind.TS)\n const links: Link[] = []\n const exports: FileFacts['exports'] = []\n const reexports: FileFacts['reexports'] = []\n const starFrom: FileFacts['starFrom'] = []\n const namespaces: FileFacts['namespaces'] = []\n for (const statement of sf.statements) {\n if (ts.isImportDeclaration(statement)) {\n if (!ts.isStringLiteral(statement.moduleSpecifier)) continue\n const specifier = statement.moduleSpecifier.text\n const clause = statement.importClause\n const names: Link['names'] = []\n if (clause && !clause.isTypeOnly) {\n if (clause.name) names.push({ imported: 'default', local: clause.name.text })\n const bindings = clause.namedBindings\n if (bindings && ts.isNamedImports(bindings)) for (const e of bindings.elements) if (!e.isTypeOnly) names.push({ imported: (e.propertyName ?? e.name).text, local: e.name.text })\n if (bindings && ts.isNamespaceImport(bindings)) names.push({ imported: '*', local: bindings.name.text })\n }\n links.push({ specifier, target: resolveSpecifier(file, specifier), names, typeOnly: !!clause?.isTypeOnly || (clause !== undefined && names.length === 0 && !!clause.namedBindings), kind: 'import' })\n continue\n }\n if (ts.isExportDeclaration(statement)) {\n const specifier = statement.moduleSpecifier && ts.isStringLiteral(statement.moduleSpecifier) ? statement.moduleSpecifier.text : null\n if (specifier === null) {\n if (!statement.isTypeOnly && statement.exportClause && ts.isNamedExports(statement.exportClause)) {\n // `export { Page as default }` is the file's default, named Page.\n for (const e of statement.exportClause.elements) if (!e.isTypeOnly) exports.push({ name: e.name.text, local: (e.propertyName ?? e.name).text, isDefault: e.name.text === 'default', node: null })\n }\n continue\n }\n const target = resolveSpecifier(file, specifier)\n links.push({ specifier, target, names: [], typeOnly: statement.isTypeOnly, kind: 're-export' })\n if (statement.isTypeOnly) continue\n if (!statement.exportClause) starFrom.push({ specifier, target })\n else if (ts.isNamedExports(statement.exportClause)) {\n for (const e of statement.exportClause.elements) if (!e.isTypeOnly) reexports.push({ name: e.name.text, source: (e.propertyName ?? e.name).text, specifier, target })\n } else if (ts.isNamespaceExport(statement.exportClause)) {\n // `export * as Parts from './parts'`: a caller's `Parts.Card` is the parts file's Card.\n namespaces.push({ name: statement.exportClause.name.text, target })\n }\n continue\n }\n if (ts.isExportAssignment(statement) && !statement.isExportEquals) {\n const e = statement.expression\n exports.push({ name: 'default', local: ts.isIdentifier(e) ? e.text : null, isDefault: true, node: ts.isIdentifier(e) ? null : e })\n continue\n }\n const mods = ts.canHaveModifiers(statement) ? (ts.getModifiers(statement) ?? []) : []\n if (!mods.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) continue\n const isDefault = mods.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)\n // An overload's signature is not a part of its own: the part is the one with a body.\n if (ts.isFunctionDeclaration(statement) && !statement.body) continue\n if (ts.isFunctionDeclaration(statement) || ts.isClassDeclaration(statement)) {\n exports.push({ name: isDefault ? 'default' : (statement.name?.text ?? 'default'), local: statement.name?.text ?? null, isDefault, node: statement })\n } else if (ts.isVariableStatement(statement)) {\n for (const d of statement.declarationList.declarations) if (ts.isIdentifier(d.name)) exports.push({ name: d.name.text, local: d.name.text, isDefault: false, node: d })\n }\n }\n const tags = new Set<string>()\n const visit = (n: ts.Node) => {\n if (ts.isCallExpression(n) && n.expression.kind === ts.SyntaxKind.ImportKeyword && n.arguments[0] && ts.isStringLiteralLike(n.arguments[0])) {\n const specifier = n.arguments[0].text\n links.push({ specifier, target: resolveSpecifier(file, specifier), names: pickedFrom(n), typeOnly: false, kind: 'dynamic' })\n }\n if ((ts.isJsxOpeningElement(n) || ts.isJsxSelfClosingElement(n)) && ts.isIdentifier(n.tagName)) tags.add(n.tagName.text)\n ts.forEachChild(n, visit)\n }\n visit(sf)\n const bindings: FileFacts['bindings'] = new Map()\n for (const link of links) if (link.kind === 'import') for (const n of link.names) if (n.imported !== '*') bindings.set(n.local, { specifier: link.specifier, imported: n.imported, target: link.target })\n facts.set(file, { file, source, sf, links, exports, reexports, starFrom, namespaces, tags, bindings })\n }\n\n const drawnAnywhere = new Set<string>()\n for (const f of facts.values()) for (const tag of f.tags) drawnAnywhere.add(tag)\n\n /** A top-level declaration of a file, by its local name. */\n const declarationOf = (f: FileFacts, local: string): ts.Node | null => {\n for (const s of f.sf.statements) {\n // Past an overload's signature, to the function with a body.\n if (ts.isFunctionDeclaration(s) && s.name?.text === local && !s.body) continue\n if ((ts.isFunctionDeclaration(s) || ts.isClassDeclaration(s)) && s.name?.text === local) return s\n if (ts.isVariableStatement(s)) for (const d of s.declarationList.declarations) if (ts.isIdentifier(d.name) && d.name.text === local) return d\n }\n return null\n }\n\n // \u2500\u2500 The parts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const problems: string[] = []\n const found: Found[] = []\n const targets = files.filter((file) => file.endsWith('.tsx') && !isStory(file) && !isTest(file))\n for (const file of targets) {\n const f = facts.get(file)!\n for (const written of f.exports) {\n const ex = unwrapDefault(written)\n // `export default memo(Avatar)` with Avatar imported: not Avatar handed on, but a\n // new part of this file that wraps it, named after the file.\n // Only a name that is a part's: `createBrowserRouter(routes)` hands out no part.\n if (ex !== written && ex.local && isPascal(ex.local) && !declarationOf(f, ex.local) && f.bindings.has(ex.local)) {\n found.push({ file, name: defaultNameOf(file), local: null, defaultExport: true, from: null })\n continue\n }\n // `export function App` and `export default App` \u2014 or `export default memo(App)`: one part, not two.\n if (ex.isDefault && ex.local && f.exports.some((other) => !other.isDefault && other.local === ex.local)) continue\n const node = ex.node ?? (ex.local ? declarationOf(f, ex.local) : null)\n // A default with no name of its own takes its file's, as a name: `memo-page.tsx` \u2192 MemoPage.\n const own = ex.local ?? (ex.isDefault ? defaultNameOf(file) : ex.name)\n const name = ex.isDefault ? own : ex.name\n if (!isPascal(name)) continue\n // `import { SkeletonBar } from '@estiva-app/ui'` and later `export { SkeletonBar }`:\n // handed on, exactly as `export { SkeletonBar } from '@estiva-app/ui'` is.\n // From another file of the app it is a barrel, and the part is listed there.\n const bound = node === null && ex.local ? f.bindings.get(ex.local) : undefined\n if (bound) {\n if (bound.target === null) found.push({ file, name, local: null, defaultExport: ex.isDefault, from: { specifier: bound.specifier, name: bound.imported } })\n continue\n }\n // `export const SkeletonSidebarList = SkeletonList`, SkeletonList imported: the\n // package's part under a second name, handed on. From an app file, a barrel.\n const alias = node && ts.isVariableDeclaration(node) && node.initializer && ts.isIdentifier(node.initializer) ? f.bindings.get(node.initializer.text) : undefined\n if (alias) {\n if (alias.target === null) found.push({ file, name, local: null, defaultExport: ex.isDefault, from: { specifier: alias.specifier, name: alias.imported } })\n continue\n }\n const body = node ? drawingBody(node) : null\n const isPart = (body !== null && draws(body)) || drawnAnywhere.has(ex.local ?? name)\n if (isPart) found.push({ file, name, local: ex.local, defaultExport: ex.isDefault, from: null })\n }\n for (const re of f.reexports) {\n // Handing on another file of the app is a barrel: the part is listed where it is written.\n if (re.target !== null || !isPascal(re.name)) continue\n found.push({ file, name: re.name, local: null, defaultExport: false, from: { specifier: re.specifier, name: re.source } })\n }\n for (const star of f.starFrom) {\n if (star.target === null) problems.push(`${file} hands on everything from '${star.specifier}' with export *: name the parts it hands on, so the catalogue can list them`)\n }\n }\n\n // \u2500\u2500 Where each is used \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const key = (file: string, name: string) => `${file}#${name}`\n const byKey = new Map(found.map((p) => [key(p.file, p.name), p]))\n const partsIn = (file: string) => found.filter((p) => p.file === file)\n /** The part a file's default export is, however it was written. */\n const defaultPartOf = (file: string): Found | null => {\n const written = facts.get(file)?.exports.find((e) => e.isDefault)\n if (!written) return null\n const d = unwrapDefault(written)\n return partsIn(file).find((p) => p.defaultExport || (d.local !== null && p.local === d.local)) ?? null\n }\n\n /** What `name`, imported from `file`, really is: follows barrels to the file that writes it. */\n const origin = (file: string, name: string, seen = new Set<string>()): Found | null => {\n if (seen.has(key(file, name))) return null\n seen.add(key(file, name))\n const direct = byKey.get(key(file, name))\n if (direct) return direct\n const f = facts.get(file)\n if (!f) return null\n // `export default Foo` elsewhere in the file: the default is Foo's part.\n if (name === 'default') {\n const d = defaultPartOf(file)\n if (d) return d\n }\n const re = f.reexports.find((r) => r.name === name)\n if (re && re.target && re.target !== '?') return origin(re.target, re.source, seen)\n // `import { X } from './X'` and `export { X }`: a barrel written in two lines.\n const ex = f.exports.find((e) => (name === 'default' ? e.isDefault : e.name === name && !e.isDefault))\n const renamed = ex?.node && ts.isVariableDeclaration(ex.node) && ex.node.initializer && ts.isIdentifier(ex.node.initializer) ? f.bindings.get(ex.node.initializer.text) : undefined\n const bound = (ex?.local && !ex.node && !declarationOf(f, ex.local) ? f.bindings.get(ex.local) : undefined) ?? renamed\n if (bound?.target && bound.target !== '?') return origin(bound.target, bound.imported, seen)\n for (const star of f.starFrom) if (star.target && star.target !== '?') {\n const hit = origin(star.target, name, seen)\n if (hit) return hit\n }\n return null\n }\n /** Every part a file hands out, through its barrels too. */\n const everyPartOf = (file: string, seen = new Set<string>()): Found[] => {\n if (seen.has(file)) return []\n seen.add(file)\n const f = facts.get(file)\n if (!f) return []\n const out = [...partsIn(file)]\n for (const re of f.reexports) if (re.target && re.target !== '?') { const o = origin(re.target, re.source); if (o) out.push(o) }\n for (const star of f.starFrom) if (star.target && star.target !== '?') out.push(...everyPartOf(star.target, seen))\n for (const ns of f.namespaces) if (ns.target && ns.target !== '?') out.push(...everyPartOf(ns.target, seen))\n return out\n }\n /** The parts a namespace export stands for, followed through barrels. */\n const namespaceParts = (file: string, name: string, seen = new Set<string>()): Found[] => {\n if (seen.has(`${file}#${name}`)) return []\n seen.add(`${file}#${name}`)\n const f = facts.get(file)\n if (!f) return []\n const ns = f.namespaces.find((x) => x.name === name)\n if (ns) return ns.target && ns.target !== '?' ? everyPartOf(ns.target) : []\n const re = f.reexports.find((r) => r.name === name)\n if (re?.target && re.target !== '?') return namespaceParts(re.target, re.source, seen)\n return f.starFrom.flatMap((star) => (star.target && star.target !== '?' ? namespaceParts(star.target, name, seen) : []))\n }\n\n const users = new Map<string, { app: Set<string>; stories: Set<string>; tests: Set<string> }>()\n for (const p of found) users.set(key(p.file, p.name), { app: new Set(), stories: new Set(), tests: new Set() })\n for (const f of facts.values()) {\n const bucket = (p: Found) => {\n const u = users.get(key(p.file, p.name))!\n return isStory(f.file) ? u.stories : isTest(f.file) ? u.tests : u.app\n }\n for (const link of f.links) {\n if (link.kind === 're-export' || link.typeOnly || !link.target || link.target === '?') continue\n for (const n of link.names) {\n if (n.imported === '*') {\n // `lazy(() => import('./Page'))` loads the default; a namespace may use any.\n const theDefault = link.kind === 'dynamic' ? defaultPartOf(link.target) : null\n const chosen = theDefault ? [theDefault] : everyPartOf(link.target)\n for (const p of chosen) if (p.file !== f.file) bucket(p).add(f.file)\n continue\n }\n const p = origin(link.target, n.imported)\n // A file that imports a part only to export it again hands it on; it does not use it.\n const handsOn = f.exports.some((e) => e.local === n.local && e.node === null) && !mentions(f.sf, n.local, null)\n if (handsOn) continue\n if (p) {\n if (p.file !== f.file) bucket(p).add(f.file)\n continue\n }\n // `import { Parts } from './barrel'`, where the barrel says `export * as Parts from './parts'`.\n for (const part of namespaceParts(link.target, n.imported)) if (part.file !== f.file) bucket(part).add(f.file)\n }\n }\n }\n // Its own file uses it when something there, other than its own declaration and\n // the export line, names it \u2014 a card drawn by the list beside it.\n for (const p of found) {\n if (p.from || !p.local) continue\n const f = facts.get(p.file)!\n const decl = declarationOf(f, p.local)\n const home = decl ? (ts.isVariableDeclaration(decl) ? decl.parent.parent : decl) : null\n if (mentions(f.sf, p.local, home)) users.get(key(p.file, p.name))!.app.add(p.file)\n }\n\n // \u2500\u2500 What ties each file to the app \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // A file is tied when it imports a package the package does not itself depend\n // on, something that is not code, or an app file that is tied. Types count: a\n // part typed by Peek's data is Peek's.\n const directTies = new Map<string, string[]>()\n const appDeps = new Map<string, string[]>()\n for (const f of facts.values()) {\n const ties: string[] = []\n const deps: string[] = []\n for (const link of f.links) {\n if (link.target === null) {\n const tie = link.specifier.startsWith('node:') ? link.specifier : allowed.has(packageOf(link.specifier)) ? null : packageOf(link.specifier)\n if (tie && !ties.includes(tie)) ties.push(tie)\n } else if (link.target === '?') {\n if (!ties.includes(link.specifier)) ties.push(link.specifier)\n } else if (link.target !== f.file && !deps.includes(link.target)) deps.push(link.target)\n }\n directTies.set(f.file, ties)\n appDeps.set(f.file, deps)\n }\n const tied = new Set([...directTies].filter(([, t]) => t.length > 0).map(([file]) => file))\n for (let changed = true; changed; ) {\n changed = false\n for (const [file, deps] of appDeps) if (!tied.has(file) && deps.some((d) => tied.has(d))) (tied.add(file), (changed = true))\n }\n const tiesOf = (file: string) => [...directTies.get(file)!, ...appDeps.get(file)!.filter((d) => tied.has(d))].sort()\n\n // \u2500\u2500 Stories: which one shows a part \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const stories = files.filter(isStory).map((file) => {\n const f = facts.get(file)!\n let title: string | null = null\n let component: string | null = null\n let noDocs = false\n const names: string[] = []\n for (const s of f.sf.statements) {\n if (!ts.isVariableStatement(s)) continue\n const exported = (ts.getModifiers(s) ?? []).some((m) => m.kind === ts.SyntaxKind.ExportKeyword)\n for (const d of s.declarationList.declarations) {\n if (!ts.isIdentifier(d.name)) continue\n if (d.name.text === 'meta') {\n let init = d.initializer\n while (init && (ts.isSatisfiesExpression(init) || ts.isAsExpression(init) || ts.isParenthesizedExpression(init))) init = init.expression\n if (init && ts.isObjectLiteralExpression(init)) {\n for (const prop of init.properties) {\n if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) continue\n if (prop.name.text === 'title' && ts.isStringLiteralLike(prop.initializer)) title = prop.initializer.text\n if (prop.name.text === 'component' && ts.isIdentifier(prop.initializer)) component = prop.initializer.text\n if (prop.name.text === 'tags' && ts.isArrayLiteralExpression(prop.initializer)) noDocs = prop.initializer.elements.some((e) => ts.isStringLiteralLike(e) && e.text === '!autodocs')\n }\n }\n } else if (exported) names.push(d.name.text)\n }\n }\n // Which part each local name is, through the imports.\n const imported = new Map<string, Found>()\n for (const link of f.links) {\n if (!link.target || link.target === '?') continue\n for (const n of link.names) {\n if (n.imported === '*') continue\n const p = origin(link.target, n.imported)\n if (p) imported.set(n.local, p)\n }\n }\n return { file, title, component: component ? (imported.get(component) ?? null) : null, noDocs, names, imports: [...imported.values()] }\n })\n const storyOf = (p: Found) => {\n const stem = (file: string) => basename(file).replace(/\\.stories\\.[cm]?[jt]sx?$/, '')\n const own = basename(p.file, extname(p.file))\n // A story file named after the part draws it even when its stories are of a\n // presentational half in the same file \u2014 `FilesPanel.stories.tsx` drawing\n // `FilesPanelView` is FilesPanel's picture, and its page attaches there (UIG-19).\n const sameFile = (s: (typeof stories)[number]) => s.imports.some((q) => q.file === p.file)\n const candidates = stories.filter((s) => s.title && s.names.length && (s.component === p || (s.imports.includes(p) && (stem(s.file) === p.name || stem(s.file) === own)) || (stem(s.file) === p.name && sameFile(s))))\n candidates.sort((a, b) => Number(b.component === p) - Number(a.component === p) || a.file.localeCompare(b.file))\n const s = candidates[0]\n if (!s || !s.title) return { docsId: null, storyId: null }\n return { docsId: s.noDocs ? null : `${sanitize(s.title)}--docs`, storyId: toId(s.title, s.names.includes(p.name) ? p.name : s.names[0]) }\n }\n\n // \u2500\u2500 Props, read the way the package's are \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n type Module = ReturnType<typeof readModule>\n const modules = new Map<string, Module>()\n const moduleAt = (file: string): Module => {\n const held = modules.get(file)\n if (held) return held\n const read = readModule(facts.get(file)!.source, (specifier, typeName): Resolved | undefined => {\n // A wrapper typed by the package's own props takes what the package's part\n // takes. The package names every part's props type after the part \u2014\n // `SearchInputProps` is `SearchInput`'s, all 65 of them \u2014 so its entry answers.\n if (isPackageImport(specifier)) {\n const part = typeName.endsWith('Props') ? theRegistry?.entries.find((entry) => entry.name === typeName.slice(0, -'Props'.length)) : undefined\n return part ? { props: part.props, variants: part.variants } : undefined\n }\n const target = resolveSpecifier(file, specifier)\n return target && target !== '?' ? moduleAt(target).resolveName(typeName) : undefined\n // A comment directly above a part is that part's, first in its file or not.\n }, { lendFirstComment: false })\n modules.set(file, read)\n return read\n }\n\n // \u2500\u2500 The entries \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const namesakes = new Set((theRegistry?.entries ?? []).map((e) => e.name))\n const importPathOf = (file: string) => {\n const abs = join(app, file)\n const alias = aliases.find((a) => abs.startsWith(a.target + sep))\n const stem = file.replace(/\\.[cm]?[jt]sx?$/, '').replace(/\\/index$/, '')\n return alias ? `${alias.prefix}${relative(alias.target, join(app, stem)).split(sep).join('/')}` : stem\n }\n const port = /(?:-p|--port)[\\s=]+(\\d+)/.exec(manifest.scripts?.storybook ?? '')?.[1] ?? '6006'\n\n // What each part owns, from what it draws (B9): a pass-on owns what its package\n // part owns; any other part what the whole of each part it draws does, followed\n // through the app's own parts, and what the Base UI parts it draws do.\n const packageOwns = new Map((theRegistry?.entries ?? []).map((e) => [e.name, e.ownsBehaviours.map((b) => b.id)]))\n const drawnByFile = new Map<string, { drawn: Map<string, Set<string>>; roots: Map<string, Set<string>> }>()\n const owned = new Map<string, Set<string>>()\n const ownsOf = (p: Found, seen: Set<string>): Set<string> => {\n const at = key(p.file, p.name)\n const held = owned.get(at)\n if (held) return held\n const out = new Set<string>()\n if (p.from) {\n if (isPackageImport(p.from.specifier)) for (const id of packageOwns.get(p.from.name) ?? []) out.add(id)\n return out\n }\n const f = facts.get(p.file)\n if (!f || !p.local || seen.has(at)) return out\n seen.add(at)\n if (!drawnByFile.has(p.file)) drawnByFile.set(p.file, { drawn: drawnIn(f.sf), roots: rootsIn(f.sf) })\n const { drawn, roots } = drawnByFile.get(p.file)!\n const imported = new Map(f.links.filter((l) => l.kind === 'import').flatMap((l) => l.names.map((n) => [n.local, { link: l, imported: n.imported }] as const)))\n // The Base UI parts it draws, anywhere in it (rare in an app: the gate refuses most).\n for (const tag of drawn.get(p.local) ?? []) {\n const [local, piece] = splitTag(tag)\n const from = imported.get(local)\n if (from && isBaseUi(from.link.specifier)) for (const id of baseUiBehaviours(from.imported, piece)) out.add(id)\n }\n // The parts it is: what it hands back at its root, the package's or the app's own.\n for (const tag of roots.get(p.local) ?? []) {\n const from = imported.get(splitTag(tag)[0])\n if (!from) continue\n let inner: Iterable<string> = []\n if (isPackageImport(from.link.specifier)) inner = handedOn(from.imported, packageOwns.get(from.imported) ?? [])\n else if (from.link.target && from.link.target !== '?') {\n const part = origin(from.link.target, from.imported)\n if (part) inner = handedOn(part.from?.name ?? part.name, ownsOf(part, seen))\n }\n for (const id of inner) out.add(id)\n }\n if (seen.size === 1) owned.set(at, out)\n seen.delete(at)\n return out\n }\n\n const entries: RegistryEntry[] = []\n for (const p of found) {\n const u = users.get(key(p.file, p.name))!\n const usedIn = [...u.app].sort()\n const pass = p.from\n const onePart = partsIn(p.file).filter((q) => !q.from).length === 1\n const module = pass ? null : moduleAt(p.file)\n // A default written as an expression has no name in its file: the builder keeps it as `default`.\n const declared = pass ? undefined : module!.declarations.get(p.local ?? 'default')\n const header = module?.headerDoc ?? ''\n // The file's default may carry its comment on `export default memo(Row)` rather than on Row.\n const doc = declared?.doc || (defaultPartOf(p.file) === p ? (module?.declarations.get('default')?.doc ?? '') : '')\n\n // Purpose: its page, else its own comment, else \u2014 for a file of one part \u2014\n // the file's. A pass-on says whose it is.\n const page = pass ? null : join(dirname(p.file), `${p.name}.mdx`).split(sep).join('/')\n const pageText = page && existsSync(join(app, page)) ? pageOpening(readFileSync(join(app, page), 'utf8')) : ''\n let purpose = ''\n let purposeFrom: RegistryEntry['purposeFrom'] = 'comment'\n if (pass) {\n const as = pass.name === p.name ? '' : ` as ${p.name}`\n purpose = isPackageImport(pass.specifier) ? `The package's ${pass.name}, handed on${as} so the app can import it from ${importPathOf(p.file)}.` : `${pass.name} from ${pass.specifier}, handed on${as} so the app can import it from ${importPathOf(p.file)}.`\n purposeFrom = 'package'\n } else if (firstSentence(pageText)) {\n purpose = firstSentence(pageText)\n purposeFrom = 'page'\n } else if (firstSentence(doc)) {\n purpose = firstSentence(doc)\n } else if (onePart && firstSentence(header)) {\n purpose = firstSentence(header)\n purposeFrom = 'file'\n }\n if (!purpose) {\n problems.push(`${p.name} in ${p.file} has no one-line description. Write one as a /** \u2026 */ comment directly above it${onePart ? ', or at the top of the file' : ''}.`)\n continue\n }\n\n // Its kind: written beside it, or read from the evidence.\n const writtenLine = WRITTEN.exec(doc) ?? (onePart ? WRITTEN.exec(header) : null)\n const ties = pass ? [] : tiesOf(p.file)\n let cls: EntryClass\n let reason: string\n let written = false\n if (pass) {\n cls = 're-export'\n reason = `Its file only hands on ${isPackageImport(pass.specifier) ? `the package's ${pass.name}` : `${pass.name} from ${pass.specifier}`}.`\n if (writtenLine) problems.push(`${p.name} in ${p.file} is a pass-on, so its kind is read from the file: remove \"@registry ${writtenLine[1]}\"`)\n } else if (writtenLine) {\n const said = writtenLine[1] as EntryClass\n if (!WRITABLE.includes(said)) {\n problems.push(`${p.name} in ${p.file} says \"@registry ${writtenLine[1]}\": the kinds a person may write are ${WRITABLE.join(', ')}`)\n continue\n }\n cls = said\n reason = writtenLine[2].trim()\n written = true\n } else if (usedIn.length === 0) {\n cls = 'unused'\n reason = u.stories.size ? 'No file of the app uses it; only its stories do.' : u.tests.size ? 'No file of the app uses it; only its tests do.' : 'Nothing uses it.'\n } else if (usedIn.length === 1) {\n cls = 'one-off'\n reason = `Used in one place: ${usedIn[0]}.`\n } else if (ties.length) {\n cls = 'reusable'\n reason = `Used in ${usedIn.length} places, and tied to the app by ${ties[0]}${ties.length > 1 ? ` and ${ties.length - 1} more` : ''}.`\n } else {\n cls = 'promote-candidate'\n reason = `Used in ${usedIn.length} places, and everything it uses is already in the package.`\n }\n\n const namesake = namesakes.has(p.name) && !(pass && isPackageImport(pass.specifier) && pass.name === p.name) ? p.name : null\n if (namesake && !(NAMESAKE.test(doc) || (onePart && NAMESAKE.test(header)))) {\n problems.push(`${p.name} in ${p.file} has the name of the package's ${namesake}. Use the package's, or write why this one is kept: \"@registry namesake: <reason>\" in its /** \u2026 */ comment.`)\n }\n\n const shape: Resolved = declared ? module!.resolve(declared.propsType) : { props: [], variants: [] }\n const facts_: AppFacts = {\n class: cls,\n reason,\n written,\n handsOn: pass ? (isPackageImport(pass.specifier) ? pass.name : `${pass.name} from ${pass.specifier}`) : null,\n usedIn,\n tiedTo: ties,\n packageNamesake: namesake,\n defaultExport: p.defaultExport,\n }\n const found = pass ? { docsId: null, storyId: null } : storyOf(p)\n // A part with a page of its own and no story file links to its page, by the\n // page's own title (Katerina's ruling B10, 25 September): Peek's EditedMarker.mdx\n // shows the part in other parts' stories, and nothing linked it.\n const titled = !found.docsId && pageText ? /<Meta\\s+title=[\"'`]([^\"'`]+)[\"'`]/.exec(readFileSync(join(app, page!), 'utf8'))?.[1] : undefined\n const { docsId, storyId } = titled ? { docsId: `${sanitize(titled)}--docs`, storyId: found.storyId } : found\n entries.push({\n name: p.name,\n repo: repoName,\n kind: 'component',\n importPath: importPathOf(p.file),\n sourceFile: p.file,\n purpose,\n purposeFrom,\n props: shape.props,\n variants: shape.variants,\n ownsBehaviours: asBehaviours(ownsOf(p, new Set())),\n status: declared?.deprecated ? 'deprecated' : 'stable',\n migrationStage: null,\n docsId,\n storyId,\n docPage: pageText ? page : null,\n app: facts_,\n // A part handed on from the package looks like the package's (UIG-25).\n looks: pass ? [] : (looksOf(parseForLooks(join(root, p.file), facts.get(p.file)!.source), [p.name]).get(p.name) ?? []),\n })\n }\n\n if (problems.length) throw new Error(`the catalogue of ${repoName} cannot be built:\\n ${problems.join('\\n ')}`)\n\n entries.sort((a, b) => a.name.localeCompare(b.name) || a.sourceFile.localeCompare(b.sourceFile))\n const withParts = new Set(found.map((p) => p.file))\n const filesWithoutParts: FileWithoutPart[] = targets\n .filter((file) => !withParts.has(file))\n .map((file) => {\n const f = facts.get(file)!\n const names = [...f.exports.map((e) => (e.isDefault ? (e.local ?? 'a default') : e.name)), ...f.reexports.map((r) => r.name)]\n return { file, reason: names.length ? `It exports no part, only ${names.join(', ')}.` : 'It exports nothing.' }\n })\n\n return {\n schemaVersion: SCHEMA_VERSION,\n builtFrom: {\n kind: 'app',\n repo: repoName,\n package: manifest.name ?? repoName,\n packageVersion: manifest.version ?? '0.0.0',\n exports: found.length,\n typeExports: 0,\n files: targets.length,\n },\n storybook: {\n docsPath: '/?path=/docs/{docsId}',\n storyPath: '/?path=/story/{storyId}',\n devUrl: `http://localhost:${port}`,\n },\n entries,\n excluded: [],\n filesWithoutParts,\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAS,YAAY,cAAc,aAAa,gBAAgB;AAChE,SAAS,UAAU,SAAS,SAAS,MAAM,UAAU,SAAS,WAAW;AACzE,OAAO,QAAQ;AAkBf,IAAM,WAAyB,CAAC,YAAY,WAAW,mBAAmB;AAC1E,IAAM,UAAU;AAEhB,IAAM,WAAW;AAEjB,IAAM,UAAU,CAAC,SAAiB,2BAA2B,KAAK,IAAI;AACtE,IAAM,SAAS,CAAC,SAAiB,+BAA+B,KAAK,IAAI,KAAK,4BAA4B,KAAK,IAAI;AACnH,IAAM,WAAW,CAAC,SAAiB,sBAAsB,KAAK,IAAI,KAAK,CAAC,eAAe,KAAK,IAAI;AAOhG,SAAS,WAAW,MAAgE;AAClF,QAAM,OAAO,KAAK;AAClB,QAAM,UAAU,MAAM;AACtB,MAAI,QAAQ,GAAG,2BAA2B,IAAI,KAAK,KAAK,KAAK,SA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,SAAS,OAAQ,OAAM,IAAI,MAAM,oBAAoB,QAAQ;AAAA,IAAwB,SAAS,KAAK,MAAM,CAAC,EAAE;AAEhH,UAAQ,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,KAAK,EAAE,WAAW,cAAc,EAAE,UAAU,CAAC;AAC/F,QAAM,YAAY,IAAI,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;AAClD,QAAM,oBAAuC,QAC1C,OAAO,CAAC,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC,EACrC,IAAI,CAAC,SAAS;AACb,UAAM,IAAI,MAAM,IAAI,IAAI;AACxB,UAAM,QAAQ,CAAC,GAAG,EAAE,QAAQ,IAAI,CAAC,MAAO,EAAE,YAAa,EAAE,SAAS,cAAe,EAAE,IAAK,GAAG,GAAG,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;AAC5H,WAAO,EAAE,MAAM,QAAQ,MAAM,SAAS,4BAA4B,MAAM,KAAK,IAAI,CAAC,MAAM,sBAAsB;AAAA,EAChH,CAAC;AAEH,SAAO;AAAA,IACL,eAAe;AAAA,IACf,WAAW;AAAA,MACT,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS,SAAS,QAAQ;AAAA,MAC1B,gBAAgB,SAAS,WAAW;AAAA,MACpC,SAAS,MAAM;AAAA,MACf,aAAa;AAAA,MACb,OAAO,QAAQ;AAAA,IACjB;AAAA,IACA,WAAW;AAAA,MACT,UAAU;AAAA,MACV,WAAW;AAAA,MACX,QAAQ,oBAAoB,IAAI;AAAA,IAClC;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,IACX;AAAA,EACF;AACF;",
6
+ "names": ["bindings", "p", "s", "found"]
7
+ }
@@ -260,7 +260,7 @@ function storyMapProblems(root2, { registry, real = sidebarHeadings(root2) } = {
260
260
 
261
261
  // src/registry/cli.ts
262
262
  var packageBuilder = () => import("./build-P6X3PTZP.js");
263
- var appBuilder = () => import("./app-LDGOH6UW.js");
263
+ var appBuilder = () => import("./app-X2GI4WTU.js");
264
264
  var gatedScan = () => import("./gated-5CPIUQAW.js");
265
265
  var [command, ...rest] = process.argv.slice(2);
266
266
  var VALUED = ["--limit", "--out", "--file", "--root", "--repo", "--also"];
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-4QWD3EBY.js";
18
18
  import {
19
19
  buildAppRegistry
20
- } from "./chunk-TQ6UQER3.js";
20
+ } from "./chunk-V67F474L.js";
21
21
  import {
22
22
  buildRegistry,
23
23
  readIndexExports,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.59.0",
3
+ "version": "0.60.0",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,9 +4,9 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.59.0",
8
- "exports": 133,
9
- "typeExports": 140,
7
+ "packageVersion": "0.60.0",
8
+ "exports": 134,
9
+ "typeExports": 141,
10
10
  "files": null
11
11
  },
12
12
  "storybook": {
@@ -34,6 +34,44 @@
34
34
  "app": null,
35
35
  "looks": []
36
36
  },
37
+ {
38
+ "name": "AppProvider",
39
+ "repo": "estiva-ui",
40
+ "kind": "component",
41
+ "importPath": "@estiva-app/ui",
42
+ "sourceFile": "src/AppProvider.tsx",
43
+ "purpose": "What the parts need to know about the app they are in, said once at its root: where a person's picture comes from, and how to change page without a reload.",
44
+ "purposeFrom": "page",
45
+ "props": [
46
+ {
47
+ "name": "pictureFor",
48
+ "takes": "a handler",
49
+ "required": false,
50
+ "note": "Where this app keeps a person's picture."
51
+ },
52
+ {
53
+ "name": "navigate",
54
+ "takes": "a handler",
55
+ "required": false,
56
+ "note": "How this app changes page without reloading."
57
+ },
58
+ {
59
+ "name": "children",
60
+ "takes": "anything",
61
+ "required": true,
62
+ "note": null
63
+ }
64
+ ],
65
+ "variants": [],
66
+ "ownsBehaviours": [],
67
+ "status": "stable",
68
+ "migrationStage": null,
69
+ "docsId": "frame-appprovider--docs",
70
+ "storyId": "frame-appprovider--pictures",
71
+ "docPage": "src/AppProvider.mdx",
72
+ "app": null,
73
+ "looks": []
74
+ },
37
75
  {
38
76
  "name": "AppShell",
39
77
  "repo": "estiva-ui",
@@ -65,7 +103,19 @@
65
103
  "name": "search",
66
104
  "takes": "anything",
67
105
  "required": false,
68
- "note": "The top bar's centre — a search field, when there is one."
106
+ "note": "The top bar's centre: something of the caller's own."
107
+ },
108
+ {
109
+ "name": "onSearch",
110
+ "takes": "a handler",
111
+ "required": false,
112
+ "note": "What searching opens: the top bar then draws its search field and answers Ctrl+K (`TopBar`'s `onSearch`)."
113
+ },
114
+ {
115
+ "name": "searchPlaceholder",
116
+ "takes": "text",
117
+ "required": false,
118
+ "note": "The words in the top bar's search field."
69
119
  },
70
120
  {
71
121
  "name": "identity",
@@ -301,7 +351,7 @@
301
351
  "name": "src",
302
352
  "takes": "text",
303
353
  "required": false,
304
- "note": "The picture URL, resolved by the caller."
354
+ "note": "The picture URL, resolved by the caller — or, when none is given, by the app's `AppProvider`."
305
355
  },
306
356
  {
307
357
  "name": "name",
@@ -6976,7 +7026,7 @@
6976
7026
  "kind": "component",
6977
7027
  "importPath": "@estiva-app/ui",
6978
7028
  "sourceFile": "src/TopBar.tsx",
6979
- "purpose": "The 52px top bar: `menu` and `logo` on the left, a `search` slot in the centre, the identity cluster on the right.",
7029
+ "purpose": "The 52px top bar: `menu` and `logo` on the left, the search field in the centre, the identity cluster on the right.",
6980
7030
  "purposeFrom": "page",
6981
7031
  "props": [
6982
7032
  {
@@ -7001,7 +7051,19 @@
7001
7051
  "name": "search",
7002
7052
  "takes": "anything",
7003
7053
  "required": false,
7004
- "note": "The centre: a search field, or a launcher affordance — or nothing; the slot holds its place."
7054
+ "note": "The centre: something of the caller's own."
7055
+ },
7056
+ {
7057
+ "name": "onSearch",
7058
+ "takes": "a handler",
7059
+ "required": false,
7060
+ "note": "What searching opens — the app's command launcher."
7061
+ },
7062
+ {
7063
+ "name": "searchPlaceholder",
7064
+ "takes": "text",
7065
+ "required": false,
7066
+ "note": "The words in the bar's own search field."
7005
7067
  },
7006
7068
  {
7007
7069
  "name": "right",
@@ -7026,14 +7088,30 @@
7026
7088
  ]
7027
7089
  }
7028
7090
  ],
7029
- "ownsBehaviours": [],
7091
+ "ownsBehaviours": [
7092
+ {
7093
+ "id": "base-ui",
7094
+ "behaviour": "Is built on Base UI"
7095
+ },
7096
+ {
7097
+ "id": "role",
7098
+ "behaviour": "Says what it is to assistive technology"
7099
+ },
7100
+ {
7101
+ "id": "tab-stop",
7102
+ "behaviour": "Is reachable with Tab"
7103
+ }
7104
+ ],
7030
7105
  "status": "stable",
7031
7106
  "migrationStage": null,
7032
7107
  "docsId": "frame-topbar--docs",
7033
7108
  "storyId": "frame-topbar--solid",
7034
7109
  "docPage": "src/TopBar.mdx",
7035
7110
  "app": null,
7036
- "looks": []
7111
+ "looks": [
7112
+ "cursor-pointer bg-bg-field border border-border-field shadow-field hover:border-border-strong rounded-lg transition-colors",
7113
+ "truncate text-left text-input-value text-text-muted"
7114
+ ]
7037
7115
  },
7038
7116
  {
7039
7117
  "name": "typeTrigger",
@@ -81,7 +81,8 @@ another; take them from tokens.
81
81
  which owns the keys, `busy` and focus. Clear a field's `error` when it
82
82
  changes, or the form will not send.
83
83
  11. **A link to an in-app page as a bare `href`**: every click reloads the app
84
- → go through the app's router, as `NavItem` does.
84
+ → give the app's router to `AppProvider`'s `navigate`, once at the root;
85
+ every link part then changes page in place.
85
86
  12. **Wrong loading and failure states**: an `EmptyState` while data is still
86
87
  coming, a hand-made pulsing box → a skeleton shaped like what is coming
87
88
  (`SkeletonList`, `SkeletonRow`, `SkeletonBar`). Say a failure in
@@ -0,0 +1,69 @@
1
+ import { Meta, Canvas } from '@storybook/addon-docs/blocks'
2
+ import * as AppProviderStories from './AppProvider.stories'
3
+
4
+ <Meta of={AppProviderStories} />
5
+
6
+ # AppProvider
7
+
8
+ What the parts need to know about the app they are in, said once at its root:
9
+ where a person's picture comes from, and how to change page without a reload.
10
+
11
+ <Canvas of={AppProviderStories.Pictures} />
12
+
13
+ ## When
14
+
15
+ - Every app, once, around everything it draws — beside `ToastProvider`.
16
+ - `pictureFor`: the app keeps people's pictures somewhere the package cannot
17
+ know. Every face handed no picture asks it: **Avatar**, and so **Person**,
18
+ **AvatarGroup**, **MembersPill**, **MembersDialog**, **PersonTrigger** and
19
+ **IdentityMenu**.
20
+ - `navigate`: the app changes page with a router. A plain click on a link to
21
+ the app's own address then goes through it: **Link**, **Card** and
22
+ **Breadcrumb**'s crumbs, **NavItem** and **NavTree**'s rows, **RailItem**,
23
+ **Chip**, **InlineChip**, **IconButton** and **ToolbarLink**.
24
+
25
+ <Canvas of={AppProviderStories.ChangingPage} />
26
+
27
+ ## When not
28
+
29
+ - A wrapper around a part that only looks a picture up, or only stops a
30
+ reload → this, once. Peek and Ship each kept their own Avatar, Person or
31
+ NavItem for one of these two jobs (Katerina, 8 October).
32
+ - One face with a picture you already have → pass it to **Avatar**'s `src`
33
+ or **Person**'s `picture`. A picture handed in always wins.
34
+ - One **Link** that does something other than change page → give it its own
35
+ `onClick` and `preventDefault()`; the provider leaves it alone.
36
+
37
+ ## How
38
+
39
+ ```tsx
40
+ import { AppProvider } from '@estiva-app/ui'
41
+
42
+ function Root({ children }) {
43
+ const pictureFor = usePictureLookup() // the app's own
44
+ const navigate = useNavigate() // the app's router
45
+ return (
46
+ <AppProvider pictureFor={pictureFor} navigate={navigate}>
47
+ {children}
48
+ </AppProvider>
49
+ )
50
+ }
51
+ ```
52
+
53
+ - Both are optional. A part with no provider above it draws as it always
54
+ did, which is also what a story or a test sees without one.
55
+ - `pictureFor` gets the person's name and returns an address, or nothing for
56
+ the initials.
57
+ - `navigate` gets the link's `href` exactly as written. The browser keeps
58
+ every other click: one already handled (`preventDefault`), one with Ctrl,
59
+ Cmd, Shift or Alt, the middle button, a link that opens a new tab or
60
+ downloads, and an address on another site or in another scheme
61
+ (`folder:`, `mailto:`).
62
+ - A link's own `onClick` runs first, so an app that still passes its router
63
+ click per link keeps working while it moves over.
64
+ - `active` is still the caller's: say which row is the current page where you
65
+ place it.
66
+
67
+ ## What it owns
68
+
69
+ Nothing. It draws nothing; it holds two answers for the parts below it.
@@ -0,0 +1,60 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { useState } from 'react'
3
+ import { IconFolder, IconMessage } from '@tabler/icons-react'
4
+ import { AppProvider } from './AppProvider'
5
+ import { Link } from './Link'
6
+ import { MembersPill } from './MembersPill'
7
+ import { NavItem } from './NavItem'
8
+ import { Person } from './Person'
9
+
10
+ /** One picture the app "knows": Ana's. Inline, so the story needs nothing from anywhere. */
11
+ const ANA = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect width="10" height="10" fill="%2346c08a"/><circle cx="5" cy="4" r="2" fill="%23fff"/></svg>'
12
+ const pictureFor = (name: string) => (name === 'Ana Duarte' ? ANA : undefined)
13
+
14
+ const meta = {
15
+ title: 'Frame/AppProvider',
16
+ component: AppProvider,
17
+ args: { children: null },
18
+ argTypes: { children: { control: false }, pictureFor: { control: false }, navigate: { control: false } },
19
+ } satisfies Meta<typeof AppProvider>
20
+
21
+ export default meta
22
+ type Story = StoryObj<typeof meta>
23
+
24
+ /**
25
+ * The app knows Ana's picture and nobody else's. No part below is handed a
26
+ * picture: each face asks the app, and Ravi, whom it does not know, keeps
27
+ * his initials.
28
+ */
29
+ export const Pictures: Story = {
30
+ render: () => (
31
+ <AppProvider pictureFor={pictureFor}>
32
+ <div className="flex flex-col items-start gap-3 text-body-2 text-text-primary">
33
+ <Person name="Ana Duarte" />
34
+ <Person name="Ravi Mehta" />
35
+ <MembersPill members={[{ name: 'Ana Duarte' }, { name: 'Ravi Mehta' }]} onClick={() => {}} />
36
+ </div>
37
+ </AppProvider>
38
+ ),
39
+ }
40
+
41
+ /**
42
+ * A click on a row or a link goes through the app's `navigate`, and the page
43
+ * is not loaded again. The line under them says where the last click went.
44
+ */
45
+ export const ChangingPage: Story = {
46
+ render: function ChangingPage() {
47
+ const [at, setAt] = useState('/topics')
48
+ return (
49
+ <AppProvider navigate={setAt}>
50
+ <div className="flex w-60 flex-col gap-px">
51
+ <NavItem href="/topics" label="Topics" icon={<IconMessage size={16} stroke={1.5} />} active={at === '/topics'} />
52
+ <NavItem href="/folders" label="Folders" icon={<IconFolder size={16} stroke={1.5} />} active={at === '/folders'} />
53
+ </div>
54
+ <p className="mt-3 text-body-2 text-text-secondary">
55
+ <Link href="/people" variant="underlined">People</Link> · now at <span className="font-mono">{at}</span>
56
+ </p>
57
+ </AppProvider>
58
+ )
59
+ },
60
+ }