@dxc-technology/halstack-react 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/HalstackContext.d.ts +4 -2
  2. package/HalstackContext.js +110 -58
  3. package/accordion/Accordion.stories.tsx +1 -1
  4. package/accordion-group/AccordionGroup.js +1 -0
  5. package/alert/Alert.js +4 -1
  6. package/badge/Badge.d.ts +1 -1
  7. package/badge/Badge.js +5 -3
  8. package/badge/types.d.ts +1 -0
  9. package/bleed/Bleed.js +1 -34
  10. package/bleed/Bleed.stories.tsx +94 -95
  11. package/bleed/types.d.ts +1 -1
  12. package/box/Box.js +22 -32
  13. package/bulleted-list/BulletedList.d.ts +7 -0
  14. package/bulleted-list/BulletedList.js +123 -0
  15. package/bulleted-list/BulletedList.stories.tsx +200 -0
  16. package/bulleted-list/types.d.ts +11 -0
  17. package/{list → bulleted-list}/types.js +0 -0
  18. package/button/Button.js +3 -1
  19. package/card/Card.js +34 -36
  20. package/checkbox/Checkbox.js +4 -1
  21. package/common/variables.js +211 -88
  22. package/date-input/DateInput.js +5 -2
  23. package/dropdown/Dropdown.stories.tsx +1 -1
  24. package/file-input/FileInput.js +9 -6
  25. package/file-input/FileItem.js +7 -5
  26. package/flex/Flex.d.ts +4 -0
  27. package/flex/Flex.js +57 -0
  28. package/flex/Flex.stories.tsx +103 -0
  29. package/flex/types.d.ts +21 -0
  30. package/{radio → flex}/types.js +0 -0
  31. package/footer/Footer.js +7 -5
  32. package/footer/Icons.js +1 -1
  33. package/header/Header.js +7 -4
  34. package/inset/Inset.js +1 -34
  35. package/inset/Inset.stories.tsx +36 -36
  36. package/inset/types.d.ts +1 -1
  37. package/layout/ApplicationLayout.d.ts +16 -6
  38. package/layout/ApplicationLayout.js +70 -117
  39. package/layout/ApplicationLayout.stories.tsx +83 -93
  40. package/layout/Icons.d.ts +5 -0
  41. package/layout/Icons.js +13 -2
  42. package/layout/SidenavContext.d.ts +5 -0
  43. package/layout/SidenavContext.js +19 -0
  44. package/layout/types.d.ts +18 -33
  45. package/link/Link.d.ts +3 -2
  46. package/link/Link.js +57 -70
  47. package/link/Link.stories.tsx +88 -53
  48. package/link/Link.test.js +7 -15
  49. package/link/types.d.ts +7 -23
  50. package/main.d.ts +7 -10
  51. package/main.js +38 -56
  52. package/number-input/types.d.ts +1 -1
  53. package/package.json +3 -1
  54. package/paginator/Paginator.js +17 -38
  55. package/paginator/Paginator.test.js +42 -0
  56. package/paragraph/Paragraph.d.ts +6 -0
  57. package/paragraph/Paragraph.js +38 -0
  58. package/paragraph/Paragraph.stories.tsx +44 -0
  59. package/password-input/PasswordInput.js +7 -4
  60. package/password-input/PasswordInput.test.js +1 -2
  61. package/password-input/types.d.ts +1 -1
  62. package/progress-bar/ProgressBar.js +1 -1
  63. package/progress-bar/ProgressBar.stories.jsx +11 -11
  64. package/quick-nav/QuickNav.js +74 -20
  65. package/quick-nav/QuickNav.stories.tsx +43 -16
  66. package/quick-nav/types.d.ts +4 -4
  67. package/radio-group/Radio.js +1 -1
  68. package/radio-group/RadioGroup.js +10 -7
  69. package/resultsetTable/ResultsetTable.test.js +42 -0
  70. package/select/Listbox.d.ts +1 -1
  71. package/select/Listbox.js +35 -8
  72. package/select/Select.js +83 -78
  73. package/select/Select.stories.tsx +144 -100
  74. package/select/Select.test.js +299 -194
  75. package/select/types.d.ts +3 -4
  76. package/sidenav/Sidenav.d.ts +6 -5
  77. package/sidenav/Sidenav.js +172 -52
  78. package/sidenav/Sidenav.stories.tsx +154 -156
  79. package/sidenav/Sidenav.test.js +25 -37
  80. package/sidenav/types.d.ts +50 -27
  81. package/spinner/Spinner.js +1 -1
  82. package/switch/Switch.js +4 -1
  83. package/tabs/Tabs.stories.tsx +0 -6
  84. package/tabs-nav/NavTabs.d.ts +8 -0
  85. package/tabs-nav/NavTabs.js +125 -0
  86. package/tabs-nav/NavTabs.stories.tsx +170 -0
  87. package/tabs-nav/NavTabs.test.js +82 -0
  88. package/tabs-nav/Tab.d.ts +4 -0
  89. package/tabs-nav/Tab.js +132 -0
  90. package/tabs-nav/types.d.ts +53 -0
  91. package/{row → tabs-nav}/types.js +0 -0
  92. package/text-input/Suggestion.d.ts +4 -0
  93. package/text-input/Suggestion.js +55 -0
  94. package/text-input/TextInput.js +46 -72
  95. package/text-input/TextInput.test.js +1 -1
  96. package/text-input/types.d.ts +14 -2
  97. package/textarea/Textarea.js +10 -19
  98. package/textarea/types.d.ts +1 -1
  99. package/typography/Typography.d.ts +4 -0
  100. package/typography/Typography.js +131 -0
  101. package/typography/Typography.stories.tsx +198 -0
  102. package/typography/types.d.ts +18 -0
  103. package/{stack → typography}/types.js +0 -0
  104. package/useTranslatedLabels.d.ts +2 -0
  105. package/useTranslatedLabels.js +20 -0
  106. package/wizard/Wizard.js +36 -41
  107. package/wizard/Wizard.stories.tsx +20 -1
  108. package/wizard/types.d.ts +4 -3
  109. package/list/List.d.ts +0 -4
  110. package/list/List.js +0 -47
  111. package/list/List.stories.tsx +0 -95
  112. package/list/types.d.ts +0 -7
  113. package/radio/Radio.d.ts +0 -4
  114. package/radio/Radio.js +0 -173
  115. package/radio/Radio.stories.tsx +0 -192
  116. package/radio/Radio.test.js +0 -71
  117. package/radio/types.d.ts +0 -54
  118. package/row/Row.d.ts +0 -3
  119. package/row/Row.js +0 -127
  120. package/row/Row.stories.tsx +0 -237
  121. package/row/types.d.ts +0 -28
  122. package/stack/Stack.d.ts +0 -3
  123. package/stack/Stack.js +0 -97
  124. package/stack/Stack.stories.tsx +0 -164
  125. package/stack/types.d.ts +0 -24
  126. package/text/Text.d.ts +0 -7
  127. package/text/Text.js +0 -30
  128. package/text/Text.stories.tsx +0 -19
