@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,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paleta de cor categórica do 1DS: os primitivos `--umds-primitive-<família>-<tom>`.
|
|
3
|
+
*
|
|
4
|
+
* É a lista que o `ColorPicker` mostra por padrão. Ela existe como constante
|
|
5
|
+
* exportada para o app mapear o valor guardado (o nome do token) de volta para
|
|
6
|
+
* um rótulo, ou montar a própria lista a partir dela (`COLOR_PALETTE.filter(...)`).
|
|
7
|
+
*
|
|
8
|
+
* Primitivo não muda com o tema: é o certo para cor de DADO (marcador, tipo de
|
|
9
|
+
* documento, setor), que precisa ser a mesma no claro e no escuro. Para cor com
|
|
10
|
+
* PAPEL (primário, erro, sucesso) use os semânticos `--umds-semantic-color-*`,
|
|
11
|
+
* que não entram aqui.
|
|
12
|
+
*/
|
|
13
|
+
export type PaletteColor = {
|
|
14
|
+
/** Nome da variável CSS, ex.: `--umds-primitive-blue-pure`. Use como `var(${value})`. */
|
|
15
|
+
value: string;
|
|
16
|
+
/** Nome em português, ex.: "Azul escuro". */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Família: blue, red, green, orange, yellow, purple ou gray. */
|
|
19
|
+
family: string;
|
|
20
|
+
/** Tom claro o bastante para o ícone de marcação sair escuro (contraste mínimo de 3:1). */
|
|
21
|
+
onLight: boolean;
|
|
22
|
+
};
|
|
23
|
+
/** Os 31 primitivos de cor (6 famílias x 4 tons + 7 cinzas), do mais escuro ao mais claro. */
|
|
24
|
+
export declare const COLOR_PALETTE: PaletteColor[];
|
|
25
|
+
/** `#RRGGBB` completo (o `#` é opcional). Hexadecimal curto (`#FFF`) não vale. */
|
|
26
|
+
export declare const isHexColor: (texto: string) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const cor = (family, tone, label, onLight) => ({
|
|
2
|
+
value: "--umds-primitive-" + family + "-" + tone,
|
|
3
|
+
label,
|
|
4
|
+
family,
|
|
5
|
+
onLight
|
|
6
|
+
});
|
|
7
|
+
/** Os 31 primitivos de cor (6 famílias x 4 tons + 7 cinzas), do mais escuro ao mais claro. */
|
|
8
|
+
export const COLOR_PALETTE = [cor("blue", "dark", "Azul escuro", false), cor("blue", "pure", "Azul", false), cor("blue", "medium", "Azul médio", false), cor("blue", "light", "Azul claro", true), cor("red", "dark", "Vermelho escuro", false), cor("red", "pure", "Vermelho", false), cor("red", "medium", "Vermelho médio", false), cor("red", "light", "Vermelho claro", true), cor("green", "dark", "Verde escuro", false), cor("green", "pure", "Verde", false), cor("green", "medium", "Verde médio", false), cor("green", "light", "Verde claro", true), cor("orange", "dark", "Laranja escuro", false), cor("orange", "pure", "Laranja", false), cor("orange", "medium", "Laranja médio", true), cor("orange", "light", "Laranja claro", true), cor("yellow", "dark", "Amarelo escuro", false), cor("yellow", "pure", "Amarelo", true), cor("yellow", "medium", "Amarelo médio", true), cor("yellow", "light", "Amarelo claro", true), cor("purple", "dark", "Roxo escuro", false), cor("purple", "pure", "Roxo", false), cor("purple", "medium", "Roxo médio", false), cor("purple", "light", "Roxo claro", true), cor("gray", "darkest", "Cinza muito escuro", false), cor("gray", "darker", "Cinza escuro", false), cor("gray", "dark", "Cinza", false), cor("gray", "medium", "Cinza médio", true), cor("gray", "light", "Cinza claro", true), cor("gray", "lighter", "Cinza mais claro", true), cor("gray", "lightest", "Cinza muito claro", true)];
|
|
9
|
+
/** `#RRGGBB` completo (o `#` é opcional). Hexadecimal curto (`#FFF`) não vale. */
|
|
10
|
+
export const isHexColor = (texto) => /^#?[0-9a-fA-F]{6}$/.test((texto || "").trim());
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Texto para comparar: minúsculo, sem acento e sem espaço nas pontas. É o que a
|
|
3
|
+
* busca do `IconPicker` usa para achar "usuario" em "Usuário".
|
|
4
|
+
*/
|
|
5
|
+
export const semAcento = (texto) => String(texto || "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1doc/1ds-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"react-dom": "^18.0.0",
|
|
46
46
|
"typescript": "^5.0.0",
|
|
47
47
|
"vitest": "^3.2.7",
|
|
48
|
-
"@1doc/1ds-core": "2.
|
|
49
|
-
"@1doc/1ds-tokens": "0.
|
|
48
|
+
"@1doc/1ds-core": "2.9.0",
|
|
49
|
+
"@1doc/1ds-tokens": "0.5.0"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ export * from "./utils/theme";
|
|
|
5
5
|
export * from "./utils/toast";
|
|
6
6
|
// Densidade global (modo touch ≥44px via data-density)
|
|
7
7
|
export * from "./utils/density";
|
|
8
|
+
// Paleta de cor categórica (primitivos) do ColorPicker
|
|
9
|
+
export * from "./utils/paleta-de-cores";
|
|
8
10
|
// FontAwesome
|
|
9
11
|
export { library } from "@fortawesome/fontawesome-svg-core";
|
|
10
12
|
|
|
@@ -12,6 +14,9 @@ export { library } from "@fortawesome/fontawesome-svg-core";
|
|
|
12
14
|
export { default as Accordion } from "./components/Accordion/Accordion";
|
|
13
15
|
export { default as AILabel } from "./components/AILabel/AILabel";
|
|
14
16
|
export { default as AIContent } from "./components/AIContent/AIContent";
|
|
17
|
+
export { default as Calendar } from "./components/Calendar/Calendar";
|
|
18
|
+
export { default as Coachmark } from "./components/Coachmark/Coachmark";
|
|
19
|
+
export { default as CodeBlock } from "./components/CodeBlock/CodeBlock";
|
|
15
20
|
export { default as ConfirmAIAction } from "./components/ConfirmAIAction/ConfirmAIAction";
|
|
16
21
|
export { default as Alert } from "./components/Alert/Alert";
|
|
17
22
|
export { default as AppHeader } from "./components/AppHeader/AppHeader";
|
|
@@ -33,11 +38,13 @@ export { default as Button } from "./components/Button/Button";
|
|
|
33
38
|
export { default as Card } from "./components/Card/Card";
|
|
34
39
|
export { default as Checkbox } from "./components/Checkbox/Checkbox";
|
|
35
40
|
export { default as Chips } from "./components/Chips/Chips";
|
|
41
|
+
export { default as ColorPicker } from "./components/ColorPicker/ColorPicker";
|
|
36
42
|
export { default as Combobox } from "./components/Combobox/Combobox";
|
|
37
43
|
export { default as ConfirmDialog } from "./components/ConfirmDialog/ConfirmDialog";
|
|
38
44
|
export { default as Container } from "./components/Container/Container";
|
|
39
45
|
export { default as DataTable } from "./components/DataTable/DataTable";
|
|
40
46
|
export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
47
|
+
export { default as DescriptionList } from "./components/DescriptionList/DescriptionList";
|
|
41
48
|
export { default as Divider } from "./components/Divider/Divider";
|
|
42
49
|
export { default as DonutChart } from "./components/Chart/DonutChart";
|
|
43
50
|
export { default as Drawer } from "./components/Drawer/Drawer";
|
|
@@ -46,15 +53,21 @@ export { default as EmptyState } from "./components/EmptyState/EmptyState";
|
|
|
46
53
|
export { default as FileInput } from "./components/FileInput/FileInput";
|
|
47
54
|
export { default as Grid } from "./components/Grid/Grid";
|
|
48
55
|
export { default as Icon } from "./components/Icon/Icon";
|
|
56
|
+
export { default as IconPicker } from "./components/IconPicker/IconPicker";
|
|
49
57
|
export { default as Input } from "./components/Input/Input";
|
|
50
58
|
export { default as Kanban } from "./components/Kanban/Kanban";
|
|
51
59
|
export { default as KanbanCard } from "./components/Kanban/KanbanCard";
|
|
52
60
|
export { default as KanbanColumn } from "./components/Kanban/KanbanColumn";
|
|
61
|
+
export { default as Kbd } from "./components/Kbd/Kbd";
|
|
53
62
|
export { default as Link } from "./components/Link/Link";
|
|
54
63
|
export { default as LineChart } from "./components/Chart/LineChart";
|
|
64
|
+
export { default as List } from "./components/List/List";
|
|
65
|
+
export { default as ListItem } from "./components/List/ListItem";
|
|
55
66
|
export { default as Logo } from "./components/Logo/Logo";
|
|
56
67
|
export { default as Modal } from "./components/Modal/Modal";
|
|
57
68
|
export { default as MultiSelect } from "./components/MultiSelect/MultiSelect";
|
|
69
|
+
export { default as OrgChart } from "./components/OrgChart/OrgChart";
|
|
70
|
+
export { default as OtpInput } from "./components/OtpInput/OtpInput";
|
|
58
71
|
export { default as PageHeader } from "./components/PageHeader/PageHeader";
|
|
59
72
|
export { default as Pagination } from "./components/Pagination/Pagination";
|
|
60
73
|
export { default as PhoneInput } from "./components/PhoneInput/PhoneInput";
|
|
@@ -62,6 +75,7 @@ export { default as Podium } from "./components/Podium/Podium";
|
|
|
62
75
|
export { default as ProgressBar } from "./components/ProgressBar/ProgressBar";
|
|
63
76
|
export { default as Radio } from "./components/Radio/Radio";
|
|
64
77
|
export { default as RadioGroup } from "./components/Radio/RadioGroup";
|
|
78
|
+
export { default as RichTextEditor } from "./components/RichTextEditor/RichTextEditor";
|
|
65
79
|
export { default as SegmentedControl } from "./components/SegmentedControl/SegmentedControl";
|
|
66
80
|
export { default as Select } from "./components/Select/Select";
|
|
67
81
|
export { default as SidePanel } from "./components/SidePanel/SidePanel";
|
|
@@ -94,6 +108,9 @@ export { default as Tree } from "./components/Tree/Tree";
|
|
|
94
108
|
export type * from "./components/Accordion/Accordion";
|
|
95
109
|
export type * from "./components/AILabel/AILabel";
|
|
96
110
|
export type * from "./components/AIContent/AIContent";
|
|
111
|
+
export type * from "./components/Calendar/Calendar";
|
|
112
|
+
export type * from "./components/Coachmark/Coachmark";
|
|
113
|
+
export type * from "./components/CodeBlock/CodeBlock";
|
|
97
114
|
export type * from "./components/ConfirmAIAction/ConfirmAIAction";
|
|
98
115
|
export type * from "./components/Alert/Alert";
|
|
99
116
|
export type * from "./components/AppHeader/AppHeader";
|
|
@@ -115,11 +132,13 @@ export type * from "./components/Button/Button";
|
|
|
115
132
|
export type * from "./components/Card/Card";
|
|
116
133
|
export type * from "./components/Checkbox/Checkbox";
|
|
117
134
|
export type * from "./components/Chips/Chips";
|
|
135
|
+
export type * from "./components/ColorPicker/ColorPicker";
|
|
118
136
|
export type * from "./components/Combobox/Combobox";
|
|
119
137
|
export type * from "./components/ConfirmDialog/ConfirmDialog";
|
|
120
138
|
export type * from "./components/Container/Container";
|
|
121
139
|
export type * from "./components/DataTable/DataTable";
|
|
122
140
|
export type * from "./components/DatePicker/DatePicker";
|
|
141
|
+
export type * from "./components/DescriptionList/DescriptionList";
|
|
123
142
|
export type * from "./components/Divider/Divider";
|
|
124
143
|
export type * from "./components/Chart/DonutChart";
|
|
125
144
|
export type * from "./components/Drawer/Drawer";
|
|
@@ -128,15 +147,21 @@ export type * from "./components/EmptyState/EmptyState";
|
|
|
128
147
|
export type * from "./components/FileInput/FileInput";
|
|
129
148
|
export type * from "./components/Grid/Grid";
|
|
130
149
|
export type * from "./components/Icon/Icon";
|
|
150
|
+
export type * from "./components/IconPicker/IconPicker";
|
|
131
151
|
export type * from "./components/Input/Input";
|
|
132
152
|
export type * from "./components/Kanban/Kanban";
|
|
133
153
|
export type * from "./components/Kanban/KanbanCard";
|
|
134
154
|
export type * from "./components/Kanban/KanbanColumn";
|
|
155
|
+
export type * from "./components/Kbd/Kbd";
|
|
135
156
|
export type * from "./components/Link/Link";
|
|
136
157
|
export type * from "./components/Chart/LineChart";
|
|
158
|
+
export type * from "./components/List/List";
|
|
159
|
+
export type * from "./components/List/ListItem";
|
|
137
160
|
export type * from "./components/Logo/Logo";
|
|
138
161
|
export type * from "./components/Modal/Modal";
|
|
139
162
|
export type * from "./components/MultiSelect/MultiSelect";
|
|
163
|
+
export type * from "./components/OrgChart/OrgChart";
|
|
164
|
+
export type * from "./components/OtpInput/OtpInput";
|
|
140
165
|
export type * from "./components/PageHeader/PageHeader";
|
|
141
166
|
export type * from "./components/Pagination/Pagination";
|
|
142
167
|
export type * from "./components/PhoneInput/PhoneInput";
|
|
@@ -144,6 +169,7 @@ export type * from "./components/Podium/Podium";
|
|
|
144
169
|
export type * from "./components/ProgressBar/ProgressBar";
|
|
145
170
|
export type * from "./components/Radio/Radio";
|
|
146
171
|
export type * from "./components/Radio/RadioGroup";
|
|
172
|
+
export type * from "./components/RichTextEditor/RichTextEditor";
|
|
147
173
|
export type * from "./components/SegmentedControl/SegmentedControl";
|
|
148
174
|
export type * from "./components/Select/Select";
|
|
149
175
|
export type * from "./components/SidePanel/SidePanel";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import AILabel from "../components/AILabel/AILabel";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `defaultOpen` era declarado e documentado, mas nunca lido: o painel nascia
|
|
8
|
+
* fechado de qualquer jeito, e a story "Em inglês" usava `open` (controlado)
|
|
9
|
+
* para contornar — o que travava o clique.
|
|
10
|
+
*/
|
|
11
|
+
describe("AILabel · defaultOpen", () => {
|
|
12
|
+
it("abre o painel na montagem", () => {
|
|
13
|
+
render(<AILabel explanation="Resumo dos despachos." defaultOpen />);
|
|
14
|
+
expect(screen.getByRole("region")).toHaveTextContent("Resumo dos despachos.");
|
|
15
|
+
expect(screen.getByRole("button", { name: "Conteúdo gerado por IA" })).toHaveAttribute(
|
|
16
|
+
"aria-expanded",
|
|
17
|
+
"true",
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("continua não-controlado: o clique fecha e avisa", async () => {
|
|
22
|
+
const usuario = userEvent.setup();
|
|
23
|
+
const onOpenChange = vi.fn();
|
|
24
|
+
render(
|
|
25
|
+
<AILabel explanation="Resumo." defaultOpen onOpenChange={onOpenChange} />,
|
|
26
|
+
);
|
|
27
|
+
await usuario.click(screen.getByRole("button", { name: "Conteúdo gerado por IA" }));
|
|
28
|
+
expect(screen.queryByRole("region")).not.toBeInTheDocument();
|
|
29
|
+
expect(onOpenChange).toHaveBeenCalledWith(false);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("sem defaultOpen nasce fechado", () => {
|
|
33
|
+
render(<AILabel explanation="Resumo." />);
|
|
34
|
+
expect(screen.queryByRole("region")).not.toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("`open` controlado vence o defaultOpen", () => {
|
|
38
|
+
render(<AILabel explanation="Resumo." defaultOpen open={false} />);
|
|
39
|
+
expect(screen.queryByRole("region")).not.toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import Accordion from "../components/Accordion/Accordion";
|
|
4
|
+
|
|
5
|
+
describe("Accordion · conteúdo livre por item (React)", () => {
|
|
6
|
+
it("o content do item aceita qualquer nó (campos, botões)", () => {
|
|
7
|
+
render(
|
|
8
|
+
<Accordion
|
|
9
|
+
items={[
|
|
10
|
+
{
|
|
11
|
+
id: "s1",
|
|
12
|
+
title: "Seção 01",
|
|
13
|
+
defaultOpen: true,
|
|
14
|
+
content: (
|
|
15
|
+
<label>
|
|
16
|
+
Nome <input defaultValue="Maria" />
|
|
17
|
+
</label>
|
|
18
|
+
),
|
|
19
|
+
},
|
|
20
|
+
{ id: "s2", title: "Seção 02", content: <button type="button">Anexar arquivo</button> },
|
|
21
|
+
]}
|
|
22
|
+
/>,
|
|
23
|
+
);
|
|
24
|
+
expect(screen.getByDisplayValue("Maria")).toBeInTheDocument();
|
|
25
|
+
expect(screen.getByRole("button", { name: "Anexar arquivo", hidden: true })).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("o título do item é o botão do painel, sem cor própria (herda a neutra do gatilho)", () => {
|
|
29
|
+
const { container } = render(<Accordion items={[{ id: "a", title: "Seção", content: "x" }]} />);
|
|
30
|
+
const titulo = container.querySelector(".umds-accordion__title") as HTMLElement;
|
|
31
|
+
expect(titulo.closest("button")).toHaveClass("umds-accordion__trigger");
|
|
32
|
+
expect(titulo.getAttribute("style")).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("o texto simples continua funcionando", () => {
|
|
36
|
+
render(<Accordion items={[{ id: "a", title: "Seção", content: "Texto do painel", defaultOpen: true }]} />);
|
|
37
|
+
expect(screen.getByText("Texto do painel")).toBeInTheDocument();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import Alert from "../components/Alert/Alert";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* O Alert anunciava toda variante com `role="alert"`, que é assertivo: um
|
|
7
|
+
* aviso informativo ou de sucesso cortava o que o leitor de tela estava
|
|
8
|
+
* lendo. Só o erro (`negative`) pode interromper; o resto é `role="status"`.
|
|
9
|
+
*/
|
|
10
|
+
describe("Alert · anúncio ao leitor de tela", () => {
|
|
11
|
+
it("negative interrompe: role=alert e aria-live=assertive", () => {
|
|
12
|
+
render(<Alert variant="negative" title="Falhou" />);
|
|
13
|
+
const alerta = screen.getByRole("alert");
|
|
14
|
+
expect(alerta).toHaveAttribute("aria-live", "assertive");
|
|
15
|
+
expect(screen.queryByRole("status")).not.toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it.each(["positive", "info", "neutral"] as const)(
|
|
19
|
+
"%s é educado: role=status e aria-live=polite",
|
|
20
|
+
(variant) => {
|
|
21
|
+
render(<Alert variant={variant} title="Aviso" />);
|
|
22
|
+
const alerta = screen.getByRole("status");
|
|
23
|
+
expect(alerta).toHaveAttribute("aria-live", "polite");
|
|
24
|
+
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
it("sem variant cai no neutral, educado", () => {
|
|
29
|
+
render(<Alert title="Aviso" />);
|
|
30
|
+
expect(screen.getByRole("status")).toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import Text from "../components/Text/Text";
|
|
4
|
+
import Grid from "../components/Grid/Grid";
|
|
5
|
+
import Logo from "../components/Logo/Logo";
|
|
6
|
+
import Button from "../components/Button/Button";
|
|
7
|
+
import DataTable from "../components/DataTable/DataTable";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Paridade com o Vue: no Vue gerado, Text, Grid e Logo descartavam
|
|
11
|
+
* `title`, `style` e `aria-*`, o Button escrevia `autofocus="false"` e o
|
|
12
|
+
* DataTable a classe `--selected.value`. O React nunca teve o defeito; o teste
|
|
13
|
+
* garante que a correção do Vue não o introduza aqui (mesma fonte Mitosis).
|
|
14
|
+
*/
|
|
15
|
+
describe("atributos repassados ao elemento raiz", () => {
|
|
16
|
+
it("Text repassa title, style e aria-*", () => {
|
|
17
|
+
const { container } = render(
|
|
18
|
+
<Text title="Dica" style={{ marginTop: 4 }} aria-live="polite" data-x="1">
|
|
19
|
+
Olá
|
|
20
|
+
</Text>,
|
|
21
|
+
);
|
|
22
|
+
const el = container.firstElementChild as HTMLElement;
|
|
23
|
+
expect(el.getAttribute("title")).toBe("Dica");
|
|
24
|
+
expect(el.style.marginTop).toBe("4px");
|
|
25
|
+
expect(el.getAttribute("aria-live")).toBe("polite");
|
|
26
|
+
expect(el.getAttribute("data-x")).toBe("1");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("Grid repassa title, style e aria-*", () => {
|
|
30
|
+
const { container } = render(
|
|
31
|
+
<Grid container spacing="xxxs" title="Dica" style={{ marginTop: 4 }} aria-label="Área">
|
|
32
|
+
x
|
|
33
|
+
</Grid>,
|
|
34
|
+
);
|
|
35
|
+
const el = container.firstElementChild as HTMLElement;
|
|
36
|
+
expect(el.getAttribute("title")).toBe("Dica");
|
|
37
|
+
expect(el.style.marginTop).toBe("4px");
|
|
38
|
+
expect(el.getAttribute("aria-label")).toBe("Área");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("Logo repassa title, style e aria-*", () => {
|
|
42
|
+
const { container } = render(
|
|
43
|
+
<Logo title="Dica" style={{ width: 80 }} aria-hidden="true" />,
|
|
44
|
+
);
|
|
45
|
+
const el = container.firstElementChild as HTMLElement;
|
|
46
|
+
expect(el.getAttribute("title")).toBe("Dica");
|
|
47
|
+
expect(el.style.width).toBe("80px");
|
|
48
|
+
expect(el.getAttribute("aria-hidden")).toBe("true");
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("Button · autoFocus", () => {
|
|
53
|
+
it("não escreve autofocus quando falso ou ausente", () => {
|
|
54
|
+
const { container } = render(<Button>Salvar</Button>);
|
|
55
|
+
expect(container.querySelector("[autofocus]")).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("DataTable · linha selecionada", () => {
|
|
60
|
+
it("a classe --selected vai limpa, só na linha selecionada", () => {
|
|
61
|
+
const { container } = render(
|
|
62
|
+
<DataTable
|
|
63
|
+
columns={[{ key: "nome", label: "Nome" }]}
|
|
64
|
+
data={[{ nome: "Cris Lima" }, { nome: "Ana Paula" }]}
|
|
65
|
+
selectable
|
|
66
|
+
selectedRows={[0]}
|
|
67
|
+
/>,
|
|
68
|
+
);
|
|
69
|
+
const marcadas = container.querySelectorAll(".umds-datatable__row--selected");
|
|
70
|
+
expect(marcadas).toHaveLength(1);
|
|
71
|
+
expect(container.innerHTML).not.toContain(".value");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { beforeAll, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import AttachmentCard from "../components/AttachmentCard/AttachmentCard";
|
|
5
|
+
|
|
6
|
+
beforeAll(() => {
|
|
7
|
+
if (!(globalThis as any).ResizeObserver) {
|
|
8
|
+
(globalThis as any).ResizeObserver = class {
|
|
9
|
+
observe() {}
|
|
10
|
+
unobserve() {}
|
|
11
|
+
disconnect() {}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
function cartaoDeIA(extra: Record<string, any> = {}) {
|
|
17
|
+
const aoAplicar = vi.fn();
|
|
18
|
+
const ui = (
|
|
19
|
+
<AttachmentCard
|
|
20
|
+
fileName="protocolo.pdf"
|
|
21
|
+
documentType="Protocolo"
|
|
22
|
+
status="ai"
|
|
23
|
+
statusLabel="Recursos IA"
|
|
24
|
+
onOpen={() => {}}
|
|
25
|
+
panel={
|
|
26
|
+
<div>
|
|
27
|
+
<p>A IA sugere um assunto.</p>
|
|
28
|
+
<button type="button" onClick={aoAplicar}>
|
|
29
|
+
Aplicar sugestão
|
|
30
|
+
</button>
|
|
31
|
+
</div>
|
|
32
|
+
}
|
|
33
|
+
{...extra}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
return { aoAplicar, ...render(ui) };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe("AttachmentCard · status ai", () => {
|
|
40
|
+
it("escreve a classe do selo de IA e usa a varinha por padrão", () => {
|
|
41
|
+
const { container } = render(<AttachmentCard fileName="x.pdf" status="ai" statusLabel="Recursos IA" />);
|
|
42
|
+
const selo = container.querySelector(".umds-attachment-card__status") as HTMLElement;
|
|
43
|
+
expect(selo).toHaveClass("umds-attachment-card__status--ai");
|
|
44
|
+
expect(selo.querySelector("svg")).not.toBeNull();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("só o selo de IA ganha ícone por padrão", () => {
|
|
48
|
+
const { container } = render(
|
|
49
|
+
<AttachmentCard fileName="x.pdf" status="positive" statusLabel="Ok" />,
|
|
50
|
+
);
|
|
51
|
+
expect(container.querySelector(".umds-attachment-card__status svg")).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("AttachmentCard · slot panel", () => {
|
|
56
|
+
it("o painel livre substitui o resultado da conferência, e o selo vira botão sem statusDetails", async () => {
|
|
57
|
+
const usuario = userEvent.setup();
|
|
58
|
+
cartaoDeIA();
|
|
59
|
+
const selo = screen.getByRole("button", { name: /^Recursos IA/ });
|
|
60
|
+
expect(selo).toHaveAttribute("aria-haspopup", "dialog");
|
|
61
|
+
await usuario.click(selo);
|
|
62
|
+
const painel = await screen.findByRole("dialog");
|
|
63
|
+
expect(painel).toHaveTextContent("A IA sugere um assunto.");
|
|
64
|
+
expect(screen.getByRole("button", { name: "Aplicar sugestão" })).toBeInTheDocument();
|
|
65
|
+
// sem título interno: o painel é nomeado pelo selo
|
|
66
|
+
expect(painel).not.toHaveAttribute("aria-labelledby");
|
|
67
|
+
expect(painel).toHaveAccessibleName(/Recursos IA/);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("sem panel nem statusDetails o selo não é botão", () => {
|
|
71
|
+
render(<AttachmentCard fileName="x.pdf" status="ai" statusLabel="Recursos IA" />);
|
|
72
|
+
expect(screen.queryByRole("button")).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("panelWidth escreve a largura do painel; sem ela não há style", async () => {
|
|
76
|
+
const usuario = userEvent.setup();
|
|
77
|
+
cartaoDeIA({ panelWidth: 280 });
|
|
78
|
+
await usuario.click(screen.getByRole("button", { name: /^Recursos IA/ }));
|
|
79
|
+
expect((await screen.findByRole("dialog")).style.width).toBe("280px");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("sem panelWidth o painel não leva style", async () => {
|
|
83
|
+
const usuario = userEvent.setup();
|
|
84
|
+
cartaoDeIA();
|
|
85
|
+
await usuario.click(screen.getByRole("button", { name: /^Recursos IA/ }));
|
|
86
|
+
expect((await screen.findByRole("dialog")).getAttribute("style")).toBeNull();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("AttachmentCard · closePanelOnAction", () => {
|
|
91
|
+
it("acionar um botão do painel fecha, devolve o foco ao selo e a ação chega ao app", async () => {
|
|
92
|
+
const usuario = userEvent.setup();
|
|
93
|
+
const { aoAplicar } = cartaoDeIA({ closePanelOnAction: true });
|
|
94
|
+
const selo = screen.getByRole("button", { name: /^Recursos IA/ });
|
|
95
|
+
await usuario.click(selo);
|
|
96
|
+
await usuario.click(await screen.findByRole("button", { name: "Aplicar sugestão" }));
|
|
97
|
+
expect(aoAplicar).toHaveBeenCalledTimes(1);
|
|
98
|
+
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
|
|
99
|
+
expect(selo).toHaveFocus();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("sem a prop o painel continua aberto depois da ação", async () => {
|
|
103
|
+
const usuario = userEvent.setup();
|
|
104
|
+
const { aoAplicar } = cartaoDeIA();
|
|
105
|
+
await usuario.click(screen.getByRole("button", { name: /^Recursos IA/ }));
|
|
106
|
+
await usuario.click(await screen.findByRole("button", { name: "Aplicar sugestão" }));
|
|
107
|
+
expect(aoAplicar).toHaveBeenCalledTimes(1);
|
|
108
|
+
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("o botão de copiar um campo não fecha o painel", async () => {
|
|
112
|
+
const usuario = userEvent.setup();
|
|
113
|
+
render(
|
|
114
|
+
<AttachmentCard
|
|
115
|
+
fileName="cpf.pdf"
|
|
116
|
+
status="positive"
|
|
117
|
+
statusLabel="Pré-aprovado"
|
|
118
|
+
closePanelOnAction
|
|
119
|
+
statusDetails={{ fields: [{ label: "CPF", value: "384.221.760-05", copyable: true }] }}
|
|
120
|
+
/>,
|
|
121
|
+
);
|
|
122
|
+
await usuario.click(screen.getByRole("button", { name: /^Pré-aprovado/ }));
|
|
123
|
+
await usuario.click(await screen.findByRole("button", { name: "Copiar CPF" }));
|
|
124
|
+
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import AvatarGroup from "../components/Avatar/AvatarGroup";
|
|
4
|
+
|
|
5
|
+
const PESSOAS = [
|
|
6
|
+
{ name: "Ana Souza" },
|
|
7
|
+
{ name: "Bruno Lima" },
|
|
8
|
+
{ name: "Carla Dias" },
|
|
9
|
+
{ name: "Diego Ferraz" },
|
|
10
|
+
{ name: "Eduarda Neves" },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const grupo = (c: HTMLElement) => c.firstElementChild as HTMLElement;
|
|
14
|
+
|
|
15
|
+
describe("AvatarGroup · overflowCount", () => {
|
|
16
|
+
it("sem a prop, o +N é o que passou de max (como antes)", () => {
|
|
17
|
+
render(<AvatarGroup avatars={PESSOAS} max={3} />);
|
|
18
|
+
expect(screen.getByText("+2")).toBeInTheDocument();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("overflowCount vira o +N sem itens-fantasma", () => {
|
|
22
|
+
render(<AvatarGroup avatars={PESSOAS.slice(0, 3)} max={3} overflowCount={12} />);
|
|
23
|
+
expect(screen.getByText("+12")).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("soma com o que passou de max dentro de avatars", () => {
|
|
27
|
+
render(<AvatarGroup avatars={PESSOAS} max={3} overflowCount={10} />);
|
|
28
|
+
expect(screen.getByText("+12")).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("o rótulo traduzido recebe o total escondido", () => {
|
|
32
|
+
render(
|
|
33
|
+
<AvatarGroup
|
|
34
|
+
avatars={PESSOAS.slice(0, 2)}
|
|
35
|
+
max={2}
|
|
36
|
+
overflowCount={7}
|
|
37
|
+
overflowTitle={(n) => n + " others"}
|
|
38
|
+
overflowAriaLabel={(n) => n + " more avatars"}
|
|
39
|
+
/>,
|
|
40
|
+
);
|
|
41
|
+
expect(screen.getByTitle("7 others")).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("sem excedente nenhum, não há +N", () => {
|
|
45
|
+
render(<AvatarGroup avatars={PESSOAS.slice(0, 2)} max={4} />);
|
|
46
|
+
expect(screen.queryByText(/^\+/)).toBeNull();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("overflowCount 0 não cria +0", () => {
|
|
50
|
+
render(<AvatarGroup avatars={PESSOAS.slice(0, 2)} max={4} overflowCount={0} />);
|
|
51
|
+
expect(screen.queryByText(/^\+/)).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("AvatarGroup · overlap e ring", () => {
|
|
56
|
+
it("escrevem as variáveis do grupo em px", () => {
|
|
57
|
+
const { container } = render(<AvatarGroup avatars={PESSOAS} overlap={6} ring={1} />);
|
|
58
|
+
const el = grupo(container);
|
|
59
|
+
expect(el.style.getPropertyValue("--umds-avatar-group-overlap")).toBe("6px");
|
|
60
|
+
expect(el.style.getPropertyValue("--umds-avatar-group-ring")).toBe("1px");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("só overlap não mexe no anel", () => {
|
|
64
|
+
const { container } = render(<AvatarGroup avatars={PESSOAS} overlap={4} />);
|
|
65
|
+
const el = grupo(container);
|
|
66
|
+
expect(el.style.getPropertyValue("--umds-avatar-group-overlap")).toBe("4px");
|
|
67
|
+
expect(el.style.getPropertyValue("--umds-avatar-group-ring")).toBe("");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("sem as props, nenhum style: valem os padrões do CSS", () => {
|
|
71
|
+
const { container } = render(<AvatarGroup avatars={PESSOAS} />);
|
|
72
|
+
expect(grupo(container).getAttribute("style")).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import Badge from "../components/Badge/Badge";
|
|
4
|
+
import Tag from "../components/Tag/Tag";
|
|
5
|
+
|
|
6
|
+
const raiz = (c: HTMLElement) => c.firstElementChild as HTMLElement;
|
|
7
|
+
|
|
8
|
+
describe("Badge compacto, novidade e colado", () => {
|
|
9
|
+
it("size 2xs escreve a classe; sem size continua md", () => {
|
|
10
|
+
const { container } = render(
|
|
11
|
+
<>
|
|
12
|
+
<Badge size="2xs">A</Badge>
|
|
13
|
+
<Badge>B</Badge>
|
|
14
|
+
</>,
|
|
15
|
+
);
|
|
16
|
+
expect(container.children[0]).toHaveClass("umds-badge--2xs");
|
|
17
|
+
expect(container.children[1]).toHaveClass("umds-badge--md");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("variant new escreve a classe da variante", () => {
|
|
21
|
+
const { container } = render(<Badge variant="new">Novidade</Badge>);
|
|
22
|
+
expect(raiz(container)).toHaveClass("umds-badge--new");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("attached escreve o modificador; sem ele não há", () => {
|
|
26
|
+
const { container } = render(
|
|
27
|
+
<>
|
|
28
|
+
<Badge attached>A</Badge>
|
|
29
|
+
<Badge>B</Badge>
|
|
30
|
+
</>,
|
|
31
|
+
);
|
|
32
|
+
expect(container.children[0]).toHaveClass("umds-badge--attached");
|
|
33
|
+
expect(container.children[1]).not.toHaveClass("umds-badge--attached");
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("Tag compacta, soft, pílula e novidade", () => {
|
|
38
|
+
it("size xs escreve a classe e sm continua", () => {
|
|
39
|
+
const { container } = render(
|
|
40
|
+
<>
|
|
41
|
+
<Tag label="a" size="xs" />
|
|
42
|
+
<Tag label="b" size="sm" />
|
|
43
|
+
</>,
|
|
44
|
+
);
|
|
45
|
+
expect(container.children[0]).toHaveClass("umds-tag--xs");
|
|
46
|
+
expect(container.children[1]).toHaveClass("umds-tag--sm");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("appearance soft e pill escrevem as classes", () => {
|
|
50
|
+
const { container } = render(<Tag label="SOBR" appearance="soft" variant="primary" pill />);
|
|
51
|
+
expect(raiz(container)).toHaveClass("umds-tag--soft", "umds-tag--primary", "umds-tag--pill");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("sem pill não há a classe; padrão segue outlined", () => {
|
|
55
|
+
const { container } = render(<Tag label="x" />);
|
|
56
|
+
expect(raiz(container)).toHaveClass("umds-tag--outlined");
|
|
57
|
+
expect(raiz(container)).not.toHaveClass("umds-tag--pill");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("variant new escreve a classe", () => {
|
|
61
|
+
const { container } = render(<Tag label="Dado simulado" variant="new" appearance="soft" />);
|
|
62
|
+
expect(raiz(container)).toHaveClass("umds-tag--new", "umds-tag--soft");
|
|
63
|
+
});
|
|
64
|
+
});
|