@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,304 @@
1
+ /**
2
+ * @generated SignedSource<<dd76cf01ae66340bd32b6e085e5dfd47>>
3
+ * @lightSyntaxTransform
4
+ */
5
+ const node = (function () {
6
+ var v0 = {
7
+ "defaultValue": null,
8
+ "kind": "LocalArgument",
9
+ "name": "first"
10
+ }, v1 = {
11
+ "defaultValue": null,
12
+ "kind": "LocalArgument",
13
+ "name": "text"
14
+ }, v2 = [
15
+ {
16
+ "kind": "Variable",
17
+ "name": "first",
18
+ "variableName": "first"
19
+ },
20
+ {
21
+ "kind": "Variable",
22
+ "name": "text",
23
+ "variableName": "text"
24
+ }
25
+ ], v3 = {
26
+ "alias": null,
27
+ "args": null,
28
+ "kind": "ScalarField",
29
+ "name": "uri",
30
+ "storageKey": null
31
+ }, v4 = {
32
+ "alias": null,
33
+ "args": null,
34
+ "kind": "ScalarField",
35
+ "name": "__typename",
36
+ "storageKey": null
37
+ }, v5 = {
38
+ "alias": null,
39
+ "args": null,
40
+ "kind": "ScalarField",
41
+ "name": "curie",
42
+ "storageKey": null
43
+ }, v6 = {
44
+ "alias": null,
45
+ "args": null,
46
+ "concreteType": "EntityMeta",
47
+ "kind": "LinkedField",
48
+ "name": "_meta",
49
+ "plural": false,
50
+ "selections": [
51
+ (v5 /*:: as any*/)
52
+ ],
53
+ "storageKey": null
54
+ }, v7 = {
55
+ "alias": null,
56
+ "args": null,
57
+ "kind": "ScalarField",
58
+ "name": "label",
59
+ "storageKey": null
60
+ };
61
+ return {
62
+ "fragment": {
63
+ "argumentDefinitions": [
64
+ (v0 /*:: as any*/),
65
+ (v1 /*:: as any*/)
66
+ ],
67
+ "kind": "Fragment",
68
+ "metadata": null,
69
+ "name": "PrismSearchQuery",
70
+ "selections": [
71
+ {
72
+ "alias": null,
73
+ "args": (v2 /*:: as any*/),
74
+ "concreteType": "NodeConnection",
75
+ "kind": "LinkedField",
76
+ "name": "search",
77
+ "plural": false,
78
+ "selections": [
79
+ {
80
+ "alias": null,
81
+ "args": null,
82
+ "concreteType": "NodeEdge",
83
+ "kind": "LinkedField",
84
+ "name": "edges",
85
+ "plural": true,
86
+ "selections": [
87
+ {
88
+ "alias": null,
89
+ "args": null,
90
+ "concreteType": null,
91
+ "kind": "LinkedField",
92
+ "name": "node",
93
+ "plural": false,
94
+ "selections": [
95
+ (v3 /*:: as any*/),
96
+ {
97
+ "args": null,
98
+ "kind": "FragmentSpread",
99
+ "name": "PrismClasses_node"
100
+ },
101
+ {
102
+ "args": null,
103
+ "kind": "FragmentSpread",
104
+ "name": "PrismRow_node"
105
+ }
106
+ ],
107
+ "storageKey": null
108
+ }
109
+ ],
110
+ "storageKey": null
111
+ }
112
+ ],
113
+ "storageKey": null
114
+ }
115
+ ],
116
+ "type": "Query",
117
+ "abstractKey": null
118
+ },
119
+ "kind": "Request",
120
+ "operation": {
121
+ "argumentDefinitions": [
122
+ (v1 /*:: as any*/),
123
+ (v0 /*:: as any*/)
124
+ ],
125
+ "kind": "Operation",
126
+ "name": "PrismSearchQuery",
127
+ "selections": [
128
+ {
129
+ "alias": null,
130
+ "args": (v2 /*:: as any*/),
131
+ "concreteType": "NodeConnection",
132
+ "kind": "LinkedField",
133
+ "name": "search",
134
+ "plural": false,
135
+ "selections": [
136
+ {
137
+ "alias": null,
138
+ "args": null,
139
+ "concreteType": "NodeEdge",
140
+ "kind": "LinkedField",
141
+ "name": "edges",
142
+ "plural": true,
143
+ "selections": [
144
+ {
145
+ "alias": null,
146
+ "args": null,
147
+ "concreteType": null,
148
+ "kind": "LinkedField",
149
+ "name": "node",
150
+ "plural": false,
151
+ "selections": [
152
+ (v4 /*:: as any*/),
153
+ (v3 /*:: as any*/),
154
+ {
155
+ "kind": "TypeDiscriminator",
156
+ "abstractKey": "__isNode"
157
+ },
158
+ {
159
+ "alias": null,
160
+ "args": null,
161
+ "concreteType": "EntityMeta",
162
+ "kind": "LinkedField",
163
+ "name": "_meta",
164
+ "plural": false,
165
+ "selections": [
166
+ {
167
+ "alias": null,
168
+ "args": null,
169
+ "concreteType": "OntologyClass",
170
+ "kind": "LinkedField",
171
+ "name": "type",
172
+ "plural": false,
173
+ "selections": [
174
+ (v3 /*:: as any*/),
175
+ (v6 /*:: as any*/),
176
+ {
177
+ "alias": null,
178
+ "args": null,
179
+ "concreteType": "OntologyClass",
180
+ "kind": "LinkedField",
181
+ "name": "superclasses",
182
+ "plural": true,
183
+ "selections": [
184
+ (v3 /*:: as any*/),
185
+ (v6 /*:: as any*/),
186
+ {
187
+ "alias": null,
188
+ "args": null,
189
+ "concreteType": "OntologyClass",
190
+ "kind": "LinkedField",
191
+ "name": "superclasses",
192
+ "plural": true,
193
+ "selections": [
194
+ (v3 /*:: as any*/)
195
+ ],
196
+ "storageKey": null
197
+ }
198
+ ],
199
+ "storageKey": null
200
+ }
201
+ ],
202
+ "storageKey": null
203
+ },
204
+ (v5 /*:: as any*/),
205
+ {
206
+ "alias": null,
207
+ "args": null,
208
+ "concreteType": "EntitySlots",
209
+ "kind": "LinkedField",
210
+ "name": "slots",
211
+ "plural": false,
212
+ "selections": [
213
+ (v7 /*:: as any*/),
214
+ {
215
+ "alias": null,
216
+ "args": null,
217
+ "kind": "ScalarField",
218
+ "name": "category",
219
+ "storageKey": null
220
+ },
221
+ {
222
+ "alias": null,
223
+ "args": null,
224
+ "concreteType": "EntityFact",
225
+ "kind": "LinkedField",
226
+ "name": "status",
227
+ "plural": false,
228
+ "selections": [
229
+ {
230
+ "alias": null,
231
+ "args": null,
232
+ "kind": "ScalarField",
233
+ "name": "value",
234
+ "storageKey": null
235
+ },
236
+ {
237
+ "alias": null,
238
+ "args": null,
239
+ "concreteType": null,
240
+ "kind": "LinkedField",
241
+ "name": "node",
242
+ "plural": false,
243
+ "selections": [
244
+ (v4 /*:: as any*/),
245
+ {
246
+ "alias": null,
247
+ "args": null,
248
+ "concreteType": "EntityMeta",
249
+ "kind": "LinkedField",
250
+ "name": "_meta",
251
+ "plural": false,
252
+ "selections": [
253
+ (v5 /*:: as any*/),
254
+ {
255
+ "alias": null,
256
+ "args": null,
257
+ "concreteType": "EntitySlots",
258
+ "kind": "LinkedField",
259
+ "name": "slots",
260
+ "plural": false,
261
+ "selections": [
262
+ (v7 /*:: as any*/)
263
+ ],
264
+ "storageKey": null
265
+ }
266
+ ],
267
+ "storageKey": null
268
+ },
269
+ (v3 /*:: as any*/)
270
+ ],
271
+ "storageKey": null
272
+ }
273
+ ],
274
+ "storageKey": null
275
+ }
276
+ ],
277
+ "storageKey": null
278
+ }
279
+ ],
280
+ "storageKey": null
281
+ }
282
+ ],
283
+ "storageKey": null
284
+ }
285
+ ],
286
+ "storageKey": null
287
+ }
288
+ ],
289
+ "storageKey": null
290
+ }
291
+ ]
292
+ },
293
+ "params": {
294
+ "cacheID": "f93866c23332dd6707cdcda28a5e2161",
295
+ "id": null,
296
+ "metadata": {},
297
+ "name": "PrismSearchQuery",
298
+ "operationKind": "query",
299
+ "text": "query PrismSearchQuery(\n $text: String!\n $first: Int!\n) {\n search(text: $text, first: $first) {\n edges {\n node {\n __typename\n uri\n ...PrismClasses_node\n ...PrismRow_node\n }\n }\n }\n}\n\nfragment PrismClasses_node on Node {\n __isNode: __typename\n uri\n _meta {\n type {\n uri\n _meta {\n curie\n }\n superclasses {\n uri\n _meta {\n curie\n }\n superclasses {\n uri\n }\n }\n }\n }\n}\n\nfragment PrismRow_node on Node {\n __isNode: __typename\n uri\n ...PrismClasses_node\n _meta {\n curie\n slots {\n label\n category\n status {\n value\n node {\n __typename\n _meta {\n curie\n slots {\n label\n }\n }\n uri\n }\n }\n }\n }\n}\n"
300
+ }
301
+ };
302
+ })();
303
+ node.hash = "c9abf7c8fe06791028a5840ff9d66800";
304
+ export default node;
@@ -0,0 +1 @@
1
+ export * from "./PrismSearchQuery.js";
@@ -0,0 +1 @@
1
+ export { default as warmQuery } from "./warmQuery.js";
@@ -0,0 +1,43 @@
1
+ import { createOperationDescriptor, fetchQuery, getRequest, } from "relay-runtime";
2
+ /**
3
+ * Fetch a query into a Relay environment ahead of the page that reads it:
4
+ * the body of a route's `warm`. It does nothing when the environment's store
5
+ * already holds the answer.
6
+ *
7
+ * @param environment - The environment the page reads from; a route's `warm`
8
+ * receives it in the router's `context`.
9
+ * @param query - The compiled query.
10
+ * @param variables - The query's variables.
11
+ * @param options.signal - Stops the fetch: a route's `warm` passes the
12
+ * navigation's signal.
13
+ * @returns A promise that settles when the answer is in the store, or at once
14
+ * when the signal aborts; it rejects when the query fails. The server waits
15
+ * for it before rendering; navigation in the browser does not.
16
+ */
17
+ export default function warmQuery(environment, query, variables, { signal } = {}) {
18
+ const operation = createOperationDescriptor(getRequest(query), variables);
19
+ if (signal?.aborted || environment.check(operation).status === "available") {
20
+ return Promise.resolve();
21
+ }
22
+ return new Promise((resolve, reject) => {
23
+ let subscription;
24
+ const stop = () => {
25
+ subscription?.unsubscribe();
26
+ resolve();
27
+ };
28
+ const settle = () => {
29
+ signal?.removeEventListener("abort", stop);
30
+ };
31
+ signal?.addEventListener("abort", stop, { once: true });
32
+ subscription = fetchQuery(environment, query, variables).subscribe({
33
+ complete: () => {
34
+ settle();
35
+ resolve();
36
+ },
37
+ error: (error) => {
38
+ settle();
39
+ reject(error);
40
+ },
41
+ });
42
+ });
43
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @canonical/prism/server — the one server step of a Prism site.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { renderPage, } from "./lib/renderPage/index.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @canonical/prism — the site engine of Prism: a site's navigation, layout,
3
+ * command palette and search page, read from the site's own route table; the
4
+ * four projections that draw any thing of the graph from its slots, and the
5
+ * provider through which a site replaces them, or the component that draws
6
+ * text from the graph; and the helpers its routes fetch their data with.
7
+ * The server step is at `@canonical/prism/server`.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { Card, type CardProps, CardView, type CardViewProps, } from "./lib/Card/index.js";
12
+ export { Chip, type ChipProps, ChipView, type ChipViewProps, } from "./lib/Chip/index.js";
13
+ export { CommandPalette, type CommandPaletteProps, } from "./lib/CommandPalette/index.js";
14
+ export type { Lens, PrismRouteMeta } from "./lib/lens/index.js";
15
+ export { Navigation, type NavigationProps } from "./lib/Navigation/index.js";
16
+ export { PageHeader, type PageHeaderProps, PageHeaderView, type PageHeaderViewProps, } from "./lib/PageHeader/index.js";
17
+ export { type Mention, Prism, type PrismProps, type ProjectionOverrides, type TextProps, } from "./lib/Prism/index.js";
18
+ export { findMention, Prose, type ProseProps } from "./lib/Prose/index.js";
19
+ export { Row, type RowProps, RowView, type RowViewProps, } from "./lib/Row/index.js";
20
+ export type { PageData, ShellProps } from "./lib/renderPage/index.js";
21
+ export { SearchPage, type SearchPageProps } from "./lib/SearchPage/index.js";
22
+ export { SiteLayout, type SiteLayoutProps } from "./lib/SiteLayout/index.js";
23
+ export { warmSearch } from "./lib/search/index.js";
24
+ export { warmQuery } from "./lib/warmQuery/index.js";
@@ -0,0 +1,8 @@
1
+ import type { ReactElement } from "react";
2
+ import type { CardProps } from "./types.js";
3
+ /**
4
+ * A thing as a card, for any kind of thing: it reads the thing's slots and
5
+ * draws the site's card for the thing's nearest class, or the plain
6
+ * `CardView`.
7
+ */
8
+ export default function Card({ node, linked, ...props }: CardProps): ReactElement;
@@ -0,0 +1,11 @@
1
+ import type { ReactElement } from "react";
2
+ import type { CardViewProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * The plain card, in the design system's card: the thing's label, linked to
6
+ * its page when it has one, its category and location, then its
7
+ * description, and its version, status and facts as a list of terms. A slot
8
+ * the thing does not have takes no room. `children` follow the facts, for an
9
+ * override that adds its own parts.
10
+ */
11
+ export default function CardView({ uri, slots, home, className, children, ...props }: CardViewProps): ReactElement;
@@ -0,0 +1,3 @@
1
+ export { default as Card } from "./Card.js";
2
+ export { default as CardView } from "./CardView.js";
3
+ export type * from "./types.js";
@@ -0,0 +1,31 @@
1
+ import type { ComponentProps } from "react";
2
+ import type { PrismCard_node$data, PrismCard_node$key } from "../graphql/index.js";
3
+ /**
4
+ * The slots a card shows: the label, category, location, version, status,
5
+ * description and the first three facts.
6
+ */
7
+ export type CardSlots = PrismCard_node$data["_meta"]["slots"];
8
+ type CardOwnProps = {
9
+ /** The thing to draw, spread from the engine's `PrismCard_node` fragment. */
10
+ readonly node: PrismCard_node$key;
11
+ /**
12
+ * Whether the label links to the thing's page, when its class has a home
13
+ * route.
14
+ */
15
+ readonly linked?: boolean;
16
+ };
17
+ export type CardProps = CardOwnProps & Omit<ComponentProps<"div">, keyof CardOwnProps>;
18
+ type CardViewOwnProps = {
19
+ /** The thing's IRI. */
20
+ readonly uri: string;
21
+ /** What the card shows. */
22
+ readonly slots: CardSlots;
23
+ /** The name of the route that shows the thing; without it, no link. */
24
+ readonly home?: string;
25
+ };
26
+ /**
27
+ * The plain card's props. `children` are drawn after the facts, so an
28
+ * override can add its own parts inside the plain card.
29
+ */
30
+ export type CardViewProps = CardViewOwnProps & Omit<ComponentProps<"div">, keyof CardViewOwnProps>;
31
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { ReactElement } from "react";
2
+ import type { ChipProps } from "./types.js";
3
+ /**
4
+ * A thing as a chip, for any kind of thing: it reads the thing's slots and
5
+ * draws the site's chip for the thing's nearest class, or the plain
6
+ * `ChipView`.
7
+ */
8
+ export default function Chip({ node, linked, ...props }: ChipProps): ReactElement;
@@ -0,0 +1,9 @@
1
+ import type { ReactElement } from "react";
2
+ import type { ChipViewProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * The plain chip: the thing's own label, in the design system's chip, inline
6
+ * in a sentence or alone. It links to the thing's page when it has one. An
7
+ * override for a class may render it with its own parts around it.
8
+ */
9
+ export default function ChipView({ uri, slots, home, className, ...props }: ChipViewProps): ReactElement;
@@ -0,0 +1,3 @@
1
+ export { default as Chip } from "./Chip.js";
2
+ export { default as ChipView } from "./ChipView.js";
3
+ export type * from "./types.js";
@@ -0,0 +1,24 @@
1
+ import type { ComponentProps } from "react";
2
+ import type { PrismChip_node$data, PrismChip_node$key } from "../graphql/index.js";
3
+ /** The slots a chip shows: the thing's label. */
4
+ export type ChipSlots = PrismChip_node$data["_meta"]["slots"];
5
+ type ChipOwnProps = {
6
+ /** The thing to draw, spread from the engine's `PrismChip_node` fragment. */
7
+ readonly node: PrismChip_node$key;
8
+ /**
9
+ * Whether the chip 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.
11
+ */
12
+ readonly linked?: boolean;
13
+ };
14
+ export type ChipProps = ChipOwnProps & Omit<ComponentProps<"span">, keyof ChipOwnProps | "children">;
15
+ type ChipViewOwnProps = {
16
+ /** The thing's IRI. */
17
+ readonly uri: string;
18
+ /** What the chip shows. */
19
+ readonly slots: ChipSlots;
20
+ /** The name of the route that shows the thing; without it, no link. */
21
+ readonly home?: string;
22
+ };
23
+ export type ChipViewProps = ChipViewOwnProps & Omit<ComponentProps<"span">, keyof ChipViewOwnProps | "children">;
24
+ export {};
@@ -0,0 +1,16 @@
1
+ import { type ReactElement } from "react";
2
+ import type { CommandPaletteProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * A link to the search page that, with scripts, opens a native modal
6
+ * `<dialog>` instead: one combobox whose list holds the lenses matching what
7
+ * the reader types. Arrow keys move through the list, Enter opens the chosen
8
+ * lens, or the search page when none is chosen, and Escape closes the
9
+ * dialog, returning focus to the link. `/` opens it from anywhere, unless
10
+ * the reader has turned shortcuts off.
11
+ *
12
+ * With `graph`, the list also holds the things the graph's `search` field
13
+ * finds, as a second group after the lenses, each drawn as a `Row`;
14
+ * choosing one opens its page. A failed search lists no things.
15
+ */
16
+ export default function CommandPalette({ search, className, graph, }: CommandPaletteProps): ReactElement;
@@ -0,0 +1,7 @@
1
+ import { type ReactElement } from "react";
2
+ import type { ThingOptionsProps } from "./types.js";
3
+ /**
4
+ * The palette's things: a group of options after the lenses, one row each.
5
+ * A thing whose class has no home route is listed but cannot be chosen.
6
+ */
7
+ export default function ThingOptions({ variables, start, active, optionId, choices, fetchKey, onCount, onChoose, }: ThingOptionsProps): ReactElement | null;
@@ -0,0 +1,2 @@
1
+ export { default as CommandPalette } from "./CommandPalette.js";
2
+ export type * from "./types.js";
@@ -0,0 +1,45 @@
1
+ import type { RouteName } from "@canonical/router-core";
2
+ import type { RegisteredRouteMap } from "@canonical/router-react";
3
+ import type { PrismClasses_node$key, PrismRow_node$key } from "../graphql/index.js";
4
+ import type { PrismSearchQuery } from "../searchQuery/index.js";
5
+ export interface CommandPaletteProps {
6
+ /**
7
+ * The name of the route that shows the search page. The palette's trigger
8
+ * links to it, so the search still works without scripts, and a query
9
+ * that matches no lens is sent to it.
10
+ */
11
+ readonly search: RouteName<RegisteredRouteMap>;
12
+ /** Extra classes for the trigger link. */
13
+ readonly className?: string;
14
+ /**
15
+ * Whether the palette also finds things in the graph, through its
16
+ * `search` field, drawn as rows after the lenses. Leave it off for a graph
17
+ * that does not serve that field.
18
+ */
19
+ readonly graph?: boolean;
20
+ }
21
+ export interface ThingOptionsProps {
22
+ /** The search query's variables, from `searchVariables`. */
23
+ readonly variables: PrismSearchQuery["variables"];
24
+ /** Changes when a failed search is tried again, so Relay asks again. */
25
+ readonly fetchKey: number;
26
+ /** The position, in the whole list, of the first thing. */
27
+ readonly start: number;
28
+ /** The position of the option the arrow keys have reached, or -1. */
29
+ readonly active: number;
30
+ /** The id of the option at a position in the whole list. */
31
+ readonly optionId: (index: number) => string;
32
+ /** How each listed thing is opened, by its position, filled by the options. */
33
+ readonly choices: Map<number, () => void>;
34
+ /** Told how many things are listed, so the arrow keys can reach them. */
35
+ readonly onCount: (count: number) => void;
36
+ /** Opens a thing's page: the home route's name and the thing's IRI. */
37
+ readonly onChoose: (home: string, uri: string) => void;
38
+ }
39
+ export interface ThingOptionProps extends Pick<ThingOptionsProps, "choices" | "onChoose"> {
40
+ readonly node: PrismClasses_node$key & PrismRow_node$key;
41
+ /** The option's position in the whole list. */
42
+ readonly index: number;
43
+ readonly id: string;
44
+ readonly selected: boolean;
45
+ }
@@ -0,0 +1,7 @@
1
+ import type { ReactNode } from "react";
2
+ import type { FactValueProps } from "./types.js";
3
+ /**
4
+ * The value of one of a thing's facts: the thing it names, as a chip, or its
5
+ * text.
6
+ */
7
+ export default function FactValue({ fact }: FactValueProps): ReactNode;
@@ -0,0 +1,2 @@
1
+ export { default as FactValue } from "./FactValue.js";
2
+ export type * from "./types.js";
@@ -0,0 +1,5 @@
1
+ import type { PrismFact_fact$key } from "../graphql/index.js";
2
+ export interface FactValueProps {
3
+ /** The fact, spread from the engine's `PrismFact_fact` fragment. */
4
+ readonly fact: PrismFact_fact$key;
5
+ }
@@ -0,0 +1,15 @@
1
+ import { type ReactElement } from "react";
2
+ import type { NavigationProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * The list of a site's lenses, read from its route table: every route with
6
+ * `meta.lens`, in the order the lenses state. The lens the current page
7
+ * belongs to carries the mark at the leading edge: `aria-current="page"` on
8
+ * its list page, and `"true"` on its other pages, which name it in
9
+ * `meta.lensOf`.
10
+ *
11
+ * A lens's shortcut opens it on a single key press, unless the reader has
12
+ * turned shortcuts off in their preferences. The key is shown either way:
13
+ * the preference lives in the browser, so the server cannot draw it.
14
+ */
15
+ export default function Navigation({ className, "aria-label": ariaLabel, }: NavigationProps): ReactElement;
@@ -0,0 +1,2 @@
1
+ export { default as Navigation } from "./Navigation.js";
2
+ export type * from "./types.js";
@@ -0,0 +1,6 @@
1
+ export interface NavigationProps {
2
+ /** Extra classes for the `<nav>`. */
3
+ readonly className?: string;
4
+ /** The navigation's accessible name; "Lenses" by default. */
5
+ readonly "aria-label"?: string;
6
+ }
@@ -0,0 +1,8 @@
1
+ import type { ReactElement } from "react";
2
+ import type { PageHeaderProps } from "./types.js";
3
+ /**
4
+ * The header of a thing's page, for any kind of thing: it reads the thing's
5
+ * slots and draws the site's header for the thing's nearest class, or the
6
+ * plain `PageHeaderView`.
7
+ */
8
+ export default function PageHeader({ node, ...props }: PageHeaderProps): ReactElement;
@@ -0,0 +1,10 @@
1
+ import type { ReactElement } from "react";
2
+ import type { PageHeaderViewProps } from "./types.js";
3
+ import "./styles.css";
4
+ /**
5
+ * The plain header of a thing's page: the thing's parents as chips, farthest
6
+ * first, then its label as the page's heading, its category and location,
7
+ * its version and status as a list of terms, and its description. A slot
8
+ * the thing does not have takes no room.
9
+ */
10
+ export default function PageHeaderView({ uri, slots, home: _home, className, children, ...props }: PageHeaderViewProps): ReactElement;