@fragments-sdk/ui 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/fragments.json +1 -1
  2. package/package.json +13 -2
  3. package/src/components/Accordion/Accordion.test.tsx +171 -0
  4. package/src/components/Alert/Alert.test.tsx +127 -0
  5. package/src/components/AppShell/AppShell.module.scss +5 -5
  6. package/src/components/AppShell/AppShell.test.tsx +80 -0
  7. package/src/components/Avatar/Avatar.test.tsx +40 -0
  8. package/src/components/Avatar/index.tsx +11 -1
  9. package/src/components/Badge/Badge.test.tsx +58 -0
  10. package/src/components/Box/Box.test.tsx +43 -0
  11. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +75 -0
  12. package/src/components/Button/Button.module.scss +3 -3
  13. package/src/components/Button/Button.test.tsx +53 -0
  14. package/src/components/ButtonGroup/ButtonGroup.test.tsx +44 -0
  15. package/src/components/Card/Card.test.tsx +71 -0
  16. package/src/components/Chart/Chart.module.scss +5 -0
  17. package/src/components/Chart/Chart.test.tsx +123 -0
  18. package/src/components/Chart/index.tsx +34 -0
  19. package/src/components/Checkbox/Checkbox.test.tsx +63 -0
  20. package/src/components/Checkbox/index.tsx +29 -4
  21. package/src/components/Chip/Chip.module.scss +73 -7
  22. package/src/components/Chip/Chip.test.tsx +50 -0
  23. package/src/components/Chip/index.tsx +36 -26
  24. package/src/components/CodeBlock/CodeBlock.module.scss +6 -6
  25. package/src/components/CodeBlock/CodeBlock.test.tsx +78 -0
  26. package/src/components/CodeBlock/index.tsx +4 -1
  27. package/src/components/Collapsible/Collapsible.test.tsx +103 -0
  28. package/src/components/ColorPicker/ColorPicker.test.tsx +55 -0
  29. package/src/components/ColorPicker/index.tsx +4 -1
  30. package/src/components/Combobox/Combobox.test.tsx +202 -0
  31. package/src/components/ConversationList/ConversationList.module.scss +4 -4
  32. package/src/components/ConversationList/ConversationList.test.tsx +79 -0
  33. package/src/components/Dialog/Dialog.test.tsx +277 -0
  34. package/src/components/Dialog/index.tsx +14 -6
  35. package/src/components/EmptyState/EmptyState.module.scss +3 -3
  36. package/src/components/EmptyState/EmptyState.test.tsx +67 -0
  37. package/src/components/Field/Field.test.tsx +65 -0
  38. package/src/components/Fieldset/Fieldset.test.tsx +48 -0
  39. package/src/components/Form/Form.test.tsx +41 -0
  40. package/src/components/Grid/Grid.module.scss +3 -3
  41. package/src/components/Grid/Grid.test.tsx +65 -0
  42. package/src/components/Header/Header.module.scss +4 -4
  43. package/src/components/Header/Header.test.tsx +83 -0
  44. package/src/components/Icon/Icon.test.tsx +38 -0
  45. package/src/components/Image/Image.test.tsx +39 -0
  46. package/src/components/Input/Input.test.tsx +72 -0
  47. package/src/components/Input/index.tsx +15 -1
  48. package/src/components/Link/Link.test.tsx +37 -0
  49. package/src/components/List/List.test.tsx +57 -0
  50. package/src/components/Listbox/Listbox.module.scss +16 -5
  51. package/src/components/Listbox/Listbox.test.tsx +100 -0
  52. package/src/components/Listbox/index.tsx +186 -13
  53. package/src/components/Loading/Loading.test.tsx +38 -0
  54. package/src/components/Markdown/Markdown.module.scss +3 -3
  55. package/src/components/Markdown/Markdown.test.tsx +41 -0
  56. package/src/components/Menu/Menu.module.scss +3 -3
  57. package/src/components/Menu/Menu.test.tsx +336 -0
  58. package/src/components/Message/Message.module.scss +9 -3
  59. package/src/components/Message/Message.test.tsx +75 -0
  60. package/src/components/Popover/Popover.test.tsx +105 -0
  61. package/src/components/Popover/index.tsx +4 -1
  62. package/src/components/Progress/Progress.test.tsx +58 -0
  63. package/src/components/Prompt/Prompt.module.scss +6 -5
  64. package/src/components/Prompt/Prompt.test.tsx +89 -0
  65. package/src/components/RadioGroup/RadioGroup.test.tsx +105 -0
  66. package/src/components/RadioGroup/index.tsx +37 -4
  67. package/src/components/Select/Select.test.tsx +161 -0
  68. package/src/components/Select/index.tsx +3 -2
  69. package/src/components/Separator/Separator.test.tsx +33 -0
  70. package/src/components/Sidebar/Sidebar.module.scss +32 -22
  71. package/src/components/Sidebar/Sidebar.test.tsx +85 -0
  72. package/src/components/Sidebar/index.tsx +31 -9
  73. package/src/components/Skeleton/Skeleton.test.tsx +56 -0
  74. package/src/components/Slider/Slider.test.tsx +51 -0
  75. package/src/components/Slider/index.tsx +13 -3
  76. package/src/components/Stack/Stack.test.tsx +47 -0
  77. package/src/components/Table/Table.module.scss +20 -11
  78. package/src/components/Table/Table.test.tsx +129 -0
  79. package/src/components/Table/index.tsx +52 -30
  80. package/src/components/Tabs/Tabs.test.tsx +180 -0
  81. package/src/components/Text/Text.test.tsx +40 -0
  82. package/src/components/Textarea/Textarea.test.tsx +57 -0
  83. package/src/components/Textarea/index.tsx +22 -2
  84. package/src/components/Theme/Theme.test.tsx +114 -0
  85. package/src/components/ThinkingIndicator/ThinkingIndicator.test.tsx +54 -0
  86. package/src/components/Toast/Toast.test.tsx +192 -0
  87. package/src/components/Toast/index.tsx +124 -20
  88. package/src/components/Toggle/Toggle.test.tsx +49 -0
  89. package/src/components/ToggleGroup/ToggleGroup.fragment.tsx +96 -78
  90. package/src/components/ToggleGroup/ToggleGroup.test.tsx +90 -0
  91. package/src/components/ToggleGroup/index.tsx +70 -1
  92. package/src/components/Tooltip/Tooltip.module.scss +1 -1
  93. package/src/components/Tooltip/Tooltip.test.tsx +107 -0
  94. package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +31 -0
  95. package/src/test/setup.ts +74 -0
  96. package/src/test/utils.tsx +71 -0
  97. package/src/tokens/_computed.scss +2 -0
  98. package/src/tokens/_density.scss +4 -0
  99. package/src/tokens/_derive.scss +16 -16
  100. package/src/tokens/_variables.scss +8 -2
  101. package/src/utils/a11y.test.tsx +79 -0
