@surfaces-ui/components 0.0.0-stage → 0.2.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 (264) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +48 -2
  4. package/dist/appComponents.d.ts +86 -0
  5. package/dist/appComponents.js +555 -0
  6. package/dist/appComponents.js.map +1 -0
  7. package/dist/chart/BulletGraph.d.ts +44 -0
  8. package/dist/chart/BulletGraph.js +40 -0
  9. package/dist/chart/BulletGraph.js.map +1 -0
  10. package/dist/chart/Chart.d.ts +177 -0
  11. package/dist/chart/Chart.js +279 -0
  12. package/dist/chart/Chart.js.map +1 -0
  13. package/dist/chart/Sparkline.d.ts +35 -0
  14. package/dist/chart/Sparkline.js +37 -0
  15. package/dist/chart/Sparkline.js.map +1 -0
  16. package/dist/chart/advice.d.ts +28 -0
  17. package/dist/chart/advice.js +39 -0
  18. package/dist/chart/advice.js.map +1 -0
  19. package/dist/chart/option.d.ts +90 -0
  20. package/dist/chart/option.js +252 -0
  21. package/dist/chart/option.js.map +1 -0
  22. package/dist/controls/Combobox.d.ts +39 -0
  23. package/dist/controls/Combobox.js +75 -0
  24. package/dist/controls/Combobox.js.map +1 -0
  25. package/dist/controls/ConfirmDialog.d.ts +35 -0
  26. package/dist/controls/ConfirmDialog.js +84 -0
  27. package/dist/controls/ConfirmDialog.js.map +1 -0
  28. package/dist/controls/ItemControls.d.ts +115 -0
  29. package/dist/controls/ItemControls.js +109 -0
  30. package/dist/controls/ItemControls.js.map +1 -0
  31. package/dist/controls/Popover.d.ts +31 -0
  32. package/dist/controls/Popover.js +114 -0
  33. package/dist/controls/Popover.js.map +1 -0
  34. package/dist/controls/ResizeHandle.d.ts +48 -0
  35. package/dist/controls/ResizeHandle.js +91 -0
  36. package/dist/controls/ResizeHandle.js.map +1 -0
  37. package/dist/controls/SegmentedControl.d.ts +27 -0
  38. package/dist/controls/SegmentedControl.js +17 -0
  39. package/dist/controls/SegmentedControl.js.map +1 -0
  40. package/dist/controls/StatusBadge.d.ts +17 -0
  41. package/dist/controls/StatusBadge.js +10 -0
  42. package/dist/controls/StatusBadge.js.map +1 -0
  43. package/dist/controls/context.d.ts +17 -0
  44. package/dist/controls/context.js +2 -0
  45. package/dist/controls/context.js.map +1 -0
  46. package/dist/controls/placement.d.ts +43 -0
  47. package/dist/controls/placement.js +19 -0
  48. package/dist/controls/placement.js.map +1 -0
  49. package/dist/controls/resize.d.ts +23 -0
  50. package/dist/controls/resize.js +49 -0
  51. package/dist/controls/resize.js.map +1 -0
  52. package/dist/data/DataSourceProvider.d.ts +11 -0
  53. package/dist/data/DataSourceProvider.js +21 -0
  54. package/dist/data/DataSourceProvider.js.map +1 -0
  55. package/dist/data/export.d.ts +33 -0
  56. package/dist/data/export.js +77 -0
  57. package/dist/data/export.js.map +1 -0
  58. package/dist/data/format.d.ts +44 -0
  59. package/dist/data/format.js +127 -0
  60. package/dist/data/format.js.map +1 -0
  61. package/dist/data/messages.d.ts +13 -0
  62. package/dist/data/messages.js +2 -0
  63. package/dist/data/messages.js.map +1 -0
  64. package/dist/data/useRowWindow.d.ts +70 -0
  65. package/dist/data/useRowWindow.js +175 -0
  66. package/dist/data/useRowWindow.js.map +1 -0
  67. package/dist/discovery/AskData.d.ts +22 -0
  68. package/dist/discovery/AskData.js +48 -0
  69. package/dist/discovery/AskData.js.map +1 -0
  70. package/dist/discovery/ContextBuilder.d.ts +49 -0
  71. package/dist/discovery/ContextBuilder.js +167 -0
  72. package/dist/discovery/ContextBuilder.js.map +1 -0
  73. package/dist/discovery/DataSearch.d.ts +27 -0
  74. package/dist/discovery/DataSearch.js +73 -0
  75. package/dist/discovery/DataSearch.js.map +1 -0
  76. package/dist/discovery/ObjectDetail.d.ts +38 -0
  77. package/dist/discovery/ObjectDetail.js +129 -0
  78. package/dist/discovery/ObjectDetail.js.map +1 -0
  79. package/dist/discovery/RelationshipGraph.d.ts +19 -0
  80. package/dist/discovery/RelationshipGraph.js +64 -0
  81. package/dist/discovery/RelationshipGraph.js.map +1 -0
  82. package/dist/discovery/shared.d.ts +38 -0
  83. package/dist/discovery/shared.js +64 -0
  84. package/dist/discovery/shared.js.map +1 -0
  85. package/dist/editor/SqlEditor.d.ts +41 -0
  86. package/dist/editor/SqlEditor.js +181 -0
  87. package/dist/editor/SqlEditor.js.map +1 -0
  88. package/dist/explore/Explorer.d.ts +110 -0
  89. package/dist/explore/Explorer.js +471 -0
  90. package/dist/explore/Explorer.js.map +1 -0
  91. package/dist/explore/ModelLineage.d.ts +22 -0
  92. package/dist/explore/ModelLineage.js +70 -0
  93. package/dist/explore/ModelLineage.js.map +1 -0
  94. package/dist/explore/ReportBuilder.d.ts +39 -0
  95. package/dist/explore/ReportBuilder.js +98 -0
  96. package/dist/explore/ReportBuilder.js.map +1 -0
  97. package/dist/explore/SemanticModelEditor.d.ts +60 -0
  98. package/dist/explore/SemanticModelEditor.js +220 -0
  99. package/dist/explore/SemanticModelEditor.js.map +1 -0
  100. package/dist/explore/SemanticRows.d.ts +42 -0
  101. package/dist/explore/SemanticRows.js +117 -0
  102. package/dist/explore/SemanticRows.js.map +1 -0
  103. package/dist/explore/SemanticsProvider.d.ts +31 -0
  104. package/dist/explore/SemanticsProvider.js +72 -0
  105. package/dist/explore/SemanticsProvider.js.map +1 -0
  106. package/dist/explore/model.d.ts +151 -0
  107. package/dist/explore/model.js +344 -0
  108. package/dist/explore/model.js.map +1 -0
  109. package/dist/explore/report.d.ts +60 -0
  110. package/dist/explore/report.js +92 -0
  111. package/dist/explore/report.js.map +1 -0
  112. package/dist/explore/semantic-proposal.d.ts +44 -0
  113. package/dist/explore/semantic-proposal.js +67 -0
  114. package/dist/explore/semantic-proposal.js.map +1 -0
  115. package/dist/explore/semantic.d.ts +44 -0
  116. package/dist/explore/semantic.js +154 -0
  117. package/dist/explore/semantic.js.map +1 -0
  118. package/dist/files/FileBrowser.d.ts +42 -0
  119. package/dist/files/FileBrowser.js +314 -0
  120. package/dist/files/FileBrowser.js.map +1 -0
  121. package/dist/files/files.d.ts +65 -0
  122. package/dist/files/files.js +165 -0
  123. package/dist/files/files.js.map +1 -0
  124. package/dist/filter/FilterBar.d.ts +49 -0
  125. package/dist/filter/FilterBar.js +153 -0
  126. package/dist/filter/FilterBar.js.map +1 -0
  127. package/dist/filter/QueryFilters.d.ts +25 -0
  128. package/dist/filter/QueryFilters.js +58 -0
  129. package/dist/filter/QueryFilters.js.map +1 -0
  130. package/dist/form/Form.d.ts +76 -0
  131. package/dist/form/Form.js +131 -0
  132. package/dist/form/Form.js.map +1 -0
  133. package/dist/graph/NodeGraph.d.ts +30 -0
  134. package/dist/graph/NodeGraph.js +86 -0
  135. package/dist/graph/NodeGraph.js.map +1 -0
  136. package/dist/graph/model.d.ts +68 -0
  137. package/dist/graph/model.js +122 -0
  138. package/dist/graph/model.js.map +1 -0
  139. package/dist/grid/DataGrid.d.ts +98 -0
  140. package/dist/grid/DataGrid.js +399 -0
  141. package/dist/grid/DataGrid.js.map +1 -0
  142. package/dist/index.d.ts +84 -0
  143. package/dist/index.js +86 -0
  144. package/dist/index.js.map +1 -0
  145. package/dist/locale/SurfacesText.d.ts +17 -0
  146. package/dist/locale/SurfacesText.js +17 -0
  147. package/dist/locale/SurfacesText.js.map +1 -0
  148. package/dist/locale/locale.d.ts +305 -0
  149. package/dist/locale/locale.js +359 -0
  150. package/dist/locale/locale.js.map +1 -0
  151. package/dist/menu/ContextMenu.d.ts +31 -0
  152. package/dist/menu/ContextMenu.js +95 -0
  153. package/dist/menu/ContextMenu.js.map +1 -0
  154. package/dist/metric/Metric.d.ts +33 -0
  155. package/dist/metric/Metric.js +63 -0
  156. package/dist/metric/Metric.js.map +1 -0
  157. package/dist/metric/useMeasure.d.ts +23 -0
  158. package/dist/metric/useMeasure.js +43 -0
  159. package/dist/metric/useMeasure.js.map +1 -0
  160. package/dist/model/ModelDiagram.d.ts +142 -0
  161. package/dist/model/ModelDiagram.js +699 -0
  162. package/dist/model/ModelDiagram.js.map +1 -0
  163. package/dist/panzoom/usePanZoom.d.ts +117 -0
  164. package/dist/panzoom/usePanZoom.js +313 -0
  165. package/dist/panzoom/usePanZoom.js.map +1 -0
  166. package/dist/pipeline/DatasetReview.d.ts +48 -0
  167. package/dist/pipeline/DatasetReview.js +157 -0
  168. package/dist/pipeline/DatasetReview.js.map +1 -0
  169. package/dist/pipeline/IngestWizard.d.ts +51 -0
  170. package/dist/pipeline/IngestWizard.js +79 -0
  171. package/dist/pipeline/IngestWizard.js.map +1 -0
  172. package/dist/pipeline/Pipeline.d.ts +171 -0
  173. package/dist/pipeline/Pipeline.js +203 -0
  174. package/dist/pipeline/Pipeline.js.map +1 -0
  175. package/dist/pipeline/PipelineView.d.ts +63 -0
  176. package/dist/pipeline/PipelineView.js +239 -0
  177. package/dist/pipeline/PipelineView.js.map +1 -0
  178. package/dist/pivot/PivotTable.d.ts +94 -0
  179. package/dist/pivot/PivotTable.js +171 -0
  180. package/dist/pivot/PivotTable.js.map +1 -0
  181. package/dist/plan/QueryPlan.d.ts +29 -0
  182. package/dist/plan/QueryPlan.js +79 -0
  183. package/dist/plan/QueryPlan.js.map +1 -0
  184. package/dist/result/QueryResult.d.ts +51 -0
  185. package/dist/result/QueryResult.js +255 -0
  186. package/dist/result/QueryResult.js.map +1 -0
  187. package/dist/review/ActionReceipt.d.ts +52 -0
  188. package/dist/review/ActionReceipt.js +32 -0
  189. package/dist/review/ActionReceipt.js.map +1 -0
  190. package/dist/review/PiiReview.d.ts +37 -0
  191. package/dist/review/PiiReview.js +29 -0
  192. package/dist/review/PiiReview.js.map +1 -0
  193. package/dist/review/PlanReview.d.ts +42 -0
  194. package/dist/review/PlanReview.js +37 -0
  195. package/dist/review/PlanReview.js.map +1 -0
  196. package/dist/review/StepFlow.d.ts +25 -0
  197. package/dist/review/StepFlow.js +21 -0
  198. package/dist/review/StepFlow.js.map +1 -0
  199. package/dist/review/pii.d.ts +21 -0
  200. package/dist/review/pii.js +67 -0
  201. package/dist/review/pii.js.map +1 -0
  202. package/dist/rows/RowList.d.ts +41 -0
  203. package/dist/rows/RowList.js +71 -0
  204. package/dist/rows/RowList.js.map +1 -0
  205. package/dist/schema/ObjectBrowser.d.ts +78 -0
  206. package/dist/schema/ObjectBrowser.js +467 -0
  207. package/dist/schema/ObjectBrowser.js.map +1 -0
  208. package/dist/schema/ObjectInfo.d.ts +25 -0
  209. package/dist/schema/ObjectInfo.js +69 -0
  210. package/dist/schema/ObjectInfo.js.map +1 -0
  211. package/dist/schema/SchemaExplorer.d.ts +32 -0
  212. package/dist/schema/SchemaExplorer.js +175 -0
  213. package/dist/schema/SchemaExplorer.js.map +1 -0
  214. package/dist/schema/refs.d.ts +32 -0
  215. package/dist/schema/refs.js +65 -0
  216. package/dist/schema/refs.js.map +1 -0
  217. package/dist/site/Site.d.ts +191 -0
  218. package/dist/site/Site.js +138 -0
  219. package/dist/site/Site.js.map +1 -0
  220. package/dist/source/ConnectionBuilder.d.ts +54 -0
  221. package/dist/source/ConnectionBuilder.js +115 -0
  222. package/dist/source/ConnectionBuilder.js.map +1 -0
  223. package/dist/source/SourceList.d.ts +17 -0
  224. package/dist/source/SourceList.js +71 -0
  225. package/dist/source/SourceList.js.map +1 -0
  226. package/dist/styles.css +9882 -0
  227. package/dist/styles.layer.css +9886 -0
  228. package/dist/table/DataTable.d.ts +72 -0
  229. package/dist/table/DataTable.js +68 -0
  230. package/dist/table/DataTable.js.map +1 -0
  231. package/dist/table/Pagination.d.ts +20 -0
  232. package/dist/table/Pagination.js +16 -0
  233. package/dist/table/Pagination.js.map +1 -0
  234. package/dist/table/SelectionBar.d.ts +43 -0
  235. package/dist/table/SelectionBar.js +18 -0
  236. package/dist/table/SelectionBar.js.map +1 -0
  237. package/dist/text/Markdown.d.ts +71 -0
  238. package/dist/text/Markdown.js +187 -0
  239. package/dist/text/Markdown.js.map +1 -0
  240. package/dist/text/highlight.d.ts +23 -0
  241. package/dist/text/highlight.js +196 -0
  242. package/dist/text/highlight.js.map +1 -0
  243. package/dist/theme/ThemePicker.d.ts +16 -0
  244. package/dist/theme/ThemePicker.js +49 -0
  245. package/dist/theme/ThemePicker.js.map +1 -0
  246. package/dist/theme/ThemeProvider.d.ts +43 -0
  247. package/dist/theme/ThemeProvider.js +107 -0
  248. package/dist/theme/ThemeProvider.js.map +1 -0
  249. package/dist/workspace/NavBar.d.ts +23 -0
  250. package/dist/workspace/NavBar.js +171 -0
  251. package/dist/workspace/NavBar.js.map +1 -0
  252. package/dist/workspace/SideNav.d.ts +61 -0
  253. package/dist/workspace/SideNav.js +149 -0
  254. package/dist/workspace/SideNav.js.map +1 -0
  255. package/dist/workspace/Workspace.d.ts +50 -0
  256. package/dist/workspace/Workspace.js +243 -0
  257. package/dist/workspace/Workspace.js.map +1 -0
  258. package/dist/workspace/icons.d.ts +34 -0
  259. package/dist/workspace/icons.js +37 -0
  260. package/dist/workspace/icons.js.map +1 -0
  261. package/dist/workspace/layout.d.ts +74 -0
  262. package/dist/workspace/layout.js +276 -0
  263. package/dist/workspace/layout.js.map +1 -0
  264. package/package.json +85 -3