@@ -1,182 +1,180 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
2
  import DxcSidenav from "./Sidenav";
4
3
  import Title from "../../.storybook/components/Title";
5
4
  import ExampleContainer from "../../.storybook/components/ExampleContainer";
5
+ import { userEvent, within } from "@storybook/testing-library";
6
6
 
7
7
  export default {
8
8
  title: "Sidenav",
9
9
  component: DxcSidenav,
10
10
  };
11
11
 
12
- const linkClick = () => {
13
- console.log("click");
14
- };
12
+ const iconSVG = (
13
+ <svg viewBox="0 0 24 24" fill="currentColor">
14
+ <path d="M0 0h24v24H0z" fill="none" />
15
+ <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
16
+ </svg>
17
+ );
15
18
 
16
- const StyledContainer = styled["div"]`
17
- display: flex;
18
- flex-direction: row;
19
- height: 500px;
20
- `;
19
+ const TitleComponent = () => {
20
+ return <DxcSidenav.Title>Dxc technology</DxcSidenav.Title>;
21
+ };
21
22
 
22
23
  export const Chromatic = () => (
23
24
  <>
24
25
  <ExampleContainer>
25
- <Title title="Deafult sidenav" theme="light" level={4} />
26
- <DxcSidenav>
27
- {" "}
28
- <p>Lorem ipsum</p>
29
- <p>Lorem ipsum</p>
30
- <p>Lorem ipsum</p>
31
- <p>Lorem ipsum</p>
32
- <p>Lorem ipsum</p>{" "}
33
- </DxcSidenav>
34
- </ExampleContainer>
35
-
36
- <ExampleContainer>
37
- <Title title="Sidenav with xxsmall padding" theme="light" level={4} />
38
- <DxcSidenav padding="xxsmall">
39
- {" "}
40
- <p>Lorem ipsum</p>
41
- <p>Lorem ipsum</p>
42
- <p>Lorem ipsum</p>
43
- <p>Lorem ipsum</p>
44
- <p>Lorem ipsum</p>{" "}
45
- </DxcSidenav>
46
- </ExampleContainer>
47
-
48
- <ExampleContainer>
49
- <Title title="Sidenav with xsmall padding" theme="light" level={4} />
50
- <DxcSidenav padding="xsmall">
51
- {" "}
52
- <p>Lorem ipsum</p>
53
- <p>Lorem ipsum</p>
54
- <p>Lorem ipsum</p>
55
- <p>Lorem ipsum</p>
56
- <p>Lorem ipsum</p>{" "}
57
- </DxcSidenav>
58
- </ExampleContainer>
59
-
60
- <ExampleContainer>
61
- <Title title="Sidenav with small padding" theme="light" level={4} />
62
- <DxcSidenav padding="small">
63
- {" "}
64
- <p>Lorem ipsum</p>
65
- <p>Lorem ipsum</p>
66
- <p>Lorem ipsum</p>
67
- <p>Lorem ipsum</p>
68
- <p>Lorem ipsum</p>{" "}
69
- </DxcSidenav>
70
- </ExampleContainer>
71
-
72
- <ExampleContainer>
73
- <Title title="Sidenav with medium padding" theme="light" level={4} />
74
- <DxcSidenav padding="medium">
75
- {" "}
76
- <p>Lorem ipsum</p>
77
- <p>Lorem ipsum</p>
78
- <p>Lorem ipsum</p>
79
- <p>Lorem ipsum</p>
80
- <p>Lorem ipsum</p>{" "}
26
+ <Title title="Default sidenav" theme="light" level={4} />
27
+ <DxcSidenav title={<TitleComponent />}>
28
+ <DxcSidenav.Section>
29
+ <p>
30
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ullamcorper consectetur mollis. Suspendisse
31
+ vitae lacinia libero.
32
+ </p>
33
+ </DxcSidenav.Section>
34
+ <DxcSidenav.Section>
35
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
36
+ <DxcSidenav.Group collapsable={false} title="Single Group" icon={iconSVG}>
37
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
38
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
39
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
40
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
41
+ </DxcSidenav.Group>
42
+ </DxcSidenav.Section>
43
+ <DxcSidenav.Section>
44
+ <DxcSidenav.Group collapsable={true} title="Section Group" icon={iconSVG}>
45
+ <DxcSidenav.Link selected>Group Link</DxcSidenav.Link>
46
+ <DxcSidenav.Link icon={iconSVG}>Group Link</DxcSidenav.Link>
47
+ </DxcSidenav.Group>
48
+ <DxcSidenav.Link icon={iconSVG}>Single Link</DxcSidenav.Link>
49
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
50
+ <DxcSidenav.Group collapsable={false} title="Section Group">
51
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
52
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
53
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
54
+ </DxcSidenav.Group>
55
+ </DxcSidenav.Section>
81
56
  </DxcSidenav>
82
57
  </ExampleContainer>
58
+ </>
59
+ );
83
60
 
