@1doc/1ds-react 2.7.2 → 2.9.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 (302) hide show
  1. package/CHANGELOG.md +1280 -0
  2. package/dist/components/AIContent/AIContent.d.ts +10 -0
  3. package/dist/components/AIContent/AIContent.js +1 -1
  4. package/dist/components/AILabel/AILabel.d.ts +4 -0
  5. package/dist/components/AILabel/AILabel.js +2 -2
  6. package/dist/components/Accordion/Accordion.d.ts +6 -2
  7. package/dist/components/Alert/Alert.css +2 -0
  8. package/dist/components/Alert/Alert.d.ts +3 -1
  9. package/dist/components/Alert/Alert.js +7 -1
  10. package/dist/components/AppHeader/AppHeader.css +82 -8
  11. package/dist/components/AppHeader/AppHeader.d.ts +12 -1
  12. package/dist/components/AppHeader/AppHeader.js +186 -1
  13. package/dist/components/AppNavItem/AppNavItem.css +11 -3
  14. package/dist/components/AppShell/AppShell.css +9 -0
  15. package/dist/components/AppShell/AppShell.d.ts +8 -0
  16. package/dist/components/AppShell/AppShell.js +4 -1
  17. package/dist/components/AppSidebar/AppSidebar.css +1 -1
  18. package/dist/components/AppSidebar/AppSidebar.d.ts +4 -0
  19. package/dist/components/AppSidebar/AppSidebar.js +3 -1
  20. package/dist/components/AttachmentCard/AttachmentCard.css +17 -1
  21. package/dist/components/AttachmentCard/AttachmentCard.d.ts +29 -2
  22. package/dist/components/AttachmentCard/AttachmentCard.js +88 -20
  23. package/dist/components/Avatar/Avatar.css +7 -2
  24. package/dist/components/Avatar/AvatarGroup.d.ts +27 -0
  25. package/dist/components/Avatar/AvatarGroup.js +28 -4
  26. package/dist/components/Badge/Badge.css +61 -3
  27. package/dist/components/Badge/Badge.d.ts +14 -4
  28. package/dist/components/Badge/Badge.js +1 -0
  29. package/dist/components/BottomSheet/BottomSheet.css +1 -0
  30. package/dist/components/BottomSheet/BottomSheet.d.ts +8 -0
  31. package/dist/components/BottomSheet/BottomSheet.js +14 -2
  32. package/dist/components/Box/Box.css +83 -0
  33. package/dist/components/Box/Box.d.ts +82 -2
  34. package/dist/components/Box/Box.js +42 -2
  35. package/dist/components/Button/Button.css +29 -0
  36. package/dist/components/Button/Button.d.ts +4 -4
  37. package/dist/components/Button/Button.js +4 -1
  38. package/dist/components/Calendar/Calendar.css +245 -0
  39. package/dist/components/Calendar/Calendar.d.ts +125 -0
  40. package/dist/components/Calendar/Calendar.js +320 -0
  41. package/dist/components/Chart/BarChart.d.ts +6 -0
  42. package/dist/components/Chart/BarChart.js +3 -1
  43. package/dist/components/Chart/LineChart.d.ts +6 -0
  44. package/dist/components/Chart/LineChart.js +3 -1
  45. package/dist/components/Checkbox/Checkbox.css +4 -1
  46. package/dist/components/Chips/Chips.css +39 -0
  47. package/dist/components/Chips/Chips.d.ts +7 -2
  48. package/dist/components/Chips/Chips.js +6 -2
  49. package/dist/components/Coachmark/Coachmark.css +118 -0
  50. package/dist/components/Coachmark/Coachmark.d.ts +75 -0
  51. package/dist/components/Coachmark/Coachmark.js +321 -0
  52. package/dist/components/CodeBlock/CodeBlock.css +96 -0
  53. package/dist/components/CodeBlock/CodeBlock.d.ts +47 -0
  54. package/dist/components/CodeBlock/CodeBlock.js +103 -0
  55. package/dist/components/ColorPicker/ColorPicker.css +133 -0
  56. package/dist/components/ColorPicker/ColorPicker.d.ts +73 -0
  57. package/dist/components/ColorPicker/ColorPicker.js +219 -0
  58. package/dist/components/Combobox/Combobox.css +11 -3
  59. package/dist/components/ConfirmAIAction/ConfirmAIAction.d.ts +11 -1
  60. package/dist/components/ConfirmAIAction/ConfirmAIAction.js +6 -1
  61. package/dist/components/ConfirmDialog/ConfirmDialog.css +3 -0
  62. package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +14 -0
  63. package/dist/components/ConfirmDialog/ConfirmDialog.js +2 -2
  64. package/dist/components/DataTable/DataTable.css +80 -0
  65. package/dist/components/DataTable/DataTable.d.ts +23 -4
  66. package/dist/components/DataTable/DataTable.js +61 -15
  67. package/dist/components/DatePicker/DatePicker.css +8 -0
  68. package/dist/components/DatePicker/DatePicker.d.ts +4 -0
  69. package/dist/components/DatePicker/DatePicker.js +14 -1
  70. package/dist/components/DescriptionList/DescriptionList.css +113 -0
  71. package/dist/components/DescriptionList/DescriptionList.d.ts +59 -0
  72. package/dist/components/DescriptionList/DescriptionList.js +51 -0
  73. package/dist/components/Drawer/Drawer.css +1 -0
  74. package/dist/components/Dropdown/Dropdown.js +47 -29
  75. package/dist/components/FileInput/FileInput.css +24 -4
  76. package/dist/components/FileInput/FileInput.d.ts +22 -2
  77. package/dist/components/FileInput/FileInput.js +23 -2
  78. package/dist/components/Grid/Grid.js +5 -5
  79. package/dist/components/IconPicker/IconPicker.css +107 -0
  80. package/dist/components/IconPicker/IconPicker.d.ts +74 -0
  81. package/dist/components/IconPicker/IconPicker.js +194 -0
  82. package/dist/components/Input/Input.css +41 -3
  83. package/dist/components/Input/Input.d.ts +14 -1
  84. package/dist/components/Input/Input.js +72 -6
  85. package/dist/components/Kanban/Kanban.css +5 -0
  86. package/dist/components/Kanban/Kanban.d.ts +41 -0
  87. package/dist/components/Kanban/Kanban.js +59 -27
  88. package/dist/components/Kanban/KanbanCard.d.ts +2 -0
  89. package/dist/components/Kanban/KanbanCard.js +1 -1
  90. package/dist/components/Kanban/KanbanColumn.d.ts +2 -0
  91. package/dist/components/Kanban/KanbanColumn.js +3 -0
  92. package/dist/components/Kbd/Kbd.css +66 -0
  93. package/dist/components/Kbd/Kbd.d.ts +32 -0
  94. package/dist/components/Kbd/Kbd.js +40 -0
  95. package/dist/components/Link/Link.css +1 -1
  96. package/dist/components/List/List.css +136 -0
  97. package/dist/components/List/List.d.ts +82 -0
  98. package/dist/components/List/List.js +53 -0
  99. package/dist/components/List/ListItem.d.ts +85 -0
  100. package/dist/components/List/ListItem.js +81 -0
  101. package/dist/components/Modal/Modal.css +93 -8
  102. package/dist/components/Modal/Modal.d.ts +45 -7
  103. package/dist/components/Modal/Modal.js +106 -6
  104. package/dist/components/MultiSelect/MultiSelect.css +9 -1
  105. package/dist/components/MultiSelect/MultiSelect.js +45 -8
  106. package/dist/components/OrgChart/OrgChart.css +149 -0
  107. package/dist/components/OrgChart/OrgChart.d.ts +83 -0
  108. package/dist/components/OrgChart/OrgChart.js +297 -0
  109. package/dist/components/OtpInput/OtpInput.css +93 -0
  110. package/dist/components/OtpInput/OtpInput.d.ts +60 -0
  111. package/dist/components/OtpInput/OtpInput.js +215 -0
  112. package/dist/components/Pagination/Pagination.d.ts +6 -0
  113. package/dist/components/Pagination/Pagination.js +9 -1
  114. package/dist/components/PhoneInput/PhoneInput.css +9 -1
  115. package/dist/components/PhoneInput/PhoneInput.d.ts +10 -0
  116. package/dist/components/PhoneInput/PhoneInput.js +20 -3
  117. package/dist/components/Popover/Popover.d.ts +7 -0
  118. package/dist/components/Popover/Popover.js +11 -1
  119. package/dist/components/RichTextEditor/RichTextEditor.css +203 -0
  120. package/dist/components/RichTextEditor/RichTextEditor.d.ts +83 -0
  121. package/dist/components/RichTextEditor/RichTextEditor.js +494 -0
  122. package/dist/components/SegmentedControl/SegmentedControl.d.ts +2 -0
  123. package/dist/components/SegmentedControl/SegmentedControl.js +21 -8
  124. package/dist/components/Select/Select.css +71 -1
  125. package/dist/components/Select/Select.d.ts +12 -0
  126. package/dist/components/Select/Select.js +93 -10
  127. package/dist/components/SidePanel/SidePanel.css +4 -4
  128. package/dist/components/SidePanelItem/SidePanelItem.css +7 -5
  129. package/dist/components/SidePanelSearch/SidePanelSearch.css +2 -2
  130. package/dist/components/SidePanelSection/SidePanelSection.css +7 -5
  131. package/dist/components/Stack/Stack.css +49 -0
  132. package/dist/components/Stack/Stack.d.ts +65 -7
  133. package/dist/components/Stack/Stack.js +30 -2
  134. package/dist/components/StatCard/StatCard.css +73 -0
  135. package/dist/components/StatCard/StatCard.d.ts +17 -0
  136. package/dist/components/StatCard/StatCard.js +4 -1
  137. package/dist/components/Stepper/Stepper.css +4 -1
  138. package/dist/components/Stepper/Stepper.d.ts +8 -0
  139. package/dist/components/Stepper/Stepper.js +4 -4
  140. package/dist/components/Switch/Switch.css +1 -0
  141. package/dist/components/Tabs/Tab.d.ts +15 -0
  142. package/dist/components/Tabs/Tab.js +30 -1
  143. package/dist/components/Tabs/Tabs.css +132 -0
  144. package/dist/components/Tabs/Tabs.d.ts +7 -0
  145. package/dist/components/Tabs/Tabs.js +13 -2
  146. package/dist/components/Tag/Tag.css +85 -2
  147. package/dist/components/Tag/Tag.d.ts +13 -6
  148. package/dist/components/Tag/Tag.js +1 -0
  149. package/dist/components/Text/Text.d.ts +9 -1
  150. package/dist/components/Text/Text.js +2 -2
  151. package/dist/components/Textarea/Textarea.css +11 -3
  152. package/dist/components/TimePicker/TimePicker.css +8 -0
  153. package/dist/components/TimePicker/TimePicker.d.ts +6 -0
  154. package/dist/components/TimePicker/TimePicker.js +1 -1
  155. package/dist/components/Tooltip/Tooltip.css +40 -0
  156. package/dist/components/Tooltip/Tooltip.d.ts +11 -0
  157. package/dist/components/Tooltip/Tooltip.js +114 -11
  158. package/dist/index.d.ts +25 -0
  159. package/dist/index.js +14 -0
  160. package/dist/teste/AILabel.test.d.ts +1 -0
  161. package/dist/teste/AILabel.test.js +33 -0
  162. package/dist/teste/AccordionConteudoLivre.test.d.ts +1 -0
  163. package/dist/teste/AccordionConteudoLivre.test.js +29 -0
  164. package/dist/teste/Alert.test.d.ts +1 -0
  165. package/dist/teste/Alert.test.js +27 -0
  166. package/dist/teste/AtributosRepassados.test.d.ts +1 -0
  167. package/dist/teste/AtributosRepassados.test.js +52 -0
  168. package/dist/teste/AttachmentCardIA.test.d.ts +1 -0
  169. package/dist/teste/AttachmentCardIA.test.js +89 -0
  170. package/dist/teste/AvatarGroupOverlap.test.d.ts +1 -0
  171. package/dist/teste/AvatarGroupOverlap.test.js +56 -0
  172. package/dist/teste/BadgeTag.test.d.ts +1 -0
  173. package/dist/teste/BadgeTag.test.js +42 -0
  174. package/dist/teste/BottomSheet.test.d.ts +1 -0
  175. package/dist/teste/BottomSheet.test.js +23 -0
  176. package/dist/teste/BoxItemFlex.test.d.ts +1 -0
  177. package/dist/teste/BoxItemFlex.test.js +54 -0
  178. package/dist/teste/BoxLayout.test.d.ts +1 -0
  179. package/dist/teste/BoxLayout.test.js +35 -0
  180. package/dist/teste/Button.test.d.ts +1 -0
  181. package/dist/teste/Button.test.js +27 -0
  182. package/dist/teste/Calendar.test.d.ts +1 -0
  183. package/dist/teste/Calendar.test.js +221 -0
  184. package/dist/teste/ChipsXs.test.d.ts +1 -0
  185. package/dist/teste/ChipsXs.test.js +31 -0
  186. package/dist/teste/Coachmark.test.d.ts +1 -0
  187. package/dist/teste/Coachmark.test.js +149 -0
  188. package/dist/teste/ColorPicker.test.d.ts +1 -0
  189. package/dist/teste/ColorPicker.test.js +132 -0
  190. package/dist/teste/ConfirmAIAction.test.d.ts +1 -0
  191. package/dist/teste/ConfirmAIAction.test.js +33 -0
  192. package/dist/teste/DataTableCelulaLivre.test.d.ts +1 -0
  193. package/dist/teste/DataTableCelulaLivre.test.js +76 -0
  194. package/dist/teste/DataTableDocumento.test.d.ts +1 -0
  195. package/dist/teste/DataTableDocumento.test.js +92 -0
  196. package/dist/teste/DatePicker.test.js +23 -0
  197. package/dist/teste/Dropdown.test.js +111 -0
  198. package/dist/teste/FileInputTrigger.test.d.ts +1 -0
  199. package/dist/teste/FileInputTrigger.test.js +53 -0
  200. package/dist/teste/IconPicker.test.d.ts +1 -0
  201. package/dist/teste/IconPicker.test.js +130 -0
  202. package/dist/teste/InputMascaraEAfins.test.d.ts +1 -0
  203. package/dist/teste/InputMascaraEAfins.test.js +99 -0
  204. package/dist/teste/KbdCodeBlock.test.d.ts +1 -0
  205. package/dist/teste/KbdCodeBlock.test.js +95 -0
  206. package/dist/teste/List.test.d.ts +1 -0
  207. package/dist/teste/List.test.js +153 -0
  208. package/dist/teste/Modal.test.d.ts +1 -0
  209. package/dist/teste/Modal.test.js +26 -0
  210. package/dist/teste/ModalVariantes.test.d.ts +1 -0
  211. package/dist/teste/ModalVariantes.test.js +151 -0
  212. package/dist/teste/MultiSelectErro.test.d.ts +1 -0
  213. package/dist/teste/MultiSelectErro.test.js +62 -0
  214. package/dist/teste/NomeAcessivelSsr.test.d.ts +1 -0
  215. package/dist/teste/NomeAcessivelSsr.test.js +88 -0
  216. package/dist/teste/OrgChart.test.d.ts +1 -0
  217. package/dist/teste/OrgChart.test.js +162 -0
  218. package/dist/teste/OtpInput.test.d.ts +1 -0
  219. package/dist/teste/OtpInput.test.js +143 -0
  220. package/dist/teste/PopoverMaxHeight.test.d.ts +1 -0
  221. package/dist/teste/PopoverMaxHeight.test.js +38 -0
  222. package/dist/teste/RichTextEditor.test.d.ts +1 -0
  223. package/dist/teste/RichTextEditor.test.js +287 -0
  224. package/dist/teste/RotulosTraduziveis.test.d.ts +1 -0
  225. package/dist/teste/RotulosTraduziveis.test.js +405 -0
  226. package/dist/teste/SegmentedControl.test.js +33 -0
  227. package/dist/teste/Select.test.d.ts +1 -0
  228. package/dist/teste/Select.test.js +62 -0
  229. package/dist/teste/SelectPlacementFiltro.test.d.ts +1 -0
  230. package/dist/teste/SelectPlacementFiltro.test.js +88 -0
  231. package/dist/teste/Stack.test.d.ts +1 -0
  232. package/dist/teste/Stack.test.js +57 -0
  233. package/dist/teste/StatCardRotuloTopo.test.d.ts +1 -0
  234. package/dist/teste/StatCardRotuloTopo.test.js +34 -0
  235. package/dist/teste/TabsContadorFechavel.test.d.ts +1 -0
  236. package/dist/teste/TabsContadorFechavel.test.js +79 -0
  237. package/dist/teste/Tooltip.test.d.ts +1 -0
  238. package/dist/teste/Tooltip.test.js +109 -0
  239. package/dist/teste/TooltipDark.test.d.ts +1 -0
  240. package/dist/teste/TooltipDark.test.js +31 -0
  241. package/dist/utils/calendario.d.ts +28 -0
  242. package/dist/utils/calendario.js +73 -0
  243. package/dist/utils/chart.d.ts +4 -0
  244. package/dist/utils/chart.js +3 -2
  245. package/dist/utils/html-seguro.d.ts +27 -0
  246. package/dist/utils/html-seguro.js +97 -0
  247. package/dist/utils/id.d.ts +2 -0
  248. package/dist/utils/id.js +23 -0
  249. package/dist/utils/paleta-de-cores.d.ts +26 -0
  250. package/dist/utils/paleta-de-cores.js +10 -0
  251. package/dist/utils/texto.d.ts +5 -0
  252. package/dist/utils/texto.js +5 -0
  253. package/package.json +3 -3
  254. package/src/index.ts +26 -0
  255. package/src/teste/AILabel.test.tsx +41 -0
  256. package/src/teste/AccordionConteudoLivre.test.tsx +39 -0
  257. package/src/teste/Alert.test.tsx +32 -0
  258. package/src/teste/AtributosRepassados.test.tsx +73 -0
  259. package/src/teste/AttachmentCardIA.test.tsx +126 -0
  260. package/src/teste/AvatarGroupOverlap.test.tsx +74 -0
  261. package/src/teste/BadgeTag.test.tsx +64 -0
  262. package/src/teste/BottomSheet.test.tsx +25 -0
  263. package/src/teste/BoxItemFlex.test.tsx +81 -0
  264. package/src/teste/BoxLayout.test.tsx +50 -0
  265. package/src/teste/Button.test.tsx +39 -0
  266. package/src/teste/Calendar.test.tsx +282 -0
  267. package/src/teste/ChipsXs.test.tsx +41 -0
  268. package/src/teste/Coachmark.test.tsx +198 -0
  269. package/src/teste/ColorPicker.test.tsx +153 -0
  270. package/src/teste/ConfirmAIAction.test.tsx +41 -0
  271. package/src/teste/DataTableCelulaLivre.test.tsx +103 -0
  272. package/src/teste/DataTableDocumento.test.tsx +102 -0
  273. package/src/teste/DatePicker.test.tsx +38 -0
  274. package/src/teste/Dropdown.test.tsx +146 -0
  275. package/src/teste/FileInputTrigger.test.tsx +89 -0
  276. package/src/teste/IconPicker.test.tsx +145 -0
  277. package/src/teste/InputMascaraEAfins.test.tsx +124 -0
  278. package/src/teste/KbdCodeBlock.test.tsx +106 -0
  279. package/src/teste/List.test.tsx +269 -0
  280. package/src/teste/Modal.test.tsx +28 -0
  281. package/src/teste/ModalVariantes.test.tsx +173 -0
  282. package/src/teste/MultiSelectErro.test.tsx +97 -0
  283. package/src/teste/NomeAcessivelSsr.test.tsx +110 -0
  284. package/src/teste/OrgChart.test.tsx +183 -0
  285. package/src/teste/OtpInput.test.tsx +163 -0
  286. package/src/teste/PopoverMaxHeight.test.tsx +47 -0
  287. package/src/teste/RichTextEditor.test.tsx +329 -0
  288. package/src/teste/RotulosTraduziveis.test.tsx +545 -0
  289. package/src/teste/SegmentedControl.test.tsx +57 -0
  290. package/src/teste/Select.test.tsx +97 -0
  291. package/src/teste/SelectPlacementFiltro.test.tsx +110 -0
  292. package/src/teste/Stack.test.tsx +80 -0
  293. package/src/teste/StatCardRotuloTopo.test.tsx +44 -0
  294. package/src/teste/TabsContadorFechavel.test.tsx +144 -0
  295. package/src/teste/Tooltip.test.tsx +219 -0
  296. package/src/teste/TooltipDark.test.tsx +51 -0
  297. package/src/utils/calendario.ts +78 -0
  298. package/src/utils/chart.ts +7 -2
  299. package/src/utils/html-seguro.ts +94 -0
  300. package/src/utils/id.ts +24 -0
  301. package/src/utils/paleta-de-cores.ts +34 -0
  302. package/src/utils/texto.ts +5 -0
