@canonical/prism 0.0.0-stage → 0.51.0-experimental.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 (191) hide show
  1. package/README.md +357 -2
  2. package/dist/esm/index.js +22 -0
  3. package/dist/esm/lib/Card/Card.js +16 -0
  4. package/dist/esm/lib/Card/CardView.js +19 -0
  5. package/dist/esm/lib/Card/index.js +2 -0
  6. package/dist/esm/lib/Card/styles.css +68 -0
  7. package/dist/esm/lib/Card/types.js +1 -0
  8. package/dist/esm/lib/Chip/Chip.js +16 -0
  9. package/dist/esm/lib/Chip/ChipView.js +14 -0
  10. package/dist/esm/lib/Chip/index.js +2 -0
  11. package/dist/esm/lib/Chip/styles.css +11 -0
  12. package/dist/esm/lib/Chip/types.js +1 -0
  13. package/dist/esm/lib/CommandPalette/CommandPalette.js +166 -0
  14. package/dist/esm/lib/CommandPalette/ThingOptions.js +38 -0
  15. package/dist/esm/lib/CommandPalette/index.js +1 -0
  16. package/dist/esm/lib/CommandPalette/styles.css +91 -0
  17. package/dist/esm/lib/CommandPalette/types.js +1 -0
  18. package/dist/esm/lib/Fact/FactValue.js +12 -0
  19. package/dist/esm/lib/Fact/index.js +1 -0
  20. package/dist/esm/lib/Fact/types.js +1 -0
  21. package/dist/esm/lib/Navigation/Navigation.js +46 -0
  22. package/dist/esm/lib/Navigation/index.js +1 -0
  23. package/dist/esm/lib/Navigation/styles.css +44 -0
  24. package/dist/esm/lib/Navigation/types.js +1 -0
  25. package/dist/esm/lib/PageHeader/PageHeader.js +16 -0
  26. package/dist/esm/lib/PageHeader/PageHeaderView.js +18 -0
  27. package/dist/esm/lib/PageHeader/index.js +2 -0
  28. package/dist/esm/lib/PageHeader/readParents.js +19 -0
  29. package/dist/esm/lib/PageHeader/styles.css +67 -0
  30. package/dist/esm/lib/PageHeader/types.js +1 -0
  31. package/dist/esm/lib/Prism/Prism.js +14 -0
  32. package/dist/esm/lib/Prism/context.js +10 -0
  33. package/dist/esm/lib/Prism/index.js +2 -0
  34. package/dist/esm/lib/Prism/types.js +1 -0
  35. package/dist/esm/lib/Prose/Prose.js +26 -0
  36. package/dist/esm/lib/Prose/findMention.js +22 -0
  37. package/dist/esm/lib/Prose/index.js +2 -0
  38. package/dist/esm/lib/Prose/styles.css +10 -0
  39. package/dist/esm/lib/Prose/types.js +1 -0
  40. package/dist/esm/lib/Row/Row.js +16 -0
  41. package/dist/esm/lib/Row/RowView.js +18 -0
  42. package/dist/esm/lib/Row/index.js +2 -0
  43. package/dist/esm/lib/Row/styles.css +28 -0
  44. package/dist/esm/lib/Row/types.js +1 -0
  45. package/dist/esm/lib/SearchBoundary/SearchBoundary.js +37 -0
  46. package/dist/esm/lib/SearchBoundary/index.js +1 -0
  47. package/dist/esm/lib/SearchBoundary/types.js +1 -0
  48. package/dist/esm/lib/SearchPage/SearchPage.js +35 -0
  49. package/dist/esm/lib/SearchPage/index.js +1 -0
  50. package/dist/esm/lib/SearchPage/styles.css +62 -0
  51. package/dist/esm/lib/SearchPage/types.js +1 -0
  52. package/dist/esm/lib/SiteLayout/SiteLayout.js +20 -0
  53. package/dist/esm/lib/SiteLayout/index.js +1 -0
  54. package/dist/esm/lib/SiteLayout/styles.css +112 -0
  55. package/dist/esm/lib/SiteLayout/types.js +1 -0
  56. package/dist/esm/lib/ThingLink/ThingLink.js +10 -0
  57. package/dist/esm/lib/ThingLink/index.js +1 -0
  58. package/dist/esm/lib/ThingLink/types.js +1 -0
  59. package/dist/esm/lib/ThingResults/ThingList.js +11 -0
  60. package/dist/esm/lib/ThingResults/ThingResults.js +36 -0
  61. package/dist/esm/lib/ThingResults/index.js +1 -0
  62. package/dist/esm/lib/ThingResults/types.js +1 -0
  63. package/dist/esm/lib/graphql/PrismCard.js +35 -0
  64. package/dist/esm/lib/graphql/PrismChip.js +17 -0
  65. package/dist/esm/lib/graphql/PrismClasses.js +33 -0
  66. package/dist/esm/lib/graphql/PrismFact.js +17 -0
  67. package/dist/esm/lib/graphql/PrismPageHeader.js +59 -0
  68. package/dist/esm/lib/graphql/PrismRow.js +32 -0
  69. package/dist/esm/lib/graphql/__generated__/PrismCard_node.graphql.js +136 -0
  70. package/dist/esm/lib/graphql/__generated__/PrismChip_node.graphql.js +64 -0
  71. package/dist/esm/lib/graphql/__generated__/PrismClasses_node.graphql.js +92 -0
  72. package/dist/esm/lib/graphql/__generated__/PrismFact_fact.graphql.js +46 -0
  73. package/dist/esm/lib/graphql/__generated__/PrismPageHeader_node.graphql.js +237 -0
  74. package/dist/esm/lib/graphql/__generated__/PrismRow_node.graphql.js +127 -0
  75. package/dist/esm/lib/graphql/index.js +6 -0
  76. package/dist/esm/lib/lens/constants.js +2 -0
  77. package/dist/esm/lib/lens/index.js +3 -0
  78. package/dist/esm/lib/lens/isShortcutKey.js +22 -0
  79. package/dist/esm/lib/lens/readLenses.js +106 -0
  80. package/dist/esm/lib/lens/types.js +1 -0
  81. package/dist/esm/lib/projection/findNearest.js +12 -0
  82. package/dist/esm/lib/projection/index.js +5 -0
  83. package/dist/esm/lib/projection/orderClasses.js +14 -0
  84. package/dist/esm/lib/projection/readHomes.js +43 -0
  85. package/dist/esm/lib/projection/types.js +1 -0
  86. package/dist/esm/lib/projection/useProjection.js +34 -0
  87. package/dist/esm/lib/projection/withLabel.js +9 -0
  88. package/dist/esm/lib/renderPage/index.js +1 -0
  89. package/dist/esm/lib/renderPage/renderPage.js +125 -0
  90. package/dist/esm/lib/renderPage/types.js +1 -0
  91. package/dist/esm/lib/search/filterLenses.js +11 -0
  92. package/dist/esm/lib/search/index.js +3 -0
  93. package/dist/esm/lib/search/searchVariables.js +11 -0
  94. package/dist/esm/lib/search/warmSearch.js +14 -0
  95. package/dist/esm/lib/searchQuery/PrismSearchQuery.js +23 -0
  96. package/dist/esm/lib/searchQuery/__generated__/PrismSearchQuery.graphql.js +304 -0
  97. package/dist/esm/lib/searchQuery/index.js +1 -0
  98. package/dist/esm/lib/warmQuery/index.js +1 -0
  99. package/dist/esm/lib/warmQuery/warmQuery.js +43 -0
  100. package/dist/esm/server.js +6 -0
  101. package/dist/types/index.d.ts +24 -0
  102. package/dist/types/lib/Card/Card.d.ts +8 -0
  103. package/dist/types/lib/Card/CardView.d.ts +11 -0
  104. package/dist/types/lib/Card/index.d.ts +3 -0
  105. package/dist/types/lib/Card/types.d.ts +31 -0
  106. package/dist/types/lib/Chip/Chip.d.ts +8 -0
  107. package/dist/types/lib/Chip/ChipView.d.ts +9 -0
  108. package/dist/types/lib/Chip/index.d.ts +3 -0
  109. package/dist/types/lib/Chip/types.d.ts +24 -0
  110. package/dist/types/lib/CommandPalette/CommandPalette.d.ts +16 -0
  111. package/dist/types/lib/CommandPalette/ThingOptions.d.ts +7 -0
  112. package/dist/types/lib/CommandPalette/index.d.ts +2 -0
  113. package/dist/types/lib/CommandPalette/types.d.ts +45 -0
  114. package/dist/types/lib/Fact/FactValue.d.ts +7 -0
  115. package/dist/types/lib/Fact/index.d.ts +2 -0
  116. package/dist/types/lib/Fact/types.d.ts +5 -0
  117. package/dist/types/lib/Navigation/Navigation.d.ts +15 -0
  118. package/dist/types/lib/Navigation/index.d.ts +2 -0
  119. package/dist/types/lib/Navigation/types.d.ts +6 -0
  120. package/dist/types/lib/PageHeader/PageHeader.d.ts +8 -0
  121. package/dist/types/lib/PageHeader/PageHeaderView.d.ts +10 -0
  122. package/dist/types/lib/PageHeader/index.d.ts +3 -0
  123. package/dist/types/lib/PageHeader/readParents.d.ts +13 -0
  124. package/dist/types/lib/PageHeader/types.d.ts +32 -0
  125. package/dist/types/lib/Prism/Prism.d.ts +8 -0
  126. package/dist/types/lib/Prism/context.d.ts +7 -0
  127. package/dist/types/lib/Prism/index.d.ts +3 -0
  128. package/dist/types/lib/Prism/types.d.ts +67 -0
  129. package/dist/types/lib/Prose/Prose.d.ts +11 -0
  130. package/dist/types/lib/Prose/findMention.d.ts +8 -0
  131. package/dist/types/lib/Prose/index.d.ts +3 -0
  132. package/dist/types/lib/Prose/types.d.ts +7 -0
  133. package/dist/types/lib/Row/Row.d.ts +8 -0
  134. package/dist/types/lib/Row/RowView.d.ts +12 -0
  135. package/dist/types/lib/Row/index.d.ts +3 -0
  136. package/dist/types/lib/Row/types.d.ts +25 -0
  137. package/dist/types/lib/SearchBoundary/SearchBoundary.d.ts +17 -0
  138. package/dist/types/lib/SearchBoundary/index.d.ts +2 -0
  139. package/dist/types/lib/SearchBoundary/types.d.ts +22 -0
  140. package/dist/types/lib/SearchPage/SearchPage.d.ts +15 -0
  141. package/dist/types/lib/SearchPage/index.d.ts +2 -0
  142. package/dist/types/lib/SearchPage/types.d.ts +10 -0
  143. package/dist/types/lib/SiteLayout/SiteLayout.d.ts +17 -0
  144. package/dist/types/lib/SiteLayout/index.d.ts +2 -0
  145. package/dist/types/lib/SiteLayout/types.d.ts +11 -0
  146. package/dist/types/lib/ThingLink/ThingLink.d.ts +8 -0
  147. package/dist/types/lib/ThingLink/index.d.ts +2 -0
  148. package/dist/types/lib/ThingLink/types.d.ts +9 -0
  149. package/dist/types/lib/ThingResults/ThingList.d.ts +4 -0
  150. package/dist/types/lib/ThingResults/ThingResults.d.ts +16 -0
  151. package/dist/types/lib/ThingResults/index.d.ts +2 -0
  152. package/dist/types/lib/ThingResults/types.d.ts +14 -0
  153. package/dist/types/lib/graphql/PrismCard.d.ts +6 -0
  154. package/dist/types/lib/graphql/PrismChip.d.ts +3 -0
  155. package/dist/types/lib/graphql/PrismClasses.d.ts +8 -0
  156. package/dist/types/lib/graphql/PrismFact.d.ts +6 -0
  157. package/dist/types/lib/graphql/PrismPageHeader.d.ts +8 -0
  158. package/dist/types/lib/graphql/PrismRow.d.ts +6 -0
  159. package/dist/types/lib/graphql/__generated__/PrismCard_node.graphql.d.ts +38 -0
  160. package/dist/types/lib/graphql/__generated__/PrismChip_node.graphql.d.ts +23 -0
  161. package/dist/types/lib/graphql/__generated__/PrismClasses_node.graphql.d.ts +33 -0
  162. package/dist/types/lib/graphql/__generated__/PrismFact_fact.graphql.d.ts +20 -0
  163. package/dist/types/lib/graphql/__generated__/PrismPageHeader_node.graphql.d.ts +60 -0
  164. package/dist/types/lib/graphql/__generated__/PrismRow_node.graphql.d.ts +35 -0
  165. package/dist/types/lib/graphql/index.d.ts +6 -0
  166. package/dist/types/lib/lens/constants.d.ts +2 -0
  167. package/dist/types/lib/lens/index.d.ts +4 -0
  168. package/dist/types/lib/lens/isShortcutKey.d.ts +6 -0
  169. package/dist/types/lib/lens/readLenses.d.ts +27 -0
  170. package/dist/types/lib/lens/types.d.ts +48 -0
  171. package/dist/types/lib/projection/findNearest.d.ts +6 -0
  172. package/dist/types/lib/projection/index.d.ts +6 -0
  173. package/dist/types/lib/projection/orderClasses.d.ts +19 -0
  174. package/dist/types/lib/projection/readHomes.d.ts +11 -0
  175. package/dist/types/lib/projection/types.d.ts +15 -0
  176. package/dist/types/lib/projection/useProjection.d.ts +9 -0
  177. package/dist/types/lib/projection/withLabel.d.ts +8 -0
  178. package/dist/types/lib/renderPage/index.d.ts +2 -0
  179. package/dist/types/lib/renderPage/renderPage.d.ts +21 -0
  180. package/dist/types/lib/renderPage/types.d.ts +49 -0
  181. package/dist/types/lib/search/filterLenses.d.ts +6 -0
  182. package/dist/types/lib/search/index.d.ts +3 -0
  183. package/dist/types/lib/search/searchVariables.d.ts +9 -0
  184. package/dist/types/lib/search/warmSearch.d.ts +9 -0
  185. package/dist/types/lib/searchQuery/PrismSearchQuery.d.ts +8 -0
  186. package/dist/types/lib/searchQuery/__generated__/PrismSearchQuery.graphql.d.ts +26 -0
  187. package/dist/types/lib/searchQuery/index.d.ts +1 -0
  188. package/dist/types/lib/warmQuery/index.d.ts +1 -0
  189. package/dist/types/lib/warmQuery/warmQuery.d.ts +19 -0
  190. package/dist/types/server.d.ts +6 -0
  191. package/package.json +107 -4