84
- <ExampleContainer>
85
- <Title title="Sidenav with large padding" theme="light" level={4} />
86
- <DxcSidenav padding="large">
87
- {" "}
88
- <p>Lorem ipsum</p>
89
- <p>Lorem ipsum</p>
90
- <p>Lorem ipsum</p>
91
- <p>Lorem ipsum</p>
92
- <p>Lorem ipsum</p>{" "}
93
- </DxcSidenav>
94
- </ExampleContainer>
61
+ export const FocusedSidenav = () => (
62
+ <ExampleContainer pseudoState="pseudo-focus">
63
+ <Title title="Default sidenav" theme="light" level={4} />
64
+ <DxcSidenav title={<TitleComponent />}>
65
+ <DxcSidenav.Section>
66
+ <p>
67
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ullamcorper consectetur mollis. Suspendisse vitae
68
+ lacinia libero.
69
+ </p>
70
+ </DxcSidenav.Section>
71
+ <DxcSidenav.Section>
72
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
73
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
74
+ <DxcSidenav.Group collapsable={true} title="Collapsable Group">
75
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
76
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
77
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
78
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
79
+ </DxcSidenav.Group>
80
+ </DxcSidenav.Section>
81
+ <DxcSidenav.Section>
82
+ <DxcSidenav.Group collapsable={true} title="Collapsable Group">
83
+ <DxcSidenav.Link selected>Group Link</DxcSidenav.Link>
84
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
85
+ </DxcSidenav.Group>
86
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
87
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
88
+ <DxcSidenav.Group collapsable={false} title="Section Group">
89
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
90
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
91
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
92
+ </DxcSidenav.Group>
93
+ </DxcSidenav.Section>
94
+ </DxcSidenav>
95
+ </ExampleContainer>
96
+ );
95
97
 