@@ -0,0 +1,79 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { render, screen, expectNoA11yViolations } from '../test/utils';
3
+ import { handleArrowNavigation, VisuallyHidden } from './a11y';
4
+
5
+ describe('handleArrowNavigation', () => {
6
+ const items = ['a', 'b', 'c'];
7
+
8
+ function makeEvent(key: string): React.KeyboardEvent {
9
+ return { key, preventDefault: () => {} } as unknown as React.KeyboardEvent;
10
+ }
11
+
12
+ it('moves down with ArrowDown in vertical orientation', () => {
13
+ expect(handleArrowNavigation(makeEvent('ArrowDown'), items, 0, { orientation: 'vertical' })).toBe(1);
14
+ });
15
+
16
+ it('moves up with ArrowUp in vertical orientation', () => {
17
+ expect(handleArrowNavigation(makeEvent('ArrowUp'), items, 1, { orientation: 'vertical' })).toBe(0);
18
+ });
19
+
20
+ it('ignores ArrowDown in horizontal orientation', () => {
21
+ expect(handleArrowNavigation(makeEvent('ArrowDown'), items, 0, { orientation: 'horizontal' })).toBeUndefined();
22
+ });
23
+
24
+ it('moves right with ArrowRight in horizontal orientation', () => {
25
+ expect(handleArrowNavigation(makeEvent('ArrowRight'), items, 0, { orientation: 'horizontal' })).toBe(1);
26
+ });
27
+
28
+ it('loops from last to first when loop is enabled', () => {
29
+ expect(handleArrowNavigation(makeEvent('ArrowDown'), items, 2, { orientation: 'vertical', loop: true })).toBe(0);
30
+ });
31
+
32
+ it('clamps at boundary when loop is disabled', () => {
33
+ expect(handleArrowNavigation(makeEvent('ArrowDown'), items, 2, { orientation: 'vertical', loop: false })).toBe(2);
34
+ });
35
+
36
+ it('navigates to first item on Home', () => {
37
+ expect(handleArrowNavigation(makeEvent('Home'), items, 2)).toBe(0);
38
+ });
39
+
40
+ it('navigates to last item on End', () => {
41
+ expect(handleArrowNavigation(makeEvent('End'), items, 0)).toBe(2);
42
+ });
43
+
44
+ it('handles both orientation (vertical + horizontal keys)', () => {
45
+ expect(handleArrowNavigation(makeEvent('ArrowDown'), items, 0, { orientation: 'both' })).toBe(1);
46
+ expect(handleArrowNavigation(makeEvent('ArrowRight'), items, 0, { orientation: 'both' })).toBe(1);
47
+ });
48
+
49
+ it('returns undefined for unrelated keys', () => {
50
+ expect(handleArrowNavigation(makeEvent('Enter'), items, 0)).toBeUndefined();
51
+ });
52
+ });
53
+
54
+ describe('VisuallyHidden (utils)', () => {
55
+ it('hides content visually with inline styles', () => {
56
+ render(<VisuallyHidden>SR only</VisuallyHidden>);
57
+ const el = screen.getByText('SR only');
58
+ expect(el.style.position).toBe('absolute');
59
+ expect(el.style.width).toBe('1px');
60
+ expect(el.style.height).toBe('1px');
61
+ expect(el.style.overflow).toBe('hidden');
62
+ });
63
+
64
+ it('does not apply hidden styles when focusable', () => {
65
+ render(<VisuallyHidden focusable>Skip link</VisuallyHidden>);
66
+ const el = screen.getByText('Skip link');
67
+ expect(el.style.position).not.toBe('absolute');
68
+ });
69
+
70
+ it('sets data-visually-hidden attribute when not focusable', () => {
71
+ render(<VisuallyHidden>Hidden</VisuallyHidden>);
72
+ expect(screen.getByText('Hidden')).toHaveAttribute('data-visually-hidden', 'true');
73
+ });
74
+
75
+ it('has no accessibility violations', async () => {
76
+ const { container } = render(<VisuallyHidden>Accessible</VisuallyHidden>);
77
+ await expectNoA11yViolations(container);
78
+ });
79
+ });