@@ -0,0 +1,3 @@
1
+ export { default as PageHeader } from "./PageHeader.js";
2
+ export { default as PageHeaderView } from "./PageHeaderView.js";
3
+ export type * from "./types.js";
@@ -0,0 +1,13 @@
1
+ import type { PrismChip_node$key } from "../graphql/index.js";
2
+ import type { PageHeaderSlots } from "./types.js";
3
+ /** One parent, with the IRI that tells it apart. */
4
+ export interface Parent {
5
+ readonly uri: string;
6
+ readonly node: PrismChip_node$key;
7
+ }
8
+ /**
9
+ * A thing's parents, farthest first, as many as the slots carry. Parents may
10
+ * form a cycle, so the walk stops at the first thing it has already met,
11
+ * the thing itself included.
12
+ */
13
+ export default function readParents(uri: string, slots: PageHeaderSlots): readonly Parent[];
@@ -0,0 +1,32 @@
1
+ import type { ComponentProps } from "react";
2
+ import type { PrismPageHeader_node$data, PrismPageHeader_node$key } from "../graphql/index.js";
3
+ /**
4
+ * The slots a page header shows: the label, category, location, version,
5
+ * status, description and the parents, three deep.
6
+ */
7
+ export type PageHeaderSlots = PrismPageHeader_node$data["_meta"]["slots"];
8
+ type PageHeaderOwnProps = {
9
+ /**
10
+ * The thing the page shows, spread from the engine's
11
+ * `PrismPageHeader_node` fragment.
12
+ */
13
+ readonly node: PrismPageHeader_node$key;
14
+ };
15
+ export type PageHeaderProps = PageHeaderOwnProps & Omit<ComponentProps<"header">, keyof PageHeaderOwnProps>;
16
+ type PageHeaderViewOwnProps = {
17
+ /** The thing's IRI. */
18
+ readonly uri: string;
19
+ /** What the header shows. */
20
+ readonly slots: PageHeaderSlots;
21
+ /**
22
+ * The name of the route that shows the thing. The plain header does not
23
+ * link to the page it heads; an override may use it.
24
+ */
25
+ readonly home?: string;
26
+ };
27
+ /**
28
+ * The plain page header's props. `children` are drawn last, so an override
29
+ * or a page can add its own parts inside the plain header.
30
+ */
31
+ export type PageHeaderViewProps = PageHeaderViewOwnProps & Omit<ComponentProps<"header">, keyof PageHeaderViewOwnProps>;
32
+ export {};
@@ -0,0 +1,8 @@
1
+ import { type ReactElement } from "react";
2
+ import type { PrismProps } from "./types.js";
3
+ /**
4
+ * Passes the site's replacements for the four projections, and its
5
+ * component for text from the graph, to everything below it. A site that
6
+ * replaces nothing renders no provider at all.
7
+ */
8
+ export default function Prism({ overrides, Text, children, }: PrismProps): ReactElement;
@@ -0,0 +1,7 @@
1
+ import type { PrismContextValue } from "./types.js";
2
+ /**
3
+ * What is in force: no replacement and the plain text, unless a `Prism`
4
+ * provider passes its own.
5
+ */
6
+ declare const PrismContext: import("react").Context<PrismContextValue>;
7
+ export default PrismContext;
@@ -0,0 +1,3 @@
1
+ export { default as PrismContext } from "./context.js";
2
+ export { default as Prism } from "./Prism.js";
3
+ export type * from "./types.js";
@@ -0,0 +1,67 @@
1
+ import type { ComponentType, ReactNode } from "react";
2
+ import type { CardViewProps } from "../Card/types.js";
3
+ import type { ChipViewProps } from "../Chip/types.js";
4
+ import type { PrismChip_node$key } from "../graphql/index.js";
5
+ import type { PageHeaderViewProps } from "../PageHeader/types.js";
6
+ import type { RowViewProps } from "../Row/types.js";
7
+ /**
8
+ * The components that draw the things of one class, one per projection.
9
+ * Each receives the props of the plain view it replaces, and may render that
10
+ * view itself, around or beside its own parts.
11
+ */
12
+ export interface ProjectionOverride {
13
+ readonly chip?: ComponentType<ChipViewProps>;
14
+ readonly row?: ComponentType<RowViewProps>;
15
+ readonly card?: ComponentType<CardViewProps>;
16
+ readonly header?: ComponentType<PageHeaderViewProps>;
17
+ }
18
+ /** The props of each projection's plain view, by its key in an override. */
19
+ export interface ProjectionViewProps {
20
+ readonly chip: ChipViewProps;
21
+ readonly row: RowViewProps;
22
+ readonly card: CardViewProps;
23
+ readonly header: PageHeaderViewProps;
24
+ }
25
+ /**
26
+ * The site's replacements, by class: each key is a class's IRI or its
27
+ * compact name as the graph gives it (`_meta.curie`), such as `"ds:Token"`.
28
+ * A replacement applies to the class and its subclasses, unless a nearer
29
+ * class has its own for the same projection.
30
+ */
31
+ export type ProjectionOverrides = Readonly<Record<string, ProjectionOverride>>;
32
+ /** A thing a text mentions, as a site's text component receives it. */
33
+ export interface Mention {
34
+ /** The thing's IRI. */
35
+ readonly uri: string;
36
+ /** Its compact name, as the graph gives it (`_meta.curie`). */
37
+ readonly curie: string;
38
+ /** What `<Chip node={…} />` needs to draw it. */
39
+ readonly node: PrismChip_node$key;
40
+ }
41
+ /** What a site's text component receives: the text, and what it mentions. */
42
+ export interface TextProps {
43
+ /** The text, exactly as the graph holds it. */
44
+ readonly text: string;
45
+ /**
46
+ * The things the text mentions, for `findMention`: a seam nothing fills
47
+ * yet. It is always empty until the contract can say which things a text
48
+ * mentions.
49
+ */
50
+ readonly mentions: readonly Mention[];
51
+ }
52
+ export interface PrismProps {
53
+ /** The site's replacements, by class: each key's components, by projection. */
54
+ readonly overrides?: ProjectionOverrides;
55
+ /**
56
+ * The component that draws text from the graph, such as a description,
57
+ * wherever the engine shows one. Without it, text is drawn as plain
58
+ * paragraphs, with no markup read.
59
+ */
60
+ readonly Text?: ComponentType<TextProps>;
61
+ readonly children?: ReactNode;
62
+ }
63
+ /** What the `Prism` provider passes down. */
64
+ export interface PrismContextValue {
65
+ readonly overrides: ProjectionOverrides;
66
+ readonly Text: ComponentType<TextProps> | undefined;
67
+ }
@@ -0,0 +1,11 @@
1
+ import { type ReactElement } from "react";
2
+ import type { ProseProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * Text from the graph, such as a description. The site's `Text` component,
6
+ * passed to `Prism`, draws it; the engine reads no markup of its own.
7
+ * Without one, the text is drawn as plain paragraphs, parted on blank lines,
8
+ * each trimmed and otherwise as written: no markup is interpreted and no
9
+ * link is followed.
10
+ */
11
+ export default function Prose({ children, className, ...props }: ProseProps): ReactElement;
@@ -0,0 +1,8 @@
1
+ import type { Mention } from "../Prism/index.js";
2
+ /**
3
+ * The mentioned thing a link points at, by its IRI or its compact name,
4
+ * written as is or percent-encoded, as a Markdown parser hands a link's
5
+ * target over. A site's link component calls it to draw `<Chip>` for a
6
+ * thing and an ordinary link for anything else.
7
+ */
8
+ export default function findMention(mentions: readonly Mention[], href: string): Mention | undefined;
@@ -0,0 +1,3 @@
1
+ export { default as findMention } from "./findMention.js";
2
+ export { default as Prose } from "./Prose.js";
3
+ export type * from "./types.js";
@@ -0,0 +1,7 @@
1
+ import type { ComponentProps } from "react";
2
+ type ProseOwnProps = {
3
+ /** The text, exactly as the graph holds it. */
4
+ readonly children: string;
5
+ };
6
+ export type ProseProps = ProseOwnProps & Omit<ComponentProps<"div">, keyof ProseOwnProps>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ReactElement } from "react";
2
+ import type { RowProps } from "./types.js";
3
+ /**
4
+ * A thing as a row of a list, for any kind of thing: it reads the thing's
5
+ * slots and draws the site's row for the thing's nearest class, or the plain
6
+ * `RowView`.
7
+ */
8
+ export default function Row({ node, linked, ...props }: RowProps): ReactElement;
@@ -0,0 +1,12 @@
1
+ import type { ReactElement } from "react";
2
+ import type { RowViewProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * The plain row: one line of a list, with the thing's label, linked to its
6
+ * page when it has one, then its category and, when it has one, its status,
7
+ * as text: the label of the thing a status names (its compact name when the
8
+ * label has no text), or its value.
9
+ * The spaces between them are for a screen reader, which reads the row as
10
+ * one phrase; the flex layout draws the gaps.
11
+ */
12
+ export default function RowView({ uri, slots, home, className, ...props }: RowViewProps): ReactElement;
@@ -0,0 +1,3 @@
1
+ export { default as Row } from "./Row.js";
2
+ export { default as RowView } from "./RowView.js";
3
+ export type * from "./types.js";
@@ -0,0 +1,25 @@
1
+ import type { ComponentProps } from "react";
2
+ import type { PrismRow_node$data, PrismRow_node$key } from "../graphql/index.js";
3
+ /** The slots a row shows: the thing's label, category and status. */
4
+ export type RowSlots = PrismRow_node$data["_meta"]["slots"];
5
+ type RowOwnProps = {
6
+ /** The thing to draw, spread from the engine's `PrismRow_node` fragment. */
7
+ readonly node: PrismRow_node$key;
8
+ /**
9
+ * Whether the label links to the thing's page, when its class has a home
10
+ * route. Turn it off inside a control that handles the choice itself, such
11
+ * as an option of a list box.
12
+ */
13
+ readonly linked?: boolean;
14
+ };
15
+ export type RowProps = RowOwnProps & Omit<ComponentProps<"div">, keyof RowOwnProps | "children">;
16
+ type RowViewOwnProps = {
17
+ /** The thing's IRI. */
18
+ readonly uri: string;
19
+ /** What the row shows. */
20
+ readonly slots: RowSlots;
21
+ /** The name of the route that shows the thing; without it, no link. */
22
+ readonly home?: string;
23
+ };
24
+ export type RowViewProps = RowViewOwnProps & Omit<ComponentProps<"div">, keyof RowViewOwnProps | "children">;
25
+ export {};
@@ -0,0 +1,17 @@
1
+ import { Component, type ReactNode } from "react";
2
+ import type { SearchBoundaryProps, SearchBoundaryState } from "./types.js";
3
+ /**
4
+ * Keeps a failed search to the results it would have drawn: the search
5
+ * field fails, the rest of the page stays. Its children stay mounted while
6
+ * nothing fails, so the last results stay on screen while the next answer
7
+ * is on its way. A failure is remembered only for the words that failed:
8
+ * any other words try again, and so do those words once the reader has
9
+ * typed something else.
10
+ */
11
+ export default class SearchBoundary extends Component<SearchBoundaryProps, SearchBoundaryState> {
12
+ state: SearchBoundaryState;
13
+ static getDerivedStateFromError(): Partial<SearchBoundaryState>;
14
+ componentDidCatch(): void;
15
+ componentDidUpdate(previous: SearchBoundaryProps): void;
16
+ render(): ReactNode;
17
+ }
@@ -0,0 +1,2 @@
1
+ export { default as SearchBoundary } from "./SearchBoundary.js";
2
+ export type * from "./types.js";
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from "react";
2
+ export interface SearchBoundaryProps {
3
+ /** What stands in for the results when the search fails. */
4
+ readonly fallback: ReactNode;
5
+ /**
6
+ * The results, read from the graph's `search` field, given how many times
7
+ * a failed search has been tried again: passed to Relay as `fetchKey`, it
8
+ * makes Relay ask again rather than repeat the failure it remembers.
9
+ */
10
+ readonly children: (attempt: number) => ReactNode;
11
+ /** The words searched for: new words try again after a failure. */
12
+ readonly text: string;
13
+ }
14
+ export interface SearchBoundaryState {
15
+ /**
16
+ * The words whose search failed: `null` between the failure and the
17
+ * moment they are recorded, `undefined` when nothing failed.
18
+ */
19
+ readonly failedText: string | null | undefined;
20
+ /** How many times a failed search has been tried again. */
21
+ readonly attempt: number;
22
+ }
@@ -0,0 +1,15 @@
1
+ import { type ReactElement } from "react";
2
+ import type { SearchPageProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * The search page: what the command palette does, at its own address, for a
6
+ * reader without scripts. It reads the query from the address's `q`, and its
7
+ * form sends a new one there with a plain GET, so it works the same rendered
8
+ * on the server or in the browser.
9
+ *
10
+ * With `graph`, it also lists the things the graph's `search` field finds,
11
+ * each drawn as a `Row`; the search route's `warm` fetches them with
12
+ * `warmSearch`, so the server renders them. A failed search says so and
13
+ * leaves the rest of the page.
14
+ */
15
+ export default function SearchPage({ className, graph, }: SearchPageProps): ReactElement;
@@ -0,0 +1,2 @@
1
+ export { default as SearchPage } from "./SearchPage.js";
2
+ export type * from "./types.js";
@@ -0,0 +1,10 @@
1
+ export interface SearchPageProps {
2
+ /** Extra classes for the page's `<section>`. */
3
+ readonly className?: string;
4
+ /**
5
+ * Whether the page also finds things in the graph, through its `search`
6
+ * field, drawn as rows. Leave it off for a graph that does not serve that
7
+ * field.
8
+ */
9
+ readonly graph?: boolean;
10
+ }
@@ -0,0 +1,17 @@
1
+ import type { ReactElement } from "react";
2
+ import type { SiteLayoutProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * The frame of a Prism site: the navigation in a column of its own, off the
6
+ * grid at a fixed width, and the page on the intrinsic grid beside it. Put it
7
+ * in a router wrapper shared by the site's routes, so it stays mounted while
8
+ * the reader moves between pages; on a small screen the navigation moves
9
+ * above the page.
10
+ *
11
+ * The page region is a `.grid.intrinsic` from `@canonical/styles`, with one
12
+ * correction: below the width of four 100px columns the minimum gives way, so
13
+ * a phone still gets four columns and never scrolls sideways. Each child of
14
+ * the page region takes a whole row; a page lays out its own parts on the
15
+ * grid with spans of 2, 4 or 8 columns.
16
+ */
17
+ export default function SiteLayout({ navigation, header, children, className, }: SiteLayoutProps): ReactElement;
@@ -0,0 +1,2 @@
1
+ export { default as SiteLayout } from "./SiteLayout.js";
2
+ export type * from "./types.js";
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from "react";
2
+ export interface SiteLayoutProps {
3
+ /** The navigation column: the site's name, its lenses and its utilities. */
4
+ readonly navigation: ReactNode;
5
+ /** A band above the page that stays in place while the page scrolls. */
6
+ readonly header?: ReactNode;
7
+ /** The page. */
8
+ readonly children?: ReactNode;
9
+ /** Extra classes for the frame, such as the site's own tokens. */
10
+ readonly className?: string;
11
+ }
@@ -0,0 +1,8 @@
1
+ import type { ReactElement } from "react";
2
+ import type { ThingLinkProps } from "./types.js";
3
+ /**
4
+ * A link to a thing's page: its home route, with its IRI as `uri`. A home
5
+ * route's name is read from the route table at run time, so the router's
6
+ * types cannot check it or its params.
7
+ */
8
+ export default function ThingLink({ home, uri, ...props }: ThingLinkProps): ReactElement;
@@ -0,0 +1,2 @@
1
+ export { default as ThingLink } from "./ThingLink.js";
2
+ export type * from "./types.js";
@@ -0,0 +1,9 @@
1
+ import type { ComponentProps } from "react";
2
+ type ThingLinkOwnProps = {
3
+ /** The name of the thing's home route. */
4
+ readonly home: string;
5
+ /** The thing's IRI. */
6
+ readonly uri: string;
7
+ };
8
+ export type ThingLinkProps = ThingLinkOwnProps & Omit<ComponentProps<"a">, keyof ThingLinkOwnProps | "href">;
9
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { ReactElement } from "react";
2
+ import type { ThingListProps } from "./types.js";
3
+ /** The things matching a query, each drawn as a row in a list, under a count. */
4
+ export default function ThingList({ variables, query, fetchPolicy, fetchKey, }: ThingListProps): ReactElement;
@@ -0,0 +1,16 @@
1
+ import { type ReactElement } from "react";
2
+ import type { ThingResultsProps } from "./types.js";
3
+ /**
4
+ * The things the graph's search finds, on the search page.
5
+ *
6
+ * On the server, error boundaries do not run and a fetch during the render
7
+ * would ask the graph a second time, in the middle of the stream: so the
8
+ * list renders only from what the search route's `warm` put in the store,
9
+ * read without fetching, and the page says the search is unavailable when
10
+ * the store does not have it. The browser's hydration pass makes the same
11
+ * choice from the records the server sent, so the markup matches; once
12
+ * hydrated, the list fetches what the server did not have, says
13
+ * "Searching…" meanwhile, and says the search is unavailable when it fails.
14
+ * Both sides render the same boundary and suspense around it.
15
+ */
16
+ export default function ThingResults({ variables, query, }: ThingResultsProps): ReactElement;
@@ -0,0 +1,2 @@
1
+ export { default as ThingResults } from "./ThingResults.js";
2
+ export type * from "./types.js";
@@ -0,0 +1,14 @@
1
+ import type { FetchPolicy } from "relay-runtime";
2
+ import type { PrismSearchQuery } from "../searchQuery/index.js";
3
+ export interface ThingResultsProps {
4
+ /** The search query's variables, from `searchVariables`. */
5
+ readonly variables: PrismSearchQuery["variables"];
6
+ /** What the reader typed, as the count quotes it. */
7
+ readonly query: string;
8
+ }
9
+ export interface ThingListProps extends ThingResultsProps {
10
+ /** Relay's fetch policy: `store-only` on the server, which never fetches. */
11
+ readonly fetchPolicy?: FetchPolicy;
12
+ /** Changes when a failed search is tried again, so Relay asks again. */
13
+ readonly fetchKey?: number;
14
+ }
@@ -0,0 +1,6 @@
1
+ export type { PrismCard_node$data, PrismCard_node$key, } from "./__generated__/PrismCard_node.graphql.js";
2
+ /**
3
+ * What a card reads: every slot but the parent, with the default three
4
+ * facts.
5
+ */
6
+ export declare const prismCardFragment: import("relay-runtime").ReaderFragment;
@@ -0,0 +1,3 @@
1
+ export type { PrismChip_node$data, PrismChip_node$key, } from "./__generated__/PrismChip_node.graphql.js";
2
+ /** What a chip reads: the thing's label. */
3
+ export declare const prismChipFragment: import("relay-runtime").ReaderFragment;
@@ -0,0 +1,8 @@
1
+ export type { PrismClasses_node$key } from "./__generated__/PrismClasses_node.graphql.js";
2
+ /**
3
+ * A thing's identity, its class and every ancestor of that class, each with
4
+ * how many ancestors it has in turn, from which the engine orders them
5
+ * nearest first. An override and a home route are each looked up along that
6
+ * order.
7
+ */
8
+ export declare const prismClassesFragment: import("relay-runtime").ReaderFragment;
@@ -0,0 +1,6 @@
1
+ export type { PrismFact_fact$key } from "./__generated__/PrismFact_fact.graphql.js";
2
+ /**
3
+ * One value a thing shows: its property's name, its display value, and the
4
+ * thing it names, drawn as a chip, when it names one.
5
+ */
6
+ export declare const prismFactFragment: import("relay-runtime").ReaderFragment;
@@ -0,0 +1,8 @@
1
+ export type { PrismPageHeader_node$data, PrismPageHeader_node$key, } from "./__generated__/PrismPageHeader_node.graphql.js";
2
+ /**
3
+ * What a page header reads: the label, category, location, version, status
4
+ * and description, and the thing's parents three deep. Parents may form a
5
+ * cycle, so the walk stops at a fixed depth, and the header stops earlier at
6
+ * the first thing it has already shown.
7
+ */
8
+ export declare const prismPageHeaderFragment: import("relay-runtime").ReaderFragment;
@@ -0,0 +1,6 @@
1
+ export type { PrismRow_node$data, PrismRow_node$key, } from "./__generated__/PrismRow_node.graphql.js";
2
+ /**
3
+ * What a row reads: the thing's label, category and status, with the label
4
+ * of the thing a status names, since a row draws its status as text.
5
+ */
6
+ export declare const prismRowFragment: import("relay-runtime").ReaderFragment;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @generated SignedSource<<65c9e3c2563d8e6b98cf203766dd9d2e>>
3
+ * @lightSyntaxTransform
4
+ */
5
+ import type { ReaderFragment } from 'relay-runtime';
6
+ import type { FragmentRefs } from "relay-runtime";
7
+ export type PrismCard_node$data = {
8
+ readonly _meta: {
9
+ readonly curie: string;
10
+ readonly slots: {
11
+ readonly category: string;
12
+ readonly description: string | null | undefined;
13
+ readonly facts: ReadonlyArray<{
14
+ readonly name: string;
15
+ readonly " $fragmentSpreads": FragmentRefs<"PrismFact_fact">;
16
+ }>;
17
+ readonly label: string;
18
+ readonly location: {
19
+ readonly " $fragmentSpreads": FragmentRefs<"PrismFact_fact">;
20
+ } | null | undefined;
21
+ readonly status: {
22
+ readonly " $fragmentSpreads": FragmentRefs<"PrismFact_fact">;
23
+ } | null | undefined;
24
+ readonly version: {
25
+ readonly " $fragmentSpreads": FragmentRefs<"PrismFact_fact">;
26
+ } | null | undefined;
27
+ };
28
+ };
29
+ readonly uri: string;
30
+ readonly " $fragmentSpreads": FragmentRefs<"PrismClasses_node">;
31
+ readonly " $fragmentType": "PrismCard_node";
32
+ };
33
+ export type PrismCard_node$key = {
34
+ readonly " $data"?: PrismCard_node$data;
35
+ readonly " $fragmentSpreads": FragmentRefs<"PrismCard_node">;
36
+ };
37
+ declare const node: ReaderFragment;
38
+ export default node;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @generated SignedSource<<0a05cc508b4759306d0ef1276f9f1e13>>
3
+ * @lightSyntaxTransform
4
+ */
5
+ import type { ReaderFragment } from 'relay-runtime';
6
+ import type { FragmentRefs } from "relay-runtime";
7
+ export type PrismChip_node$data = {
8
+ readonly _meta: {
9
+ readonly curie: string;
10
+ readonly slots: {
11
+ readonly label: string;
12
+ };
13
+ };
14
+ readonly uri: string;
15
+ readonly " $fragmentSpreads": FragmentRefs<"PrismClasses_node">;
16
+ readonly " $fragmentType": "PrismChip_node";
17
+ };
18
+ export type PrismChip_node$key = {
19
+ readonly " $data"?: PrismChip_node$data;
20
+ readonly " $fragmentSpreads": FragmentRefs<"PrismChip_node">;
21
+ };
22
+ declare const node: ReaderFragment;
23
+ export default node;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @generated SignedSource<<5022d3e987340c13bf81963b874b19bf>>
3
+ * @lightSyntaxTransform
4
+ */
5
+ import type { ReaderFragment } from 'relay-runtime';
6
+ import type { FragmentRefs } from "relay-runtime";
7
+ export type PrismClasses_node$data = {
8
+ readonly _meta: {
9
+ readonly type: {
10
+ readonly _meta: {
11
+ readonly curie: string;
12
+ };
13
+ readonly superclasses: ReadonlyArray<{
14
+ readonly _meta: {
15
+ readonly curie: string;
16
+ };
17
+ readonly superclasses: ReadonlyArray<{
18
+ readonly uri: string;
19
+ }>;
20
+ readonly uri: string;
21
+ }>;
22
+ readonly uri: string;
23
+ };
24
+ };
25
+ readonly uri: string;
26
+ readonly " $fragmentType": "PrismClasses_node";
27
+ };
28
+ export type PrismClasses_node$key = {
29
+ readonly " $data"?: PrismClasses_node$data;
30
+ readonly " $fragmentSpreads": FragmentRefs<"PrismClasses_node">;
31
+ };
32
+ declare const node: ReaderFragment;
33
+ export default node;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @generated SignedSource<<8ed6a70fd0e71b977c218d4c46346028>>
3
+ * @lightSyntaxTransform
4
+ */
5
+ import type { ReaderFragment } from 'relay-runtime';
6
+ import type { FragmentRefs } from "relay-runtime";
7
+ export type PrismFact_fact$data = {
8
+ readonly name: string;
9
+ readonly node: {
10
+ readonly " $fragmentSpreads": FragmentRefs<"PrismChip_node">;
11
+ } | null | undefined;
12
+ readonly value: string;
13
+ readonly " $fragmentType": "PrismFact_fact";
14
+ };
15
+ export type PrismFact_fact$key = {
16
+ readonly " $data"?: PrismFact_fact$data;
17
+ readonly " $fragmentSpreads": FragmentRefs<"PrismFact_fact">;
18
+ };
19
+ declare const node: ReaderFragment;
20
+ export default node;