98
+ const CollapsedGroup = () => (
99
+ <>
96
100
  <ExampleContainer>
97
- <Title title="Sidenav with xlarge padding" theme="light" level={4} />
98
- <DxcSidenav padding="xlarge">
99
- {" "}
100
- <p>Lorem ipsum</p>
101
- <p>Lorem ipsum</p>
102
- <p>Lorem ipsum</p>
103
- <p>Lorem ipsum</p>
104
- <p>Lorem ipsum</p>{" "}
101
+ <Title title="Default sidenav" theme="light" level={4} />
102
+ <DxcSidenav title={<TitleComponent />}>
103
+ <DxcSidenav.Section>
104
+ <DxcSidenav.Group collapsable={true} title="Collapsable Group" icon={iconSVG}>
105
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
106
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
107
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
108
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
109
+ </DxcSidenav.Group>
110
+ </DxcSidenav.Section>
111
+ <DxcSidenav.Section>
112
+ <DxcSidenav.Group collapsable={true} title="Collapsable Group">
113
+ <DxcSidenav.Link selected>Group Link</DxcSidenav.Link>
114
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
115
+ </DxcSidenav.Group>
116
+ <DxcSidenav.Group collapsable={false} title="Section Group">
117
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
118
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
119
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
120
+ </DxcSidenav.Group>
121
+ </DxcSidenav.Section>
105
122
  </DxcSidenav>
106
123
  </ExampleContainer>
124
+ </>
125
+ );
107
126
 
108
- <ExampleContainer>
109
- <Title title="Sidenav with xxlarge padding" theme="light" level={4} />
110
- <DxcSidenav padding="xxlarge">
111
- {" "}
112
- <p>Lorem ipsum</p>
113
- <p>Lorem ipsum</p>
114
- <p>Lorem ipsum</p>
115
- <p>Lorem ipsum</p>
116
- <p>Lorem ipsum</p>{" "}
117
- </DxcSidenav>
118
- </ExampleContainer>
127
+ const HoverSidenav = () => (
128
+ <ExampleContainer pseudoState="pseudo-hover">
129
+ <Title title="Default sidenav" theme="light" level={4} />
130
+ <DxcSidenav title={<TitleComponent />}>
131
+ <DxcSidenav.Section>
132
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
133
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
134
+ <DxcSidenav.Group collapsable={true} title="Collapsable Group">
135
+ <DxcSidenav.Link selected>Group Link</DxcSidenav.Link>
136
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
137
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
138
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
139
+ </DxcSidenav.Group>
140
+ </DxcSidenav.Section>
141
+ <DxcSidenav.Section>
142
+ <DxcSidenav.Group collapsable={true} title="Not Collapsed Group">
143
+ <DxcSidenav.Link selected>Group Link</DxcSidenav.Link>
144
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
145
+ </DxcSidenav.Group>
146
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
147
+ <DxcSidenav.Link>Single Link</DxcSidenav.Link>
148
+ <DxcSidenav.Group collapsable={true} title="Collapsable Group">
149
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
150
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
151
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
152
+ </DxcSidenav.Group>
119
153
 
120
- <ExampleContainer>
121
- <Title title="Sidenav compound components" theme="light" level={4} />
122
- <DxcSidenav>
123
- <DxcSidenav.Title>My sidenav</DxcSidenav.Title>
124
- <DxcSidenav.Subtitle>Components</DxcSidenav.Subtitle>
125
- <DxcSidenav.Link href="#">Button</DxcSidenav.Link>
126
- <DxcSidenav.Link href="#">Date</DxcSidenav.Link>
127
- <DxcSidenav.Subtitle>Guidelines</DxcSidenav.Subtitle>
128
- <DxcSidenav.Link onClick={linkClick}>Layout</DxcSidenav.Link>
129
- <DxcSidenav.Link onClick={linkClick}>Footer</DxcSidenav.Link>
130
- </DxcSidenav>
131
- </ExampleContainer>
154
+ <DxcSidenav.Group collapsable={true} title="Collapsable Group">
155
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
156
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
157
+ <DxcSidenav.Link>Group Link</DxcSidenav.Link>
158
+ </DxcSidenav.Group>
159
+ </DxcSidenav.Section>
160
+ </DxcSidenav>
161
+ </ExampleContainer>
162
+ );
132
163
 
