@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.
- package/CHANGELOG.md +1280 -0
- package/dist/components/AIContent/AIContent.d.ts +10 -0
- package/dist/components/AIContent/AIContent.js +1 -1
- package/dist/components/AILabel/AILabel.d.ts +4 -0
- package/dist/components/AILabel/AILabel.js +2 -2
- package/dist/components/Accordion/Accordion.d.ts +6 -2
- package/dist/components/Alert/Alert.css +2 -0
- package/dist/components/Alert/Alert.d.ts +3 -1
- package/dist/components/Alert/Alert.js +7 -1
- package/dist/components/AppHeader/AppHeader.css +82 -8
- package/dist/components/AppHeader/AppHeader.d.ts +12 -1
- package/dist/components/AppHeader/AppHeader.js +186 -1
- package/dist/components/AppNavItem/AppNavItem.css +11 -3
- package/dist/components/AppShell/AppShell.css +9 -0
- package/dist/components/AppShell/AppShell.d.ts +8 -0
- package/dist/components/AppShell/AppShell.js +4 -1
- package/dist/components/AppSidebar/AppSidebar.css +1 -1
- package/dist/components/AppSidebar/AppSidebar.d.ts +4 -0
- package/dist/components/AppSidebar/AppSidebar.js +3 -1
- package/dist/components/AttachmentCard/AttachmentCard.css +17 -1
- package/dist/components/AttachmentCard/AttachmentCard.d.ts +29 -2
- package/dist/components/AttachmentCard/AttachmentCard.js +88 -20
- package/dist/components/Avatar/Avatar.css +7 -2
- package/dist/components/Avatar/AvatarGroup.d.ts +27 -0
- package/dist/components/Avatar/AvatarGroup.js +28 -4
- package/dist/components/Badge/Badge.css +61 -3
- package/dist/components/Badge/Badge.d.ts +14 -4
- package/dist/components/Badge/Badge.js +1 -0
- package/dist/components/BottomSheet/BottomSheet.css +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +8 -0
- package/dist/components/BottomSheet/BottomSheet.js +14 -2
- package/dist/components/Box/Box.css +83 -0
- package/dist/components/Box/Box.d.ts +82 -2
- package/dist/components/Box/Box.js +42 -2
- package/dist/components/Button/Button.css +29 -0
- package/dist/components/Button/Button.d.ts +4 -4
- package/dist/components/Button/Button.js +4 -1
- package/dist/components/Calendar/Calendar.css +245 -0
- package/dist/components/Calendar/Calendar.d.ts +125 -0
- package/dist/components/Calendar/Calendar.js +320 -0
- package/dist/components/Chart/BarChart.d.ts +6 -0
- package/dist/components/Chart/BarChart.js +3 -1
- package/dist/components/Chart/LineChart.d.ts +6 -0
- package/dist/components/Chart/LineChart.js +3 -1
- package/dist/components/Checkbox/Checkbox.css +4 -1
- package/dist/components/Chips/Chips.css +39 -0
- package/dist/components/Chips/Chips.d.ts +7 -2
- package/dist/components/Chips/Chips.js +6 -2
- package/dist/components/Coachmark/Coachmark.css +118 -0
- package/dist/components/Coachmark/Coachmark.d.ts +75 -0
- package/dist/components/Coachmark/Coachmark.js +321 -0
- package/dist/components/CodeBlock/CodeBlock.css +96 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +47 -0
- package/dist/components/CodeBlock/CodeBlock.js +103 -0
- package/dist/components/ColorPicker/ColorPicker.css +133 -0
- package/dist/components/ColorPicker/ColorPicker.d.ts +73 -0
- package/dist/components/ColorPicker/ColorPicker.js +219 -0
- package/dist/components/Combobox/Combobox.css +11 -3
- package/dist/components/ConfirmAIAction/ConfirmAIAction.d.ts +11 -1
- package/dist/components/ConfirmAIAction/ConfirmAIAction.js +6 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.css +3 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +14 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.js +2 -2
- package/dist/components/DataTable/DataTable.css +80 -0
- package/dist/components/DataTable/DataTable.d.ts +23 -4
- package/dist/components/DataTable/DataTable.js +61 -15
- package/dist/components/DatePicker/DatePicker.css +8 -0
- package/dist/components/DatePicker/DatePicker.d.ts +4 -0
- package/dist/components/DatePicker/DatePicker.js +14 -1
- package/dist/components/DescriptionList/DescriptionList.css +113 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +59 -0
- package/dist/components/DescriptionList/DescriptionList.js +51 -0
- package/dist/components/Drawer/Drawer.css +1 -0
- package/dist/components/Dropdown/Dropdown.js +47 -29
- package/dist/components/FileInput/FileInput.css +24 -4
- package/dist/components/FileInput/FileInput.d.ts +22 -2
- package/dist/components/FileInput/FileInput.js +23 -2
- package/dist/components/Grid/Grid.js +5 -5
- package/dist/components/IconPicker/IconPicker.css +107 -0
- package/dist/components/IconPicker/IconPicker.d.ts +74 -0
- package/dist/components/IconPicker/IconPicker.js +194 -0
- package/dist/components/Input/Input.css +41 -3
- package/dist/components/Input/Input.d.ts +14 -1
- package/dist/components/Input/Input.js +72 -6
- package/dist/components/Kanban/Kanban.css +5 -0
- package/dist/components/Kanban/Kanban.d.ts +41 -0
- package/dist/components/Kanban/Kanban.js +59 -27
- package/dist/components/Kanban/KanbanCard.d.ts +2 -0
- package/dist/components/Kanban/KanbanCard.js +1 -1
- package/dist/components/Kanban/KanbanColumn.d.ts +2 -0
- package/dist/components/Kanban/KanbanColumn.js +3 -0
- package/dist/components/Kbd/Kbd.css +66 -0
- package/dist/components/Kbd/Kbd.d.ts +32 -0
- package/dist/components/Kbd/Kbd.js +40 -0
- package/dist/components/Link/Link.css +1 -1
- package/dist/components/List/List.css +136 -0
- package/dist/components/List/List.d.ts +82 -0
- package/dist/components/List/List.js +53 -0
- package/dist/components/List/ListItem.d.ts +85 -0
- package/dist/components/List/ListItem.js +81 -0
- package/dist/components/Modal/Modal.css +93 -8
- package/dist/components/Modal/Modal.d.ts +45 -7
- package/dist/components/Modal/Modal.js +106 -6
- package/dist/components/MultiSelect/MultiSelect.css +9 -1
- package/dist/components/MultiSelect/MultiSelect.js +45 -8
- package/dist/components/OrgChart/OrgChart.css +149 -0
- package/dist/components/OrgChart/OrgChart.d.ts +83 -0
- package/dist/components/OrgChart/OrgChart.js +297 -0
- package/dist/components/OtpInput/OtpInput.css +93 -0
- package/dist/components/OtpInput/OtpInput.d.ts +60 -0
- package/dist/components/OtpInput/OtpInput.js +215 -0
- package/dist/components/Pagination/Pagination.d.ts +6 -0
- package/dist/components/Pagination/Pagination.js +9 -1
- package/dist/components/PhoneInput/PhoneInput.css +9 -1
- package/dist/components/PhoneInput/PhoneInput.d.ts +10 -0
- package/dist/components/PhoneInput/PhoneInput.js +20 -3
- package/dist/components/Popover/Popover.d.ts +7 -0
- package/dist/components/Popover/Popover.js +11 -1
- package/dist/components/RichTextEditor/RichTextEditor.css +203 -0
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +83 -0
- package/dist/components/RichTextEditor/RichTextEditor.js +494 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +2 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +21 -8
- package/dist/components/Select/Select.css +71 -1
- package/dist/components/Select/Select.d.ts +12 -0
- package/dist/components/Select/Select.js +93 -10
- package/dist/components/SidePanel/SidePanel.css +4 -4
- package/dist/components/SidePanelItem/SidePanelItem.css +7 -5
- package/dist/components/SidePanelSearch/SidePanelSearch.css +2 -2
- package/dist/components/SidePanelSection/SidePanelSection.css +7 -5
- package/dist/components/Stack/Stack.css +49 -0
- package/dist/components/Stack/Stack.d.ts +65 -7
- package/dist/components/Stack/Stack.js +30 -2
- package/dist/components/StatCard/StatCard.css +73 -0
- package/dist/components/StatCard/StatCard.d.ts +17 -0
- package/dist/components/StatCard/StatCard.js +4 -1
- package/dist/components/Stepper/Stepper.css +4 -1
- package/dist/components/Stepper/Stepper.d.ts +8 -0
- package/dist/components/Stepper/Stepper.js +4 -4
- package/dist/components/Switch/Switch.css +1 -0
- package/dist/components/Tabs/Tab.d.ts +15 -0
- package/dist/components/Tabs/Tab.js +30 -1
- package/dist/components/Tabs/Tabs.css +132 -0
- package/dist/components/Tabs/Tabs.d.ts +7 -0
- package/dist/components/Tabs/Tabs.js +13 -2
- package/dist/components/Tag/Tag.css +85 -2
- package/dist/components/Tag/Tag.d.ts +13 -6
- package/dist/components/Tag/Tag.js +1 -0
- package/dist/components/Text/Text.d.ts +9 -1
- package/dist/components/Text/Text.js +2 -2
- package/dist/components/Textarea/Textarea.css +11 -3
- package/dist/components/TimePicker/TimePicker.css +8 -0
- package/dist/components/TimePicker/TimePicker.d.ts +6 -0
- package/dist/components/TimePicker/TimePicker.js +1 -1
- package/dist/components/Tooltip/Tooltip.css +40 -0
- package/dist/components/Tooltip/Tooltip.d.ts +11 -0
- package/dist/components/Tooltip/Tooltip.js +114 -11
- package/dist/index.d.ts +25 -0
- package/dist/index.js +14 -0
- package/dist/teste/AILabel.test.d.ts +1 -0
- package/dist/teste/AILabel.test.js +33 -0
- package/dist/teste/AccordionConteudoLivre.test.d.ts +1 -0
- package/dist/teste/AccordionConteudoLivre.test.js +29 -0
- package/dist/teste/Alert.test.d.ts +1 -0
- package/dist/teste/Alert.test.js +27 -0
- package/dist/teste/AtributosRepassados.test.d.ts +1 -0
- package/dist/teste/AtributosRepassados.test.js +52 -0
- package/dist/teste/AttachmentCardIA.test.d.ts +1 -0
- package/dist/teste/AttachmentCardIA.test.js +89 -0
- package/dist/teste/AvatarGroupOverlap.test.d.ts +1 -0
- package/dist/teste/AvatarGroupOverlap.test.js +56 -0
- package/dist/teste/BadgeTag.test.d.ts +1 -0
- package/dist/teste/BadgeTag.test.js +42 -0
- package/dist/teste/BottomSheet.test.d.ts +1 -0
- package/dist/teste/BottomSheet.test.js +23 -0
- package/dist/teste/BoxItemFlex.test.d.ts +1 -0
- package/dist/teste/BoxItemFlex.test.js +54 -0
- package/dist/teste/BoxLayout.test.d.ts +1 -0
- package/dist/teste/BoxLayout.test.js +35 -0
- package/dist/teste/Button.test.d.ts +1 -0
- package/dist/teste/Button.test.js +27 -0
- package/dist/teste/Calendar.test.d.ts +1 -0
- package/dist/teste/Calendar.test.js +221 -0
- package/dist/teste/ChipsXs.test.d.ts +1 -0
- package/dist/teste/ChipsXs.test.js +31 -0
- package/dist/teste/Coachmark.test.d.ts +1 -0
- package/dist/teste/Coachmark.test.js +149 -0
- package/dist/teste/ColorPicker.test.d.ts +1 -0
- package/dist/teste/ColorPicker.test.js +132 -0
- package/dist/teste/ConfirmAIAction.test.d.ts +1 -0
- package/dist/teste/ConfirmAIAction.test.js +33 -0
- package/dist/teste/DataTableCelulaLivre.test.d.ts +1 -0
- package/dist/teste/DataTableCelulaLivre.test.js +76 -0
- package/dist/teste/DataTableDocumento.test.d.ts +1 -0
- package/dist/teste/DataTableDocumento.test.js +92 -0
- package/dist/teste/DatePicker.test.js +23 -0
- package/dist/teste/Dropdown.test.js +111 -0
- package/dist/teste/FileInputTrigger.test.d.ts +1 -0
- package/dist/teste/FileInputTrigger.test.js +53 -0
- package/dist/teste/IconPicker.test.d.ts +1 -0
- package/dist/teste/IconPicker.test.js +130 -0
- package/dist/teste/InputMascaraEAfins.test.d.ts +1 -0
- package/dist/teste/InputMascaraEAfins.test.js +99 -0
- package/dist/teste/KbdCodeBlock.test.d.ts +1 -0
- package/dist/teste/KbdCodeBlock.test.js +95 -0
- package/dist/teste/List.test.d.ts +1 -0
- package/dist/teste/List.test.js +153 -0
- package/dist/teste/Modal.test.d.ts +1 -0
- package/dist/teste/Modal.test.js +26 -0
- package/dist/teste/ModalVariantes.test.d.ts +1 -0
- package/dist/teste/ModalVariantes.test.js +151 -0
- package/dist/teste/MultiSelectErro.test.d.ts +1 -0
- package/dist/teste/MultiSelectErro.test.js +62 -0
- package/dist/teste/NomeAcessivelSsr.test.d.ts +1 -0
- package/dist/teste/NomeAcessivelSsr.test.js +88 -0
- package/dist/teste/OrgChart.test.d.ts +1 -0
- package/dist/teste/OrgChart.test.js +162 -0
- package/dist/teste/OtpInput.test.d.ts +1 -0
- package/dist/teste/OtpInput.test.js +143 -0
- package/dist/teste/PopoverMaxHeight.test.d.ts +1 -0
- package/dist/teste/PopoverMaxHeight.test.js +38 -0
- package/dist/teste/RichTextEditor.test.d.ts +1 -0
- package/dist/teste/RichTextEditor.test.js +287 -0
- package/dist/teste/RotulosTraduziveis.test.d.ts +1 -0
- package/dist/teste/RotulosTraduziveis.test.js +405 -0
- package/dist/teste/SegmentedControl.test.js +33 -0
- package/dist/teste/Select.test.d.ts +1 -0
- package/dist/teste/Select.test.js +62 -0
- package/dist/teste/SelectPlacementFiltro.test.d.ts +1 -0
- package/dist/teste/SelectPlacementFiltro.test.js +88 -0
- package/dist/teste/Stack.test.d.ts +1 -0
- package/dist/teste/Stack.test.js +57 -0
- package/dist/teste/StatCardRotuloTopo.test.d.ts +1 -0
- package/dist/teste/StatCardRotuloTopo.test.js +34 -0
- package/dist/teste/TabsContadorFechavel.test.d.ts +1 -0
- package/dist/teste/TabsContadorFechavel.test.js +79 -0
- package/dist/teste/Tooltip.test.d.ts +1 -0
- package/dist/teste/Tooltip.test.js +109 -0
- package/dist/teste/TooltipDark.test.d.ts +1 -0
- package/dist/teste/TooltipDark.test.js +31 -0
- package/dist/utils/calendario.d.ts +28 -0
- package/dist/utils/calendario.js +73 -0
- package/dist/utils/chart.d.ts +4 -0
- package/dist/utils/chart.js +3 -2
- package/dist/utils/html-seguro.d.ts +27 -0
- package/dist/utils/html-seguro.js +97 -0
- package/dist/utils/id.d.ts +2 -0
- package/dist/utils/id.js +23 -0
- package/dist/utils/paleta-de-cores.d.ts +26 -0
- package/dist/utils/paleta-de-cores.js +10 -0
- package/dist/utils/texto.d.ts +5 -0
- package/dist/utils/texto.js +5 -0
- package/package.json +3 -3
- package/src/index.ts +26 -0
- package/src/teste/AILabel.test.tsx +41 -0
- package/src/teste/AccordionConteudoLivre.test.tsx +39 -0
- package/src/teste/Alert.test.tsx +32 -0
- package/src/teste/AtributosRepassados.test.tsx +73 -0
- package/src/teste/AttachmentCardIA.test.tsx +126 -0
- package/src/teste/AvatarGroupOverlap.test.tsx +74 -0
- package/src/teste/BadgeTag.test.tsx +64 -0
- package/src/teste/BottomSheet.test.tsx +25 -0
- package/src/teste/BoxItemFlex.test.tsx +81 -0
- package/src/teste/BoxLayout.test.tsx +50 -0
- package/src/teste/Button.test.tsx +39 -0
- package/src/teste/Calendar.test.tsx +282 -0
- package/src/teste/ChipsXs.test.tsx +41 -0
- package/src/teste/Coachmark.test.tsx +198 -0
- package/src/teste/ColorPicker.test.tsx +153 -0
- package/src/teste/ConfirmAIAction.test.tsx +41 -0
- package/src/teste/DataTableCelulaLivre.test.tsx +103 -0
- package/src/teste/DataTableDocumento.test.tsx +102 -0
- package/src/teste/DatePicker.test.tsx +38 -0
- package/src/teste/Dropdown.test.tsx +146 -0
- package/src/teste/FileInputTrigger.test.tsx +89 -0
- package/src/teste/IconPicker.test.tsx +145 -0
- package/src/teste/InputMascaraEAfins.test.tsx +124 -0
- package/src/teste/KbdCodeBlock.test.tsx +106 -0
- package/src/teste/List.test.tsx +269 -0
- package/src/teste/Modal.test.tsx +28 -0
- package/src/teste/ModalVariantes.test.tsx +173 -0
- package/src/teste/MultiSelectErro.test.tsx +97 -0
- package/src/teste/NomeAcessivelSsr.test.tsx +110 -0
- package/src/teste/OrgChart.test.tsx +183 -0
- package/src/teste/OtpInput.test.tsx +163 -0
- package/src/teste/PopoverMaxHeight.test.tsx +47 -0
- package/src/teste/RichTextEditor.test.tsx +329 -0
- package/src/teste/RotulosTraduziveis.test.tsx +545 -0
- package/src/teste/SegmentedControl.test.tsx +57 -0
- package/src/teste/Select.test.tsx +97 -0
- package/src/teste/SelectPlacementFiltro.test.tsx +110 -0
- package/src/teste/Stack.test.tsx +80 -0
- package/src/teste/StatCardRotuloTopo.test.tsx +44 -0
- package/src/teste/TabsContadorFechavel.test.tsx +144 -0
- package/src/teste/Tooltip.test.tsx +219 -0
- package/src/teste/TooltipDark.test.tsx +51 -0
- package/src/utils/calendario.ts +78 -0
- package/src/utils/chart.ts +7 -2
- package/src/utils/html-seguro.ts +94 -0
- package/src/utils/id.ts +24 -0
- package/src/utils/paleta-de-cores.ts +34 -0
- package/src/utils/texto.ts +5 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import './CodeBlock.css';
|
|
4
|
+
import { useState, useRef, useEffect } from "react";
|
|
5
|
+
import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons";
|
|
6
|
+
import Icon from "../Icon/Icon";
|
|
7
|
+
function CodeBlock(props) {
|
|
8
|
+
const codeRef = useRef(null);
|
|
9
|
+
const timerRef = useRef(null);
|
|
10
|
+
const [copied, setCopied] = useState(() => false);
|
|
11
|
+
function classes() {
|
|
12
|
+
return [
|
|
13
|
+
"umds-code-block",
|
|
14
|
+
props.wrap ? "umds-code-block--wrap" : "",
|
|
15
|
+
props.copyable ? "umds-code-block--copyable" : "",
|
|
16
|
+
props.className,
|
|
17
|
+
]
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.join(" ");
|
|
20
|
+
}
|
|
21
|
+
function scrollStyle() {
|
|
22
|
+
return props.maxHeight
|
|
23
|
+
? {
|
|
24
|
+
maxHeight: props.maxHeight + "px",
|
|
25
|
+
}
|
|
26
|
+
: undefined;
|
|
27
|
+
}
|
|
28
|
+
function regionName() {
|
|
29
|
+
return props.ariaLabel || props.language || "Código";
|
|
30
|
+
}
|
|
31
|
+
function copyText() {
|
|
32
|
+
return props.copyLabel || "Copiar";
|
|
33
|
+
}
|
|
34
|
+
function copiedText() {
|
|
35
|
+
return props.copiedLabel || "Copiado";
|
|
36
|
+
}
|
|
37
|
+
function buttonName() {
|
|
38
|
+
return copied ? copiedText() : copyText();
|
|
39
|
+
}
|
|
40
|
+
function buttonIcon() {
|
|
41
|
+
return copied ? faCheck : faCopy;
|
|
42
|
+
}
|
|
43
|
+
function announce() {
|
|
44
|
+
return copied ? copiedText() : "";
|
|
45
|
+
}
|
|
46
|
+
function textoDoBloco() {
|
|
47
|
+
if (props.code !== undefined)
|
|
48
|
+
return props.code;
|
|
49
|
+
return codeRef.current ? codeRef.current.textContent || "" : "";
|
|
50
|
+
}
|
|
51
|
+
function copiarComFallback(texto) {
|
|
52
|
+
if (typeof document === "undefined")
|
|
53
|
+
return;
|
|
54
|
+
const campo = document.createElement("textarea");
|
|
55
|
+
campo.value = texto;
|
|
56
|
+
campo.setAttribute("readonly", "");
|
|
57
|
+
campo.style.position = "fixed";
|
|
58
|
+
campo.style.opacity = "0";
|
|
59
|
+
document.body.appendChild(campo);
|
|
60
|
+
campo.select();
|
|
61
|
+
try {
|
|
62
|
+
document.execCommand("copy");
|
|
63
|
+
}
|
|
64
|
+
catch (erro) {
|
|
65
|
+
// Sem como copiar neste navegador: o botão não confirma.
|
|
66
|
+
}
|
|
67
|
+
document.body.removeChild(campo);
|
|
68
|
+
}
|
|
69
|
+
function marcarCopiado(texto) {
|
|
70
|
+
setCopied(true);
|
|
71
|
+
if (props.onCopy)
|
|
72
|
+
props.onCopy(texto);
|
|
73
|
+
if (timerRef.current)
|
|
74
|
+
clearTimeout(timerRef.current);
|
|
75
|
+
timerRef.current = setTimeout(() => {
|
|
76
|
+
setCopied(false);
|
|
77
|
+
}, 2000);
|
|
78
|
+
}
|
|
79
|
+
function handleCopy() {
|
|
80
|
+
const texto = textoDoBloco();
|
|
81
|
+
if (typeof navigator !== "undefined" &&
|
|
82
|
+
navigator.clipboard &&
|
|
83
|
+
navigator.clipboard.writeText) {
|
|
84
|
+
navigator.clipboard.writeText(texto).then(() => marcarCopiado(texto), () => {
|
|
85
|
+
copiarComFallback(texto);
|
|
86
|
+
marcarCopiado(texto);
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
copiarComFallback(texto);
|
|
91
|
+
marcarCopiado(texto);
|
|
92
|
+
}
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
return () => {
|
|
95
|
+
if (timerRef.current) {
|
|
96
|
+
clearTimeout(timerRef.current);
|
|
97
|
+
timerRef.current = null;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}, []);
|
|
101
|
+
return (_jsxs("div", { id: props.id, className: classes(), children: [props.language || props.copyable ? (_jsxs("div", { className: "umds-code-block__header", children: [_jsx("span", { className: "umds-code-block__language", children: props.language }), props.copyable ? (_jsxs("button", { type: "button", className: "umds-code-block__copy", "aria-label": buttonName(), title: buttonName(), onClick: (event) => handleCopy(), children: [_jsx(Icon, { size: "sm", variant: "inherit", icon: buttonIcon() }), _jsx("span", { className: "umds-code-block__copy-text", children: buttonName() })] })) : null] })) : null, _jsx("pre", { role: "region", className: "umds-code-block__scroll", "aria-label": regionName(), tabIndex: 0, style: scrollStyle(), children: _jsxs("code", { className: "umds-code-block__code", ref: codeRef, children: [props.code, _jsx(_Fragment, { children: props.children })] }) }), _jsx("span", { role: "status", "aria-live": "polite", className: "umds-code-block__sr", children: announce() })] }));
|
|
102
|
+
}
|
|
103
|
+
export default CodeBlock;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/* ─────────────────────────────────────────────
|
|
2
|
+
COLOR PICKER
|
|
3
|
+
Grade de amostras da paleta do 1DS (primitivos de cor). Valor = nome do token.
|
|
4
|
+
|
|
5
|
+
Na paleta do DS a grade tem 7 colunas (os cinzas são 7) e a PRIMEIRA amostra
|
|
6
|
+
de cada família abre linha nova: uma linha por família, sem aninhar nada no
|
|
7
|
+
DOM — a ordem de Tab e das setas continua a da lista.
|
|
8
|
+
|
|
9
|
+
A amostra escolhida tem dois sinais além da cor: anel duplo e ícone de
|
|
10
|
+
marcação. O ícone usa primitivos (branco ou cinza escuro), porque a cor da
|
|
11
|
+
amostra é primitiva e não muda com o tema: o contraste fica o mesmo no escuro.
|
|
12
|
+
|
|
13
|
+
Cores: semânticos (e primitivos, na marcação) · Medidas: primitivos
|
|
14
|
+
───────────────────────────────────────────── */
|
|
15
|
+
|
|
16
|
+
.umds-color-picker {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: var(--umds-primitive-spacing-nano); /* 8px */
|
|
20
|
+
font-family: var(--umds-semantic-font-family-base);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.umds-color-picker__label {
|
|
24
|
+
font-size: var(--umds-semantic-field-label-size);
|
|
25
|
+
font-weight: var(--umds-semantic-field-label-weight);
|
|
26
|
+
color: var(--umds-semantic-field-label-color);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ── Grade ── */
|
|
30
|
+
.umds-color-picker__swatches {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-wrap: wrap;
|
|
33
|
+
gap: var(--umds-primitive-spacing-nano); /* 8px */
|
|
34
|
+
/* Folga para o anel de seleção (4px) não ser cortado por um overflow do pai. */
|
|
35
|
+
padding: var(--umds-primitive-spacing-quarck);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.umds-color-picker--sm .umds-color-picker__swatches {
|
|
39
|
+
gap: var(--umds-primitive-spacing-quarck); /* 4px */
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.umds-color-picker__swatches--familias {
|
|
43
|
+
display: grid;
|
|
44
|
+
grid-template-columns: repeat(7, max-content);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.umds-color-picker__swatch--nova-linha {
|
|
48
|
+
grid-column-start: 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* ── Amostra ── */
|
|
52
|
+
.umds-color-picker__swatch {
|
|
53
|
+
display: inline-flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
margin: 0;
|
|
58
|
+
padding: 0;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
/* Anel de 1px: amostra clara não some no fundo branco. */
|
|
61
|
+
border: var(--umds-primitive-border-width-hairline) solid var(--umds-semantic-color-neutral-light-down);
|
|
62
|
+
border-radius: var(--umds-primitive-border-radius-sm);
|
|
63
|
+
/* A cor da amostra vem do `style` (background-color); o ícone herda o branco. */
|
|
64
|
+
/* stylelint-disable-next-line 1ds/cor-por-token -- a amostra é primitivo (não muda com o tema); a marcação precisa do par fixo, senão o semântico inverte no escuro e perde o contraste */
|
|
65
|
+
color: var(--umds-primitive-white);
|
|
66
|
+
transition: box-shadow var(--umds-semantic-motion-duration-fast) var(--umds-semantic-motion-easing-standard);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.umds-color-picker--md .umds-color-picker__swatch {
|
|
70
|
+
width: var(--umds-primitive-spacing-xs); /* 32px */
|
|
71
|
+
height: var(--umds-primitive-spacing-xs);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.umds-color-picker--sm .umds-color-picker__swatch {
|
|
75
|
+
width: var(--umds-primitive-spacing-xxs); /* 24px */
|
|
76
|
+
height: var(--umds-primitive-spacing-xxs);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.umds-color-picker__swatch--on-light {
|
|
80
|
+
/* stylelint-disable-next-line 1ds/cor-por-token -- par fixo da marcação sobre amostra clara (ver acima) */
|
|
81
|
+
color: var(--umds-primitive-gray-darkest);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.umds-color-picker__swatch:hover:not(:disabled) {
|
|
85
|
+
box-shadow: 0 0 0 var(--umds-primitive-border-width-thin) var(--umds-semantic-color-neutral-light-down);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.umds-color-picker__swatch--selected,
|
|
89
|
+
.umds-color-picker__swatch--selected:hover:not(:disabled) {
|
|
90
|
+
/* Anel duplo: a cor do fundo da página por dentro e o primário por fora. */
|
|
91
|
+
box-shadow:
|
|
92
|
+
0 0 0 var(--umds-primitive-border-width-thin) var(--umds-semantic-color-background-white),
|
|
93
|
+
0 0 0 calc(var(--umds-primitive-border-width-thin) * 2) var(--umds-semantic-color-primary-pure);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.umds-color-picker__swatch:focus-visible {
|
|
97
|
+
outline: var(--umds-primitive-border-width-thin) solid var(--umds-semantic-color-primary-pure);
|
|
98
|
+
outline-offset: var(--umds-primitive-spacing-quarck);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.umds-color-picker__swatch:disabled {
|
|
102
|
+
cursor: not-allowed;
|
|
103
|
+
opacity: var(--umds-semantic-field-disabled-opacity);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* ── Cor livre ── */
|
|
107
|
+
.umds-color-picker__custom {
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: flex-end;
|
|
110
|
+
gap: var(--umds-primitive-spacing-nano); /* 8px */
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.umds-color-picker__custom-preview {
|
|
114
|
+
flex: none;
|
|
115
|
+
box-sizing: border-box;
|
|
116
|
+
width: var(--umds-primitive-spacing-xs); /* 32px, a altura do Input sm */
|
|
117
|
+
height: var(--umds-primitive-spacing-xs);
|
|
118
|
+
border: var(--umds-primitive-border-width-hairline) solid var(--umds-semantic-color-neutral-light-down);
|
|
119
|
+
border-radius: var(--umds-primitive-border-radius-sm);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* ── Alto contraste: a marcação e a borda ficam, a cor é do usuário ── */
|
|
123
|
+
@media (forced-colors: active) {
|
|
124
|
+
.umds-color-picker__swatch {
|
|
125
|
+
forced-color-adjust: none;
|
|
126
|
+
border-color: CanvasText;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.umds-color-picker__swatch--selected {
|
|
130
|
+
outline: var(--umds-primitive-border-width-thin) solid Highlight;
|
|
131
|
+
outline-offset: var(--umds-primitive-border-width-thin);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import './ColorPicker.css';
|
|
2
|
+
/**
|
|
3
|
+
* Amostra do ColorPicker.
|
|
4
|
+
* @property {string} value - Nome da variável CSS (`--umds-primitive-blue-pure`) ou uma cor hexadecimal (`#0058DB`).
|
|
5
|
+
* @property {string} label - Nome da cor, para leitor de tela e tooltip.
|
|
6
|
+
* @property {boolean} onLight - Cor clara: o ícone de marcação sai escuro.
|
|
7
|
+
* @property {boolean} disabled - Desabilita só esta amostra.
|
|
8
|
+
*/
|
|
9
|
+
export interface ColorPickerSwatch {
|
|
10
|
+
value: string;
|
|
11
|
+
label: string;
|
|
12
|
+
onLight?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ColorPicker — escolha de UMA cor numa grade de amostras da paleta do 1DS.
|
|
18
|
+
*
|
|
19
|
+
* O valor é o NOME DO TOKEN (`--umds-primitive-blue-pure`), não o hexadecimal:
|
|
20
|
+
* guarde o nome e escreva `var(${valor})` onde pintar, e a cor acompanha a
|
|
21
|
+
* paleta do DS. As amostras são os primitivos de cor (6 famílias de 4 tons e
|
|
22
|
+
* os 7 cinzas), por isso a cor escolhida é a mesma no tema claro e no escuro,
|
|
23
|
+
* o que é o certo para cor de dado (marcador, tipo de documento, setor).
|
|
24
|
+
*
|
|
25
|
+
* É um `radiogroup`: um Tab entra na grade (na amostra escolhida, ou na
|
|
26
|
+
* primeira) e as setas movem a escolha, com Home e End nas pontas. Cada amostra
|
|
27
|
+
* tem nome acessível ("Azul escuro") e a escolhida ganha um ícone de marcação,
|
|
28
|
+
* então a seleção nunca depende só da cor.
|
|
29
|
+
*
|
|
30
|
+
* `allowCustom` liga o campo de cor livre (hexadecimal `#RRGGBB`). Vem
|
|
31
|
+
* DESLIGADO: cor fora da paleta foge do DS, e quem liga assume o desvio. O
|
|
32
|
+
* valor livre sai em maiúsculas (`#0058DB`) e se distingue do token por começar
|
|
33
|
+
* com `#`.
|
|
34
|
+
*
|
|
35
|
+
* Para um recorte da paleta (só azul e cinza) ou para traduzir os nomes, passe
|
|
36
|
+
* `swatches`; `COLOR_PALETTE` é a lista padrão, exportada para filtrar.
|
|
37
|
+
* @property {string} value - Valor escolhido (controlado): nome do token ou `#RRGGBB`
|
|
38
|
+
* @property {string} defaultValue - Valor inicial (não controlado)
|
|
39
|
+
* @property {string} label - Rótulo visível do grupo
|
|
40
|
+
* @property {string} ariaLabel - Nome acessível quando não há `label` visível
|
|
41
|
+
* @property {string} ariaLabelledby - Id do texto que nomeia o grupo
|
|
42
|
+
* @property {ColorPickerSwatch[]} swatches - Amostras no lugar da paleta do DS (ex.: nomes traduzidos)
|
|
43
|
+
* @property {string[]} families - Mostra só estas famílias da paleta do DS: 'blue' | 'red' | 'green' | 'orange' | 'yellow' | 'purple' | 'gray'
|
|
44
|
+
* @property {boolean} allowCustom - Liga o campo de cor livre (hexadecimal)
|
|
45
|
+
* @property {string} customLabel - Rótulo do campo de cor livre (padrão: "Cor livre (hexadecimal)")
|
|
46
|
+
* @property {string} customErrorMessage - Mensagem do hexadecimal inválido (padrão: "Use o formato #RRGGBB")
|
|
47
|
+
* @property {string} size - Tamanho da amostra: 'sm' (24px) | 'md' (32px)
|
|
48
|
+
* @property {boolean} disabled - Desabilita o grupo inteiro
|
|
49
|
+
* @property {string} id - Base dos ids internos; passe em SSR para os ids já saírem no HTML do servidor
|
|
50
|
+
* @property {string} className - Classes CSS adicionais
|
|
51
|
+
* @property {function} onChange - Callback com o valor escolhido (nome do token ou `#RRGGBB`)
|
|
52
|
+
* @quandoUsar Escolher a cor de um marcador, de um tipo de documento, de um setor ou de uma série de dados, sempre dentro da paleta do DS.
|
|
53
|
+
* @quandoNaoUsar Para cor com PAPEL na interface (primária, erro, sucesso), use os tokens semânticos direto: não é escolha do usuário. Para escolher entre poucas opções que não são cor, use `SegmentedControl` ou `RadioGroup`. Para uma cor qualquer da web, ligue `allowCustom` sabendo que ela sai do DS.
|
|
54
|
+
*/
|
|
55
|
+
export interface ColorPickerProps {
|
|
56
|
+
value?: string;
|
|
57
|
+
defaultValue?: string;
|
|
58
|
+
label?: string;
|
|
59
|
+
ariaLabel?: string;
|
|
60
|
+
ariaLabelledby?: string;
|
|
61
|
+
swatches?: ColorPickerSwatch[];
|
|
62
|
+
families?: string[];
|
|
63
|
+
allowCustom?: boolean;
|
|
64
|
+
customLabel?: string;
|
|
65
|
+
customErrorMessage?: string;
|
|
66
|
+
size?: "sm" | "md";
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
id?: string;
|
|
69
|
+
className?: string;
|
|
70
|
+
onChange?: (value: string) => void;
|
|
71
|
+
}
|
|
72
|
+
declare function ColorPicker(props: ColorPickerProps): import("react/jsx-runtime").JSX.Element;
|
|
73
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import './ColorPicker.css';
|
|
4
|
+
import { useState, useRef, useEffect } from "react";
|
|
5
|
+
import { faCheck } from "@fortawesome/free-solid-svg-icons";
|
|
6
|
+
import Icon from "../Icon/Icon";
|
|
7
|
+
import Input from "../Input/Input";
|
|
8
|
+
import { gerarId } from "../../utils/id";
|
|
9
|
+
import { COLOR_PALETTE, isHexColor } from "../../utils/paleta-de-cores";
|
|
10
|
+
function ColorPicker(props) {
|
|
11
|
+
const groupRef = useRef(null);
|
|
12
|
+
const [internalValue, setInternalValue] = useState(() => props.defaultValue !== undefined ? props.defaultValue : "");
|
|
13
|
+
const [uid, setUid] = useState(() => "");
|
|
14
|
+
const [hexDraft, setHexDraft] = useState(() => "");
|
|
15
|
+
const [hexEditing, setHexEditing] = useState(() => false);
|
|
16
|
+
const [hexTouched, setHexTouched] = useState(() => false);
|
|
17
|
+
function baseId() {
|
|
18
|
+
return props.id || uid;
|
|
19
|
+
}
|
|
20
|
+
function labelId() {
|
|
21
|
+
return baseId() && props.label ? baseId() + "-label" : undefined;
|
|
22
|
+
}
|
|
23
|
+
function currentValue() {
|
|
24
|
+
return props.value !== undefined ? props.value : internalValue;
|
|
25
|
+
}
|
|
26
|
+
function swatchList() {
|
|
27
|
+
if (props.swatches && props.swatches.length)
|
|
28
|
+
return props.swatches;
|
|
29
|
+
const familias = props.families;
|
|
30
|
+
if (!familias || !familias.length)
|
|
31
|
+
return COLOR_PALETTE;
|
|
32
|
+
return COLOR_PALETTE.filter((cor) => familias.indexOf(cor.family) !== -1);
|
|
33
|
+
}
|
|
34
|
+
function usaPaletaDoDs() {
|
|
35
|
+
return !(props.swatches && props.swatches.length);
|
|
36
|
+
}
|
|
37
|
+
function groupClasses() {
|
|
38
|
+
return [
|
|
39
|
+
"umds-color-picker",
|
|
40
|
+
`umds-color-picker--${props.size || "md"}`,
|
|
41
|
+
props.disabled ? "umds-color-picker--disabled" : "",
|
|
42
|
+
props.className,
|
|
43
|
+
]
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join(" ");
|
|
46
|
+
}
|
|
47
|
+
function swatchesClasses() {
|
|
48
|
+
return [
|
|
49
|
+
"umds-color-picker__swatches",
|
|
50
|
+
usaPaletaDoDs() ? "umds-color-picker__swatches--familias" : "",
|
|
51
|
+
]
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.join(" ");
|
|
54
|
+
}
|
|
55
|
+
function groupAriaLabel() {
|
|
56
|
+
if (props.ariaLabel)
|
|
57
|
+
return props.ariaLabel;
|
|
58
|
+
// Antes do onMount o label ainda não tem id para o aria-labelledby apontar.
|
|
59
|
+
return props.label && !labelId() ? props.label : undefined;
|
|
60
|
+
}
|
|
61
|
+
function groupLabelledBy() {
|
|
62
|
+
return props.ariaLabelledby || labelId();
|
|
63
|
+
}
|
|
64
|
+
function corCss(valor) {
|
|
65
|
+
if (!valor)
|
|
66
|
+
return "";
|
|
67
|
+
return valor.indexOf("--") === 0 ? "var(" + valor + ")" : valor;
|
|
68
|
+
}
|
|
69
|
+
function swatchStyle(swatch) {
|
|
70
|
+
return {
|
|
71
|
+
backgroundColor: corCss(swatch.value),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function swatchClasses(swatch) {
|
|
75
|
+
return [
|
|
76
|
+
"umds-color-picker__swatch",
|
|
77
|
+
swatch.onLight ? "umds-color-picker__swatch--on-light" : "",
|
|
78
|
+
estaEscolhida(swatch) ? "umds-color-picker__swatch--selected" : "",
|
|
79
|
+
]
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
.join(" ");
|
|
82
|
+
}
|
|
83
|
+
function novaLinha(swatch, index) {
|
|
84
|
+
if (!usaPaletaDoDs())
|
|
85
|
+
return false;
|
|
86
|
+
if (index === 0)
|
|
87
|
+
return true;
|
|
88
|
+
const anterior = swatchList()[index - 1];
|
|
89
|
+
return !!anterior && !!swatch.family && anterior.family !== swatch.family;
|
|
90
|
+
}
|
|
91
|
+
function swatchItemClasses(swatch, index) {
|
|
92
|
+
return [
|
|
93
|
+
swatchClasses(swatch),
|
|
94
|
+
novaLinha(swatch, index) ? "umds-color-picker__swatch--nova-linha" : "",
|
|
95
|
+
]
|
|
96
|
+
.filter(Boolean)
|
|
97
|
+
.join(" ");
|
|
98
|
+
}
|
|
99
|
+
function estaEscolhida(swatch) {
|
|
100
|
+
return (!!currentValue() &&
|
|
101
|
+
swatch.value.toLowerCase() === currentValue().toLowerCase());
|
|
102
|
+
}
|
|
103
|
+
function estaDesabilitada(swatch) {
|
|
104
|
+
return !!props.disabled || !!swatch.disabled;
|
|
105
|
+
}
|
|
106
|
+
function indiceDoTab() {
|
|
107
|
+
const lista = swatchList();
|
|
108
|
+
for (let i = 0; i < lista.length; i++) {
|
|
109
|
+
if (estaEscolhida(lista[i]) && !estaDesabilitada(lista[i]))
|
|
110
|
+
return i;
|
|
111
|
+
}
|
|
112
|
+
for (let i = 0; i < lista.length; i++) {
|
|
113
|
+
if (!estaDesabilitada(lista[i]))
|
|
114
|
+
return i;
|
|
115
|
+
}
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
function tabIndexDa(index) {
|
|
119
|
+
return index === indiceDoTab() ? 0 : -1;
|
|
120
|
+
}
|
|
121
|
+
function emitir(valor) {
|
|
122
|
+
setInternalValue(valor);
|
|
123
|
+
if (props.onChange)
|
|
124
|
+
props.onChange(valor);
|
|
125
|
+
}
|
|
126
|
+
function escolher(swatch) {
|
|
127
|
+
if (estaDesabilitada(swatch))
|
|
128
|
+
return;
|
|
129
|
+
setHexEditing(false);
|
|
130
|
+
setHexDraft("");
|
|
131
|
+
setHexTouched(false);
|
|
132
|
+
emitir(swatch.value);
|
|
133
|
+
}
|
|
134
|
+
function handleKeyDown(event, index) {
|
|
135
|
+
if (!event || event.altKey || event.ctrlKey || event.metaKey)
|
|
136
|
+
return;
|
|
137
|
+
const lista = swatchList();
|
|
138
|
+
const total = lista.length;
|
|
139
|
+
if (!total)
|
|
140
|
+
return;
|
|
141
|
+
let passo = 0;
|
|
142
|
+
let alvo = index;
|
|
143
|
+
if (event.key === "ArrowRight" || event.key === "ArrowDown")
|
|
144
|
+
passo = 1;
|
|
145
|
+
else if (event.key === "ArrowLeft" || event.key === "ArrowUp")
|
|
146
|
+
passo = -1;
|
|
147
|
+
else if (event.key === "Home") {
|
|
148
|
+
passo = 1;
|
|
149
|
+
alvo = -1;
|
|
150
|
+
}
|
|
151
|
+
else if (event.key === "End") {
|
|
152
|
+
passo = -1;
|
|
153
|
+
alvo = total;
|
|
154
|
+
}
|
|
155
|
+
else
|
|
156
|
+
return;
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
for (let tentativa = 0; tentativa < total; tentativa++) {
|
|
159
|
+
alvo = (alvo + passo + total) % total;
|
|
160
|
+
if (!estaDesabilitada(lista[alvo]))
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
if (estaDesabilitada(lista[alvo]))
|
|
164
|
+
return;
|
|
165
|
+
escolher(lista[alvo]);
|
|
166
|
+
if (groupRef.current) {
|
|
167
|
+
const botoes = groupRef.current.querySelectorAll('[role="radio"]');
|
|
168
|
+
const botao = botoes[alvo];
|
|
169
|
+
if (botao)
|
|
170
|
+
botao.focus();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function hexText() {
|
|
174
|
+
if (hexEditing)
|
|
175
|
+
return hexDraft;
|
|
176
|
+
const atual = currentValue();
|
|
177
|
+
return atual && atual.indexOf("#") === 0 ? atual : "";
|
|
178
|
+
}
|
|
179
|
+
function hexInvalid() {
|
|
180
|
+
return hexTouched && !!hexText() && !isHexColor(hexText());
|
|
181
|
+
}
|
|
182
|
+
function customPreview() {
|
|
183
|
+
const texto = hexText();
|
|
184
|
+
return isHexColor(texto) ? corCss(normalizarHex(texto)) : "";
|
|
185
|
+
}
|
|
186
|
+
function customLabelText() {
|
|
187
|
+
return props.customLabel || "Cor livre (hexadecimal)";
|
|
188
|
+
}
|
|
189
|
+
function customErrorText() {
|
|
190
|
+
return hexInvalid()
|
|
191
|
+
? props.customErrorMessage || "Use o formato #RRGGBB"
|
|
192
|
+
: undefined;
|
|
193
|
+
}
|
|
194
|
+
function normalizarHex(texto) {
|
|
195
|
+
const limpo = texto.trim();
|
|
196
|
+
return (limpo.indexOf("#") === 0 ? limpo : "#" + limpo).toUpperCase();
|
|
197
|
+
}
|
|
198
|
+
function handleHexInput(texto) {
|
|
199
|
+
setHexEditing(true);
|
|
200
|
+
setHexDraft(texto);
|
|
201
|
+
if (isHexColor(texto))
|
|
202
|
+
emitir(normalizarHex(texto));
|
|
203
|
+
}
|
|
204
|
+
function handleHexBlur() {
|
|
205
|
+
setHexTouched(true);
|
|
206
|
+
if (isHexColor(hexDraft)) {
|
|
207
|
+
setHexEditing(false);
|
|
208
|
+
setHexDraft("");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
if (!props.id)
|
|
213
|
+
setUid(gerarId("umds-color-picker"));
|
|
214
|
+
}, []);
|
|
215
|
+
return (_jsxs("div", { className: groupClasses(), children: [props.label ? (_jsx("span", { className: "umds-color-picker__label", id: labelId(), children: props.label })) : null, _jsx("div", { role: "radiogroup", ref: groupRef, "aria-label": groupAriaLabel(), "aria-labelledby": groupLabelledBy(), className: swatchesClasses(), children: swatchList()?.map((swatch, index) => (_jsx("button", { type: "button", role: "radio", style: swatchStyle(swatch), "aria-checked": estaEscolhida(swatch) ? "true" : "false", "aria-label": swatch.label, title: swatch.label, disabled: estaDesabilitada(swatch), tabIndex: tabIndexDa(index), onClick: (event) => escolher(swatch), onKeyDown: (event) => handleKeyDown(event, index), className: swatchItemClasses(swatch, index), children: estaEscolhida(swatch) ? (_jsx(Icon, { size: "sm", variant: "inherit", icon: faCheck })) : null }, swatch.value))) }), props.allowCustom ? (_jsxs("div", { className: "umds-color-picker__custom", children: [_jsx("span", { "aria-hidden": "true", className: "umds-color-picker__custom-preview", style: {
|
|
216
|
+
backgroundColor: customPreview(),
|
|
217
|
+
} }), _jsx(Input, { size: "sm", placeholder: "#0058DB", label: customLabelText(), value: hexText(), disabled: props.disabled, errorMessage: customErrorText(), onChange: (texto) => handleHexInput(texto), onBlur: (event) => handleHexBlur() })] })) : null] }));
|
|
218
|
+
}
|
|
219
|
+
export default ColorPicker;
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
display: flex;
|
|
42
42
|
align-items: center;
|
|
43
43
|
background-color: var(--umds-semantic-color-background-white);
|
|
44
|
-
border: 1px solid var(--umds-semantic-
|
|
44
|
+
border: 1px solid var(--umds-semantic-field-border-default);
|
|
45
45
|
border-radius: var(--umds-primitive-border-radius-sm);
|
|
46
46
|
box-sizing: border-box;
|
|
47
47
|
transition:
|
|
@@ -203,17 +203,25 @@
|
|
|
203
203
|
/* ── Estado: ReadOnly ── */
|
|
204
204
|
.umds-combobox--readonly .umds-combobox__field {
|
|
205
205
|
background-color: var(--umds-semantic-field-readonly-background);
|
|
206
|
-
border-color: var(--umds-semantic-
|
|
206
|
+
border-color: var(--umds-semantic-field-border-default);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
.umds-combobox--readonly .umds-combobox__field:hover {
|
|
210
|
-
border-color: var(--umds-semantic-
|
|
210
|
+
border-color: var(--umds-semantic-field-border-default);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
.umds-combobox--readonly .umds-combobox__control {
|
|
214
214
|
cursor: default;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
/* Somente leitura não é desabilitado: o texto segue lido e a WCAG 1.4.3 vale
|
|
218
|
+
sem isenção. O placeholder padrão foi calibrado para fundo branco e cai para
|
|
219
|
+
~4,2:1 sobre o fundo de somente leitura; neutral-dark-down passa 4,5:1 em
|
|
220
|
+
todos os temas (1doc 6,78:1 · 1doc-dark 10,83:1 · alto contraste 16,48:1). */
|
|
221
|
+
.umds-combobox--readonly .umds-combobox__control::placeholder {
|
|
222
|
+
color: var(--umds-semantic-color-neutral-dark-down);
|
|
223
|
+
}
|
|
224
|
+
|
|
217
225
|
/* ── Dropdown (espelha .umds-select__dropdown) ── */
|
|
218
226
|
.umds-combobox__dropdown {
|
|
219
227
|
position: absolute;
|
|
@@ -16,13 +16,23 @@ import './ConfirmAIAction.css';
|
|
|
16
16
|
* @property {Function} onConfirm - Confirmação. Só dispara quando o risco permite.
|
|
17
17
|
* @property {Function} onCancel - Cancelamento
|
|
18
18
|
* @property {string} className - Classes CSS adicionais
|
|
19
|
-
*
|
|
19
|
+
* Em risco alto, o botão de confirmar fica desabilitado (`confirmDisabled` do `ConfirmDialog`) até a frase digitada conferir; o handler bloqueia de novo, por garantia.
|
|
20
20
|
* @quandoUsar Ação sugerida por IA que o usuário não pode desfazer sozinho, ou que dispara efeito em cascata: despachar, tramitar, arquivar, notificar o cidadão. Cascata conta como risco alto mesmo quando cada passo é reversível.
|
|
21
21
|
* @quandoNaoUsar Ação reversível em um clique — mantenha só o "desfazer" e não interrompa. Para confirmação que não veio de sugestão de IA, use `ConfirmDialog` direto.
|
|
22
22
|
*/
|
|
23
23
|
export interface ConfirmAIActionProps {
|
|
24
24
|
/** Rótulo acessível do bloco de impacto. @default 'O que será afetado' */
|
|
25
25
|
impactLabel?: string;
|
|
26
|
+
/** Aviso de irreversibilidade em risco alto. Troque para traduzir. @default 'Esta ação não pode ser desfeita.' */
|
|
27
|
+
irreversibleLabel?: string;
|
|
28
|
+
/** Texto antes da frase a digitar em risco alto (a frase vem depois, em negrito). Troque para traduzir. @default 'Para confirmar, digite' */
|
|
29
|
+
typePhraseLabel?: string;
|
|
30
|
+
/** Anúncio (aria-live) quando a frase digitada confere. Troque para traduzir. @default 'Texto confere. O botão de confirmar foi liberado.' */
|
|
31
|
+
phraseMatchedLabel?: string;
|
|
32
|
+
/** Anúncio (aria-live) enquanto a frase digitada não confere. Troque para traduzir. @default 'O botão de confirmar fica desabilitado até o texto conferir.' */
|
|
33
|
+
phrasePendingLabel?: string;
|
|
34
|
+
/** Texto do botão de confirmar durante `confirmLoading`, repassado ao ConfirmDialog. Troque para traduzir. @default 'Aguarde...' */
|
|
35
|
+
loadingLabel?: string;
|
|
26
36
|
open?: any;
|
|
27
37
|
risk?: "baixo" | "medio" | "alto";
|
|
28
38
|
title: string;
|
|
@@ -19,6 +19,9 @@ function ConfirmAIAction(props) {
|
|
|
19
19
|
return true;
|
|
20
20
|
return ((props.typedValue || "").trim().toUpperCase() === frase().toUpperCase());
|
|
21
21
|
}
|
|
22
|
+
function textoDigite() {
|
|
23
|
+
return (props.typePhraseLabel || "Para confirmar, digite") + " ";
|
|
24
|
+
}
|
|
22
25
|
function variante() {
|
|
23
26
|
return nivel() === "alto" ? "negative" : "info";
|
|
24
27
|
}
|
|
@@ -47,6 +50,8 @@ function ConfirmAIAction(props) {
|
|
|
47
50
|
props.onConfirm(event);
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
|
-
return (_jsx(ConfirmDialog, { open: props.open, title: props.title, description: props.description, variant: variante(), confirmLabel: props.confirmLabel || "Confirmar", cancelLabel: props.cancelLabel || "Cancelar", confirmLoading: props.confirmLoading, onConfirm: (event) => handleConfirm(event), onCancel: (event) => handleCancel(event), children: _jsxs("div", { className: classes(), children: [props.affected && props.affected.length > 0 ? (_jsxs("div", { className: "umds-confirmai__bloco", children: [_jsx("p", { className: "umds-confirmai__rotulo", children: "O que
|
|
53
|
+
return (_jsx(ConfirmDialog, { open: props.open, title: props.title, description: props.description, variant: variante(), confirmLabel: props.confirmLabel || "Confirmar", cancelLabel: props.cancelLabel || "Cancelar", confirmLoading: props.confirmLoading, loadingLabel: props.loadingLabel, confirmDisabled: !liberado(), onConfirm: (event) => handleConfirm(event), onCancel: (event) => handleCancel(event), children: _jsxs("div", { className: classes(), children: [props.affected && props.affected.length > 0 ? (_jsxs("div", { className: "umds-confirmai__bloco", children: [_jsx("p", { className: "umds-confirmai__rotulo", children: props.impactLabel || "O que será afetado" }), _jsx("ul", { className: "umds-confirmai__lista", tabIndex: 0, "aria-label": props.impactLabel || "O que será afetado", children: listaAfetados()?.map((item) => (_jsx("li", { children: item }, item))) })] })) : null, _jsx(_Fragment, { children: props.children }), exigeDigitacao() ? (_jsxs("div", { className: "umds-confirmai__bloco umds-confirmai__alto", children: [_jsxs("p", { className: "umds-confirmai__aviso", children: [_jsx(Icon, { size: "sm", variant: "inherit", icon: faTriangleExclamation }), _jsx("span", { children: props.irreversibleLabel || "Esta ação não pode ser desfeita." })] }), _jsxs("label", { className: "umds-confirmai__label", htmlFor: "umds-confirmai-frase", children: [textoDigite(), _jsx("strong", { children: frase() })] }), _jsx("input", { id: "umds-confirmai-frase", className: "umds-confirmai__campo", type: "text", autoComplete: "off", value: props.typedValue, onInput: (event) => handleTyped(event) }), _jsx("p", { className: "umds-confirmai__estado", "aria-live": "polite", children: liberado() ? (_jsx(_Fragment, { children: props.phraseMatchedLabel ||
|
|
54
|
+
"Texto confere. O botão de confirmar foi liberado." })) : (_jsx(_Fragment, { children: props.phrasePendingLabel ||
|
|
55
|
+
"O botão de confirmar fica desabilitado até o texto conferir." })) })] })) : null] }) }));
|
|
51
56
|
}
|
|
52
57
|
export default ConfirmAIAction;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
.umds-confirm-dialog-overlay {
|
|
12
12
|
position: fixed;
|
|
13
13
|
inset: 0;
|
|
14
|
+
/* stylelint-disable-next-line 1ds/cor-por-token -- o DS não tem token de scrim/overlay (candidato a novo token) */
|
|
14
15
|
background: rgba(0, 0, 0, 0.45); /* overlay escuro — sem token 1DS (mesma abordagem do Modal) */
|
|
15
16
|
display: flex;
|
|
16
17
|
align-items: center;
|
|
@@ -168,7 +169,9 @@
|
|
|
168
169
|
/* Escurecimento dinâmico do feedback-info-dark (decisão 25/07: info/warning
|
|
169
170
|
permanece LARANJA; sem token -darker — derivado por color-mix). No tema
|
|
170
171
|
1doc resolve no mesmo #7a3909 de antes; acompanha tema/dark nos demais. */
|
|
172
|
+
/* stylelint-disable-next-line 1ds/cor-por-token -- escurecimento por color-mix com preto: o DS não tem token -darker nem preto semântico (candidato a novo token) */
|
|
171
173
|
background: color-mix(in srgb, var(--umds-semantic-color-feedback-info-dark) 80%, black);
|
|
174
|
+
/* stylelint-disable-next-line 1ds/cor-por-token -- escurecimento por color-mix com preto: o DS não tem token -darker nem preto semântico (candidato a novo token) */
|
|
172
175
|
border-color: color-mix(in srgb, var(--umds-semantic-color-feedback-info-dark) 80%, black);
|
|
173
176
|
}
|
|
174
177
|
|
|
@@ -40,11 +40,25 @@ export interface ConfirmDialogProps {
|
|
|
40
40
|
* @default 'Cancelar'
|
|
41
41
|
*/
|
|
42
42
|
cancelLabel?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Texto do botão de confirmação enquanto `confirmLoading` está ligado.
|
|
45
|
+
* Troque para traduzir.
|
|
46
|
+
* @default 'Aguarde...'
|
|
47
|
+
*/
|
|
48
|
+
loadingLabel?: string;
|
|
43
49
|
/**
|
|
44
50
|
* Desabilita o botão de confirmação e exibe estado de carregamento.
|
|
45
51
|
* @default false
|
|
46
52
|
*/
|
|
47
53
|
confirmLoading?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Desabilita o botão de confirmação sem estado de carregamento — para quando
|
|
56
|
+
* a confirmação depende de uma condição ainda não cumprida (ex.: digitar a
|
|
57
|
+
* frase de segurança). O botão sai com `disabled` nativo: não recebe foco
|
|
58
|
+
* nem clique, e o leitor de tela o anuncia como indisponível.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
confirmDisabled?: boolean;
|
|
48
62
|
/**
|
|
49
63
|
* Renderiza o diálogo inline (overlay relativo, sem fixed) — útil para
|
|
50
64
|
* documentação/Storybook, onde o overlay fixed ficaria preso em containers
|