@slotted/react 0.1.0-beta.42 → 0.1.0-beta.43

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 (298) hide show
  1. package/dist/{app-shell-D54YkU7E.js → app-shell-DsWhsSMU.js} +3 -2
  2. package/dist/app-shell.js +1 -1
  3. package/dist/attachment-TZykYNu5.js +300 -0
  4. package/dist/attachment.js +2 -2
  5. package/dist/{avatar-group-bJaZE1_C.js → avatar-group-Bzmmj2HI.js} +2 -1
  6. package/dist/avatar-group.js +1 -1
  7. package/dist/{carousel-B9nMK7Yf.js → carousel-CRNz-T3g.js} +1 -1
  8. package/dist/carousel.js +1 -1
  9. package/dist/{command-palette-C90CzfQi.js → command-palette-Bgf5tfCI.js} +160 -156
  10. package/dist/command-palette.js +1 -1
  11. package/dist/{data-grid-D106baPp.js → data-grid-DUft3rJb.js} +1 -1
  12. package/dist/data-grid.js +1 -1
  13. package/dist/{data-list-BA0xrySM.js → data-list-Dv3orBtf.js} +15 -15
  14. package/dist/data-list.js +1 -1
  15. package/dist/detail-panel-Cke3ZFU3.js +342 -0
  16. package/dist/detail-panel.js +2 -2
  17. package/dist/docs/action-bar.examples.md +768 -0
  18. package/dist/docs/action-bar.json +74 -50
  19. package/dist/docs/action-bar.md +49 -311
  20. package/dist/docs/app-shell.examples.md +1221 -64
  21. package/dist/docs/app-shell.json +92 -60
  22. package/dist/docs/app-shell.md +92 -57
  23. package/dist/docs/attachment.examples.md +689 -0
  24. package/dist/docs/attachment.json +69 -37
  25. package/dist/docs/attachment.md +44 -203
  26. package/dist/docs/avatar-group.json +111 -23
  27. package/dist/docs/avatar-group.md +487 -28
  28. package/dist/docs/button-group.json +98 -2
  29. package/dist/docs/button-group.md +411 -8
  30. package/dist/docs/calendar.examples.md +512 -0
  31. package/dist/docs/calendar.json +72 -24
  32. package/dist/docs/calendar.md +18 -147
  33. package/dist/docs/carousel.examples.md +868 -0
  34. package/dist/docs/carousel.json +58 -50
  35. package/dist/docs/carousel.md +66 -300
  36. package/dist/docs/cascader.examples.md +1269 -0
  37. package/dist/docs/cascader.json +72 -16
  38. package/dist/docs/cascader.md +78 -154
  39. package/dist/docs/chart.examples.md +734 -24
  40. package/dist/docs/chart.json +93 -13
  41. package/dist/docs/chart.md +28 -7
  42. package/dist/docs/clock.json +71 -15
  43. package/dist/docs/clock.md +326 -21
  44. package/dist/docs/code-block.json +79 -55
  45. package/dist/docs/code-block.md +417 -74
  46. package/dist/docs/color-picker.json +60 -12
  47. package/dist/docs/color-picker.md +245 -22
  48. package/dist/docs/column-manager.examples.md +764 -0
  49. package/dist/docs/column-manager.json +68 -12
  50. package/dist/docs/column-manager.md +44 -203
  51. package/dist/docs/command-palette.examples.md +747 -0
  52. package/dist/docs/command-palette.json +48 -24
  53. package/dist/docs/command-palette.md +60 -339
  54. package/dist/docs/currency-field.examples.md +355 -73
  55. package/dist/docs/currency-field.json +96 -64
  56. package/dist/docs/currency-field.md +57 -50
  57. package/dist/docs/dashboard-grid.examples.md +629 -0
  58. package/dist/docs/dashboard-grid.json +64 -16
  59. package/dist/docs/dashboard-grid.md +34 -152
  60. package/dist/docs/data-list.examples.md +1556 -0
  61. package/dist/docs/data-list.json +58 -18
  62. package/dist/docs/data-list.md +139 -224
  63. package/dist/docs/date-field.examples.md +543 -0
  64. package/dist/docs/date-field.json +64 -24
  65. package/dist/docs/date-field.md +22 -168
  66. package/dist/docs/datetime-field.examples.md +699 -0
  67. package/dist/docs/datetime-field.json +79 -31
  68. package/dist/docs/datetime-field.md +24 -269
  69. package/dist/docs/datetime-range-picker.examples.md +682 -0
  70. package/dist/docs/datetime-range-picker.json +117 -61
  71. package/dist/docs/datetime-range-picker.md +59 -224
  72. package/dist/docs/description-list.examples.md +652 -0
  73. package/dist/docs/description-list.json +49 -25
  74. package/dist/docs/description-list.md +33 -188
  75. package/dist/docs/detail-panel.examples.md +1177 -0
  76. package/dist/docs/detail-panel.json +69 -53
  77. package/dist/docs/detail-panel.md +114 -324
  78. package/dist/docs/entity-picker.examples.md +1037 -0
  79. package/dist/docs/entity-picker.json +66 -18
  80. package/dist/docs/entity-picker.md +56 -246
  81. package/dist/docs/event-calendar.examples.md +749 -49
  82. package/dist/docs/event-calendar.json +46 -22
  83. package/dist/docs/event-calendar.md +81 -11
  84. package/dist/docs/field-group.examples.md +554 -0
  85. package/dist/docs/field-group.json +98 -34
  86. package/dist/docs/field-group.md +55 -133
  87. package/dist/docs/filter-bar.examples.md +772 -0
  88. package/dist/docs/filter-bar.json +41 -25
  89. package/dist/docs/filter-bar.md +42 -246
  90. package/dist/docs/form.examples.md +579 -0
  91. package/dist/docs/form.json +87 -39
  92. package/dist/docs/form.md +53 -177
  93. package/dist/docs/fullscreen.examples.md +558 -0
  94. package/dist/docs/fullscreen.json +58 -18
  95. package/dist/docs/fullscreen.md +50 -169
  96. package/dist/docs/highlight.json +57 -25
  97. package/dist/docs/highlight.md +402 -50
  98. package/dist/docs/icon.json +85 -5
  99. package/dist/docs/icon.md +401 -10
  100. package/dist/docs/image.examples.md +670 -0
  101. package/dist/docs/image.json +44 -28
  102. package/dist/docs/image.md +24 -176
  103. package/dist/docs/import-export-center.examples.md +1280 -0
  104. package/dist/docs/import-export-center.json +67 -27
  105. package/dist/docs/import-export-center.md +121 -226
  106. package/dist/docs/list-item.examples.md +769 -0
  107. package/dist/docs/list-item.json +110 -38
  108. package/dist/docs/list-item.md +84 -201
  109. package/dist/docs/listbox.examples.md +858 -0
  110. package/dist/docs/listbox.json +76 -28
  111. package/dist/docs/listbox.md +41 -263
  112. package/dist/docs/markdown.json +79 -55
  113. package/dist/docs/markdown.md +581 -85
  114. package/dist/docs/media-viewer.examples.md +1038 -0
  115. package/dist/docs/media-viewer.json +70 -15
  116. package/dist/docs/media-viewer.md +84 -135
  117. package/dist/docs/message-scroller.examples.md +1193 -0
  118. package/dist/docs/message-scroller.json +41 -17
  119. package/dist/docs/message-scroller.md +80 -134
  120. package/dist/docs/message.examples.md +944 -0
  121. package/dist/docs/message.json +64 -16
  122. package/dist/docs/message.md +34 -326
  123. package/dist/docs/meter.json +58 -26
  124. package/dist/docs/meter.md +312 -32
  125. package/dist/docs/navigation-menu.examples.md +1107 -0
  126. package/dist/docs/navigation-menu.json +57 -41
  127. package/dist/docs/navigation-menu.md +105 -298
  128. package/dist/docs/notification-center.examples.md +1045 -0
  129. package/dist/docs/notification-center.json +71 -15
  130. package/dist/docs/notification-center.md +76 -266
  131. package/dist/docs/otp-input.examples.md +490 -0
  132. package/dist/docs/otp-input.json +65 -25
  133. package/dist/docs/otp-input.md +20 -191
  134. package/dist/docs/page-header.examples.md +1041 -0
  135. package/dist/docs/page-header.json +75 -43
  136. package/dist/docs/page-header.md +79 -291
  137. package/dist/docs/page.examples.md +633 -0
  138. package/dist/docs/page.json +48 -16
  139. package/dist/docs/page.md +62 -129
  140. package/dist/docs/prompt-composer.examples.md +630 -0
  141. package/dist/docs/prompt-composer.json +66 -18
  142. package/dist/docs/prompt-composer.md +35 -161
  143. package/dist/docs/prose.json +69 -37
  144. package/dist/docs/prose.md +393 -75
  145. package/dist/docs/rating.examples.md +525 -0
  146. package/dist/docs/rating.json +92 -28
  147. package/dist/docs/rating.md +27 -241
  148. package/dist/docs/saved-views.examples.md +1108 -0
  149. package/dist/docs/saved-views.json +53 -21
  150. package/dist/docs/saved-views.md +86 -171
  151. package/dist/docs/scroll-area.examples.md +837 -0
  152. package/dist/docs/scroll-area.json +64 -24
  153. package/dist/docs/scroll-area.md +57 -140
  154. package/dist/docs/section.examples.md +676 -0
  155. package/dist/docs/section.json +68 -20
  156. package/dist/docs/section.md +39 -162
  157. package/dist/docs/segmented-control.examples.md +480 -0
  158. package/dist/docs/segmented-control.json +76 -28
  159. package/dist/docs/segmented-control.md +20 -191
  160. package/dist/docs/side-navigation.examples.md +1468 -0
  161. package/dist/docs/side-navigation.json +53 -53
  162. package/dist/docs/side-navigation.md +79 -354
  163. package/dist/docs/slider.examples.md +505 -0
  164. package/dist/docs/slider.json +91 -51
  165. package/dist/docs/slider.md +47 -212
  166. package/dist/docs/sparkline.json +60 -36
  167. package/dist/docs/sparkline.md +447 -71
  168. package/dist/docs/split-button.examples.md +509 -0
  169. package/dist/docs/split-button.json +73 -41
  170. package/dist/docs/split-button.md +64 -194
  171. package/dist/docs/splitter.examples.md +921 -0
  172. package/dist/docs/splitter.json +94 -46
  173. package/dist/docs/splitter.md +75 -182
  174. package/dist/docs/stat-card.examples.md +725 -0
  175. package/dist/docs/stat-card.json +89 -41
  176. package/dist/docs/stat-card.md +55 -227
  177. package/dist/docs/status-indicator.json +80 -32
  178. package/dist/docs/status-indicator.md +409 -65
  179. package/dist/docs/stepper.json +53 -21
  180. package/dist/docs/stepper.md +369 -48
  181. package/dist/docs/table-of-contents.examples.md +550 -0
  182. package/dist/docs/table-of-contents.json +60 -28
  183. package/dist/docs/table-of-contents.md +70 -205
  184. package/dist/docs/tags-input.examples.md +541 -0
  185. package/dist/docs/tags-input.json +64 -16
  186. package/dist/docs/tags-input.md +15 -262
  187. package/dist/docs/time-field.examples.md +587 -0
  188. package/dist/docs/time-field.json +69 -29
  189. package/dist/docs/time-field.md +21 -223
  190. package/dist/docs/time-picker.json +117 -53
  191. package/dist/docs/time-picker.md +499 -54
  192. package/dist/docs/time-range-picker.examples.md +750 -0
  193. package/dist/docs/time-range-picker.json +139 -75
  194. package/dist/docs/time-range-picker.md +63 -225
  195. package/dist/docs/timeline.examples.md +617 -0
  196. package/dist/docs/timeline.json +44 -28
  197. package/dist/docs/timeline.md +34 -208
  198. package/dist/docs/toolbar.json +56 -16
  199. package/dist/docs/toolbar.md +357 -63
  200. package/dist/docs/top-navigation.examples.md +1206 -140
  201. package/dist/docs/top-navigation.json +49 -33
  202. package/dist/docs/top-navigation.md +87 -36
  203. package/dist/docs/tour.examples.md +960 -0
  204. package/dist/docs/tour.json +57 -25
  205. package/dist/docs/tour.md +60 -244
  206. package/dist/docs/transfer.examples.md +631 -0
  207. package/dist/docs/transfer.json +80 -16
  208. package/dist/docs/transfer.md +41 -170
  209. package/dist/docs/typography.json +96 -0
  210. package/dist/docs/typography.md +352 -4
  211. package/dist/docs/upload.examples.md +555 -53
  212. package/dist/docs/upload.json +62 -30
  213. package/dist/docs/upload.md +46 -11
  214. package/dist/docs/wizard.examples.md +1389 -0
  215. package/dist/docs/wizard.json +89 -49
  216. package/dist/docs/wizard.md +122 -263
  217. package/dist/{entity-picker-CC4VoC3p.js → entity-picker-C78f3Z0o.js} +9 -6
  218. package/dist/entity-picker.js +1 -1
  219. package/dist/{event-calendar-CjmF_e0H.js → event-calendar-DJPoCi-O.js} +1 -1
  220. package/dist/event-calendar.js +1 -1
  221. package/dist/{filter-bar-B3QJD7SZ.js → filter-bar-D61wiQFP.js} +1 -1
  222. package/dist/filter-bar.js +1 -1
  223. package/dist/{import-export-center-CW8YVZev.js → import-export-center-mqvmlzwB.js} +44 -36
  224. package/dist/import-export-center.js +1 -1
  225. package/dist/index.js +58 -58
  226. package/dist/{markdown-BdskE4-L.js → markdown-8CtV4k44.js} +2 -2
  227. package/dist/markdown.js +1 -1
  228. package/dist/{media-viewer-zEXcwfEY.js → media-viewer-C_cbuAq-.js} +64 -60
  229. package/dist/media-viewer.js +2 -2
  230. package/dist/message-P91bEGyV.js +455 -0
  231. package/dist/message.js +2 -2
  232. package/dist/{page-header-DmwBGwlm.js → page-header-jeAIQSZM.js} +103 -108
  233. package/dist/page-header.js +1 -1
  234. package/dist/section-CVTQdWBl.js +216 -0
  235. package/dist/section.js +2 -2
  236. package/dist/{segmented-control-CbK7SurB.js → segmented-control-BSMVjukr.js} +1 -1
  237. package/dist/segmented-control.js +1 -1
  238. package/dist/{side-navigation-CKRETc8E.js → side-navigation-BQzBxz2B.js} +179 -179
  239. package/dist/side-navigation.js +1 -1
  240. package/dist/{stat-card-CL3Xe6pV.js → stat-card-BpGZiFbG.js} +12 -14
  241. package/dist/stat-card.js +1 -1
  242. package/dist/{stepper-DHdrANZI.js → stepper-Cxb_tHnA.js} +130 -127
  243. package/dist/stepper.js +2 -2
  244. package/dist/styles/carousel.css +1 -1
  245. package/dist/styles/index.css +1 -1
  246. package/dist/styles.css +1 -1
  247. package/dist/{timeline-BiL2CXfn.js → timeline-ZngK6zLC.js} +9 -6
  248. package/dist/timeline.js +1 -1
  249. package/dist/top-navigation-YSEQzBhD.js +744 -0
  250. package/dist/top-navigation.js +2 -2
  251. package/dist/{transfer-sKUvmEKe.js → transfer-Cv5yQuTN.js} +1 -1
  252. package/dist/transfer.js +1 -1
  253. package/dist/types/attachment/attachment-parts.d.ts +24 -11
  254. package/dist/types/attachment/attachment-parts.d.ts.map +1 -1
  255. package/dist/types/attachment/attachment.d.ts +3 -3
  256. package/dist/types/attachment/attachment.d.ts.map +1 -1
  257. package/dist/types/avatar-group/avatar-group.d.ts.map +1 -1
  258. package/dist/types/carousel/carousel-parts.d.ts +2 -2
  259. package/dist/types/command-palette/command-palette.d.ts.map +1 -1
  260. package/dist/types/data-list/data-list.d.ts.map +1 -1
  261. package/dist/types/detail-panel/detail-panel-parts.d.ts +10 -3
  262. package/dist/types/detail-panel/detail-panel-parts.d.ts.map +1 -1
  263. package/dist/types/detail-panel/detail-panel.d.ts.map +1 -1
  264. package/dist/types/detail-panel/detail-panel.types.d.ts +7 -0
  265. package/dist/types/detail-panel/detail-panel.types.d.ts.map +1 -1
  266. package/dist/types/entity-picker/entity-picker.d.ts.map +1 -1
  267. package/dist/types/import-export-center/import-export-center.d.ts.map +1 -1
  268. package/dist/types/media-viewer/index.d.ts +2 -2
  269. package/dist/types/media-viewer/index.d.ts.map +1 -1
  270. package/dist/types/media-viewer/media-viewer-bar.d.ts +3 -1
  271. package/dist/types/media-viewer/media-viewer-bar.d.ts.map +1 -1
  272. package/dist/types/media-viewer/media-viewer.types.d.ts +1 -0
  273. package/dist/types/media-viewer/media-viewer.types.d.ts.map +1 -1
  274. package/dist/types/message/message-parts.d.ts +7 -0
  275. package/dist/types/message/message-parts.d.ts.map +1 -1
  276. package/dist/types/message/message.d.ts.map +1 -1
  277. package/dist/types/page-header/page-header-parts.d.ts.map +1 -1
  278. package/dist/types/section/section-parts.d.ts +16 -8
  279. package/dist/types/section/section-parts.d.ts.map +1 -1
  280. package/dist/types/section/section.d.ts.map +1 -1
  281. package/dist/types/segmented-control/segmented-control-parts.d.ts.map +1 -1
  282. package/dist/types/side-navigation/side-navigation-parts.d.ts.map +1 -1
  283. package/dist/types/stat-card/stat-card-delta.d.ts.map +1 -1
  284. package/dist/types/stat-card/stat-card-parts.d.ts +3 -3
  285. package/dist/types/stat-card/stat-card-parts.d.ts.map +1 -1
  286. package/dist/types/stepper/stepper-parts.d.ts +11 -2
  287. package/dist/types/stepper/stepper-parts.d.ts.map +1 -1
  288. package/dist/types/stepper/stepper.d.ts.map +1 -1
  289. package/dist/types/timeline/timeline-parts.d.ts.map +1 -1
  290. package/dist/types/top-navigation/top-navigation.d.ts.map +1 -1
  291. package/dist/{wizard-4c0X7Bx_.js → wizard-Dfryz1id.js} +214 -214
  292. package/dist/wizard.js +1 -1
  293. package/package.json +6 -6
  294. package/dist/attachment-MqczA38F.js +0 -292
  295. package/dist/detail-panel-EImAtksY.js +0 -327
  296. package/dist/message-D1Dd6Y2k.js +0 -452
  297. package/dist/section-D_qOfdxR.js +0 -213
  298. package/dist/top-navigation-D8IHPOmm.js +0 -744