133
- <ExampleContainer>
134
- <Title title="Sidenav with scroll" theme="light" level={4} />
135
- <StyledContainer>
136
- <DxcSidenav>
137
- <p>
138
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna,
139
- placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing
140
- elit. Donec congue laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus
141
- tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus
142
- eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue
143
- gravida enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare,
144
- malesuada urna eu, fringilla mauris. Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam
145
- sit amet maximus augue. Vivamus erat sapien, ultricies fringilla tellus id, condimentum blandit justo.
146
- Praesent quis nunc dignissim, pharetra neque molestie, molestie lectus. Lorem ipsum dolor sit amet,
147
- consectetur adipiscing elit. Morbi egestas luctus porttitor. Donec massa magna, placerat sit amet felis
148
- eget, venenatis fringilla ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec congue
149
- laoreet orci, nec elementum dolor consequat quis. Curabitur rhoncus justo sed dapibus tincidunt. Vestibulum
150
- cursus ut risus sit amet congue. Nunc luctus, urna ullamcorper facilisis Jia Le, risus eros aliquam erat, ut
151
- efficitur ante neque id odio. Nam orci leo, dignissim sit amet dolor ut, congue gravida enim. Donec rhoncus
152
- aliquam nisl, ac cursus enim bibendum vitae. Nunc sit amet elit ornare, malesuada urna eu, fringilla mauris.
153
- Vivamus bibendum turpis est, id elementum purus euismod sit amet. Etiam sit amet maximus augue. Vivamus erat
154
- sapien, ultricies fringilla tellus id, condimentum blandit justo. Praesent quis nunc dignissim, pharetra
155
- neque molestie, molestie lectus.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas
156
- luctus porttitor. Donec massa magna, placerat sit amet felis eget, venenatis fringilla ipsum. Lorem ipsum
157
- dolor sit amet, consectetur adipiscing elit. Donec congue laoreet orci, nec elementum dolor consequat quis.
158
- Curabitur rhoncus justo sed dapibus tincidunt. Vestibulum cursus ut risus sit amet congue. Nunc luctus, urna
159
- ullamcorper facilisis Jia Le, risus eros aliquam erat, ut efficitur ante neque id odio. Nam orci leo,
160
- dignissim sit amet dolor ut, congue gravida enim. Donec rhoncus aliquam nisl, ac cursus enim bibendum vitae.
161
- Nunc sit amet elit ornare, malesuada urna eu, fringilla mauris. Vivamus bibendum turpis est, id elementum
162
- purus euismod sit amet. Etiam sit amet maximus augue. Vivamus erat sapien, ultricies fringilla tellus id,
163
- condimentum blandit justo. Praesent quis nunc dignissim, pharetra neque molestie, molestie lectus.
164
- </p>
165
- </DxcSidenav>
166
- </StyledContainer>
167
- </ExampleContainer>
164
+ export const CollapseGroup = CollapsedGroup.bind({});
165
+ CollapseGroup.play = async ({ canvasElement }) => {
166
+ const canvas = within(canvasElement);
167
+ const collapsableGroups = canvas.getAllByText("Collapsable Group");
168
+ collapsableGroups.forEach((group) => {
169
+ userEvent.click(group);
170
+ });
171
+ };
168
172
 