@@ -0,0 +1,555 @@
1
+ /** Checks a description against the component's props type `P`: every prop it names must be one of `P`'s. */
2
+ export function describeAppComponent() {
3
+ return (doc) => doc;
4
+ }
5
+ const COMPONENTS = "@surfaces-ui/components";
6
+ const PRESET_HIDE = ["mode", "presets", "accent", "charts", "radius", "font", "density"];
7
+ export const themePickerDoc = describeAppComponent()({
8
+ name: "ThemePicker",
9
+ from: COMPONENTS,
10
+ description: "Lets a person choose how everything looks: a preset, light or dark, the accent, chart colours, corner radius, font and density. It changes the theme held by the `ThemeProvider` above it, which keeps the choice. Hide the controls a product does not want to offer.",
11
+ props: {
12
+ type: "object",
13
+ properties: {
14
+ hide: { type: "array", description: "Controls to leave out.", items: { type: "string", enum: PRESET_HIDE } },
15
+ },
16
+ },
17
+ parts: [{ prop: "presets", label: "Your own presets", description: "Themes offered as one-click choices in place of the built-in presets." }],
18
+ callbacks: [],
19
+ example: { hide: [] },
20
+ });
21
+ export const connectionBuilderDoc = describeAppComponent()({
22
+ name: "ConnectionBuilder",
23
+ from: COMPONENTS,
24
+ description: "Sets up Parquet, Delta or Iceberg data on S3, GCS, Azure, https or disk, and writes the configuration for the server with the names of the environment variables to set. It holds the name of a secret, never a credential.",
25
+ props: {
26
+ type: "object",
27
+ properties: {
28
+ value: {
29
+ type: "object",
30
+ description: "The connection being set up.",
31
+ properties: {
32
+ sourceId: { type: "string", description: "The source's id." },
33
+ storage: { type: "string", enum: ["s3", "gcs", "azure", "http", "local"], description: "Where the files are." },
34
+ scope: { type: "string", description: "The bucket or prefix the connection covers, e.g. s3://acme-lake/sales." },
35
+ credentials: { type: "string", enum: ["secret", "ambient", "public"], description: "A named secret, the machine's own role, or public data with none." },
36
+ secret: { type: "string", description: "The name of the server-side secret, e.g. LAKE." },
37
+ region: { type: "string" },
38
+ endpoint: { type: "string", description: "For S3-compatible stores such as MinIO." },
39
+ },
40
+ },
41
+ },
42
+ required: ["value"],
43
+ },
44
+ parts: [],
45
+ callbacks: [{ prop: "onChange", description: "Every change to the connection, as the whole draft. Required: the host holds the draft." }],
46
+ example: { value: { sourceId: "lake", storage: "s3", scope: "s3://acme-lake/sales", credentials: "secret", secret: "LAKE", region: "eu-west-1", endpoint: "", tables: [{ name: "orders", format: "delta", path: "s3://acme-lake/sales/orders" }], catalogUri: "", catalogWarehouse: "" } },
47
+ });
48
+ export const modelLineageDoc = describeAppComponent()({
49
+ name: "ModelLineage",
50
+ from: COMPONENTS,
51
+ description: "Where a semantic model's rows come from when a pipeline builds them: the dataset, when it was last built, the latest run's checks, whether its key was checked and what it reads. One line over an explorer or a report, or a panel. Display only: it queries nothing.",
52
+ props: {
53
+ type: "object",
54
+ properties: {
55
+ model: {
56
+ type: "object",
57
+ description: "A model whose rows are a pipeline's dataset (`dataset`); anything else draws nothing.",
58
+ properties: {
59
+ sourceId: { type: "string" },
60
+ sql: { type: "string" },
61
+ grain: { type: "string" },
62
+ primaryKey: { type: "array", items: { type: "string" } },
63
+ dataset: { type: "object", properties: { pipelineId: { type: "string" }, dataset: { type: "string" } } },
64
+ },
65
+ },
66
+ compact: { type: "boolean", description: "One line, for above an explorer or a report." },
67
+ },
68
+ required: ["model"],
69
+ },
70
+ parts: [{ prop: "pipelines", label: "Pipelines backend", description: "Where the dataset's definition and runs come from. Without it (or a PipelinesProvider) only the dataset's name is shown.", on: true }],
71
+ callbacks: [
72
+ { prop: "onUseDataset", description: "Offered when the model's grain or key differs from the dataset's." },
73
+ { prop: "onOpenDataset", description: "Opens the dataset in the host's pipeline view." },
74
+ ],
75
+ example: { compact: false },
76
+ });
77
+ export const checksPanelDoc = describeAppComponent()({
78
+ name: "ChecksPanel",
79
+ from: COMPONENTS,
80
+ description: "A dataset's checks (unique, not null, relationships, accepted values, row count) with their latest results, failures first. Display only: the counts come from the engine.",
81
+ props: {
82
+ type: "object",
83
+ properties: {
84
+ checks: {
85
+ type: "array",
86
+ description: "Each check with its latest outcome.",
87
+ items: { type: "object", properties: { name: { type: "string" }, description: { type: "string", description: "The check in words." }, severity: { type: "string", enum: ["fail", "warn"] }, failedRecords: { type: "integer", description: "Rows that break it; absent when not run since it was added." }, summary: { type: "string" } }, required: ["name", "description", "severity"] },
88
+ },
89
+ },
90
+ required: ["checks"],
91
+ },
92
+ parts: [],
93
+ callbacks: [{ prop: "onOpenFailing", description: "Look at what breaks a check. Nothing runs unless the host runs it." }],
94
+ example: {
95
+ checks: [
96
+ { name: "order_id_unique", description: "order_id never repeats", severity: "fail", failedRecords: 0, fromKey: true },
97
+ { name: "status_values", description: "status is one of placed, shipped, returned", severity: "warn", failedRecords: 12, summary: "12 rows have another status." },
98
+ ],
99
+ },
100
+ });
101
+ export const objectInfoDoc = describeAppComponent()({
102
+ name: "ObjectInfo",
103
+ from: COMPONENTS,
104
+ description: "What the backend knows about a database, schema or table: its kind, format, size, columns and keys. Names only, never values.",
105
+ props: {
106
+ type: "object",
107
+ properties: {
108
+ sourceId: { type: "string", description: "The source to ask." },
109
+ catalog: { type: "string", description: "A catalog (database)." },
110
+ schema: { type: "string" },
111
+ table: { type: "string", description: "With a table, it describes the table; without, the schema or catalog." },
112
+ },
113
+ required: ["sourceId"],
114
+ },
115
+ parts: [{ prop: "dataSource", label: "Its own data source", description: "Left out, the one from `DataSourceProvider`." }],
116
+ callbacks: [{ prop: "onClose", description: "Shows a close button." }],
117
+ example: {},
118
+ });
119
+ export const certificationBadgeDoc = describeAppComponent()({
120
+ name: "CertificationBadge",
121
+ from: COMPONENTS,
122
+ description: "Marks certified or deprecated data wherever an object is shown, with a symbol and words as well as colour. Who certified it, when and why show on hover and focus.",
123
+ props: {
124
+ type: "object",
125
+ properties: {
126
+ certification: {
127
+ type: "object",
128
+ description: "The verdict a person recorded with `setCertification`; none draws nothing.",
129
+ properties: {
130
+ status: { type: "integer", enum: [1, 2], description: "1 certified, 2 deprecated." },
131
+ setBy: { type: "string" },
132
+ setAt: { type: "string" },
133
+ note: { type: "string" },
134
+ },
135
+ },
136
+ },
137
+ },
138
+ parts: [],
139
+ callbacks: [],
140
+ example: { certification: { status: 1, setBy: "Ada Lovelace", setAt: "2026-11-01T10:00:00Z", note: "Reconciled with finance." } },
141
+ });
142
+ export const itemControlsDoc = describeAppComponent()({
143
+ name: "ItemControls",
144
+ from: COMPONENTS,
145
+ description: "The controls of one item (a tile, a framed component) as a row of icons: quiet until the item is pointed at or focused, each named at once in a tooltip, one tab stop with arrows between them. Build the shared actions with `standardControls(name, actions)` so their order, wording and icons are the same everywhere.",
146
+ props: {
147
+ type: "object",
148
+ properties: {
149
+ label: { type: "string", description: 'Names the group: "Refund rate by category controls".' },
150
+ show: { type: "string", enum: ["hover", "always"], description: "Shown on hover and focus (and always on touch), or always." },
151
+ quietable: { type: "boolean", description: "Whether an outer layer of controls can hide these." },
152
+ },
153
+ required: ["label"],
154
+ },
155
+ parts: [{ prop: "controls", label: "Controls", description: "The actions, from `standardControls`. On the page: change, wider, narrower, earlier, later, duplicate and remove.", required: true }],
156
+ callbacks: [],
157
+ example: { label: "Revenue by month controls", show: "always" },
158
+ });
159
+ export const navBarDoc = describeAppComponent()({
160
+ name: "NavBar",
161
+ from: COMPONENTS,
162
+ description: "Navigation across the top of a site, after Apple's: the sections on a glass bar that stays at the top, and beneath it the current section's name and its pages. Content scrolls under both and an edge appears once it does. On a narrow screen the sections fold into a menu that covers the screen as a dialog. It takes the same groups as `SideNav`, so a site can move between the two.",
163
+ props: {
164
+ type: "object",
165
+ properties: {
166
+ label: { type: "string", description: 'What the navigation is for, for assistive technology: "Surfaces UI".' },
167
+ groups: {
168
+ type: "array",
169
+ description: "The sections, each with its pages. A section goes to its first page.",
170
+ items: {
171
+ type: "object",
172
+ properties: {
173
+ label: { type: "string", description: "The section's name in the bar." },
174
+ items: { type: "array", items: { type: "object", properties: { id: { type: "string" }, label: { type: "string" }, href: { type: "string" } }, required: ["id", "label"] } },
175
+ },
176
+ required: ["items"],
177
+ },
178
+ },
179
+ current: { type: "string", description: "The id of the page being shown." },
180
+ },
181
+ required: ["label", "groups"],
182
+ },
183
+ parts: [
184
+ { prop: "brand", label: "Brand", description: "A name or mark at the bar's start.", on: true },
185
+ { prop: "actions", label: "Actions", description: "A status or a picker at the bar's end; it moves into the menu on a narrow screen." },
186
+ ],
187
+ callbacks: [{ prop: "onSelect", description: "The id of the page a person chose." }],
188
+ example: {
189
+ label: "Acme analytics",
190
+ current: "revenue",
191
+ groups: [
192
+ { label: "Reports", items: [{ id: "revenue", label: "Revenue" }, { id: "refunds", label: "Refunds" }, { id: "stores", label: "Stores" }] },
193
+ { label: "Data", items: [{ id: "tables", label: "Tables" }, { id: "models", label: "Models" }] },
194
+ { label: "Settings", items: [{ id: "people", label: "People" }] },
195
+ ],
196
+ },
197
+ });
198
+ export const resizeHandleDoc = describeAppComponent()({
199
+ name: "ResizeHandle",
200
+ from: COMPONENTS,
201
+ description: "A handle on the right or bottom edge of something, dragged to change its width or height: the same handle Arrange draws between a Grid's columns and under a component, for an app to place between two panes of its own. A focusable separator that says its value and bounds; dragged with pointer events, so a mouse, a pen and a finger all work; moved by the arrow keys (Shift for bigger steps), Home and End; put back by Enter or a double click. It holds no size of its own: the host keeps `value`, draws each change from `onChange` and keeps the size on `onChangeEnd`. Its parent must be positioned, since it sits on that parent's edge.",
202
+ props: {
203
+ type: "object",
204
+ properties: {
205
+ edge: { type: "string", enum: ["right", "bottom"], description: '"right" sizes a width, dragged left and right; "bottom" a height, dragged up and down.' },
206
+ value: { type: "number", description: "The size it stands for, in any unit: pixels, a share, a percentage. Left out when no size is set yet." },
207
+ min: { type: "number", description: "The least it can be." },
208
+ max: { type: "number", description: "The most it can be." },
209
+ snap: { type: "number", description: "Values land on multiples of this (10 rounds to ten pixels)." },
210
+ step: { type: "number", description: "How far an arrow key moves it; Shift moves five steps. A twentieth of the range by default." },
211
+ unitPixels: { type: "number", description: "How many pixels on screen one unit is: 1 for pixels, a pane's width for a share of it. A function of the handle is read when a drag starts." },
212
+ label: { type: "string", description: 'What it resizes, for assistive technology: "Resize the map and the list".' },
213
+ valueText: { type: "string", description: 'The value in words, when a number alone does not say it: "40% and 60%".' },
214
+ always: { type: "boolean", description: "Shown all the time, rather than when its parent is pointed at or it has focus (it always shows on touch)." },
215
+ },
216
+ required: ["edge", "label"],
217
+ },
218
+ parts: [
219
+ { prop: "onReset", label: "Reset", description: "Enter or a double click puts the size back. On the page: back to half and half.", on: true },
220
+ { prop: "startFrom", label: "Start from what is drawn", description: "Where a drag starts when no `value` is set, such as the height drawn now." },
221
+ ],
222
+ callbacks: [
223
+ { prop: "onChange", description: "Each new value while it is dragged, and after each key." },
224
+ { prop: "onChangeEnd", description: "When a drag ends (committed, or cancelled by Escape back where it started) and after each key: where to keep the size." },
225
+ ],
226
+ example: { edge: "right", value: 0.5, min: 0.25, max: 0.75, step: 0.05, label: "Resize the map and the list", valueText: "50% and 50%" },
227
+ });
228
+ export const segmentedControlDoc = describeAppComponent()({
229
+ name: "SegmentedControl",
230
+ from: COMPONENTS,
231
+ description: "A few equal choices of which exactly one holds, as one bar: build or view, chart or table, light or dark. It is the bar `ReportBuilder` switches modes with. A radio group, so it is one tab stop and the arrow keys move the choice; the chosen segment is one thumb that slides between the options. It holds no choice of its own: the host keeps `value` and sets it from `onChange`. Use it to switch what is shown in place, for two to eight short options; for actions use buttons, and for many or long options a select.",
232
+ props: {
233
+ type: "object",
234
+ properties: {
235
+ label: { type: "string", description: 'What is being chosen, for assistive technology: "Mode", "Preview mode".' },
236
+ options: {
237
+ type: "array",
238
+ description: "The choices, in order. They share the width equally.",
239
+ items: {
240
+ type: "object",
241
+ properties: {
242
+ value: { type: "string", description: "What `onChange` reports." },
243
+ label: { type: "string", description: "The words on the segment." },
244
+ disabled: { type: "boolean", description: "Greyed and still reachable, for a choice that makes no sense right now." },
245
+ },
246
+ required: ["value", "label"],
247
+ },
248
+ },
249
+ value: { type: "string", description: "The chosen option's value." },
250
+ fit: { type: "string", enum: ["content", "fill"], description: '"content" is as wide as its options need; "fill" takes its parent\'s width.' },
251
+ name: { type: "string", description: "The radio group's name, when a form reads it. Made up otherwise." },
252
+ },
253
+ required: ["label", "options", "value"],
254
+ },
255
+ parts: [],
256
+ callbacks: [{ prop: "onChange", description: "The value of the option a person chose." }],
257
+ example: {
258
+ label: "Preview mode",
259
+ value: "page",
260
+ fit: "content",
261
+ options: [
262
+ { value: "page", label: "As the page" },
263
+ { value: "light", label: "Light" },
264
+ { value: "dark", label: "Dark" },
265
+ ],
266
+ },
267
+ });
268
+ const PEOPLE_EXAMPLE = [
269
+ { id: "u1", name: "Ana Admin", email: "ana@example.com", status: "On", owns: 4, signedIn: "Today" },
270
+ { id: "u2", name: "Ben Brook", email: "ben@example.com", status: "Turned off", owns: 0, signedIn: "3 May" },
271
+ { id: "u3", name: "Cleo Chen", email: "cleo@example.com", status: "On", owns: 12, signedIn: "Yesterday" },
272
+ { id: "u4", name: "Dev Diaz", email: "dev@example.com", status: "On", owns: 1, signedIn: "Never" },
273
+ ];
274
+ export const dataTableDoc = describeAppComponent()({
275
+ name: "DataTable",
276
+ from: COMPONENTS,
277
+ description: "The rows an app holds, as a table: people, invitations, jobs, keys. Headings ask the host to sort; check boxes say which rows are chosen (with `SelectionBar` for what to do with them); each row can carry its everyday actions as `ItemControls` and a menu on a right click. It sorts, filters and pages nothing itself: the host asks its own server and hands over one page, with `Pagination` beneath. Columns marked `medium` or `wide` give way as the table, not the window, narrows. For the rows of a query use `DataGrid`, which asks the engine.",
278
+ props: {
279
+ type: "object",
280
+ properties: {
281
+ label: { type: "string", description: 'What the rows are, for assistive technology: "People".' },
282
+ columns: {
283
+ type: "array",
284
+ description: "The columns, in order. A column's `cell` function draws it; without one the row's value under `id` is shown as text.",
285
+ items: {
286
+ type: "object",
287
+ properties: {
288
+ id: { type: "string", description: "Tells columns apart, and names the sort the table reports." },
289
+ label: { type: "string", description: "The heading." },
290
+ sortable: { type: "boolean", description: "Whether a press on the heading asks the host to sort by it." },
291
+ align: { type: "string", enum: ["start", "end"], description: '"end" for numbers.' },
292
+ show: { type: "string", enum: ["always", "medium", "wide"], description: "From what width of the table the column is shown: always, 36rem, or 52rem." },
293
+ },
294
+ required: ["id", "label"],
295
+ },
296
+ },
297
+ rows: { type: "array", description: "One page of rows, already sorted and filtered by the host, shown in the order given.", items: { type: "object" } },
298
+ rowHeader: { type: "string", description: "The column that names each row, drawn as its header. Defaults to the first." },
299
+ sort: {
300
+ type: "object",
301
+ description: "How the host has sorted the rows.",
302
+ properties: { column: { type: "string" }, desc: { type: "boolean" } },
303
+ required: ["column", "desc"],
304
+ },
305
+ allSelected: { type: "boolean", description: "Every row that matches is chosen, past this page too (see `SelectionBar`)." },
306
+ controlsShow: { type: "string", enum: ["always", "hover"], description: "Whether a row's controls are always shown (the default) or on hover and focus." },
307
+ loading: { type: "boolean", description: "The rows are being fetched." },
308
+ },
309
+ required: ["label", "columns", "rows"],
310
+ },
311
+ parts: [
312
+ { prop: "rowKey", label: "Row key", description: "A function giving each row a value that tells it apart: an id.", required: true },
313
+ { prop: "rowName", label: "Row name", description: 'A function giving the row\'s name, for its check box and controls: "Select Ana Admin". Defaults to the first column\'s text.' },
314
+ { prop: "selected", label: "Selection", description: "The keys of the rows ticked, with `onSelectedChange`: adds a check box to each row and the heading.", on: true },
315
+ { prop: "selectable", label: "Who can be chosen", description: "A function saying whether a row can be ticked: one that cannot shows no box." },
316
+ { prop: "rowControls", label: "Row controls", description: "A function giving a row's everyday actions, drawn with `ItemControls`.", on: true },
317
+ { prop: "rowMenu", label: "Row menu", description: "A function giving a row's menu, opened by a right click, a long press or the Menu key." },
318
+ { prop: "rowState", label: "Row state", description: 'A function giving a word put on the row as `data-state` for the host\'s own styling: "off".' },
319
+ { prop: "empty", label: "When empty", description: "What to show in place of rows when there are none." },
320
+ ],
321
+ callbacks: [
322
+ { prop: "onSortChange", description: "The column and direction a person asked to sort by. Fetch the rows in that order and pass them back." },
323
+ { prop: "onSelectedChange", description: "The keys now ticked." },
324
+ ],
325
+ example: {
326
+ label: "People",
327
+ rowHeader: "name",
328
+ sort: { column: "name", desc: false },
329
+ columns: [
330
+ { id: "name", label: "Name", sortable: true },
331
+ { id: "email", label: "Email", sortable: true, show: "medium" },
332
+ { id: "status", label: "Status" },
333
+ { id: "signedIn", label: "Last signed in", show: "wide" },
334
+ { id: "owns", label: "Owns", sortable: true, align: "end", show: "wide" },
335
+ ],
336
+ rows: PEOPLE_EXAMPLE,
337
+ },
338
+ });
339
+ export const selectionBarDoc = describeAppComponent()({
340
+ name: "SelectionBar",
341
+ from: COMPONENTS,
342
+ description: "What to do with the rows a person chose in a `DataTable`: how many, the actions, and Clear. When the whole page is ticked and more rows match, it offers to take every row that matches, so an action can reach rows on pages never opened; the host then acts on its search and filters, not on a list of keys. An action that takes something away comes last, after a gap. It runs nothing itself: ask first for anything hard to undo with `useConfirm`, and report what happened, and whom it left alone, with `ActionReceipt`. Nothing is drawn with nothing chosen.",
343
+ props: {
344
+ type: "object",
345
+ properties: {
346
+ count: { type: "integer", minimum: 0, description: "How many rows are chosen: those ticked, or all that match when `allMatching`." },
347
+ actions: {
348
+ type: "array",
349
+ description: "What can be done to them, in order; one with `danger` is moved last.",
350
+ items: {
351
+ type: "object",
352
+ properties: {
353
+ id: { type: "string" },
354
+ label: { type: "string", description: 'The button\'s words: "Turn off".' },
355
+ danger: { type: "boolean", description: "For an action that takes something away." },
356
+ disabled: { type: "boolean" },
357
+ expanded: { type: "boolean", description: "For an action that opens a form below the bar: whether it is open." },
358
+ },
359
+ required: ["id", "label"],
360
+ },
361
+ },
362
+ label: { type: "string", description: 'Names the bar for assistive technology. Defaults to "With the selected rows".' },
363
+ pageSelected: { type: "boolean", description: "Every row on this page is ticked." },
364
+ total: { type: "integer", minimum: 0, description: "How many rows match in all, across every page." },
365
+ allMatching: { type: "boolean", description: "Every row that matches is chosen, not only those ticked." },
366
+ busy: { type: "boolean", description: "An action is running: every button waits." },
367
+ },
368
+ required: ["count", "actions"],
369
+ },
370
+ parts: [{ prop: "children", label: "Form below", description: "Drawn under the actions: a form an action opened, such as who to hand the rows to." }],
371
+ callbacks: [
372
+ { prop: "onClear", description: "Untick everything." },
373
+ { prop: "onAllMatchingChange", description: "True when a person chooses every row that matches; false to go back to this page. Without it nothing is offered past the page." },
374
+ ],
375
+ example: {
376
+ count: 50,
377
+ total: 126,
378
+ pageSelected: true,
379
+ actions: [
380
+ { id: "turn-off", label: "Turn off", danger: true },
381
+ { id: "turn-on", label: "Turn back on" },
382
+ { id: "sign-out", label: "Sign out everywhere" },
383
+ ],
384
+ },
385
+ });
386
+ export const paginationDoc = describeAppComponent()({
387
+ name: "Pagination",
388
+ from: COMPONENTS,
389
+ description: 'Which rows are shown, "51–100 of 126", with Previous and Next, under a `DataTable` a host pages on its server. It holds no page of its own: the host keeps `offset` and fetches the page `onChange` asks for. Nothing is drawn when every row fits on one page.',
390
+ props: {
391
+ type: "object",
392
+ properties: {
393
+ offset: { type: "integer", minimum: 0, description: "Where this page starts, counting from 0." },
394
+ pageSize: { type: "integer", minimum: 1, description: "How many rows a page holds." },
395
+ total: { type: "integer", minimum: 0, description: "How many rows there are in all." },
396
+ label: { type: "string", description: 'Names the navigation. Defaults to "Pages".' },
397
+ busy: { type: "boolean", description: "A page is being fetched." },
398
+ },
399
+ required: ["offset", "pageSize", "total"],
400
+ },
401
+ parts: [],
402
+ callbacks: [{ prop: "onChange", description: "The offset of the page a person moved to." }],
403
+ example: { offset: 50, pageSize: 50, total: 126 },
404
+ });
405
+ export const confirmDialogDoc = describeAppComponent()({
406
+ name: "ConfirmDialog",
407
+ from: COMPONENTS,
408
+ description: 'Asks a person to confirm one action before it runs, as a modal dialog: the page behind cannot be used, focus starts inside (on Cancel for something that takes away) and returns where it was, and Escape or a press outside cancels. Name the button for the action ("Turn off"), never "OK", and say what cannot be undone. From an event handler, `useConfirm()` gives `confirm({ title, body, confirmLabel, danger })`, which resolves true or false. For something that can be undone, prefer doing it and offering Undo with `ActionReceipt`.',
409
+ props: {
410
+ type: "object",
411
+ properties: {
412
+ open: { type: "boolean", description: "Whether the dialog is showing." },
413
+ title: { type: "string", description: 'The question: "Turn off 5 accounts?"' },
414
+ confirmLabel: { type: "string", description: 'The button that goes ahead, named for what it does. Defaults to "Confirm".' },
415
+ cancelLabel: { type: "string", description: 'Defaults to "Cancel".' },
416
+ danger: { type: "boolean", description: "For something that takes away or cannot be undone." },
417
+ },
418
+ required: ["open", "title"],
419
+ },
420
+ parts: [{ prop: "body", label: "What will happen", description: "A sentence or two on what the action does and what cannot be undone.", on: true }],
421
+ callbacks: [
422
+ { prop: "onConfirm", description: "The person went ahead." },
423
+ { prop: "onCancel", description: "Cancel, Escape, or a press outside the dialog." },
424
+ ],
425
+ example: { open: false, title: "Turn off 5 accounts?", confirmLabel: "Turn off", danger: true },
426
+ });
427
+ export const statusBadgeDoc = describeAppComponent()({
428
+ name: "StatusBadge",
429
+ from: COMPONENTS,
430
+ description: "A short status beside the thing it describes: an account on or turned off, a job running or failed, an invitation waiting. Its words carry the meaning; the tone backs them up with a colour and a shape (a ring, a dot, a diamond, a square), so it reads the same without colour. For data that is certified or deprecated use `CertificationBadge`.",
431
+ props: {
432
+ type: "object",
433
+ properties: {
434
+ label: { type: "string", description: 'The status in a word or two: "Turned off".' },
435
+ tone: { type: "string", enum: ["neutral", "info", "success", "warning", "danger"], description: "How it should strike a person. Defaults to neutral." },
436
+ description: { type: "string", description: 'A sentence more, shown on hover and read after the label: "by Ana on 3 May".' },
437
+ },
438
+ required: ["label"],
439
+ },
440
+ parts: [],
441
+ callbacks: [],
442
+ example: { label: "Turned off", tone: "danger", description: "by Ana on 3 May" },
443
+ });
444
+ export const comboboxDoc = describeAppComponent()({
445
+ name: "Combobox",
446
+ from: COMPONENTS,
447
+ description: "A text box that suggests as a person types: a person to hand work to, a table, a tag. Anything may be typed; a suggestion is a shortcut. The host searches (on its server, for a long list) and passes the matches back as `options`; the box filters nothing. The ARIA 1.2 combobox: Down and Up move through the suggestions with focus kept in the box, Enter chooses (and with none highlighted, leaves Enter to the form), Escape closes the list and then clears the box. How many suggestions there are is announced.",
448
+ props: {
449
+ type: "object",
450
+ properties: {
451
+ label: { type: "string", description: "The field's name, shown above it." },
452
+ value: { type: "string", description: "The text in the box." },
453
+ options: {
454
+ type: "array",
455
+ description: "The suggestions for the text as it is now, best first.",
456
+ items: {
457
+ type: "object",
458
+ properties: {
459
+ value: { type: "string", description: "What choosing it puts in the box: an email, an id." },
460
+ label: { type: "string", description: "The words shown for it: a name." },
461
+ detail: { type: "string", description: "A second line." },
462
+ },
463
+ required: ["value", "label"],
464
+ },
465
+ },
466
+ loading: { type: "boolean", description: "Suggestions are being fetched." },
467
+ type: { type: "string", enum: ["text", "email", "search"], description: "The input's type." },
468
+ placeholder: { type: "string" },
469
+ required: { type: "boolean" },
470
+ disabled: { type: "boolean" },
471
+ name: { type: "string", description: "The input's name, when a form reads it." },
472
+ help: { type: "string", description: "A sentence under the field." },
473
+ },
474
+ required: ["label", "value", "options"],
475
+ },
476
+ parts: [],
477
+ callbacks: [
478
+ { prop: "onChange", description: "Every change to the text, typed or chosen. Search with it." },
479
+ { prop: "onPick", description: "The suggestion a person chose." },
480
+ ],
481
+ example: {
482
+ label: "Hand their work to",
483
+ type: "email",
484
+ value: "",
485
+ placeholder: "Their name or email",
486
+ options: [
487
+ { value: "ana@example.com", label: "Ana Admin", detail: "ana@example.com" },
488
+ { value: "cleo@example.com", label: "Cleo Chen", detail: "cleo@example.com" },
489
+ ],
490
+ },
491
+ });
492
+ /** Every app component of `@surfaces-ui/components`. */
493
+ export const popoverDoc = describeAppComponent()({
494
+ name: "Popover",
495
+ from: COMPONENTS,
496
+ description: "A button that opens a small panel of controls beneath it: a view's width, zoom and data state behind one View button on a crowded toolbar. The button carries its label and, optionally, a short summary of what is set now. The panel is a non-modal dialog opened by a disclosure button (`aria-expanded`, `aria-controls`): opening moves focus to its first control, Tab moves through it and on past it (which closes it), Escape closes it and puts focus back on the button, and a press or focus anywhere else closes it. It sits below the button, lined up with its start or end edge, moves along to stay inside the window and goes above the button only when there is no room below. It holds its own open state unless the host passes `open`. For a list of actions use `useContextMenu`; for a question that must be answered first, `ConfirmDialog`.",
497
+ props: {
498
+ type: "object",
499
+ properties: {
500
+ label: { type: "string", description: 'What the button says, and the panel\'s name for assistive technology: "View".' },
501
+ summary: { type: "string", description: 'A few words after the label saying what is set now: "Fit · 100% · Real data". Part of the button\'s name.' },
502
+ align: { type: "string", enum: ["start", "end"], description: "Line the panel up with the button's start edge (the default) or its end edge." },
503
+ open: { type: "boolean", description: "Open, when the host holds it. Leave out to let the popover hold it." },
504
+ defaultOpen: { type: "boolean", description: "Open at first, when the popover holds it. Being open when first drawn takes no focus from the page." },
505
+ disabled: { type: "boolean" },
506
+ },
507
+ required: ["label"],
508
+ },
509
+ parts: [{ prop: "children", label: "The panel's controls", description: "What the panel holds: selects, a `SegmentedControl`, check boxes. On the page: width, zoom and data state.", required: true }],
510
+ callbacks: [{ prop: "onOpenChange", description: "Every change asked for: the button, Escape, a press or focus outside. Set `open` from it when the host holds it." }],
511
+ example: { label: "View", summary: "Fit · 100% · Real data", align: "end" },
512
+ });
513
+ export const componentsAppComponents = [themePickerDoc, connectionBuilderDoc, modelLineageDoc, checksPanelDoc, objectInfoDoc, certificationBadgeDoc, itemControlsDoc, resizeHandleDoc, segmentedControlDoc, dataTableDoc, selectionBarDoc, paginationDoc, confirmDialogDoc, statusBadgeDoc, comboboxDoc, popoverDoc, navBarDoc];
514
+ /** A component's reference page, as Markdown: what it is for, its props, the parts a host supplies and an example. */
515
+ export function appComponentMarkdown(doc) {
516
+ const required = new Set(doc.props.required ?? []);
517
+ const typeOf = (schema) => (schema.enum ? schema.enum.map((v) => JSON.stringify(v)).join(" | ") : schema.type === "array" ? `${schema.items ? typeOf(schema.items) : "unknown"}[]` : (schema.type ?? "object"));
518
+ const cell = (text = "") => text.replace(/\|/g, "\\|").replace(/\n/g, " ");
519
+ const lines = [`# ${doc.name}`, "", `\`import { ${doc.name} } from "${doc.from}";\``, "", doc.description, ""];
520
+ const props = Object.entries(doc.props.properties);
521
+ if (props.length > 0) {
522
+ lines.push("## Props", "", "| Prop | Type | Required | What it is |", "|---|---|---|---|");
523
+ for (const [name, schema] of props)
524
+ lines.push(`| \`${name}\` | ${cell(typeOf(schema))} | ${required.has(name) ? "yes" : ""} | ${cell(schema.description)} |`);
525
+ lines.push("");
526
+ }
527
+ if (doc.parts.length > 0) {
528
+ lines.push("## Parts the host supplies", "", "Props that take code. Each is optional unless marked; the component leaves out what it needs it for.", "");
529
+ for (const part of doc.parts)
530
+ lines.push(`- \`${part.prop}\`${part.required ? " (required)" : ""}: **${part.label}.** ${part.description}`);
531
+ lines.push("");
532
+ }
533
+ if (doc.callbacks.length > 0) {
534
+ lines.push("## Callbacks", "");
535
+ for (const callback of doc.callbacks)
536
+ lines.push(`- \`${callback.prop}\`: ${callback.description}`);
537
+ lines.push("");
538
+ }
539
+ lines.push("## Example", "", "```tsx", appComponentCode(doc, doc.example, doc.parts.filter((p) => p.required || p.on).map((p) => p.prop)), "```", "");
540
+ return lines.join("\n");
541
+ }
542
+ /** The JSX for a component with these plain props and these parts switched on: what a page shows as its code. */
543
+ export function appComponentCode(doc, props, parts) {
544
+ const attribute = (name, value) => value === true ? name : typeof value === "string" ? `${name}=${JSON.stringify(value)}` : `${name}={${JSON.stringify(value)}}`;
545
+ const attributes = [
546
+ ...Object.entries(props)
547
+ .filter(([, value]) => value !== undefined && value !== false && !(Array.isArray(value) && value.length === 0))
548
+ .map(([name, value]) => attribute(name, value)),
549
+ ...doc.parts.filter((part) => parts.includes(part.prop)).map((part) => `${part.prop}={${part.prop}}`),
550
+ ...doc.callbacks.map((callback) => `${callback.prop}={…}`),
551
+ ];
552
+ const oneLine = `<${doc.name} ${attributes.join(" ")} />`;
553
+ return oneLine.length <= 100 ? oneLine : [`<${doc.name}`, ...attributes.map((a) => ` ${a}`), "/>"].join("\n");
554
+ }
555
+ //# sourceMappingURL=appComponents.js.map