@@ -11,6 +11,7 @@ function Chips(props) {
11
11
  `umds-chip--${props.variant || "default"}`,
12
12
  props.disabled ? "umds-chip--disabled" : "",
13
13
  props.removable ? "umds-chip--removable" : "",
14
+ props.removable && props.circularRemove ? "umds-chip--remove-circle" : "",
14
15
  props.selected ? "umds-chip--selected" : "",
15
16
  props.onClick ? "umds-chip--clickable" : "",
16
17
  props.className,
@@ -19,7 +20,10 @@ function Chips(props) {
19
20
  .join(" ");
20
21
  }
21
22
  function iconSize() {
22
- return props.size === "sm" ? "8px" : "10px";
23
+ return props.size === "sm" || props.size === "xs" ? "8px" : "10px";
24
+ }
25
+ function removeLabelText() {
26
+ return (props.removeAriaLabel || "Remover") + " " + props.label;
23
27
  }
24
28
  function handleClick(event) {
25
29
  if (!props.disabled && props.onClick) {
@@ -31,6 +35,6 @@ function Chips(props) {
31
35
  props.onRemove(event);
32
36
  }
33
37
  }
34
- return (_jsxs("span", { className: chipClasses(), children: [props.onClick ? (_jsx("button", { type: "button", className: "umds-chip__action", onClick: (event) => handleClick(event), "aria-pressed": !!props.selected, disabled: props.disabled, children: _jsx("span", { className: "umds-chip__label", children: props.label }) })) : null, !props.onClick ? (_jsx("span", { className: "umds-chip__label", children: props.label })) : null, props.removable ? (_jsx("button", { type: "button", className: "umds-chip__remove", onClick: (event) => handleRemove(event), "aria-label": `Remover ${props.label}`, disabled: props.disabled, children: _jsx(Icon, { variant: "inherit", icon: faXmark, customSize: iconSize() }) })) : null] }));
38
+ return (_jsxs("span", { className: chipClasses(), children: [props.onClick ? (_jsx("button", { type: "button", className: "umds-chip__action", onClick: (event) => handleClick(event), "aria-pressed": !!props.selected, disabled: props.disabled, children: _jsx("span", { className: "umds-chip__label", children: props.label }) })) : null, !props.onClick ? (_jsx("span", { className: "umds-chip__label", children: props.label })) : null, props.removable ? (_jsx("button", { type: "button", className: "umds-chip__remove", onClick: (event) => handleRemove(event), "aria-label": removeLabelText(), disabled: props.disabled, children: _jsx(Icon, { variant: "inherit", icon: faXmark, customSize: iconSize() }) })) : null] }));
35
39
  }
36
40
  export default Chips;
@@ -0,0 +1,118 @@
1
+ /* ─────────────────────────────────────────────
2
+ COACHMARK
3
+ Tour guiado: véu com recorte no alvo e um cartão que o aponta.
4
+
5
+ O recorte é uma caixa transparente cuja SOMBRA enorme escurece o resto da
6
+ página (um buraco no véu sem máscara nem SVG). Quando o passo não tem alvo,
7
+ o véu é cheio e o cartão vai ao centro.
8
+
9
+ Cores: semânticos · Medidas: primitivos
10
+ ───────────────────────────────────────────── */
11
+
12
+ .umds-coachmark {
13
+ position: fixed;
14
+ top: 0;
15
+ left: 0;
16
+ width: 100%;
17
+ height: 100%;
18
+ z-index: var(--umds-semantic-layer-popover);
19
+ font-family: var(--umds-semantic-font-family-base);
20
+ }
21
+
22
+ /* Captura o clique: a página atrás fica inerte durante o tour. */
23
+ .umds-coachmark__veil {
24
+ position: absolute;
25
+ top: 0;
26
+ left: 0;
27
+ width: 100%;
28
+ height: 100%;
29
+ }
30
+
31
+ .umds-coachmark--no-target .umds-coachmark__veil {
32
+ /* stylelint-disable-next-line 1ds/cor-por-token -- o DS não tem token de scrim/overlay (candidato a novo token); mesmo valor do Modal */
33
+ background-color: rgba(0, 0, 0, 0.4);
34
+ }
35
+
36
+ .umds-coachmark__cutout {
37
+ position: absolute;
38
+ box-sizing: border-box;
39
+ pointer-events: none;
40
+ border-radius: var(--umds-primitive-border-radius-sm);
41
+ /* 100vmax: maior que qualquer tela, o recorte nunca deixa a borda do véu à mostra. */
42
+ /* stylelint-disable-next-line 1ds/cor-por-token -- o DS não tem token de scrim/overlay (candidato a novo token); mesmo valor do Modal */
43
+ box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.4);
44
+ transition:
45
+ top var(--umds-semantic-motion-duration-base) var(--umds-semantic-motion-easing-standard),
46
+ left var(--umds-semantic-motion-duration-base) var(--umds-semantic-motion-easing-standard),
47
+ width var(--umds-semantic-motion-duration-base) var(--umds-semantic-motion-easing-standard),
48
+ height var(--umds-semantic-motion-duration-base) var(--umds-semantic-motion-easing-standard);
49
+ }
50
+
51
+ /* ── Cartão ── */
52
+ .umds-coachmark__card {
53
+ position: absolute;
54
+ top: 0;
55
+ left: 0;
56
+ box-sizing: border-box;
57
+ display: flex;
58
+ flex-direction: column;
59
+ gap: var(--umds-primitive-spacing-nano); /* 8px */
60
+ /* 360px: 200px + 160px da escala; nunca passa da tela. */
61
+ width: calc(var(--umds-primitive-spacing-giant) + var(--umds-primitive-spacing-huge));
62
+ max-width: calc(100vw - var(--umds-primitive-spacing-xs));
63
+ padding: var(--umds-primitive-spacing-xxs); /* 24px */
64
+ background: var(--umds-semantic-color-background-white);
65
+ color: var(--umds-semantic-color-neutral-dark-pure);
66
+ border-radius: var(--umds-primitive-border-radius-md); /* 16px */
67
+ box-shadow: var(--umds-primitive-shadow-level-3);
68
+ outline: none;
69
+ }
70
+
71
+ .umds-coachmark__card--centered {
72
+ top: 50%;
73
+ left: 50%;
74
+ transform: translate(-50%, -50%);
75
+ }
76
+
77
+ .umds-coachmark__card:focus-visible {
78
+ outline: var(--umds-primitive-border-width-thin) solid var(--umds-semantic-color-primary-pure);
79
+ outline-offset: calc(var(--umds-primitive-border-width-thin) * -1);
80
+ }
81
+
82
+ .umds-coachmark__footer {
83
+ display: flex;
84
+ align-items: center;
85
+ justify-content: space-between;
86
+ gap: var(--umds-primitive-spacing-nano); /* 8px */
87
+ margin-top: var(--umds-primitive-spacing-nano);
88
+ }
89
+
90
+ .umds-coachmark__actions {
91
+ display: inline-flex;
92
+ gap: var(--umds-primitive-spacing-nano); /* 8px */
93
+ margin-left: auto;
94
+ }
95
+
96
+ /* Só para leitor de tela: "2 de 8: título", a cada passo. */
97
+ .umds-coachmark__sr {
98
+ position: absolute;
99
+ width: 1px;
100
+ height: 1px;
101
+ padding: 0;
102
+ margin: -1px;
103
+ overflow: hidden;
104
+ clip: rect(0, 0, 0, 0);
105
+ clip-path: inset(50%);
106
+ white-space: nowrap;
107
+ border: 0;
108
+ }
109
+
110
+ @media (forced-colors: active) {
111
+ .umds-coachmark__card {
112
+ border: var(--umds-primitive-border-width-thin) solid CanvasText;
113
+ }
114
+
115
+ .umds-coachmark__cutout {
116
+ outline: var(--umds-primitive-border-width-thin) solid Highlight;
117
+ }
118
+ }
@@ -0,0 +1,75 @@
1
+ import './Coachmark.css';
2
+ /**
3
+ * Passo do tour.
4
+ * @property {string} id - Identidade do passo (opcional)
5
+ * @property {any} target - O que o passo aponta: seletor CSS (`"#aba-fluxos"`), elemento, ref do React (`{ current }`), ref do Vue (`{ value }`) ou função que devolve um deles. Sem alvo (ou alvo que não existe na tela), o cartão fica no centro e a página inteira escurece.
6
+ * @property {string} title - Título do passo
7
+ * @property {string} content - Texto do passo
8
+ * @property {string} placement - Lado do cartão em relação ao alvo: 'top' | 'bottom' | 'left' | 'right' (padrão 'bottom'; inverte sozinho se não couber)
9
+ */
10
+ export interface CoachmarkStep {
11
+ id?: string;
12
+ target?: any;
13
+ title: string;
14
+ content?: string;
15
+ placement?: "top" | "bottom" | "left" | "right";
16
+ [key: string]: any;
17
+ }
18
+ /**
19
+ * Coachmark — tour guiado: uma sequência de passos, cada um apontando um
20
+ * elemento da tela com um cartão, enquanto o resto da página escurece e o
21
+ * elemento fica destacado num recorte.
22
+ *
23
+ * O cartão é um diálogo modal (`role="dialog"`, `aria-modal`): o foco entra nele
24
+ * ao abrir, o Tab fica preso nele, Esc sai do tour, as setas esquerda e direita
25
+ * voltam e avançam, e o foco volta ao elemento de antes ao fechar. A cada passo o
26
+ * leitor de tela ouve "2 de 8: título" (região `aria-live`).
27
+ *
28
+ * O componente é CONTROLADO por `open`: o tour só existe com `open` verdadeiro, e
29
+ * `onClose(motivo)` avisa quando ele quer fechar (`"finish"` no último
30
+ * "Concluir", `"skip"` em "Sair do tour", `"escape"` no Esc). O passo atual é
31
+ * interno (`defaultStep` para começar adiante), ou controlado por `step` com
32
+ * `onStepChange`. Reabrir recomeça do primeiro passo.
33
+ *
34
+ * O alvo é achado por seletor, elemento ou ref e acompanhado: rolagem,
35
+ * redimensionamento e mudança de tamanho do alvo reposicionam o recorte e o
36
+ * cartão. Todos os textos do cartão são props (`nextLabel`, `previousLabel`,
37
+ * `finishLabel`, `skipLabel`, `counterLabel`): em tela em inglês, passe todos.
38
+ *
39
+ * Limite: a página atrás fica inerte (o véu captura o clique), então o alvo
40
+ * não é clicável durante o tour.
41
+ * @property {boolean} open - Mostra o tour
42
+ * @property {CoachmarkStep[]} steps - Os passos, em ordem
43
+ * @property {number} step - Passo atual, a partir de 0 (controlado)
44
+ * @property {number} defaultStep - Passo inicial (não controlado)
45
+ * @property {number} padding - Folga do recorte em torno do alvo, em px (padrão 8)
46
+ * @property {string} nextLabel - Texto de "Próximo" (padrão: "Próximo")
47
+ * @property {string} previousLabel - Texto de "Anterior" (padrão: "Anterior")
48
+ * @property {string} finishLabel - Texto do botão do último passo (padrão: "Concluir")
49
+ * @property {string} skipLabel - Texto de sair do tour (padrão: "Sair do tour")
50
+ * @property {string} counterLabel - Contador; `{current}` e `{total}` são trocados (padrão: "{current} de {total}")
51
+ * @property {boolean} hideSkip - Esconde o "Sair do tour" (o Esc continua saindo)
52
+ * @property {string} className - Classes CSS adicionais no cartão
53
+ * @property {function} onClose - Chamado com o motivo: 'finish' | 'skip' | 'escape'
54
+ * @property {function} onStepChange - Chamado com o novo passo (a partir de 0)
55
+ * @quandoUsar Apresentar uma tela nova ou uma funcionalidade em poucos passos curtos (até uns 8), na primeira visita ou a pedido ("Fazer o tour guiado").
56
+ * @quandoNaoUsar Para uma dica sobre UM elemento, use `Tooltip` ou `Popover`. Para uma informação que não pode ser perdida, use texto na própria tela: tour se fecha e se esquece. Para um fluxo em etapas que a pessoa preenche, use `Stepper`.
57
+ */
58
+ export interface CoachmarkProps {
59
+ open?: boolean;
60
+ steps?: CoachmarkStep[];
61
+ step?: number;
62
+ defaultStep?: number;
63
+ padding?: number;
64
+ nextLabel?: string;
65
+ previousLabel?: string;
66
+ finishLabel?: string;
67
+ skipLabel?: string;
68
+ counterLabel?: string;
69
+ hideSkip?: boolean;
70
+ className?: string;
71
+ onClose?: (reason: "finish" | "skip" | "escape") => void;
72
+ onStepChange?: (step: number) => void;
73
+ }
74
+ declare function Coachmark(props: CoachmarkProps): import("react/jsx-runtime").JSX.Element;
75
+ export default Coachmark;
@@ -0,0 +1,321 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import './Coachmark.css';
4
+ import { useState, useRef, useEffect } from "react";
5
+ import { computePosition, autoUpdate, offset, flip, shift, } from "@floating-ui/dom";
6
+ import Button from "../Button/Button";
7
+ import Portal from "../Portal/Portal";
8
+ import Text from "../Text/Text";
9
+ import { gerarId } from "../../utils/id";
10
+ function Coachmark(props) {
11
+ const cardRef = useRef(null);
12
+ const cleanupRef = useRef(null);
13
+ const previousFocusRef = useRef(null);
14
+ const attachedRef = useRef(null);
15
+ const [internalStep, setInternalStep] = useState(() => props.defaultStep || 0);
16
+ const [uid, setUid] = useState(() => "");
17
+ const [active, setActive] = useState(() => false);
18
+ const [hasTarget, setHasTarget] = useState(() => false);
19
+ const [positioned, setPositioned] = useState(() => false);
20
+ const [rectTop, setRectTop] = useState(() => 0);
21
+ const [rectLeft, setRectLeft] = useState(() => 0);
22
+ const [rectWidth, setRectWidth] = useState(() => 0);
23
+ const [rectHeight, setRectHeight] = useState(() => 0);
24
+ const [posX, setPosX] = useState(() => 0);
25
+ const [posY, setPosY] = useState(() => 0);
26
+ const [tentativas, setTentativas] = useState(() => 0);
27
+ function stepList() {
28
+ return props.steps || [];
29
+ }
30
+ function stepCount() {
31
+ return stepList().length;
32
+ }
33
+ function index() {
34
+ const bruto = props.step !== undefined ? props.step : internalStep;
35
+ const max = stepCount() > 0 ? stepCount() - 1 : 0;
36
+ return Math.max(0, Math.min(bruto, max));
37
+ }
38
+ function currentStep() {
39
+ return (stepList()[index()] || {
40
+ title: "",
41
+ });
42
+ }
43
+ function isFirst() {
44
+ return index() === 0;
45
+ }
46
+ function isLast() {
47
+ return index() === stepCount() - 1;
48
+ }
49
+ function baseId() {
50
+ return uid || "umds-coachmark";
51
+ }
52
+ function titleId() {
53
+ return baseId() + "-title";
54
+ }
55
+ function contentId() {
56
+ return baseId() + "-content";
57
+ }
58
+ function counterText() {
59
+ const modelo = props.counterLabel || "{current} de {total}";
60
+ return modelo
61
+ .replace("{current}", String(index() + 1))
62
+ .replace("{total}", String(stepCount()));
63
+ }
64
+ function announceText() {
65
+ return counterText() + ": " + currentStep().title;
66
+ }
67
+ function nextText() {
68
+ if (isLast())
69
+ return props.finishLabel || "Concluir";
70
+ return props.nextLabel || "Próximo";
71
+ }
72
+ function previousText() {
73
+ return props.previousLabel || "Anterior";
74
+ }
75
+ function skipText() {
76
+ return props.skipLabel || "Sair do tour";
77
+ }
78
+ function showSkip() {
79
+ return !props.hideSkip;
80
+ }
81
+ function show() {
82
+ return !!props.open && stepCount() > 0;
83
+ }
84
+ function rootClasses() {
85
+ return [
86
+ "umds-coachmark",
87
+ hasTarget ? "" : "umds-coachmark--no-target",
88
+ positioned ? "umds-coachmark--ready" : "",
89
+ ]
90
+ .filter(Boolean)
91
+ .join(" ");
92
+ }
93
+ function cardClasses() {
94
+ return [
95
+ "umds-coachmark__card",
96
+ hasTarget ? "" : "umds-coachmark__card--centered",
97
+ props.className,
98
+ ]
99
+ .filter(Boolean)
100
+ .join(" ");
101
+ }
102
+ function cutoutStyle() {
103
+ const folga = props.padding !== undefined ? props.padding : 8;
104
+ return {
105
+ top: rectTop - folga + "px",
106
+ left: rectLeft - folga + "px",
107
+ width: rectWidth + folga * 2 + "px",
108
+ height: rectHeight + folga * 2 + "px",
109
+ };
110
+ }
111
+ function cardStyle() {
112
+ if (!hasTarget)
113
+ return undefined;
114
+ // Opacidade, e não `visibility`: o cartão precisa poder receber o foco antes de ser posicionado.
115
+ return {
116
+ transform: "translate(" + posX + "px, " + posY + "px)",
117
+ opacity: positioned ? 1 : 0,
118
+ };
119
+ }
120
+ function resolverAlvo(alvo) {
121
+ if (!alvo || typeof document === "undefined")
122
+ return null;
123
+ if (typeof alvo === "string") {
124
+ try {
125
+ return document.querySelector(alvo);
126
+ }
127
+ catch (erro) {
128
+ return null;
129
+ }
130
+ }
131
+ if (typeof alvo === "function")
132
+ return resolverAlvo(alvo());
133
+ if (alvo.nodeType === 1)
134
+ return alvo;
135
+ if (alvo.current !== undefined)
136
+ return resolverAlvo(alvo.current);
137
+ if (alvo.value !== undefined)
138
+ return resolverAlvo(alvo.value);
139
+ if (alvo.$el)
140
+ return alvo.$el.nodeType === 1 ? alvo.$el : null;
141
+ return null;
142
+ }
143
+ function atualizar(alvo) {
144
+ if (!alvo || !cardRef.current)
145
+ return;
146
+ const caixa = alvo.getBoundingClientRect();
147
+ setRectTop(caixa.top);
148
+ setRectLeft(caixa.left);
149
+ setRectWidth(caixa.width);
150
+ setRectHeight(caixa.height);
151
+ const lado = (currentStep().placement || "bottom");
152
+ computePosition(alvo, cardRef.current, {
153
+ placement: lado,
154
+ strategy: "fixed",
155
+ middleware: [
156
+ offset(16),
157
+ flip(),
158
+ shift({
159
+ padding: 16,
160
+ }),
161
+ ],
162
+ }).then((posicao) => {
163
+ const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
164
+ setPosX(Math.round(posicao.x * dpr) / dpr);
165
+ setPosY(Math.round(posicao.y * dpr) / dpr);
166
+ setPositioned(true);
167
+ });
168
+ }
169
+ function ligar() {
170
+ desligar();
171
+ const alvo = resolverAlvo(currentStep().target);
172
+ attachedRef.current = index();
173
+ if (!alvo) {
174
+ setHasTarget(false);
175
+ setPositioned(true);
176
+ return;
177
+ }
178
+ setHasTarget(true);
179
+ if (alvo.scrollIntoView) {
180
+ const caixa = alvo.getBoundingClientRect();
181
+ const altura = typeof window !== "undefined" ? window.innerHeight : 0;
182
+ if (caixa.top < 0 || caixa.bottom > altura) {
183
+ alvo.scrollIntoView({
184
+ block: "center",
185
+ inline: "nearest",
186
+ });
187
+ }
188
+ }
189
+ if (cardRef.current) {
190
+ cleanupRef.current = autoUpdate(alvo, cardRef.current, () => atualizar(alvo));
191
+ }
192
+ }
193
+ function desligar() {
194
+ if (cleanupRef.current) {
195
+ cleanupRef.current();
196
+ cleanupRef.current = null;
197
+ }
198
+ }
199
+ function sincronizar() {
200
+ if (typeof document === "undefined")
201
+ return;
202
+ if (show() && !active && !cardRef.current) {
203
+ if (tentativas < 30) {
204
+ requestAnimationFrame(() => {
205
+ setTentativas(tentativas + 1);
206
+ });
207
+ }
208
+ return;
209
+ }
210
+ if (show() && !active) {
211
+ setActive(true);
212
+ setTentativas(0);
213
+ previousFocusRef.current = document.activeElement;
214
+ ligar();
215
+ if (cardRef.current)
216
+ cardRef.current.focus({
217
+ preventScroll: true,
218
+ });
219
+ }
220
+ else if (show() && active && attachedRef.current !== index()) {
221
+ ligar();
222
+ }
223
+ else if (!show() && active) {
224
+ setActive(false);
225
+ desligar();
226
+ attachedRef.current = null;
227
+ setHasTarget(false);
228
+ setPositioned(false);
229
+ if (props.step === undefined)
230
+ setInternalStep(props.defaultStep || 0);
231
+ if (previousFocusRef.current && previousFocusRef.current.focus) {
232
+ previousFocusRef.current.focus();
233
+ previousFocusRef.current = null;
234
+ }
235
+ }
236
+ }
237
+ function irPara(proximo) {
238
+ if (proximo < 0 || proximo > stepCount() - 1)
239
+ return;
240
+ setInternalStep(proximo);
241
+ if (props.onStepChange)
242
+ props.onStepChange(proximo);
243
+ }
244
+ function fechar(motivo) {
245
+ if (props.onClose)
246
+ props.onClose(motivo);
247
+ }
248
+ function handleNext() {
249
+ if (isLast())
250
+ fechar("finish");
251
+ else
252
+ irPara(index() + 1);
253
+ }
254
+ function handlePrevious() {
255
+ irPara(index() - 1);
256
+ }
257
+ function handleKeyDown(event) {
258
+ if (!event)
259
+ return;
260
+ if (event.key === "Escape") {
261
+ event.preventDefault();
262
+ fechar("escape");
263
+ return;
264
+ }
265
+ if (event.altKey || event.ctrlKey || event.metaKey)
266
+ return;
267
+ if (event.key === "ArrowRight") {
268
+ event.preventDefault();
269
+ handleNext();
270
+ return;
271
+ }
272
+ if (event.key === "ArrowLeft") {
273
+ event.preventDefault();
274
+ handlePrevious();
275
+ return;
276
+ }
277
+ if (event.key !== "Tab" || !cardRef.current)
278
+ return;
279
+ // Foco preso: Tab e Shift+Tab giram dentro do cartão.
280
+ const focaveis = cardRef.current.querySelectorAll("button:not([disabled])");
281
+ if (focaveis.length === 0) {
282
+ event.preventDefault();
283
+ return;
284
+ }
285
+ const primeiro = focaveis[0];
286
+ const ultimo = focaveis[focaveis.length - 1];
287
+ const ativo = document.activeElement;
288
+ if (event.shiftKey) {
289
+ if (ativo === primeiro || ativo === cardRef.current) {
290
+ event.preventDefault();
291
+ ultimo.focus();
292
+ }
293
+ }
294
+ else if (ativo === ultimo) {
295
+ event.preventDefault();
296
+ primeiro.focus();
297
+ }
298
+ }
299
+ function handleVeilMouseDown(event) {
300
+ if (event && event.preventDefault)
301
+ event.preventDefault();
302
+ if (cardRef.current)
303
+ cardRef.current.focus({
304
+ preventScroll: true,
305
+ });
306
+ }
307
+ useEffect(() => {
308
+ setUid(gerarId("umds-coachmark"));
309
+ sincronizar();
310
+ }, []);
311
+ useEffect(() => {
312
+ sincronizar();
313
+ });
314
+ useEffect(() => {
315
+ return () => {
316
+ desligar();
317
+ };
318
+ }, []);
319
+ return (_jsx(_Fragment, { children: show() ? (_jsx(_Fragment, { children: _jsx(Portal, { children: _jsxs("div", { className: rootClasses(), children: [_jsx("div", { "aria-hidden": "true", className: "umds-coachmark__veil", onMouseDown: (event) => handleVeilMouseDown(event) }), hasTarget ? (_jsx("div", { "aria-hidden": "true", className: "umds-coachmark__cutout", style: cutoutStyle() })) : null, _jsxs("div", { role: "dialog", "aria-modal": "true", ref: cardRef, style: cardStyle(), "aria-labelledby": titleId(), "aria-describedby": contentId(), tabIndex: -1, onKeyDown: (event) => handleKeyDown(event), className: cardClasses(), children: [_jsx("span", { "aria-live": "polite", className: "umds-coachmark__sr", children: announceText() }), _jsx(Text, { as: "span", variant: "body2", weight: "bold", color: "primary", "aria-hidden": "true", children: counterText() }), _jsx(Text, { as: "h2", variant: "subtitle1", weight: "bold", id: titleId(), children: currentStep().title }), currentStep().content ? (_jsx(Text, { as: "p", variant: "body2", color: "secondary", id: contentId(), children: currentStep().content })) : null, _jsxs("div", { className: "umds-coachmark__footer", children: [showSkip() ? (_jsx(Button, { variant: "text", size: "sm", onClick: (event) => fechar("skip"), children: skipText() })) : null, _jsxs("span", { className: "umds-coachmark__actions", children: [!isFirst() ? (_jsx(Button, { variant: "secondary", size: "md", onClick: (event) => handlePrevious(), children: previousText() })) : null, _jsx(Button, { variant: "primary", size: "md", onClick: (event) => handleNext(), children: nextText() })] })] })] })] }) }) })) : null }));
320
+ }
321
+ export default Coachmark;
@@ -0,0 +1,96 @@
1
+ /* ─────────────────────────────────────────────
2
+ CODE BLOCK
3
+ Texto em fonte monoespaçada, com borda, rolagem e botão de copiar.
4
+
5
+ Fundo claro e texto escuro (contraste de texto, nos temas claro e escuro: os
6
+ dois vêm dos semânticos). Sem cor de sintaxe.
7
+
8
+ Cores: semânticos · Medidas: primitivos
9
+ ───────────────────────────────────────────── */
10
+
11
+ .umds-code-block {
12
+ display: flex;
13
+ flex-direction: column;
14
+ min-width: 0;
15
+ background: var(--umds-semantic-color-background-light);
16
+ border: var(--umds-primitive-border-width-hairline) solid var(--umds-semantic-color-neutral-light-down);
17
+ border-radius: var(--umds-primitive-border-radius-sm);
18
+ overflow: hidden;
19
+ }
20
+
21
+ .umds-code-block__header {
22
+ display: flex;
23
+ align-items: center;
24
+ justify-content: space-between;
25
+ gap: var(--umds-primitive-spacing-nano); /* 8px */
26
+ padding: var(--umds-primitive-spacing-quarck) var(--umds-primitive-spacing-nano); /* 4px 8px */
27
+ border-bottom: var(--umds-primitive-border-width-hairline) solid var(--umds-semantic-color-neutral-light-down);
28
+ }
29
+
30
+ .umds-code-block__language {
31
+ font-family: var(--umds-semantic-font-family-mono);
32
+ font-size: var(--umds-primitive-font-size-xxxs); /* 12px */
33
+ font-weight: var(--umds-primitive-font-weight-semibold);
34
+ color: var(--umds-semantic-color-neutral-dark-down);
35
+ }
36
+
37
+ .umds-code-block__copy {
38
+ display: inline-flex;
39
+ align-items: center;
40
+ gap: var(--umds-primitive-spacing-quarck); /* 4px */
41
+ margin: 0 0 0 auto;
42
+ padding: var(--umds-primitive-spacing-quarck) var(--umds-primitive-spacing-nano); /* 4px 8px */
43
+ border: none;
44
+ border-radius: var(--umds-primitive-border-radius-sm);
45
+ background: transparent;
46
+ font: inherit;
47
+ font-size: var(--umds-primitive-font-size-xxxs); /* 12px */
48
+ font-weight: var(--umds-primitive-font-weight-semibold);
49
+ color: var(--umds-semantic-color-neutral-dark-down);
50
+ cursor: pointer;
51
+ }
52
+
53
+ .umds-code-block__copy:hover {
54
+ background: var(--umds-semantic-color-neutral-light-medium);
55
+ color: var(--umds-semantic-color-neutral-dark-pure);
56
+ }
57
+
58
+ .umds-code-block__copy:focus-visible,
59
+ .umds-code-block__scroll:focus-visible {
60
+ outline: var(--umds-primitive-border-width-thin) solid var(--umds-semantic-color-primary-pure);
61
+ outline-offset: calc(var(--umds-primitive-border-width-thin) * -1);
62
+ }
63
+
64
+ .umds-code-block__scroll {
65
+ margin: 0;
66
+ padding: var(--umds-primitive-spacing-mini) var(--umds-primitive-spacing-xxxs); /* 12px 16px */
67
+ overflow: auto;
68
+ font-family: var(--umds-semantic-font-family-mono);
69
+ font-size: var(--umds-primitive-font-size-xxs); /* 14px */
70
+ line-height: var(--umds-primitive-font-line-height-lg);
71
+ color: var(--umds-semantic-color-neutral-dark-pure);
72
+ white-space: pre;
73
+ tab-size: 2;
74
+ }
75
+
76
+ .umds-code-block--wrap .umds-code-block__scroll {
77
+ white-space: pre-wrap;
78
+ overflow-wrap: anywhere;
79
+ }
80
+
81
+ .umds-code-block__code {
82
+ font-family: inherit;
83
+ }
84
+
85
+ .umds-code-block__sr {
86
+ position: absolute;
87
+ width: 1px;
88
+ height: 1px;
89
+ padding: 0;
90
+ margin: -1px;
91
+ overflow: hidden;
92
+ clip: rect(0, 0, 0, 0);
93
+ clip-path: inset(50%);
94
+ white-space: nowrap;
95
+ border: 0;
96
+ }
@@ -0,0 +1,47 @@
1
+ import './CodeBlock.css';
2
+ /**
3
+ * CodeBlock — trecho de código (ou JSON, ou um log) em fonte monoespaçada, com
4
+ * borda, rolagem e botão de copiar.
5
+ *
6
+ * O texto vem por `code` ou como conteúdo (`<CodeBlock>{...}</CodeBlock>`); o
7
+ * espaço e as quebras de linha são mantidos. Linha longa rola na horizontal
8
+ * (ou quebra, com `wrap`), e `maxHeight` limita a altura e rola na vertical. A
9
+ * área de rolagem é focável (Tab) e tem nome (`ariaLabel`), para quem usa o
10
+ * teclado poder rolar.
11
+ *
12
+ * `copyable` põe o botão de copiar no canto: copia o texto inteiro (não o que
13
+ * está à vista), troca o ícone por "Copiado" por dois segundos e anuncia isso ao
14
+ * leitor de tela. `onCopy` recebe o texto. Os textos são props.
15
+ *
16
+ * É só texto: não colore sintaxe (isso pede uma biblioteca, e o bloco do 1Doc
17
+ * mostra JSON e logs, que ficam bem em uma cor só).
18
+ * @property {string} code - O texto (ou passe como conteúdo)
19
+ * @property {string} language - Nome da linguagem, mostrado no topo (ex.: "JSON"). É só rótulo
20
+ * @property {boolean} wrap - Quebra a linha longa em vez de rolar
21
+ * @property {number} maxHeight - Altura máxima, em px (rola dentro dela)
22
+ * @property {boolean} copyable - Mostra o botão de copiar
23
+ * @property {string} copyLabel - Nome do botão de copiar (padrão "Copiar")
24
+ * @property {string} copiedLabel - Nome do botão e anúncio depois de copiar (padrão "Copiado")
25
+ * @property {string} ariaLabel - Nome da área de rolagem (padrão: a linguagem, ou "Código")
26
+ * @property {string} className - Classes CSS adicionais
27
+ * @property {function} onCopy - Chamado com o texto depois de copiar
28
+ * @quandoUsar Mostrar JSON de uma resposta, um comando, um log, um exemplo de uso: texto que se lê em fonte monoespaçada e se copia.
29
+ * @quandoNaoUsar Para uma tecla ou atalho, use `Kbd`. Para código dentro de uma frase, use `<code>` direto. Para editar código, use um editor especializado: este bloco só mostra.
30
+ */
31
+ export interface CodeBlockProps {
32
+ code?: string;
33
+ language?: string;
34
+ wrap?: boolean;
35
+ maxHeight?: number;
36
+ copyable?: boolean;
37
+ copyLabel?: string;
38
+ copiedLabel?: string;
39
+ ariaLabel?: string;
40
+ className?: string;
41
+ id?: string;
42
+ onCopy?: (code: string) => void;
43
+ /** O texto, quando não vem por `code`. */
44
+ children?: any;
45
+ }
46
+ declare function CodeBlock(props: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
47
+ export default CodeBlock;