169
- <ExampleContainer pseudoState="pseudo-focus-visible">
170
- <Title title="Focused" theme="light" level={4} />
171
- <DxcSidenav>
172
- <DxcSidenav.Title>My sidenav</DxcSidenav.Title>
173
- <DxcSidenav.Subtitle>Components</DxcSidenav.Subtitle>
174
- <DxcSidenav.Link href="#">Button</DxcSidenav.Link>
175
- <DxcSidenav.Link href="#">Date</DxcSidenav.Link>
176
- <DxcSidenav.Subtitle>Guidelines</DxcSidenav.Subtitle>
177
- <DxcSidenav.Link onClick={linkClick}>Layout</DxcSidenav.Link>
178
- <DxcSidenav.Link onClick={linkClick}>Footer</DxcSidenav.Link>
179
- </DxcSidenav>
180
- </ExampleContainer>
181
- </>
182
- );
173
+ export const CollapseHoverGroup = HoverSidenav.bind({});
174
+ CollapseHoverGroup.play = async ({ canvasElement }) => {
175
+ const canvas = within(canvasElement);
176
+ const collapsableGroups = canvas.getAllByText("Collapsable Group");
177
+ collapsableGroups.forEach((group) => {
178
+ userEvent.click(group);
179
+ });
180
+ };
@@ -6,51 +6,39 @@ var _react = _interopRequireDefault(require("react"));
6
6
 
7
7
  var _react2 = require("@testing-library/react");
8
8
 
9
- var _Sidenav = _interopRequireDefault(require("./Sidenav"));
10
-
11
- var navContent = /*#__PURE__*/_react["default"].createElement("p", null, "nav-content-test");
9
+ var _Sidenav = _interopRequireDefault(require("./Sidenav.tsx"));
12
10
 
13
11
  describe("Sidenav component tests", function () {
14
- test("Sidenav renders nav content", function () {
15
- var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Sidenav["default"], null, navContent)),
12
+ test("Sidenav renders anchors and Section correctly", function () {
13
+ var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Sidenav["default"], null, /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Section, null, /*#__PURE__*/_react["default"].createElement("p", null, "nav-content-test"), /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
14
+ href: "#"
15
+ }, "Link")))),
16
16
  getByText = _render.getByText;
17
17
 
18
18
  expect(getByText("nav-content-test")).toBeTruthy();
19
+ var link = getByText("Link");
20
+ expect(link.closest("a").getAttribute("href")).toBe("#");
19
21
  });
20
- test("Sidenav renders nav and page content in mobile version", function () {
21
- //425 is mobile width
22
- Object.defineProperty(HTMLElement.prototype, "offsetWidth", {
23
- configurable: true,
24
- value: 425
25
- });
26
-
27
- var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Sidenav["default"], null, navContent)),
28
- getByText = _render2.getByText;
29
-
30
- expect(getByText("nav-content-test")).toBeTruthy();
31
- });
32
- test("Sidenav renders compound components", function () {
33
- var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Sidenav["default"], null, /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Title, null, "test-title"), /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Subtitle, null, "test-subtitle"), /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
22
+ test("Sidenav renders groups correctly", function () {
23
+ var sidenav = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Sidenav["default"], null, /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Section, null, /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Group, {
24
+ title: "Collapsable",
25
+ collapsable: true
26
+ }, /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
34
27
  href: "#"
35
- }, "test-link"))),
36
- getByText = _render3.getByText;
37
-
38
- expect(getByText("test-title")).toBeTruthy();
39
- expect(getByText("test-subtitle")).toBeTruthy();
40
- expect(getByText("test-link")).toBeTruthy();
41
- });
42
- test("Sidenav link onClick", function () {
43
- var onClick = jest.fn();
44
-
45
- var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Sidenav["default"], null, /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
46
- onClick: onClick
47
- }, "test-link"))),
48
- getByText = _render4.getByText;
49
-
50
- var link = getByText("test-link");
28
+ }, "Lorem ipsum"), /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
29
+ href: "#"
30
+ }, "Lorem ipsum"), /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
31
+ href: "#"
32
+ }, "Lorem ipsum"), /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
33
+ href: "#"
34
+ }, "Lorem ipsum"), /*#__PURE__*/_react["default"].createElement(_Sidenav["default"].Link, {
35
+ href: "#"
36
+ }, "Lorem ipsum")))));
37
+ expect(sidenav.getByText("Collapsable")).toBeTruthy();
38
+ expect(sidenav.getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("true");
51
39
 
52
- _react2.fireEvent.click(link);
40
+ _react2.fireEvent.click(sidenav.getByText("Collapsable"));
53
41
 
54
- expect(onClick).toHaveBeenCalled();
42
+ expect(sidenav.getAllByRole("button")[0].getAttribute("aria-expanded")).toBe("false");
55
43
  });
