@contractspec/bundle.library 3.9.8 → 3.9.9

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 (70) hide show
  1. package/.turbo/turbo-build.log +222 -214
  2. package/CHANGELOG.md +52 -0
  3. package/dist/components/docs/DocsIndexPage.js +2 -2
  4. package/dist/components/docs/docsManifest.js +1 -1
  5. package/dist/components/docs/getting-started/DataViewTutorialPage.js +81 -6
  6. package/dist/components/docs/getting-started/index.js +94 -19
  7. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.d.ts +6 -0
  8. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +176 -0
  9. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.d.ts +1 -0
  10. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +176 -0
  11. package/dist/components/docs/guides/GuidesIndexPage.js +2 -2
  12. package/dist/components/docs/guides/index.d.ts +1 -0
  13. package/dist/components/docs/guides/index.js +220 -46
  14. package/dist/components/docs/index.js +1003 -309
  15. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.d.ts +22 -5
  16. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.js +125 -37
  17. package/dist/components/docs/libraries/LibrariesApplicationShellPage.js +125 -37
  18. package/dist/components/docs/libraries/LibrariesDataViewsPage.js +120 -3
  19. package/dist/components/docs/libraries/LibrariesDesignSystemPage.js +101 -2
  20. package/dist/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  21. package/dist/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  22. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.d.ts +10 -0
  23. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +43 -0
  24. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.d.ts +1 -0
  25. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.js +43 -0
  26. package/dist/components/docs/libraries/index.d.ts +1 -0
  27. package/dist/components/docs/libraries/index.js +496 -97
  28. package/dist/components/docs/specs/SpecsDataViewsPage.js +49 -3
  29. package/dist/components/docs/specs/index.js +60 -14
  30. package/dist/index.js +1014 -320
  31. package/dist/node/components/docs/DocsIndexPage.js +2 -2
  32. package/dist/node/components/docs/docsManifest.js +1 -1
  33. package/dist/node/components/docs/getting-started/DataViewTutorialPage.js +81 -6
  34. package/dist/node/components/docs/getting-started/index.js +94 -19
  35. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +175 -0
  36. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +175 -0
  37. package/dist/node/components/docs/guides/GuidesIndexPage.js +2 -2
  38. package/dist/node/components/docs/guides/index.js +220 -46
  39. package/dist/node/components/docs/index.js +1003 -309
  40. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.content.js +125 -37
  41. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.js +125 -37
  42. package/dist/node/components/docs/libraries/LibrariesDataViewsPage.js +120 -3
  43. package/dist/node/components/docs/libraries/LibrariesDesignSystemPage.js +101 -2
  44. package/dist/node/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  45. package/dist/node/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  46. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +42 -0
  47. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.js +42 -0
  48. package/dist/node/components/docs/libraries/index.js +496 -97
  49. package/dist/node/components/docs/specs/SpecsDataViewsPage.js +49 -3
  50. package/dist/node/components/docs/specs/index.js +60 -14
  51. package/dist/node/index.js +1014 -320
  52. package/package.json +74 -26
  53. package/src/components/docs/docsManifest.test.ts +87 -0
  54. package/src/components/docs/docsManifest.ts +90 -3
  55. package/src/components/docs/generated/docs-index.notifications.json +7 -7
  56. package/src/components/docs/getting-started/DataViewTutorialPage.tsx +181 -50
  57. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.ts +185 -0
  58. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.tsx +186 -0
  59. package/src/components/docs/guides/GuidesIndexPage.tsx +49 -42
  60. package/src/components/docs/guides/index.ts +1 -0
  61. package/src/components/docs/libraries/LibrariesApplicationShellPage.content.ts +148 -35
  62. package/src/components/docs/libraries/LibrariesApplicationShellPage.tsx +38 -5
  63. package/src/components/docs/libraries/LibrariesDataViewsPage.tsx +267 -64
  64. package/src/components/docs/libraries/LibrariesDesignSystemPage.tsx +235 -0
  65. package/src/components/docs/libraries/LibrariesOverviewPage.tsx +8 -2
  66. package/src/components/docs/libraries/LibrariesPersonalizationPage.tsx +141 -31
  67. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.content.ts +78 -0
  68. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.tsx +137 -0
  69. package/src/components/docs/libraries/index.ts +1 -0
  70. package/src/components/docs/specs/SpecsDataViewsPage.tsx +239 -113