@@ -150,13 +150,13 @@
150
150
  "part": "spotlight",
151
151
  "element": "div",
152
152
  "required": false,
153
- "purpose": "The cutout round the target; its shadow is the scrim. It travels from one target to the next. Absent on a centerd step and under spotlight={false}."
153
+ "purpose": "The cutout round the target; its shadow is the scrim. It travels from one target to the next. Absent on a centered step and under spotlight={false}."
154
154
  },
155
155
  {
156
156
  "part": "surface",
157
157
  "element": "div",
158
158
  "required": true,
159
- "purpose": "The layer the positioner places, with data-side and data-align; centerd by the stylesheet when the step has no target."
159
+ "purpose": "The layer the positioner places, with data-side and data-align; centered by the stylesheet when the step has no target."
160
160
  },
161
161
  {
162
162
  "part": "focus-guard",
@@ -168,7 +168,7 @@
168
168
  "part": "arrow",
169
169
  "element": "div",
170
170
  "required": false,
171
- "purpose": "Points at the target from the card’s edge. Absent on a centerd step and under arrow={false}."
171
+ "purpose": "Points at the target from the card’s edge. Absent on a centered step and under arrow={false}."
172
172
  },
173
173
  {
174
174
  "part": "content",
@@ -389,7 +389,7 @@
389
389
  "type": "'center' | 'skip'",
390
390
  "defaultValue": "center",
391
391
  "appliesTo": "Tour",
392
- "description": "A step whose target cannot be found is shown centerd, or passed over"
392
+ "description": "A step whose target cannot be found is shown centered, or passed over"
393
393
  },