56
44
  });
@@ -1,50 +1,73 @@
1
1
  /// <reference types="react" />
2
- declare type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- declare type Padding = {
4
- top?: Space;
5
- bottom?: Space;
6
- left?: Space;
7
- right?: Space;
8
- };
9
- export declare type SidenavLinkPropsType = {
10
- /**
11
- * Value of the tabindex.
12
- */
13
- tabIndex?: number;
2
+ declare type SVG = React.SVGProps<SVGSVGElement>;
3
+ declare type SidenavPropsType = {
14
4
  /**
15
- * Page to be opened when the user clicks on the link.
5
+ * The area inside the sidenav. This area can be used to render the content inside the sidenav.
16
6
  */
17
- href?: string;
7
+ children: React.ReactNode;
18
8
  /**
19
- * This function will be called when the user clicks the link.
9
+ * The area assigned to render the sidenav title. It is highly recommended to use the sidenav title.
20
10
  */
21
- onClick?: () => void;
11
+ title?: React.ReactNode;
12
+ };
13
+ export declare type SidenavTitlePropsType = {
22
14
  /**
23
- * The area inside the sidenav link. This area can be used to render custom content.
15
+ * The area inside the sidenav title. This area can be used to render custom content.
24
16
  */
25
17
  children: React.ReactNode;
26
18
  };
27
- export declare type SidenavTitlePropsType = {
19
+ export declare type SidenavSectionPropsType = {
28
20
  /**
29
- * The area inside the sidenav title. This area can be used to render custom content.
21
+ * The area inside the sidenav section. This area can be used to render sidenav groups, links and custom content.
30
22
  */
31
23
  children: React.ReactNode;
32
24
  };
33
- export declare type SidenavSubtitlePropsType = {
25
+ export declare type SidenavGroupPropsType = {
34
26
  /**
35
- * The area inside the sidenav subtitle. This area can be used to render custom content.
27
+ * The area inside the sidenav group. This area can be used to render sidenav links.
36
28
  */
37
29
  children: React.ReactNode;
30
+ /**
31
+ * The title of the sidenav group.
32
+ */
33
+ title?: string;
34
+ /**
35
+ * If true the sidenav group title will be considered a button and the group will be collapsable.
36
+ */
37
+ collapsable?: boolean;
38
+ /**
39
+ * The icon to be displayed next to the title of the group.
40
+ */
41
+ icon?: string | SVG;
38
42
  };
39
- declare type SidenavPropsType = {
43
+ export declare type SidenavLinkPropsType = {
40
44
  /**
41
- * Size of the padding to be applied to the custom area ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
42
- * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different padding sizes.
45
+ * Value of the tabindex.
43
46
  */
44
- padding?: Space | Padding;
47
+ tabIndex?: number;
45
48
  /**
46
- * The area inside the sidenav. This area can be used to render custom content.
49
+ * Page to be opened when the user clicks on the link.
47
50
  */
48
- children: React.ReactNode;
51
+ href?: string;
52
+ /**
53
+ * If true, the page is opened in a new browser tab.
54
+ */
55
+ newWindow?: boolean;
56
+ /**
57
+ * Element or path used as the icon that will be placed to the left of the link text.
58
+ */
59
+ icon?: string | SVG;
60
+ /**
61
+ * If true, the link will be marked as selected. This can also affect the group if it is closed to indicate that one of its links is selected.
62
+ */
63
+ selected?: boolean;
64
+ /**
65
+ * The area inside the sidenav link.
66
+ */
67
+ children: string;
68
+ /**
69
+ * This function will be called when the user clicks the link.
70
+ */
71
+ onClick?: ($event: any) => void;
49
72
  };
50
73
  export default SidenavPropsType;
@@ -199,7 +199,7 @@ var SVGSpinner = _styledComponents["default"].svg(_templateObject8 || (_template
199
199
  var CircleSpinner = _styledComponents["default"].circle(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n fill: transparent;\n stroke-linecap: initial;\n vector-effect: non-scaling-stroke;\n animation: ", ";\n stroke: ", ";\n transform-origin: ", ";\n stroke-dasharray: ", ";\n stroke-width: ", ";\n stroke-dashoffset: ", ";\n"])), function (props) {
200
200
  return props.isDeterminated ? "none" : props.mode !== "small" ? "1.4s ease-in-out infinite both svg-circle-large" : "1.4s ease-in-out infinite both svg-circle-small";
201
201
  }, function (props) {
202
- return props.backgroundType === "dark" ? props.theme.trackCircleColorOnDark : props.theme.trackCircleColor;
202
+ return props.backgroundType === "dark" || props.mode === "overlay" ? props.theme.trackCircleColorOverlay : props.theme.trackCircleColor;
203
203
  }, function (props) {
204
204
  return !props.isDeterminated ? "50% 50%" : "";
205
205
  }, function (props) {
package/switch/Switch.js CHANGED
@@ -29,6 +29,8 @@ var _utils = require("../common/utils.js");
29
29
 
30
30
  var _useTheme = _interopRequireDefault(require("../useTheme"));
31
31
 
32
+ var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
33
+
32
34
  var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
33
35
 
34
36
  var _templateObject, _templateObject2;
@@ -70,6 +72,7 @@ var DxcSwitch = function DxcSwitch(_ref) {
70
72
  setInnerChecked = _useState4[1];
71
73
 
72
74
  var colorsTheme = (0, _useTheme["default"])();
75
+ var translatedLabels = (0, _useTranslatedLabels["default"])();
73
76
  var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
74
77
 
75
78
  var handlerSwitchChange = function handlerSwitchChange(event) {
@@ -88,7 +91,7 @@ var DxcSwitch = function DxcSwitch(_ref) {
88
91
  onClick: !disabled && handlerSwitchChange,
89
92
  disabled: disabled,
90
93
  backgroundType: backgroundType
91
- }, labelPosition === "before" ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, label, " ", optional && /*#__PURE__*/_react["default"].createElement("span", null, "(Optional)")) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, optional && /*#__PURE__*/_react["default"].createElement("span", null, "(Optional)"), " ", label));
94
+ }, labelPosition === "before" ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, label, " ", optional && /*#__PURE__*/_react["default"].createElement("span", null, translatedLabels.formFields.optionalLabel)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, optional && /*#__PURE__*/_react["default"].createElement("span", null, translatedLabels.formFields.optionalLabel), " ", label));
92
95
 
93
96
  return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
94
97
  theme: colorsTheme["switch"]
@@ -78,12 +78,6 @@ export const Chromatic = () => (
78
78
  <Title title="With icon on the left and notification number" theme="light" level={4} />
79
79
  <DxcTabs tabs={tabsNotificationIcon} iconPosition="left" />
80
80
  </ExampleContainer>
81
- <ExampleContainer>
82
- <Title title="Scrollable" theme="light" level={4} />
83
- <div style={{ width: "400px" }}>
84
- <DxcTabs tabs={tabsNotificationIcon} iconPosition="left" defaultActiveTabIndex={1} />
85
- </div>
86
- </ExampleContainer>
87
81
  <Title title="Margins" theme="light" level={2} />
88
82
  <ExampleContainer>
89
83
  <Title title="Xxsmall margin" theme="light" level={4} />
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { NavTabsContextProps, NavTabsProps } from "./types";
3
+ export declare const NavTabsContext: React.Context<NavTabsContextProps>;
4
+ declare const DxcNavTabs: {
5
+ ({ iconPosition, tabIndex, children }: NavTabsProps): JSX.Element;
6
+ Tab: React.ForwardRefExoticComponent<import("./types").TabProps & React.RefAttributes<HTMLAnchorElement>>;
7
+ };
8
+ export default DxcNavTabs;