@@ -1,3 +1,14 @@
1
+ import { CodeBlock } from '@contractspec/lib.design-system';
2
+ import { HStack, VStack } from '@contractspec/lib.design-system/layout';
3
+ import { List, ListItem } from '@contractspec/lib.design-system/list';
4
+ import {
5
+ Code,
6
+ H1,
7
+ H2,
8
+ H3,
9
+ P,
10
+ Text,
11
+ } from '@contractspec/lib.design-system/typography';
1
12
  import Link from '@contractspec/lib.ui-link';
2
13
  import { ChevronRight } from 'lucide-react';
3
14
 
@@ -64,8 +75,41 @@ export const DataGridShowcaseDataView = defineDataView({
64
75
  dataPath: 'lastActivityAt',
65
76
  format: { type: 'datetime', dateStyle: 'medium', timeStyle: 'short' },
66
77
  },
67
- { key: 'notes', label: 'Notes', dataPath: 'notes' },
78
+ {
79
+ key: 'notes',
80
+ label: 'Notes',
81
+ dataPath: 'notes',
82
+ visibility: { minDataDepth: 'detailed' },
83
+ },
68
84
  ],
85
+ collection: {
86
+ viewModes: {
87
+ defaultMode: 'table',
88
+ allowedModes: ['list', 'grid', 'table'],
89
+ },
90
+ pagination: {
91
+ pageSize: 25,
92
+ pageSizeOptions: [10, 25, 50],
93
+ },
94
+ toolbar: {
95
+ search: true,
96
+ viewMode: true,
97
+ filters: true,
98
+ density: true,
99
+ dataDepth: true,
100
+ },
101
+ density: 'comfortable',
102
+ dataDepth: 'standard',
103
+ personalization: {
104
+ enabled: true,
105
+ persist: {
106
+ viewMode: true,
107
+ density: true,
108
+ dataDepth: true,
109
+ pageSize: true,
110
+ },
111
+ },
112
+ },
69
113
  filters: [
70
114
  { key: 'status', label: 'Status', field: 'status', type: 'enum' },
71
115
  {
@@ -94,163 +138,245 @@ export const DataGridShowcaseDataView = defineDataView({
94
138
 
95
139
  export function SpecsDataViewsPage() {
96
140
  return (
97
- <div className="space-y-8">
98
- <div className="space-y-4">
99
- <h1 className="font-bold text-4xl">DataViews</h1>
100
- <p className="text-muted-foreground">
101
- A <strong>DataViewSpec</strong> describes how data should be queried,
102
- filtered, sorted, and presented to users. Runtime adapters execute
103
- optimized database queries and serve list views, detail views, and
104
- search interfaces while respecting policy constraints.
105
- </p>
106
- </div>
141
+ <VStack className="space-y-8">
142
+ <VStack className="space-y-4">
143
+ <H1 className="font-bold text-4xl">DataViews</H1>
144
+ <P className="text-muted-foreground">
145
+ A <Text className="font-semibold">DataViewSpec</Text> describes how
146
+ data should be queried, filtered, sorted, and presented to users.
147
+ Runtime adapters execute optimized database queries and serve list
148
+ views, detail views, and search interfaces while respecting policy
149
+ constraints.
150
+ </P>
151
+ </VStack>
107
152
 
108
- <div className="space-y-4">
109
- <h2 className="font-bold text-2xl">Core concepts</h2>
110
- <div className="space-y-3">
111
- <div>
112
- <h3 className="font-semibold text-lg">Data sources</h3>
113
- <p className="text-muted-foreground">
153
+ <VStack className="space-y-4">
154
+ <H2 className="font-bold text-2xl">Core concepts</H2>
155
+ <VStack className="space-y-3">
156
+ <VStack>
157
+ <H3 className="font-semibold text-lg">Data sources</H3>
158
+ <P className="text-muted-foreground">
114
159
  A DataView connects to one or more data sources—databases, APIs,
115
160
  or other capabilities. You specify the source and the fields you
116
161
  want to expose.
117
- </p>
118
- </div>
119
- <div>
120
- <h3 className="font-semibold text-lg">Filtering</h3>
121
- <p className="text-muted-foreground">
162
+ </P>
163
+ </VStack>
164
+ <VStack>
165
+ <H3 className="font-semibold text-lg">Filtering</H3>
166
+ <P className="text-muted-foreground">
122
167
  Define filters that users can apply to narrow down results.
123
168
  Filters are typed as search, enum, number, percent, currency,
124
169
  date, time, datetime, duration, or boolean so renderers and query
125
170
  helpers can validate values before execution.
126
- </p>
127
- </div>
128
- <div>
129
- <h3 className="font-semibold text-lg">Sorting</h3>
130
- <p className="text-muted-foreground">
171
+ </P>
172
+ </VStack>
173
+ <VStack>
174
+ <H3 className="font-semibold text-lg">Sorting</H3>
175
+ <P className="text-muted-foreground">
131
176
  Specify which fields can be sorted and the default sort order.
132
177
  ContractSpec generates efficient database queries with proper
133
178
  indexes.
134
- </p>
135
- </div>
136
- <div>
137
- <h3 className="font-semibold text-lg">Pagination</h3>
138
- <p className="text-muted-foreground">
179
+ </P>
180
+ </VStack>
181
+ <VStack>
182
+ <H3 className="font-semibold text-lg">Pagination</H3>
183
+ <P className="text-muted-foreground">
139
184
  DataViews automatically support pagination to handle large
140
185
  datasets. You can configure page size limits and cursor-based or
141
186
  offset-based pagination.
142
- </p>
143
- </div>
144
- <div>
145
- <h3 className="font-semibold text-lg">Aggregations</h3>
146
- <p className="text-muted-foreground">
147
- Compute aggregates like counts, sums, averages, and group-by
148
- operations. These are useful for dashboards and summary views.
149
- </p>
150
- </div>
151
- </div>
152
- </div>
187
+ </P>
188
+ </VStack>
189
+ <VStack>
190
+ <H3 className="font-semibold text-lg">
191
+ Collection modes and data depth
192
+ </H3>
193
+ <P className="text-muted-foreground">
194
+ List, grid, and table views can share a single{' '}
195
+ <Code>view.collection</Code> contract. It declares allowed view
196
+ modes, toolbar controls, page-size defaults, density, data depth,
197
+ and persistence hints. Fields can use{' '}
198
+ <Code>visibility.minDataDepth</Code> so summary views stay light
199
+ while detailed views expose richer context.
200
+ </P>
201
+ </VStack>
202
+ <VStack>
203
+ <H3 className="font-semibold text-lg">Personalization hints</H3>
204
+ <P className="text-muted-foreground">
205
+ The contract layer stays neutral: it can opt into persistence with{' '}
206
+ <Code>view.collection.personalization</Code>, but it does not
207
+ import the personalization runtime. Host apps resolve preferences
208
+ and behavior insights into renderer props.
209
+ </P>
210
+ </VStack>
211
+ </VStack>
212
+ </VStack>
153
213
 
154
- <div className="space-y-4">
155
- <h2 className="font-bold text-2xl">Example DataViewSpec</h2>
156
- <p className="text-muted-foreground">
214
+ <VStack className="space-y-4">
215
+ <H2 className="font-bold text-2xl">Example DataViewSpec</H2>
216
+ <P className="text-muted-foreground">
157
217
  Here is the canonical table contract used by the live{' '}
158
218
  <Link
159
219
  href="/docs/examples/data-grid-showcase"
160
220
  className="text-[color:var(--rust)] underline underline-offset-4"
161
221
  >
162
- Data Grid Showcase
222
+ <Text>Data Grid Showcase</Text>
163
223
  </Link>
164
224
  :
165
- </p>
166
- <div className="overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm">
167
- <pre>{SPECS_DATAVIEWS_EXAMPLE}</pre>
168
- </div>
169
- <p className="text-muted-foreground text-sm">
225
+ </P>
226
+ <CodeBlock language="typescript" code={SPECS_DATAVIEWS_EXAMPLE} />
227
+ <P className="text-muted-foreground text-sm">
170
228
  This one contract drives the DataView lane, while the same rows and
171
229
  controller also feed the raw web primitive, native-first primitive,
172
230
  and composed design-system demos.
173
- </p>
174
- </div>
231
+ </P>
232
+ </VStack>
175
233
 
176
- <div className="space-y-4">
177
- <h2 className="font-bold text-2xl">Policy integration</h2>
178
- <p className="text-muted-foreground">
234
+ <VStack className="space-y-4">
235
+ <H2 className="font-bold text-2xl">Policy integration</H2>
236
+ <P className="text-muted-foreground">
179
237
  DataViews automatically enforce{' '}
180
238
  <Link
181
239
  href="/docs/specs/policy"
182
240
  className="text-violet-400 hover:text-violet-300"
183
241
  >
184
- PolicySpecs
242
+ <Text>PolicySpecs</Text>
185
243
  </Link>
186
244
  . If a user doesn't have permission to see certain fields, those
187
245
  fields are automatically filtered out or redacted. If a user can only
188
246
  see their own data, the query is automatically scoped.
189
- </p>
190
- <p className="text-muted-foreground">
247
+ </P>
248
+ <P className="text-muted-foreground">
191
249
  This means you define the data view once, and it works correctly for
192
250
  all users based on their permissions—no need to write separate queries
193
251
  for different roles.
194
- </p>
195
- </div>
252
+ </P>
253
+ </VStack>
254
+
255
+ <VStack className="space-y-4">
256
+ <H2 className="font-bold text-2xl">Personalized Rendering Pattern</H2>
257
+ <P className="text-muted-foreground">
258
+ To personalize a DataView, keep the spec declarative and resolve
259
+ user-specific defaults at the app boundary. Use{' '}
260
+ <Code>resolveDataViewPreferences</Code> from{' '}
261
+ <Code>@contractspec/lib.personalization/data-view-preferences</Code>
262
+ to compute <Code>viewMode</Code>, <Code>density</Code>,{' '}
263
+ <Code>dataDepth</Code>, and <Code>pageSize</Code>. Pass those values
264
+ to <Code>DataViewRenderer</Code> as controlled or default props, then
265
+ record UI changes with <Code>trackDataViewInteraction</Code>.
266
+ </P>
267
+ <CodeBlock
268
+ language="tsx"
269
+ code={`const resolved = resolveDataViewPreferences({
270
+ spec: DataGridShowcaseDataView,
271
+ preferences: profile.canonical,
272
+ insights,
273
+ record: savedPreference,
274
+ });
275
+
276
+ <DataViewRenderer
277
+ spec={DataGridShowcaseDataView}
278
+ items={rows}
279
+ defaultViewMode={resolved.viewMode}
280
+ defaultDensity={resolved.density}
281
+ defaultDataDepth={resolved.dataDepth}
282
+ />;`}
283
+ />
284
+ </VStack>
196
285
 
197
- <div className="space-y-4">
198
- <h2 className="font-bold text-2xl">Served outputs</h2>
199
- <p className="text-muted-foreground">
286
+ <VStack className="space-y-4">
287
+ <H2 className="font-bold text-2xl">Served outputs</H2>
288
+ <P className="text-muted-foreground">
200
289
  From a DataViewSpec, ContractSpec serves:
201
- </p>
202
- <ul className="list-inside list-disc space-y-2 text-muted-foreground">
203
- <li>
204
- <strong>Database queries</strong> – Optimized SQL or NoSQL queries
205
- executed at runtime
206
- </li>
207
- <li>
208
- <strong>API endpoints</strong> – RESTful or GraphQL endpoints for
209
- fetching data
210
- </li>
211
- <li>
212
- <strong>UI components</strong> List views, tables, cards, and
213
- detail views
214
- </li>
215
- <li>
216
- <strong>Search interfaces</strong> – Full-text search with
217
- autocomplete
218
- </li>
219
- <li>
220
- <strong>Export functions</strong> – CSV, JSON, or Excel exports
221
- </li>
222
- </ul>
223
- </div>
290
+ </P>
291
+ <List className="list-inside list-disc space-y-2 text-muted-foreground">
292
+ <ListItem>
293
+ <Text>
294
+ <Text className="font-semibold">Database queries</Text> –
295
+ Optimized SQL or NoSQL queries executed at runtime
296
+ </Text>
297
+ </ListItem>
298
+ <ListItem>
299
+ <Text>
300
+ <Text className="font-semibold">API endpoints</Text> – RESTful or
301
+ GraphQL endpoints for fetching data
302
+ </Text>
303
+ </ListItem>
304
+ <ListItem>
305
+ <Text>
306
+ <Text className="font-semibold">UI components</Text> – List views,
307
+ tables, cards, and detail views
308
+ </Text>
309
+ </ListItem>
310
+ <ListItem>
311
+ <Text>
312
+ <Text className="font-semibold">Personalized defaults</Text>
313
+ Plain renderer props for preferred mode, density, data depth, and
314
+ page size
315
+ </Text>
316
+ </ListItem>
317
+ <ListItem>
318
+ <Text>
319
+ <Text className="font-semibold">Search interfaces</Text> –
320
+ Full-text search with autocomplete
321
+ </Text>
322
+ </ListItem>
323
+ <ListItem>
324
+ <Text>
325
+ <Text className="font-semibold">Export functions</Text> – CSV,
326
+ JSON, or Excel exports
327
+ </Text>
328
+ </ListItem>
329
+ </List>
330
+ </VStack>
224
331
 
225
- <div className="space-y-4">
226
- <h2 className="font-bold text-2xl">Best practices</h2>
227
- <ul className="list-inside list-disc space-y-2 text-muted-foreground">
228
- <li>
229
- Only expose fields that users actually need—this improves
230
- performance and security.
231
- </li>
232
- <li>Use appropriate indexes for sortable and filterable fields.</li>
233
- <li>
234
- Set reasonable pagination limits to prevent performance issues.
235
- </li>
236
- <li>
237
- Use aggregations sparingly—they can be expensive on large datasets.
238
- </li>
239
- <li>
240
- Test DataViews with realistic data volumes to ensure they perform
241
- well.
242
- </li>
243
- </ul>
244
- </div>
332
+ <VStack className="space-y-4">
333
+ <H2 className="font-bold text-2xl">Best practices</H2>
334
+ <List className="list-inside list-disc space-y-2 text-muted-foreground">
335
+ <ListItem>
336
+ <Text>
337
+ Only expose fields that users actually need—this improves
338
+ performance and security.
339
+ </Text>
340
+ </ListItem>
341
+ <ListItem>
342
+ <Text>
343
+ Use appropriate indexes for sortable and filterable fields.
344
+ </Text>
345
+ </ListItem>
346
+ <ListItem>
347
+ <Text>
348
+ Set reasonable pagination limits to prevent performance issues.
349
+ </Text>
350
+ </ListItem>
351
+ <ListItem>
352
+ <Text>
353
+ Use <Code>allowedModes</Code> to constrain mode switching to
354
+ layouts that the fields and row actions can support.
355
+ </Text>
356
+ </ListItem>
357
+ <ListItem>
358
+ <Text>
359
+ Store preferences only for dimensions enabled by{' '}
360
+ <Code>view.collection.personalization.persist</Code>.
361
+ </Text>
362
+ </ListItem>
363
+ <ListItem>
364
+ <Text>
365
+ Test DataViews with realistic data volumes to ensure they perform
366
+ well.
367
+ </Text>
368
+ </ListItem>
369
+ </List>
370
+ </VStack>
245
371
 
246
- <div className="flex items-center gap-4 pt-4">
372
+ <HStack className="items-center gap-4 pt-4">
247
373
  <Link href="/docs/specs/capabilities" className="btn-ghost">
248
- Previous: Capabilities
374
+ <Text>Previous: Capabilities</Text>
249
375
  </Link>
250
376
  <Link href="/docs/specs/workflows" className="btn-primary">
251
- Next: Workflows <ChevronRight size={16} />
377
+ <Text>Next: Workflows</Text> <ChevronRight size={16} />
252
378
  </Link>
253
- </div>
254
- </div>
379
+ </HStack>
380
+ </VStack>
255
381
  );
256
382
  }