394
394
  {
395
395
  "name": "keyboardNavigation",
@@ -445,7 +445,7 @@
445
445
  "type": "Element | Ref | string | () => Element | null",
446
446
  "defaultValue": "—",
447
447
  "appliesTo": "TourStep",
448
- "description": "What the step points at; absent for a centerd step"
448
+ "description": "What the step points at; absent for a centered step"
449
449
  },
450
450
  {
451
451
  "name": "title",
@@ -529,7 +529,7 @@
529
529
  "type": "(props) => ReactElement",
530
530
  "defaultValue": "the part’s element",
531
531
  "appliesTo": "every part",
532
- "description": "Substitutes a part’s element; attach props.ref beside your own"
532
+ "description": "Substitutes a part’s element; attach props.ref beside any ref the consumer holds"
533
533
  },
534
534
  {
535
535
  "name": "native props",
@@ -561,7 +561,7 @@
561
561
  {
562
562
  "name": "onClick and onKeyDown on each part",
563
563
  "payload": "the element’s own event",
564
- "when": "Run before the family’s own handler; preventDefault() in yours stops it — a Next that validates first."
564
+ "when": "Runs before the tour’s own handler; preventDefault() in it stops that handler — a Next that validates first."
565
565
  }
566
566
  ],
567
567
  "accessibility": [
@@ -655,16 +655,16 @@
655
655
  "title": "Where the card stands",
656
656
  "note": "Each step names the side of its target; the card flips when that side has no room and slides along the edge to stay on screen, and the arrow keeps pointing at the target.",
657
657
  "language": "tsx",
658
- "source": "const steps: TourStep[] = [\n { id: 'nav', target: '#nav', side: 'inline-end', title: 'Every workspace' },\n { id: 'export', target: '#export', side: 'top', align: 'end', title: 'Export' },\n];\n\n<Tour side=\"bottom\" steps={steps} />;\n",
659
- "verdict": "excerpt"
658
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Tour, type TourStep } from '@slotted/react/tour';\n\nconst STEPS: TourStep[] = [\n {\n id: 'top',\n target: '#tour-placement-orders',\n side: 'top',\n align: 'start',\n title: 'Above, at the start',\n description: 'side top, align start.',\n },\n {\n id: 'bottom',\n target: '#tour-placement-orders',\n side: 'bottom',\n align: 'end',\n title: 'Below, at the end',\n description: 'side bottom, align end.',\n },\n {\n id: 'inline-start',\n target: '#tour-placement-orders',\n side: 'inline-start',\n align: 'center',\n title: 'Before the target',\n description: 'side inline-start, align center. The side follows the writing direction.',\n },\n {\n id: 'inline-end',\n target: '#tour-placement-orders',\n side: 'inline-end',\n align: 'start',\n title: 'After the target',\n description: 'side inline-end, align start. The side follows the writing direction.',\n },\n {\n id: 'left',\n target: '#tour-placement-orders',\n side: 'left',\n align: 'end',\n title: 'On the physical left',\n description: 'side left, align end. The side ignores the writing direction.',\n },\n {\n id: 'right',\n target: '#tour-placement-orders',\n side: 'right',\n align: 'center',\n title: 'On the physical right',\n description: 'side right, align center. The side ignores the writing direction.',\n },\n {\n id: 'default',\n target: '#tour-placement-orders',\n title: 'The tour decides',\n description: 'The step names no side and no align, so the side and align of the tour apply.',\n },\n];\n\nexport default function TourPlacement() {\n const [open, setOpen] = useState(false);\n\n return (\n <Inline align=\"center\" gap={3} justify=\"center\">\n <Button id=\"tour-placement-orders\" tone=\"secondary\" variant=\"outline\">\n Open orders\n </Button>\n <Button onClick={() => setOpen(true)}>Start tour</Button>\n <Tour align=\"start\" open={open} onOpenChange={setOpen} side=\"bottom\" steps={STEPS} />\n </Inline>\n );\n}\n",
659
+ "verdict": "example"
660
660
  },
661
661
  {
662
662
  "id": "centered",
663
663
  "title": "A step with no target",
664
664
  "note": "The opening step points at nothing: it stands in the middle of the screen over the whole scrim, with a picture above the header and its own words, “Not now” and “Start tour”.",
665
665
  "language": "tsx",
666
- "source": "const step: TourStep = {\n id: 'welcome',\n title: 'Welcome to Reports',\n description: 'Five stops, about a minute.',\n media: <img alt=\"\" src=\"/tour/reports.png\" />,\n messages: { next: 'Start tour', skip: 'Not now' },\n};\n",
667
- "verdict": "excerpt"
666
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Tour, type TourStep } from '@slotted/react/tour';\n\nconst STEPS: TourStep[] = [\n {\n id: 'welcome',\n title: 'Welcome to Shipments',\n description: 'Follow every order from the pick list to the carrier. Two stops, under a minute.',\n media: (\n <svg aria-hidden=\"true\" height=\"96\" viewBox=\"0 0 320 96\" width=\"100%\">\n <rect fill=\"currentColor\" height=\"96\" opacity=\"0.08\" width=\"320\" />\n <rect fill=\"currentColor\" height=\"36\" opacity=\"0.35\" width=\"40\" x=\"60\" y=\"48\" />\n <rect fill=\"currentColor\" height=\"56\" opacity=\"0.5\" width=\"40\" x=\"120\" y=\"28\" />\n <rect fill=\"currentColor\" height=\"44\" opacity=\"0.35\" width=\"40\" x=\"180\" y=\"40\" />\n <rect fill=\"currentColor\" height=\"68\" opacity=\"0.65\" width=\"40\" x=\"240\" y=\"16\" />\n </svg>\n ),\n messages: { next: 'Start tour', skip: 'Not now' },\n },\n {\n id: 'carrier',\n target: '#tour-centered-carrier',\n title: 'Choose a carrier',\n description: 'Rates update as the parcel weight changes.',\n },\n {\n id: 'label',\n target: '#tour-centered-label',\n title: 'Print the label',\n description: 'The label carries the tracking number and the pick list reference.',\n messages: { done: 'Got it' },\n },\n];\n\nexport default function TourCentered() {\n const [open, setOpen] = useState(false);\n\n return (\n <Stack gap={4}>\n <Inline gap={3}>\n <Button id=\"tour-centered-carrier\" tone=\"secondary\" variant=\"outline\">\n Carrier\n </Button>\n <Button id=\"tour-centered-label\" tone=\"secondary\" variant=\"outline\">\n Print label\n </Button>\n </Inline>\n <Inline gap={3}>\n <Button onClick={() => setOpen(true)}>Start tour</Button>\n </Inline>\n <Tour open={open} onOpenChange={setOpen} steps={STEPS} />\n </Stack>\n );\n}\n",
667
+ "verdict": "example"
668
668
  },
669
669
  {
670
670
  "id": "spotlight",
@@ -687,48 +687,48 @@
687
687
  "title": "A step the reader completes",
688
688
  "note": "Press New report: the step is interactive, so the target stays operable, Next is gone, and the press on the target itself goes on — advanceOn names the event. Tab from the card reaches the target.",
689
689
  "language": "tsx",
690
- "source": "const step: TourStep = {\n id: 'create',\n target: '#new-report',\n title: 'Create your first report',\n description: 'Press New report. The tour continues once it opens.',\n interactive: true,\n advanceOn: 'click',\n};\n",
691
- "verdict": "excerpt"
690
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Tour, type TourStep } from '@slotted/react/tour';\nimport { Text } from '@slotted/react/typography';\n\nconst STEPS: TourStep[] = [\n {\n id: 'create',\n target: '#tour-interactive-new',\n title: 'Create your first report',\n description: 'Press New report. The tour continues once it is created.',\n interactive: true,\n advanceOn: 'click',\n },\n {\n id: 'listed',\n target: '#tour-interactive-count',\n title: 'It is on the list',\n description: 'Every saved report appears here and in the reports menu.',\n },\n];\n\nexport default function TourInteractive() {\n const [open, setOpen] = useState(false);\n const [count, setCount] = useState(2);\n\n return (\n <Stack gap={4}>\n <Inline align=\"center\" gap={3}>\n <Button id=\"tour-interactive-new\" onClick={() => setCount(count + 1)}>\n New report\n </Button>\n <Text id=\"tour-interactive-count\" size=\"sm\">\n Saved reports: {count}\n </Text>\n </Inline>\n <Inline gap={3}>\n <Button tone=\"secondary\" variant=\"outline\" onClick={() => setOpen(true)}>\n Start tour\n </Button>\n </Inline>\n <Tour open={open} onOpenChange={setOpen} steps={STEPS} />\n </Stack>\n );\n}\n",
691
+ "verdict": "example"
692
692
  },
693
693
  {
694
694
  "id": "availability",
695
695
  "title": "Steps that apply to this reader",
696
696
  "note": "Billing is only for owners: switch the role and the step drops out of the count — “1 of 3” becomes “1 of 4” — and Next and Back pass over it in both directions.",
697
697
  "language": "tsx",
698
- "source": "const step: TourStep = {\n id: 'billing',\n target: '#billing',\n title: 'Invoices and plans',\n when: () => user.role === 'owner',\n};\n",
699
- "verdict": "excerpt"
698
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Switch } from '@slotted/react/switch';\nimport { Tour, type TourStep } from '@slotted/react/tour';\n\nexport default function TourAvailability() {\n const [open, setOpen] = useState(false);\n const [owner, setOwner] = useState(false);\n\n const steps: TourStep[] = [\n {\n id: 'orders',\n target: '#tour-availability-orders',\n title: 'Orders',\n description: 'Every order from every channel, newest first.',\n },\n {\n id: 'billing',\n target: '#tour-availability-billing',\n title: 'Invoices and plans',\n description: 'Only owners see billing. Change the plan or download an invoice here.',\n when: () => owner,\n },\n {\n id: 'team',\n target: '#tour-availability-team',\n title: 'Team',\n description: 'Invite colleagues and set what each of them can do.',\n },\n ];\n\n return (\n <Stack gap={4}>\n <Switch checked={owner} labelPlacement=\"start\" onCheckedChange={setOwner}>\n Signed in as the account owner\n </Switch>\n <Inline gap={3}>\n <Button id=\"tour-availability-orders\" tone=\"secondary\" variant=\"outline\">\n Orders\n </Button>\n <Button id=\"tour-availability-billing\" tone=\"secondary\" variant=\"outline\">\n Billing\n </Button>\n <Button id=\"tour-availability-team\" tone=\"secondary\" variant=\"outline\">\n Team\n </Button>\n </Inline>\n <Inline gap={3}>\n <Button onClick={() => setOpen(true)}>Start tour</Button>\n </Inline>\n <Tour open={open} onOpenChange={setOpen} steps={steps} />\n </Stack>\n );\n}\n",
699
+ "verdict": "example"
700
700
  },
701
701
  {
702
702
  "id": "missing",
703
703
  "title": "A target that is not on the page",
704
- "note": "The sidebar is collapsed, so the sidebar step has nothing to point at. Under missing=\"center\" it stands centerd with data-missing and says what it had to say; under \"skip\" it is passed over.",
704
+ "note": "The sidebar is collapsed, so the sidebar step has nothing to point at. Under missing=\"center\" it stands centered with data-missing and says what it had to say; under \"skip\" it is passed over.",
705
705
  "language": "tsx",
706
- "source": "<Tour missing=\"skip\" steps={steps} targetTimeout={800} />;\n",
707
- "verdict": "excerpt"
706
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Tour, type TourMissing, type TourStep } from '@slotted/react/tour';\nimport { Text } from '@slotted/react/typography';\n\nconst STEPS: TourStep[] = [\n {\n id: 'search',\n target: '#tour-missing-search',\n title: 'Find any order',\n description: 'Search by order number, customer or tracking number.',\n },\n {\n id: 'warehouse',\n target: '#tour-missing-warehouse',\n title: 'Switch warehouse',\n description: 'The warehouse list is in the sidebar. Expand it to move between sites.',\n },\n {\n id: 'export',\n target: '#tour-missing-export',\n title: 'Export what you see',\n description: 'Download the filtered rows as a spreadsheet.',\n },\n];\n\nexport default function TourMissingTarget() {\n const [open, setOpen] = useState(false);\n const [missing, setMissing] = useState<TourMissing>('center');\n\n function handleStart(next: TourMissing) {\n setMissing(next);\n setOpen(true);\n }\n\n return (\n <Stack gap={4}>\n <Inline gap={3}>\n <Button id=\"tour-missing-search\" tone=\"secondary\" variant=\"outline\">\n Search\n </Button>\n <Button id=\"tour-missing-export\" tone=\"secondary\" variant=\"outline\">\n Export\n </Button>\n </Inline>\n <Text size=\"sm\" tone=\"muted\">\n The sidebar is collapsed, so the warehouse list is not on the page.\n </Text>\n <Inline gap={3}>\n <Button onClick={() => handleStart('center')}>Center the step</Button>\n <Button tone=\"secondary\" variant=\"outline\" onClick={() => handleStart('skip')}>\n Skip the step\n </Button>\n </Inline>\n <Tour missing={missing} open={open} onOpenChange={setOpen} steps={STEPS} />\n </Stack>\n );\n}\n",
707
+ "verdict": "example"
708
708
  },
709
709
  {
710
710
  "id": "prepare",
711
711
  "title": "Preparing the page for a step",
712
712
  "note": "The columns step opens the column menu first: prepare runs, Next carries its loading sweep for as long as it takes, and the card only moves once the menu — the step’s target — is on the page.",
713
713
  "language": "tsx",
714
- "source": "const step: TourStep = {\n id: 'columns',\n target: '#column-menu',\n title: 'Choose your columns',\n prepare: async (signal) => {\n setMenuOpen(true);\n await loadColumns({ signal });\n },\n};\n",
715
- "verdict": "excerpt"
714
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Card, CardBody } from '@slotted/react/card';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Tour, type TourStep } from '@slotted/react/tour';\nimport { Text } from '@slotted/react/typography';\n\nconst COLUMNS = ['Order number', 'Carrier', 'Ship date'];\n\nexport default function TourPrepare() {\n const [open, setOpen] = useState(false);\n const [menuOpen, setMenuOpen] = useState(false);\n\n const steps: TourStep[] = [\n {\n id: 'columns',\n target: '#tour-prepare-columns',\n title: 'Columns',\n description: 'Choose which columns the order table shows.',\n },\n {\n id: 'menu',\n target: '#tour-prepare-menu',\n title: 'Pick the columns',\n description: 'The list opened for this step.',\n content: 'Drag a column to change its position.',\n prepare: async () => {\n await new Promise<void>((resolve) => setTimeout(resolve, 600));\n setMenuOpen(true);\n },\n },\n ];\n\n function handleOpenChange(next: boolean) {\n setOpen(next);\n if (!next) setMenuOpen(false);\n }\n\n return (\n <Stack gap={4}>\n <Inline gap={3}>\n <Button id=\"tour-prepare-columns\" tone=\"secondary\" variant=\"outline\">\n Columns\n </Button>\n <Button onClick={() => setOpen(true)}>Start tour</Button>\n </Inline>\n {menuOpen && (\n <div id=\"tour-prepare-menu\">\n <Card>\n <CardBody>\n <Stack gap={2}>\n {COLUMNS.map((column) => (\n <Text key={column} size=\"sm\">\n {column}\n </Text>\n ))}\n </Stack>\n </CardBody>\n </Card>\n </div>\n )}\n <Tour open={open} onOpenChange={handleOpenChange} steps={steps} targetTimeout={500} />\n </Stack>\n );\n}\n",
715
+ "verdict": "example"
716
716
  },
717
717
  {
718
718
  "id": "controlled",
719
719
  "title": "The product owns the tour",
720
720
  "note": "open and step are the product’s: it starts at the step it saved, refuses to leave the filters step until a filter is chosen, and records the outcome — complete, skip or close — to decide whether to offer the tour again.",
721
721
  "language": "tsx",
722
- "source": "<Tour\n onOpenChange={(next, request) => {\n setOpen(next);\n if (!next) saveTourOutcome(request.outcome);\n }}\n onStepChange={(next, request) => {\n if (step === 'filters' && !hasFilter) return request.cancel();\n setStep(next);\n }}\n open={open}\n step={step}\n steps={steps}\n/>;\n",
723
- "verdict": "excerpt"
722
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Switch } from '@slotted/react/switch';\nimport { Tour, type TourStep } from '@slotted/react/tour';\nimport { Text } from '@slotted/react/typography';\n\nconst STEPS: TourStep[] = [\n {\n id: 'search',\n target: '#tour-controlled-search',\n title: 'Find any order',\n description: 'Search by order number, customer or tracking number.',\n },\n {\n id: 'filters',\n target: '#tour-controlled-filters',\n title: 'Turn the filter on',\n description: 'Next stays here until the filter is on.',\n interactive: true,\n },\n {\n id: 'export',\n target: '#tour-controlled-export',\n title: 'Export what you see',\n description: 'Download the filtered rows as a spreadsheet.',\n },\n];\n\nexport default function TourControlled() {\n const [open, setOpen] = useState(false);\n const [step, setStep] = useState<string | null>('search');\n const [filtered, setFiltered] = useState(false);\n const [outcome, setOutcome] = useState('none yet');\n\n function handleStart() {\n setStep('search');\n setOpen(true);\n }\n\n return (\n <Stack gap={4}>\n <Inline align=\"center\" gap={3}>\n <Button id=\"tour-controlled-search\" tone=\"secondary\" variant=\"outline\">\n Search\n </Button>\n <div id=\"tour-controlled-filters\">\n <Switch checked={filtered} onCheckedChange={setFiltered}>\n Open orders only\n </Switch>\n </div>\n <Button id=\"tour-controlled-export\" tone=\"secondary\" variant=\"outline\">\n Export\n </Button>\n </Inline>\n <Inline gap={3}>\n <Button onClick={handleStart}>Start tour</Button>\n </Inline>\n <Stack gap={1}>\n <Text size=\"sm\">Current step: {step ?? 'none'}</Text>\n <Text size=\"sm\">Last outcome: {outcome}</Text>\n </Stack>\n <Tour\n onOpenChange={(next, request) => {\n setOpen(next);\n if (!next) setOutcome(request.outcome ?? 'none');\n }}\n onStepChange={(next, request) => {\n if (step === 'filters' && next === 'export' && !filtered) request.cancel();\n else setStep(next);\n }}\n open={open}\n step={step}\n steps={STEPS}\n />\n </Stack>\n );\n}\n",
723
+ "verdict": "example"
724
724
  },
725
725
  {
726
726
  "id": "composition",
727
727
  "title": "Composing the card",
728
728
  "note": "The card is the product’s own arrangement: dots from useTour() instead of the progress text, an action of its own beside Next, and the title set as a heading one level down.",
729
729
  "language": "tsx",
730
- "source": "function Dots() {\n const { position, total } = useTour();\n return <span aria-hidden=\"true\">{'●'.repeat(position) + '○'.repeat(total - position)}</span>;\n}\n\n<Tour steps={steps}>\n <TourContent>\n <TourTitle render={(props) => <h3 {...props} />} />\n <TourDescription />\n <TourFooter>\n <Dots />\n <Button onClick={openHelp}>Read the guide</Button>\n <TourNext />\n </TourFooter>\n </TourContent>\n</Tour>;\n",
731
- "verdict": "excerpt"
730
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport {\n Tour,\n TourClose,\n TourContent,\n TourDescription,\n TourFooter,\n TourHeader,\n TourNext,\n TourPrev,\n TourProgress,\n type TourStep,\n TourTitle,\n useTour,\n} from '@slotted/react/tour';\nimport { Text } from '@slotted/react/typography';\n\nconst STEPS: TourStep[] = [\n {\n id: 'filters',\n target: '#tour-composition-filters',\n title: 'Narrow it down',\n description: 'Filter by region, carrier or date range.',\n },\n {\n id: 'export',\n target: '#tour-composition-export',\n title: 'Export what you see',\n description: 'Download the filtered rows as a spreadsheet.',\n },\n {\n id: 'share',\n target: '#tour-composition-share',\n title: 'Share with your team',\n description: 'Send a report to a colleague or a shared inbox.',\n },\n];\n\nexport default function TourComposition() {\n const [open, setOpen] = useState(false);\n const [guide, setGuide] = useState(false);\n\n return (\n <Stack gap={4}>\n <Inline gap={3}>\n <Button id=\"tour-composition-filters\" tone=\"secondary\" variant=\"outline\">\n Filters\n </Button>\n <Button id=\"tour-composition-export\" tone=\"secondary\" variant=\"outline\">\n Export\n </Button>\n <Button id=\"tour-composition-share\" tone=\"secondary\" variant=\"outline\">\n Share\n </Button>\n </Inline>\n <Inline align=\"center\" gap={3}>\n <Button onClick={() => setOpen(true)}>Start tour</Button>\n {guide && <Text size=\"sm\">The reports guide opened.</Text>}\n </Inline>\n <Tour open={open} onOpenChange={setOpen} steps={STEPS}>\n <TourContent>\n <TourHeader>\n <TourProgress />\n <TourClose />\n </TourHeader>\n <TourTitle render={(props) => <h3 {...props} />} />\n <TourDescription />\n <TourFooter>\n <Dots />\n <Button size=\"sm\" tone=\"secondary\" variant=\"ghost\" onClick={() => setGuide(true)}>\n Read the guide\n </Button>\n <TourPrev />\n <TourNext />\n </TourFooter>\n </TourContent>\n </Tour>\n </Stack>\n );\n}\n\nfunction Dots() {\n const { position, total } = useTour();\n\n return <span aria-hidden=\"true\">{'●'.repeat(position) + '○'.repeat(total - position)}</span>;\n}\n",
731
+ "verdict": "example"
732
732
  },
733
733
  {
734
734
  "id": "labels",
@@ -757,7 +757,7 @@
757
757
  {
758
758
  "id": "edges",
759
759
  "title": "Targets in the corners, and one that fills the screen",
760
- "note": "The corner steps ask for a side with no room: the card flips and slides and the arrow keeps pointing. The chart is taller than the room left around it, so its card is centerd over it while the spotlight still frames it.",
760
+ "note": "The corner steps ask for a side with no room: the card flips and slides and the arrow keeps pointing. The chart is taller than the room left around it, so its card is centered over it while the spotlight still frames it.",
761
761
  "language": "tsx",
762
762
  "source": "const steps: TourStep[] = [\n { id: 'alerts', target: '#alerts', side: 'top', title: 'Notifications' },\n { id: 'chart', target: '#chart', title: 'Revenue by region' },\n];\n",
763
763
  "verdict": "excerpt"
@@ -769,6 +769,38 @@
769
769
  "language": "tsx",
770
770
  "source": "const step: TourStep = {\n id: 'emails',\n target: '#invite-emails',\n title: 'Type their emails',\n prepare: async () => {\n setInviteOpen(true);\n },\n};\n",
771
771
  "verdict": "excerpt"
772
+ },
773
+ {
774
+ "id": "basic",
775
+ "title": "basic.tsx",
776
+ "note": null,
777
+ "language": "tsx",
778
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Tour, type TourStep } from '@slotted/react/tour';\n\nconst STEPS: TourStep[] = [\n {\n id: 'welcome',\n title: 'Welcome to Reports',\n description: 'Three stops, about a minute.',\n },\n {\n id: 'filters',\n target: '#tour-basic-filters',\n title: 'Narrow it down',\n description: 'Filter by region, carrier or date range.',\n },\n {\n id: 'share',\n target: '#tour-basic-share',\n title: 'Share with your team',\n description: 'Send a report to a colleague or a shared inbox.',\n },\n {\n id: 'export',\n target: '#tour-basic-export',\n title: 'Export what you see',\n description: 'Download the filtered rows as a spreadsheet.',\n },\n];\n\nexport default function TourBasic() {\n const [open, setOpen] = useState(false);\n\n return (\n <Stack gap={4}>\n <Inline gap={3}>\n <Button id=\"tour-basic-filters\" tone=\"secondary\" variant=\"outline\">\n Filters\n </Button>\n <Button id=\"tour-basic-share\" tone=\"secondary\" variant=\"outline\">\n Share\n </Button>\n <Button id=\"tour-basic-export\" tone=\"secondary\" variant=\"outline\">\n Export\n </Button>\n </Inline>\n <Inline gap={3}>\n <Button onClick={() => setOpen(true)}>Start tour</Button>\n </Inline>\n <Tour open={open} onOpenChange={setOpen} steps={STEPS} />\n </Stack>\n );\n}\n",
779
+ "verdict": "example"
780
+ },
781
+ {
782
+ "id": "handle",
783
+ "title": "handle.tsx",
784
+ "note": null,
785
+ "language": "tsx",
786
+ "source": "import { useRef } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Tour, type TourHandle, type TourStep } from '@slotted/react/tour';\n\nconst STEPS: TourStep[] = [\n {\n id: 'filters',\n target: '#tour-handle-filters',\n title: 'Narrow it down',\n description: 'Filter by region, carrier or date range.',\n },\n {\n id: 'share',\n target: '#tour-handle-share',\n title: 'Share with your team',\n description: 'Send a report to a colleague or a shared inbox.',\n },\n {\n id: 'export',\n target: '#tour-handle-export',\n title: 'Export what you see',\n description: 'Download the filtered rows as a spreadsheet.',\n },\n];\n\nexport default function TourHandleExample() {\n const tour = useRef<TourHandle>(null);\n\n return (\n <Stack gap={4}>\n <Inline gap={3}>\n <Button id=\"tour-handle-filters\" tone=\"secondary\" variant=\"outline\">\n Filters\n </Button>\n <Button id=\"tour-handle-share\" tone=\"secondary\" variant=\"outline\">\n Share\n </Button>\n <Button id=\"tour-handle-export\" tone=\"secondary\" variant=\"outline\">\n Export\n </Button>\n </Inline>\n <Inline gap={3}>\n <Button onClick={() => tour.current?.start()}>Start tour</Button>\n <Button tone=\"secondary\" variant=\"outline\" onClick={() => tour.current?.start('export')}>\n Show the export step\n </Button>\n </Inline>\n <Tour ref={tour} steps={STEPS} />\n </Stack>\n );\n}\n",
787
+ "verdict": "example"
788
+ },
789
+ {
790
+ "id": "options",
791
+ "title": "options.tsx",
792
+ "note": null,
793
+ "language": "tsx",
794
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Switch } from '@slotted/react/switch';\nimport { Tour, type TourStep } from '@slotted/react/tour';\n\nconst OPTIONS = [\n { key: 'spotlight', label: 'Spotlight on the target' },\n { key: 'arrow', label: 'Arrow toward the target' },\n { key: 'modal', label: 'Page inert behind the card' },\n { key: 'autoFocus', label: 'Focus the card on open' },\n { key: 'closeOnEscape', label: 'Escape closes the tour' },\n { key: 'closeOnOutsidePress', label: 'A press outside closes it' },\n { key: 'keyboardNavigation', label: 'Arrow keys go on and back' },\n] as const;\n\ntype OptionKey = (typeof OPTIONS)[number]['key'];\n\nconst INITIAL: Record<OptionKey, boolean> = {\n spotlight: true,\n arrow: true,\n modal: true,\n autoFocus: true,\n closeOnEscape: true,\n closeOnOutsidePress: false,\n keyboardNavigation: true,\n};\n\nconst STEPS: TourStep[] = [\n {\n id: 'filters',\n target: '#tour-options-filters',\n title: 'Filters',\n description: 'Narrow the order list by status or carrier.',\n },\n {\n id: 'share',\n target: '#tour-options-share',\n title: 'Share',\n description: 'Send the current view to a colleague.',\n },\n {\n id: 'export',\n target: '#tour-options-export',\n title: 'Export',\n description: 'Download the filtered rows as a spreadsheet.',\n },\n];\n\nexport default function TourOptions() {\n const [open, setOpen] = useState(false);\n const [options, setOptions] = useState(INITIAL);\n\n return (\n <Stack gap={4}>\n <Stack gap={3}>\n {OPTIONS.map((option) => (\n <Switch\n key={option.key}\n checked={options[option.key]}\n labelPlacement=\"start\"\n onCheckedChange={(checked) => setOptions({ ...options, [option.key]: checked })}\n >\n {option.label}\n </Switch>\n ))}\n </Stack>\n <Inline gap={3}>\n <Button id=\"tour-options-filters\" tone=\"secondary\" variant=\"outline\">\n Filters\n </Button>\n <Button id=\"tour-options-share\" tone=\"secondary\" variant=\"outline\">\n Share\n </Button>\n <Button id=\"tour-options-export\" tone=\"secondary\" variant=\"outline\">\n Export\n </Button>\n </Inline>\n <Inline gap={3}>\n <Button onClick={() => setOpen(true)}>Start tour</Button>\n </Inline>\n <Tour {...options} open={open} onOpenChange={setOpen} steps={STEPS} />\n </Stack>\n );\n}\n",
795
+ "verdict": "example"
796
+ },
797
+ {
798
+ "id": "sizes",
799
+ "title": "sizes.tsx",
800
+ "note": null,
801
+ "language": "tsx",
802
+ "source": "import { useState } from 'react';\n\nimport { Button } from '@slotted/react/button';\nimport { Inline } from '@slotted/react/inline';\nimport { Stack } from '@slotted/react/stack';\nimport { Tour, type TourLayout, type TourSize, type TourStep } from '@slotted/react/tour';\n\ninterface Choice {\n label: string;\n layout: TourLayout;\n size: TourSize;\n}\n\nconst CHOICES: Choice[] = [\n { label: 'Small', layout: 'auto', size: 'sm' },\n { label: 'Medium', layout: 'auto', size: 'md' },\n { label: 'Large', layout: 'auto', size: 'lg' },\n { label: 'Compact layout', layout: 'compact', size: 'md' },\n];\n\nconst STEPS: TourStep[] = [\n {\n id: 'stock',\n target: '#tour-sizes-stock',\n side: 'inline-end',\n title: 'Stock level',\n description: 'Units on hand across the Rotterdam and Antwerp warehouses.',\n },\n {\n id: 'reorder',\n target: '#tour-sizes-stock',\n side: 'inline-end',\n title: 'Reorder point',\n description: 'A product below its reorder point appears in the purchasing queue.',\n },\n];\n\nexport default function TourSizes() {\n const [open, setOpen] = useState(false);\n const [choice, setChoice] = useState<Choice>(CHOICES[1] as Choice);\n\n function handleStart(next: Choice) {\n setChoice(next);\n setOpen(true);\n }\n\n return (\n <Stack gap={4}>\n <Inline gap={3}>\n <Button id=\"tour-sizes-stock\" tone=\"secondary\" variant=\"outline\">\n Stock level\n </Button>\n </Inline>\n <Inline gap={3}>\n {CHOICES.map((item) => (\n <Button key={item.label} onClick={() => handleStart(item)}>\n {item.label}\n </Button>\n ))}\n </Inline>\n <Tour\n layout={choice.layout}\n open={open}\n onOpenChange={setOpen}\n size={choice.size}\n steps={STEPS}\n />\n </Stack>\n );\n}\n",
803
+ "verdict": "example"
772
804
  }
773
805
  ]
774
806
  }
package/dist/docs/tour.md CHANGED
@@ -11,20 +11,65 @@ import { Tour, TourDefaultsProvider, useTour } from '@slotted/react';
11
11
 
12
12
  ## Minimal example
13
13
 
14
- Excerpt — not a complete module
14
+ Example
15
15
 
16
16
  ```tsx
17
- const steps: TourStep[] = [
18
- { id: 'welcome', title: 'Welcome to Reports', description: 'Five stops, about a minute.' },
19
- { id: 'search', target: '#search', title: 'Find any report' },
20
- { id: 'filters', target: '#filters', title: 'Narrow it down' },
21
- { id: 'share', target: '#share', title: 'Share with your team' },
22
- { id: 'export', target: '#export', title: 'Export what you see' },
23
- ];
17
+ import { useState } from 'react';
18
+
19
+ import { Button } from '@slotted/react/button';
20
+ import { Inline } from '@slotted/react/inline';
21
+ import { Stack } from '@slotted/react/stack';
22
+ import { Tour, type TourStep } from '@slotted/react/tour';
24
23
 
25
- const [open, setOpen] = useState(false);
24
+ const STEPS: TourStep[] = [
25
+ {
26
+ id: 'welcome',
27
+ title: 'Welcome to Reports',
28
+ description: 'Three stops, about a minute.',
29
+ },
30
+ {
31
+ id: 'filters',
32
+ target: '#tour-basic-filters',
33
+ title: 'Narrow it down',
34
+ description: 'Filter by region, carrier or date range.',
35
+ },
36
+ {
37
+ id: 'share',
38
+ target: '#tour-basic-share',
39
+ title: 'Share with your team',
40
+ description: 'Send a report to a colleague or a shared inbox.',
41
+ },
42
+ {
43
+ id: 'export',
44
+ target: '#tour-basic-export',
45
+ title: 'Export what you see',
46
+ description: 'Download the filtered rows as a spreadsheet.',
47
+ },
48
+ ];
26
49
 
27
- <Tour onOpenChange={setOpen} open={open} steps={steps} />;
50
+ export default function TourBasic() {
51
+ const [open, setOpen] = useState(false);
52
+
53
+ return (
54
+ <Stack gap={4}>
55
+ <Inline gap={3}>
56
+ <Button id="tour-basic-filters" tone="secondary" variant="outline">
57
+ Filters
58
+ </Button>
59
+ <Button id="tour-basic-share" tone="secondary" variant="outline">
60
+ Share
61
+ </Button>
62
+ <Button id="tour-basic-export" tone="secondary" variant="outline">
63
+ Export
64
+ </Button>
65
+ </Inline>
66
+ <Inline gap={3}>
67
+ <Button onClick={() => setOpen(true)}>Start tour</Button>
68
+ </Inline>
69
+ <Tour open={open} onOpenChange={setOpen} steps={STEPS} />
70
+ </Stack>
71
+ );
72
+ }
28
73
  ```
29
74
 
30
75
  ## Anatomy
@@ -74,7 +119,7 @@ const [open, setOpen] = useState(false);
74
119
  | `closeOnEscape` | `boolean` | true | Tour | Escape closes, with the outcome close |
75
120
  | `closeOnOutsidePress` | `boolean` | false | Tour | A press outside the card closes; off so a stray press keeps the reader’s place |
76
121
  | `scrollIntoView` | `boolean` | true | Tour | Scrolls a target that is not wholly on screen to the middle |
77
- | `missing` | `'center' \| 'skip'` | center | Tour | A step whose target cannot be found is shown centerd, or passed over |
122
+ | `missing` | `'center' \| 'skip'` | center | Tour | A step whose target cannot be found is shown centered, or passed over |
78
123
  | `keyboardNavigation` | `boolean` | true | Tour | ArrowRight and ArrowLeft go on and back from the card |
79
124
  | `targetTimeout` | `number` | 0 | Tour | Milliseconds to watch the page for a target that is not there yet |
80
125
  | `messages` | `PartialMessages<TourMessages>` | — | Tour | Words laid over the language in force, key by key: next, prev, done, skip, close, preparing, and progress with {position} and {total} |
@@ -82,7 +127,7 @@ const [open, setOpen] = useState(false);
82
127
  | `children` | `ReactNode` | the whole card | Tour | The consumer’s own arrangement of the parts |
83
128
  | `ref` | `Ref<TourHandle>` | — | Tour | start(id?), next(), prev(), goTo(id), close(outcome?), reposition() |
84
129
  | `id` | `string` | — | TourStep | Unique in the tour; the value of step |
85
- | `target` | `Element \| Ref \| string \| () => Element \| null` | — | TourStep | What the step points at; absent for a centerd step |
130
+ | `target` | `Element \| Ref \| string \| () => Element \| null` | — | TourStep | What the step points at; absent for a centered step |
86
131
  | `title` | `ReactNode` | — | TourStep | The card’s title and accessible name |
87
132
  | `description` | `ReactNode` | — | TourStep | The card’s accessible description |
88
133
  | `content` | `ReactNode` | — | TourStep | The body, which scrolls |
@@ -94,7 +139,7 @@ const [open, setOpen] = useState(false);
94
139
  | `messages` | `PartialMessages<{ next, prev, skip, done }>` | — | TourStep | The step’s own words, laid over the tour’s: “Start tour”, “Got it” |
95
140
  | `actions` | `{ prev?, next?, skip?, close?: boolean }` | by position | TourStep | Shows or hides the card’s own controls for the step |
96
141
  | `announcement` | `string` | the title’s text | TourStep | Read out when the step arrives while focus is elsewhere |
97
- | `render` | `(props) => ReactElement` | the part’s element | every part | Substitutes a part’s element; attach props.ref beside your own |
142
+ | `render` | `(props) => ReactElement` | the part’s element | every part | Substitutes a part’s element; attach props.ref beside any ref the consumer holds |
98
143
  | `native props` | `ComponentPropsWithRef<…>` | — | every part | aria-*, data-*, className, style and handlers reach the part’s element |
99
144
  | `TourDefaultsProvider` | `{ size, side, align, modal, spotlight, missing, targetTimeout, container, … }` | — | a subtree | The decisions an application takes once; a tour or a step that states any of them wins |
100
145
 
@@ -104,7 +149,7 @@ const [open, setOpen] = useState(false);
104
149
  | --- | --- | --- |
105
150
  | `onOpenChange` | `(open: boolean, request: ChangeRequest<boolean> & { outcome?: 'complete' \| 'skip' \| 'close' \| 'unavailable' })` | Before the tour opens (programmatic, from start()) or closes: Done (pointer, keyboard; outcome complete), Skip (outcome skip), the close control (dismiss; close), Escape (escape; close), a press outside (outsidePress; close), the way back (back; close), or no step being available (programmatic; unavailable). cancel() keeps it open. |
106
151
  | `onStepChange` | `(step: string \| null, request: ChangeRequest<string \| null>)` | Before the current step moves: Next, Back (pointer, keyboard), the arrow keys (keyboard), advanceOn (the reason of the event on the target), goTo() and start(id) (programmatic), and a step that stood in for an unavailable one (programmatic). cancel() keeps the card where it is. |
107
- | `onClick and onKeyDown on each part` | `the element’s own event` | Run before the family’s own handler; preventDefault() in yours stops it — a Next that validates first. |
152
+ | `onClick and onKeyDown on each part` | `the element’s own event` | Runs before the tour’s own handler; preventDefault() in it stops that handler — a Next that validates first. |
108
153
 
109
154
  ## Axes and defaults
110
155
 
@@ -138,233 +183,4 @@ const [open, setOpen] = useState(false);
138
183
 
139
184
  ## Examples
140
185
 
141
- ### Where the card stands
142
-
143
- Each step names the side of its target; the card flips when that side has no room and slides along the edge to stay on screen, and the arrow keeps pointing at the target.
144
-
145
- Excerpt — not a complete module
146
-
147
- ```tsx
148
- const steps: TourStep[] = [
149
- { id: 'nav', target: '#nav', side: 'inline-end', title: 'Every workspace' },
150
- { id: 'export', target: '#export', side: 'top', align: 'end', title: 'Export' },
151
- ];
152
-
153
- <Tour side="bottom" steps={steps} />;
154
- ```
155
-
156
- ### A step with no target
157
-
158
- The opening step points at nothing: it stands in the middle of the screen over the whole scrim, with a picture above the header and its own words, “Not now” and “Start tour”.
159
-
160
- Excerpt — not a complete module
161
-
162
- ```tsx
163
- const step: TourStep = {
164
- id: 'welcome',
165
- title: 'Welcome to Reports',
166
- description: 'Five stops, about a minute.',
167
- media: <img alt="" src="/tour/reports.png" />,
168
- messages: { next: 'Start tour', skip: 'Not now' },
169
- };
170
- ```
171
-
172
- ### With and without the spotlight
173
-
174
- The spotlight cuts the target out of the scrim and travels to the next one. spotlight={false} on a non-modal tour is a coach mark: a card beside its control and nothing dimmed.
175
-
176
- Excerpt — not a complete module
177
-
178
- ```tsx
179
- <Tour
180
- modal={false}
181
- spotlight={false}
182
- steps={[{ id: 'views', target: '#views', title: 'Keep this view', messages: { done: 'Got it' } }]}
183
- />;
184
- ```
185
-
186
- ### What a modal step does to the page
187
-
188
- On a modal step the page is inert — out of reach of the pointer, the keyboard and a screen reader — Tab stays inside the card, and Escape closes. modal={false} leaves the page reachable.
189
-
190
- Excerpt — not a complete module
191
-
192
- ```tsx
193
- <Tour closeOnOutsidePress modal={false} steps={steps} />;
194
- ```
195
-
196
- ### A step the reader completes
197
-
198
- Press New report: the step is interactive, so the target stays operable, Next is gone, and the press on the target itself goes on — advanceOn names the event. Tab from the card reaches the target.
199
-
200
- Excerpt — not a complete module
201
-
202
- ```tsx
203
- const step: TourStep = {
204
- id: 'create',
205
- target: '#new-report',
206
- title: 'Create your first report',
207
- description: 'Press New report. The tour continues once it opens.',
208
- interactive: true,
209
- advanceOn: 'click',
210
- };
211
- ```
212
-
213
- ### Steps that apply to this reader
214
-
215
- Billing is only for owners: switch the role and the step drops out of the count — “1 of 3” becomes “1 of 4” — and Next and Back pass over it in both directions.
216
-
217
- Excerpt — not a complete module
218
-
219
- ```tsx
220
- const step: TourStep = {
221
- id: 'billing',
222
- target: '#billing',
223
- title: 'Invoices and plans',
224
- when: () => user.role === 'owner',
225
- };
226
- ```
227
-
228
- ### A target that is not on the page
229
-
230
- The sidebar is collapsed, so the sidebar step has nothing to point at. Under missing="center" it stands centerd with data-missing and says what it had to say; under "skip" it is passed over.
231
-
232
- Excerpt — not a complete module
233
-
234
- ```tsx
235
- <Tour missing="skip" steps={steps} targetTimeout={800} />;
236
- ```
237
-
238
- ### Preparing the page for a step
239
-
240
- The columns step opens the column menu first: prepare runs, Next carries its loading sweep for as long as it takes, and the card only moves once the menu — the step’s target — is on the page.
241
-
242
- Excerpt — not a complete module
243
-
244
- ```tsx
245
- const step: TourStep = {
246
- id: 'columns',
247
- target: '#column-menu',
248
- title: 'Choose your columns',
249
- prepare: async (signal) => {
250
- setMenuOpen(true);
251
- await loadColumns({ signal });
252
- },
253
- };
254
- ```
255
-
256
- ### The product owns the tour
257
-
258
- open and step are the product’s: it starts at the step it saved, refuses to leave the filters step until a filter is chosen, and records the outcome — complete, skip or close — to decide whether to offer the tour again.
259
-
260
- Excerpt — not a complete module
261
-
262
- ```tsx
263
- <Tour
264
- onOpenChange={(next, request) => {
265
- setOpen(next);
266
- if (!next) saveTourOutcome(request.outcome);
267
- }}
268
- onStepChange={(next, request) => {
269
- if (step === 'filters' && !hasFilter) return request.cancel();
270
- setStep(next);
271
- }}
272
- open={open}
273
- step={step}
274
- steps={steps}
275
- />;
276
- ```
277
-
278
- ### Composing the card
279
-
280
- The card is the product’s own arrangement: dots from useTour() instead of the progress text, an action of its own beside Next, and the title set as a heading one level down.
281
-
282
- Excerpt — not a complete module
283
-
284
- ```tsx
285
- function Dots() {
286
- const { position, total } = useTour();
287
- return <span aria-hidden="true">{'●'.repeat(position) + '○'.repeat(total - position)}</span>;
288
- }
289
-
290
- <Tour steps={steps}>
291
- <TourContent>
292
- <TourTitle render={(props) => <h3 {...props} />} />
293
- <TourDescription />
294
- <TourFooter>
295
- <Dots />
296
- <Button onClick={openHelp}>Read the guide</Button>
297
- <TourNext />
298
- </TourFooter>
299
- </TourContent>
300
- </Tour>;
301
- ```
302
-
303
- ### The tour in another language
304
-
305
- The language in force says Próximo, Voltar, Concluir, Pular tour and “2 de 5” once for the application; a long German progress and title wrap inside the card rather than widening it.
306
-
307
- Excerpt — not a complete module
308
-
309
- ```tsx
310
- <SlottedProvider locale="pt-BR" catalogs={{ 'pt-BR': PT_BR }}>
311
- <App />
312
- </SlottedProvider>;
313
-
314
- <Tour messages={{ progress: 'Passo {position} de {total}' }} steps={steps} />;
315
- ```
316
-
317
- ### Walking the tour from the keyboard
318
-
319
- Start with Enter: focus lands on the card. ArrowRight and ArrowLeft go on and back — mirrored right to left — Tab reaches the buttons, and Escape closes and gives focus back to Start tour.
320
-
321
- Excerpt — not a complete module
322
-
323
- ```tsx
324
- const tour = useRef<TourHandle>(null);
325
-
326
- <>
327
- <Button onClick={() => tour.current?.start()}>Start tour</Button>
328
- <Tour ref={tour} steps={steps} />
329
- </>;
330
- ```
331
-
332
- ### On a phone
333
-
334
- Below 600 pixels of viewport the card stops standing beside its target: a lateral side turns vertical and the card takes the width the screen has. layout="compact" forces it here; on a real phone auto takes it by itself.
335
-
336
- Excerpt — not a complete module
337
-
338
- ```tsx
339
- <Tour layout="compact" steps={steps} />;
340
- ```
341
-
342
- ### Targets in the corners, and one that fills the screen
343
-
344
- The corner steps ask for a side with no room: the card flips and slides and the arrow keeps pointing. The chart is taller than the room left around it, so its card is centerd over it while the spotlight still frames it.
345
-
346
- Excerpt — not a complete module
347
-
348
- ```tsx
349
- const steps: TourStep[] = [
350
- { id: 'alerts', target: '#alerts', side: 'top', title: 'Notifications' },
351
- { id: 'chart', target: '#chart', title: 'Revenue by region' },
352
- ];
353
- ```
354
-
355
- ### Over a dialog a step opens
356
-
357
- The second step opens the invite dialog in its prepare and points inside it. The tour stays on top — the dialog is the layer made inert, focus stays in the card — and Escape closes the tour while the dialog stays open.
358
-
359
- Excerpt — not a complete module
360
-
361
- ```tsx
362
- const step: TourStep = {
363
- id: 'emails',
364
- target: '#invite-emails',
365
- title: 'Type their emails',
366
- prepare: async () => {
367
- setInviteOpen(true);
368
- },
369
- };
370
- ```
186
+ See [tour.examples.md](./tour.examples.md).