@laerdal/life-react-components 3.6.0-dev.1.full → 3.6.1

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 (227) hide show
  1. package/dist/Accordion/__tests__/AccordionMenu.test.tsx +42 -0
  2. package/dist/Accordion/__tests__/ContentAccordion.test.tsx +150 -0
  3. package/dist/AuthPage/__tests__/AuthPage.test.tsx +27 -0
  4. package/dist/Banners/__tests__/Banner.test.tsx +47 -0
  5. package/dist/Banners/__tests__/OverviewBanner.test.tsx +20 -0
  6. package/dist/Breadcrumb/__tests__/Breadcrumb.test.tsx +78 -0
  7. package/dist/Button/TextButton.cjs +648 -0
  8. package/dist/Button/TextButton.cjs.map +1 -0
  9. package/dist/Button/TextButton.d.ts +77 -0
  10. package/dist/Button/TextButton.js +640 -0
  11. package/dist/Button/TextButton.js.map +1 -0
  12. package/dist/Button/__tests__/BackButton.test.tsx +32 -0
  13. package/dist/Button/__tests__/Button.test.tsx +45 -0
  14. package/dist/Button/__tests__/DualButton.test.tsx +119 -0
  15. package/dist/Button/__tests__/TextButton.test.tsx +45 -0
  16. package/dist/Card/HorizontalCard/__tests__/HorizontalCard.test.tsx +71 -0
  17. package/dist/Card/HorizontalCard/__tests__/VerticalCard.test.tsx +124 -0
  18. package/dist/Card/VerticalCard/VerticalCard.cjs +187 -0
  19. package/dist/Card/VerticalCard/VerticalCard.cjs.map +1 -0
  20. package/dist/Card/VerticalCard/VerticalCard.d.ts +25 -0
  21. package/dist/Card/VerticalCard/VerticalCard.js +178 -0
  22. package/dist/Card/VerticalCard/VerticalCard.js.map +1 -0
  23. package/dist/Card/VerticalCard/VerticalCardBottomSection.cjs +261 -0
  24. package/dist/Card/VerticalCard/VerticalCardBottomSection.cjs.map +1 -0
  25. package/dist/Card/VerticalCard/VerticalCardBottomSection.d.ts +53 -0
  26. package/dist/Card/VerticalCard/VerticalCardBottomSection.js +252 -0
  27. package/dist/Card/VerticalCard/VerticalCardBottomSection.js.map +1 -0
  28. package/dist/Card/VerticalCard/VerticalCardMiddleSection.cjs +145 -0
  29. package/dist/Card/VerticalCard/VerticalCardMiddleSection.cjs.map +1 -0
  30. package/dist/Card/VerticalCard/VerticalCardMiddleSection.d.ts +42 -0
  31. package/dist/Card/VerticalCard/VerticalCardMiddleSection.js +136 -0
  32. package/dist/Card/VerticalCard/VerticalCardMiddleSection.js.map +1 -0
  33. package/dist/Card/VerticalCard/VerticalCardTopSection.cjs +165 -0
  34. package/dist/Card/VerticalCard/VerticalCardTopSection.cjs.map +1 -0
  35. package/dist/Card/VerticalCard/VerticalCardTopSection.d.ts +45 -0
  36. package/dist/Card/VerticalCard/VerticalCardTopSection.js +156 -0
  37. package/dist/Card/VerticalCard/VerticalCardTopSection.js.map +1 -0
  38. package/dist/Card/VerticalCard/__tests__/VerticalCard.test.tsx +124 -0
  39. package/dist/Card/__tests__/Card.test.tsx +146 -0
  40. package/dist/Chips/ChoiceChips.cjs +0 -1
  41. package/dist/Chips/ChoiceChips.cjs.map +1 -1
  42. package/dist/Chips/ChoiceChips.js +0 -1
  43. package/dist/Chips/ChoiceChips.js.map +1 -1
  44. package/dist/Chips/__tests__/ActionChip.test.tsx +94 -0
  45. package/dist/Chips/__tests__/ChoiceChips.test.tsx +79 -0
  46. package/dist/Chips/__tests__/FilterChip.test.tsx +95 -0
  47. package/dist/Chips/__tests__/InputChip.test.tsx +155 -0
  48. package/dist/ChipsInput/ChipDropdownInput.cjs +1 -1
  49. package/dist/ChipsInput/ChipDropdownInput.cjs.map +1 -1
  50. package/dist/ChipsInput/ChipDropdownInput.js +1 -1
  51. package/dist/ChipsInput/ChipDropdownInput.js.map +1 -1
  52. package/dist/ChipsInput/__tests__/ChipDropdownInput.test.tsx +100 -0
  53. package/dist/ChipsInput/__tests__/ChipInputFields.test.tsx +155 -0
  54. package/dist/Dropdown/BasicDropdown.cjs +0 -2
  55. package/dist/Dropdown/BasicDropdown.cjs.map +1 -1
  56. package/dist/Dropdown/BasicDropdown.js +0 -2
  57. package/dist/Dropdown/BasicDropdown.js.map +1 -1
  58. package/dist/Dropdown/DropdownButton.cjs +0 -4
  59. package/dist/Dropdown/DropdownButton.cjs.map +1 -1
  60. package/dist/Dropdown/DropdownButton.js +0 -4
  61. package/dist/Dropdown/DropdownButton.js.map +1 -1
  62. package/dist/Dropdown/DropdownContent.cjs +1 -1
  63. package/dist/Dropdown/DropdownContent.cjs.map +1 -1
  64. package/dist/Dropdown/DropdownContent.js +1 -1
  65. package/dist/Dropdown/DropdownContent.js.map +1 -1
  66. package/dist/Dropdown/DropdownFilter.cjs +0 -2
  67. package/dist/Dropdown/DropdownFilter.cjs.map +1 -1
  68. package/dist/Dropdown/DropdownFilter.js +0 -2
  69. package/dist/Dropdown/DropdownFilter.js.map +1 -1
  70. package/dist/Dropdown/__tests__/DropdownFilter.test.tsx +39 -0
  71. package/dist/Footer/__tests__/Footer.test.tsx +182 -0
  72. package/dist/GlobalNavigationBar/__tests__/Logo.test.tsx +31 -0
  73. package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.cjs +1 -0
  74. package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.cjs.map +1 -1
  75. package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.js +1 -0
  76. package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.js.map +1 -1
  77. package/dist/GlobalNavigationBar/desktop/SubMenu.cjs +1 -0
  78. package/dist/GlobalNavigationBar/desktop/SubMenu.cjs.map +1 -1
  79. package/dist/GlobalNavigationBar/desktop/SubMenu.js +1 -0
  80. package/dist/GlobalNavigationBar/desktop/SubMenu.js.map +1 -1
  81. package/dist/GlobalNavigationBar/desktop/__tests__/DesktopActions.test.tsx +108 -0
  82. package/dist/GlobalNavigationBar/desktop/__tests__/ExtendedMainMenu.test.tsx +28 -0
  83. package/dist/GlobalNavigationBar/desktop/__tests__/MainMenu.test.tsx +55 -0
  84. package/dist/GlobalNavigationBar/desktop/__tests__/RightSideNav.test.tsx +45 -0
  85. package/dist/GlobalNavigationBar/desktop/__tests__/UserMenu.test.tsx +125 -0
  86. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenu.test.tsx +317 -0
  87. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuContent.test.tsx +294 -0
  88. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuHeader.test.tsx +195 -0
  89. package/dist/InputFields/QuickSearch.cjs +1 -1
  90. package/dist/InputFields/QuickSearch.cjs.map +1 -1
  91. package/dist/InputFields/QuickSearch.js +1 -1
  92. package/dist/InputFields/QuickSearch.js.map +1 -1
  93. package/dist/InputFields/__tests__/NumberField.test.tsx +67 -0
  94. package/dist/InputFields/__tests__/NumberInput.test.tsx +68 -0
  95. package/dist/InputFields/__tests__/QuickSearch.test.tsx +42 -0
  96. package/dist/LinearProgress/__tests__/LinearProgress.test.tsx +25 -0
  97. package/dist/List/__tests__/ListRow.test.tsx +18 -0
  98. package/dist/LoadingPage/__tests__/GlobalLoadingPage.test.tsx +23 -0
  99. package/dist/Modals/__tests__/Modal.test.tsx +169 -0
  100. package/dist/Modals/__tests__/ModalContainer.test.tsx +77 -0
  101. package/dist/Modals/__tests__/ModalContent.test.tsx +126 -0
  102. package/dist/NavItem/__tests__/NavItem.test.ts +6 -0
  103. package/dist/Navigation/NavigationProvider.cjs +43 -0
  104. package/dist/Navigation/NavigationProvider.cjs.map +1 -0
  105. package/dist/Navigation/NavigationProvider.d.ts +15 -0
  106. package/dist/Navigation/NavigationProvider.js +32 -0
  107. package/dist/Navigation/NavigationProvider.js.map +1 -0
  108. package/dist/Navigation/index.cjs +19 -0
  109. package/dist/Navigation/index.cjs.map +1 -0
  110. package/dist/Navigation/index.d.ts +2 -0
  111. package/dist/Navigation/index.js +2 -0
  112. package/dist/Navigation/index.js.map +1 -0
  113. package/dist/NotificationDot/__tests__/NotificationDot.test.tsx +33 -0
  114. package/dist/Paginator/__tests__/Paginator.test.tsx +33 -0
  115. package/dist/Popover/__tests__/Popover.test.tsx +64 -0
  116. package/dist/ProfileButton/__tests__/ProfileButton.test.tsx +31 -0
  117. package/dist/QuizButton/__tests__/QuizButton.test.tsx +53 -0
  118. package/dist/SegmentControl/__tests__/SegmentControl.test.tsx +145 -0
  119. package/dist/SideMenu/__tests__/SideMenu.test.tsx +99 -0
  120. package/dist/Switcher/__tests__/SwitcherMenuItem.tsx +14 -0
  121. package/dist/Table/Table.cjs +3 -1
  122. package/dist/Table/Table.cjs.map +1 -1
  123. package/dist/Table/Table.js +3 -1
  124. package/dist/Table/Table.js.map +1 -1
  125. package/dist/Table/TableBody.cjs +1 -1
  126. package/dist/Table/TableBody.cjs.map +1 -1
  127. package/dist/Table/TableBody.js +1 -1
  128. package/dist/Table/TableBody.js.map +1 -1
  129. package/dist/Table/TableFooter.cjs +0 -2
  130. package/dist/Table/TableFooter.cjs.map +1 -1
  131. package/dist/Table/TableFooter.js +0 -2
  132. package/dist/Table/TableFooter.js.map +1 -1
  133. package/dist/Table/__tests__/Table.test.tsx +499 -0
  134. package/dist/Tabs/__tests__/HorizontalTabs.test.tsx +95 -0
  135. package/dist/Tabs/__tests__/TabLink.test.tsx +40 -0
  136. package/dist/Tabs/__tests__/Tablist.test.tsx +37 -0
  137. package/dist/Tag/__tests__/Tag.test.tsx +86 -0
  138. package/dist/Toasters/__tests__/Toast.test.tsx +74 -0
  139. package/dist/Toggles/__tests__/ToggleButton.test.tsx +53 -0
  140. package/dist/Toggles/__tests__/ToggleSwitch.test.tsx +87 -0
  141. package/dist/Tooltips/__tests__/TooltipWrapper.test.tsx +16 -0
  142. package/dist/icons/systemicons/CreditCard.cjs +43 -0
  143. package/dist/icons/systemicons/CreditCard.cjs.map +1 -0
  144. package/dist/icons/systemicons/CreditCard.d.ts +3 -0
  145. package/dist/icons/systemicons/CreditCard.js +33 -0
  146. package/dist/icons/systemicons/CreditCard.js.map +1 -0
  147. package/dist/icons/systemicons/Discount.cjs +43 -0
  148. package/dist/icons/systemicons/Discount.cjs.map +1 -0
  149. package/dist/icons/systemicons/Discount.d.ts +3 -0
  150. package/dist/icons/systemicons/Discount.js +33 -0
  151. package/dist/icons/systemicons/Discount.js.map +1 -0
  152. package/dist/icons/systemicons/DocumentComplete.cjs +43 -0
  153. package/dist/icons/systemicons/DocumentComplete.cjs.map +1 -0
  154. package/dist/icons/systemicons/DocumentComplete.d.ts +3 -0
  155. package/dist/icons/systemicons/DocumentComplete.js +33 -0
  156. package/dist/icons/systemicons/DocumentComplete.js.map +1 -0
  157. package/dist/icons/systemicons/Folder.cjs +43 -0
  158. package/dist/icons/systemicons/Folder.cjs.map +1 -0
  159. package/dist/icons/systemicons/Folder.d.ts +3 -0
  160. package/dist/icons/systemicons/Folder.js +33 -0
  161. package/dist/icons/systemicons/Folder.js.map +1 -0
  162. package/dist/icons/systemicons/FolderNew.cjs +43 -0
  163. package/dist/icons/systemicons/FolderNew.cjs.map +1 -0
  164. package/dist/icons/systemicons/FolderNew.d.ts +3 -0
  165. package/dist/icons/systemicons/FolderNew.js +33 -0
  166. package/dist/icons/systemicons/FolderNew.js.map +1 -0
  167. package/dist/icons/systemicons/MoodHappy.cjs +43 -0
  168. package/dist/icons/systemicons/MoodHappy.cjs.map +1 -0
  169. package/dist/icons/systemicons/MoodHappy.d.ts +3 -0
  170. package/dist/icons/systemicons/MoodHappy.js +33 -0
  171. package/dist/icons/systemicons/MoodHappy.js.map +1 -0
  172. package/dist/icons/systemicons/MoodIndifferent.cjs +43 -0
  173. package/dist/icons/systemicons/MoodIndifferent.cjs.map +1 -0
  174. package/dist/icons/systemicons/MoodIndifferent.d.ts +3 -0
  175. package/dist/icons/systemicons/MoodIndifferent.js +33 -0
  176. package/dist/icons/systemicons/MoodIndifferent.js.map +1 -0
  177. package/dist/icons/systemicons/MoodSad.cjs +43 -0
  178. package/dist/icons/systemicons/MoodSad.cjs.map +1 -0
  179. package/dist/icons/systemicons/MoodSad.d.ts +3 -0
  180. package/dist/icons/systemicons/MoodSad.js +33 -0
  181. package/dist/icons/systemicons/MoodSad.js.map +1 -0
  182. package/dist/icons/systemicons/MoodVeryHappy.cjs +43 -0
  183. package/dist/icons/systemicons/MoodVeryHappy.cjs.map +1 -0
  184. package/dist/icons/systemicons/MoodVeryHappy.d.ts +3 -0
  185. package/dist/icons/systemicons/MoodVeryHappy.js +33 -0
  186. package/dist/icons/systemicons/MoodVeryHappy.js.map +1 -0
  187. package/dist/icons/systemicons/MoodVerySad.cjs +43 -0
  188. package/dist/icons/systemicons/MoodVerySad.cjs.map +1 -0
  189. package/dist/icons/systemicons/MoodVerySad.d.ts +3 -0
  190. package/dist/icons/systemicons/MoodVerySad.js +33 -0
  191. package/dist/icons/systemicons/MoodVerySad.js.map +1 -0
  192. package/dist/icons/systemicons/Orders.cjs +43 -0
  193. package/dist/icons/systemicons/Orders.cjs.map +1 -0
  194. package/dist/icons/systemicons/Orders.d.ts +3 -0
  195. package/dist/icons/systemicons/Orders.js +33 -0
  196. package/dist/icons/systemicons/Orders.js.map +1 -0
  197. package/dist/icons/systemicons/Palette.cjs +43 -0
  198. package/dist/icons/systemicons/Palette.cjs.map +1 -0
  199. package/dist/icons/systemicons/Palette.d.ts +3 -0
  200. package/dist/icons/systemicons/Palette.js +33 -0
  201. package/dist/icons/systemicons/Palette.js.map +1 -0
  202. package/dist/icons/systemicons/Stack.cjs +43 -0
  203. package/dist/icons/systemicons/Stack.cjs.map +1 -0
  204. package/dist/icons/systemicons/Stack.d.ts +3 -0
  205. package/dist/icons/systemicons/Stack.js +33 -0
  206. package/dist/icons/systemicons/Stack.js.map +1 -0
  207. package/dist/styles/design-tokens/dark/tokens.css +481 -0
  208. package/dist/styles/design-tokens/light/tokens.css +481 -0
  209. package/dist/styles/design-tokens/rqi_dark/tokens.css +481 -0
  210. package/dist/styles/design-tokens/rqi_light/tokens.css +481 -0
  211. package/dist/styles/react-datepicker.css +766 -0
  212. package/dist/styles/typography.cjs +35 -59
  213. package/dist/styles/typography.cjs.map +1 -1
  214. package/dist/styles/typography.d.ts +1 -1
  215. package/dist/styles/typography.js +35 -59
  216. package/dist/styles/typography.js.map +1 -1
  217. package/dist/test-utils.cjs +16 -10
  218. package/dist/test-utils.cjs.map +1 -1
  219. package/dist/test-utils.d.ts +5 -5
  220. package/dist/test-utils.js +14 -8
  221. package/dist/test-utils.js.map +1 -1
  222. package/dist/utils/color-tokens.cjs +91 -0
  223. package/dist/utils/color-tokens.cjs.map +1 -0
  224. package/dist/utils/color-tokens.d.ts +19 -0
  225. package/dist/utils/color-tokens.js +82 -0
  226. package/dist/utils/color-tokens.js.map +1 -0
  227. package/package.json +1 -1
@@ -0,0 +1,156 @@
1
+ import _pt from "prop-types";
2
+ import * as React from 'react';
3
+ import styled, { useTheme } from 'styled-components';
4
+ import { ComponentS, ComponentTextStyle } from '../../styles/typography';
5
+ import Checkbox from '../../InputFields/Checkbox';
6
+ import { Tag } from '../../Tag';
7
+ import { COLORS } from '../../index';
8
+ import { ImageWithFallbacks } from "../../Image";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ export const VerticalCardTopSectionImageContainer = styled.div`
11
+ border-top-right-radius: 8px;
12
+ border-top-left-radius: 8px;
13
+ height: 100%;
14
+ width: 100%;
15
+ img{
16
+ object-fit: cover;
17
+ width: 100%;
18
+ height: 100%;
19
+ border-top-right-radius: 8px;
20
+ border-top-left-radius: 8px;
21
+ }
22
+ `;
23
+ export const VerticalCardTopSectionTagContainer = styled.div`
24
+ position: absolute;
25
+
26
+ top: 16px;
27
+ left: 16px;
28
+ width: calc(100% - 32px);
29
+ `;
30
+ export const VerticalCardTopSectionContainer = styled.div`
31
+ position: relative;
32
+ width: 100%;
33
+ overflow: visible;
34
+
35
+ ${props => props.disabled ? `
36
+ img, svg {
37
+ filter: grayscale(100%);
38
+ }` : ''}
39
+ `;
40
+ export const VerticalCardTopSectionRibbonContainer = styled.div`
41
+ min-height: calc(40px - 16px);
42
+ background-color: ${props => props.$backgroundColor};
43
+ width: calc(100% - 32px);
44
+ position: absolute;
45
+ bottom: 0px;
46
+ left: 0px;
47
+ padding: 8px 16px 8px 16px;
48
+ display: flex;
49
+ flex-direction: row;
50
+ align-items: center;
51
+ gap: 8px;
52
+
53
+ svg {
54
+ color: ${props => props.$color};
55
+ width: 24px;
56
+ height: 24px;
57
+ flex-grow: 0;
58
+ flex-shrink: 0;
59
+ }
60
+ `;
61
+ export const VerticalCardTopSectionCheckboxContainer = styled.div`
62
+ position: absolute;
63
+ top: 0;
64
+ right: 0;
65
+ z-index: 120;
66
+
67
+ .checkbox-icon {
68
+ background-color: ${props => COLORS.getColor('white', props.theme)};
69
+ }
70
+ `;
71
+ const VerticalCardTopSection = /*#__PURE__*/React.forwardRef((_ref, ref) => {
72
+ let {
73
+ selected,
74
+ setSelected,
75
+ image,
76
+ tagLabel,
77
+ tagIcon,
78
+ tagVariant = 'positive',
79
+ highlightRibbonIcon,
80
+ highlightRibbonText,
81
+ highlightRibbonContentColor,
82
+ highlightRibbonBgColor,
83
+ disabled
84
+ } = _ref;
85
+ const theme = useTheme();
86
+ return /*#__PURE__*/_jsxs(VerticalCardTopSectionContainer, {
87
+ disabled: disabled,
88
+ "data-testid": 'card-topSection',
89
+ style: {
90
+ height: image?.height ?? 200
91
+ },
92
+ children: [image && /*#__PURE__*/_jsx(VerticalCardTopSectionImageContainer, {
93
+ role: "none",
94
+ "aria-hidden": "true",
95
+ children: /*#__PURE__*/_jsx(ImageWithFallbacks, {
96
+ fallbacks: image.fallbackSrc ?? '',
97
+ src: image.src,
98
+ alt: "",
99
+ loader: image.loader ?? false,
100
+ width: image.width,
101
+ height: image.height
102
+ })
103
+ }), (!!selected || !!setSelected) && /*#__PURE__*/_jsx(VerticalCardTopSectionCheckboxContainer, {
104
+ "data-testid": 'card-topSection-checkbox',
105
+ children: /*#__PURE__*/_jsx(Checkbox, {
106
+ ref: ref,
107
+ disabled: disabled,
108
+ select: selected => setSelected && setSelected(selected),
109
+ selected: selected || false
110
+ })
111
+ }), (tagLabel || tagIcon) && /*#__PURE__*/_jsx(VerticalCardTopSectionTagContainer, {
112
+ children: /*#__PURE__*/_jsx(Tag, {
113
+ label: tagLabel,
114
+ variant: tagVariant,
115
+ icon: tagIcon
116
+ })
117
+ }), (highlightRibbonIcon || highlightRibbonText) && /*#__PURE__*/_jsxs(VerticalCardTopSectionRibbonContainer, {
118
+ "data-testid": 'card-topSection-ribbon',
119
+ $color: highlightRibbonContentColor ?? '',
120
+ $backgroundColor: disabled ? COLORS.generateToken({
121
+ componentType: 'bg-fill',
122
+ state: 'disabled'
123
+ }, theme) : highlightRibbonBgColor ?? '',
124
+ children: [highlightRibbonIcon, highlightRibbonText && /*#__PURE__*/_jsx(ComponentS, {
125
+ color: disabled ? COLORS.generateToken({
126
+ componentType: 'text',
127
+ isOnFill: true,
128
+ state: 'disabled'
129
+ }, theme) : highlightRibbonContentColor ?? '',
130
+ textStyle: ComponentTextStyle.Regular,
131
+ children: highlightRibbonText
132
+ })]
133
+ })]
134
+ });
135
+ });
136
+ VerticalCardTopSection.propTypes = {
137
+ selected: _pt.bool,
138
+ setSelected: _pt.func,
139
+ tagLabel: _pt.string,
140
+ tagIcon: _pt.node,
141
+ highlightRibbonText: _pt.string,
142
+ highlightRibbonIcon: _pt.node,
143
+ highlightRibbonContentColor: _pt.string,
144
+ highlightRibbonBgColor: _pt.string,
145
+ image: _pt.shape({
146
+ src: _pt.string.isRequired,
147
+ fallbackSrc: _pt.string,
148
+ alt: _pt.string.isRequired,
149
+ height: _pt.string,
150
+ width: _pt.string,
151
+ loader: _pt.bool
152
+ }),
153
+ disabled: _pt.bool
154
+ };
155
+ export default VerticalCardTopSection;
156
+ //# sourceMappingURL=VerticalCardTopSection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VerticalCardTopSection.js","names":["React","styled","useTheme","ComponentS","ComponentTextStyle","Checkbox","Tag","COLORS","ImageWithFallbacks","jsx","_jsx","jsxs","_jsxs","VerticalCardTopSectionImageContainer","div","VerticalCardTopSectionTagContainer","VerticalCardTopSectionContainer","props","disabled","VerticalCardTopSectionRibbonContainer","$backgroundColor","$color","VerticalCardTopSectionCheckboxContainer","getColor","theme","VerticalCardTopSection","forwardRef","_ref","ref","selected","setSelected","image","tagLabel","tagIcon","tagVariant","highlightRibbonIcon","highlightRibbonText","highlightRibbonContentColor","highlightRibbonBgColor","style","height","children","role","fallbacks","fallbackSrc","src","alt","loader","width","select","label","variant","icon","generateToken","componentType","state","color","isOnFill","textStyle","Regular","propTypes","_pt","bool","func","string","node","shape","isRequired"],"sources":["../../../src/Card/VerticalCard/VerticalCardTopSection.tsx"],"sourcesContent":["import * as React from 'react';\r\nimport styled, { useTheme } from 'styled-components';\r\nimport {ComponentS, ComponentTextStyle} from '../../styles/typography';\r\nimport Checkbox from '../../InputFields/Checkbox';\r\nimport {Tag, TagVariants} from '../../Tag';\r\n\r\nimport {COLORS} from '../../index';\r\nimport {ImageWithFallbacks} from \"../../Image\";\r\n\r\nexport interface VerticalCardTopSectionProps {\r\n /** Sets initial state of select Checkbox. */\r\n selected?: boolean;\r\n /** If this action is provided, then Checkbox will be shown on the top-right corner of the Card. */\r\n setSelected?: (arg0: boolean) => void;\r\n /** Label shown in the tag in the top-left corner of the Card. */\r\n tagLabel?: string;\r\n /** Icon shown in the tag in the top-left corner of the Card. */\r\n tagIcon?: React.ReactNode;\r\n /** Tag variant shown in the tag in the top-left corner of the Card. */\r\n tagVariant?: TagVariants;\r\n /** Text shown in the Ribbon, under the Image. */\r\n highlightRibbonText?: string;\r\n /** Icon shown in the Ribbon, under the Image. */\r\n highlightRibbonIcon?: React.ReactNode;\r\n /** Content color (text and image) of the Ribbon, under the Image. */\r\n highlightRibbonContentColor?: string;\r\n /** Background color of the Ribbon, shown under the Image. */\r\n highlightRibbonBgColor?: string;\r\n /** Details of the Image shown in the section. */\r\n image?: { src: string; fallbackSrc?: string; alt: string, height?: string; width?: string; loader?: boolean };\r\n /** This property is automatically set in the Card itself and is based on 'disabled' flag of CardProps. */\r\n disabled?: boolean;\r\n}\r\n\r\nexport const VerticalCardTopSectionImageContainer = styled.div`\r\n border-top-right-radius: 8px;\r\n border-top-left-radius: 8px;\r\n height: 100%;\r\n width: 100%;\r\n img{\r\n object-fit: cover;\r\n width: 100%;\r\n height: 100%;\r\n border-top-right-radius: 8px;\r\n border-top-left-radius: 8px;\r\n }\r\n`;\r\n\r\nexport const VerticalCardTopSectionTagContainer = styled.div`\r\n position: absolute;\r\n\r\n top: 16px;\r\n left: 16px;\r\n width: calc(100% - 32px);\r\n`;\r\n\r\nexport const VerticalCardTopSectionContainer = styled.div<{ disabled?: boolean }>`\r\n position: relative;\r\n width: 100%;\r\n overflow: visible;\r\n\r\n ${props => props.disabled ? `\r\n img, svg {\r\n filter: grayscale(100%);\r\n }` : ''}\r\n`;\r\n\r\nexport const VerticalCardTopSectionRibbonContainer = styled.div<{ $color: string; $backgroundColor: string }>`\r\n min-height: calc(40px - 16px);\r\n background-color: ${props => props.$backgroundColor};\r\n width: calc(100% - 32px);\r\n position: absolute;\r\n bottom: 0px;\r\n left: 0px;\r\n padding: 8px 16px 8px 16px;\r\n display: flex;\r\n flex-direction: row;\r\n align-items: center;\r\n gap: 8px;\r\n\r\n svg {\r\n color: ${props => props.$color};\r\n width: 24px;\r\n height: 24px;\r\n flex-grow: 0;\r\n flex-shrink: 0;\r\n }\r\n`;\r\n\r\nexport const VerticalCardTopSectionCheckboxContainer = styled.div`\r\n position: absolute;\r\n top: 0;\r\n right: 0;\r\n z-index: 120;\r\n\r\n .checkbox-icon {\r\n background-color: ${props => COLORS.getColor('white', props.theme)};\r\n }\r\n`;\r\n\r\nconst VerticalCardTopSection = React.forwardRef(({\r\n selected,\r\n setSelected,\r\n image,\r\n tagLabel,\r\n tagIcon,\r\n tagVariant = 'positive',\r\n highlightRibbonIcon,\r\n highlightRibbonText,\r\n highlightRibbonContentColor,\r\n highlightRibbonBgColor,\r\n disabled\r\n }: VerticalCardTopSectionProps, ref: React.Ref<HTMLDivElement>) => {\r\n\r\n const theme = useTheme();\r\n return (\r\n <VerticalCardTopSectionContainer disabled={disabled} data-testid={'card-topSection'} style={{height: image?.height ?? 200}}>\r\n {\r\n image &&\r\n <VerticalCardTopSectionImageContainer role=\"none\" aria-hidden=\"true\">\r\n <ImageWithFallbacks fallbacks={image.fallbackSrc ?? ''} src={image.src} alt=\"\" loader={image.loader ?? false} width={image.width} height={image.height}/>\r\n </VerticalCardTopSectionImageContainer>\r\n }\r\n {(!!selected || !!setSelected) && (\r\n <VerticalCardTopSectionCheckboxContainer data-testid={'card-topSection-checkbox'}>\r\n <Checkbox ref={ref}\r\n disabled={disabled}\r\n select={(selected: boolean) => setSelected && setSelected(selected)}\r\n selected={selected || false}/>\r\n </VerticalCardTopSectionCheckboxContainer>\r\n )}\r\n {(tagLabel || tagIcon) && (\r\n <VerticalCardTopSectionTagContainer>\r\n <Tag label={tagLabel} variant={tagVariant} icon={tagIcon}/>\r\n </VerticalCardTopSectionTagContainer>\r\n )}\r\n {(highlightRibbonIcon || highlightRibbonText) && (\r\n <VerticalCardTopSectionRibbonContainer data-testid={'card-topSection-ribbon'} $color={highlightRibbonContentColor ?? ''}\r\n $backgroundColor={disabled ? COLORS.generateToken({componentType:'bg-fill', state:'disabled'}, theme) : highlightRibbonBgColor ?? ''}>\r\n {highlightRibbonIcon}\r\n {highlightRibbonText && (\r\n <ComponentS color={disabled ? COLORS.generateToken({componentType:'text', isOnFill: true, state:'disabled'}, theme) : highlightRibbonContentColor ?? ''} textStyle={ComponentTextStyle.Regular}>\r\n {highlightRibbonText}\r\n </ComponentS>\r\n )}\r\n </VerticalCardTopSectionRibbonContainer>\r\n )}\r\n </VerticalCardTopSectionContainer>\r\n );\r\n});\r\n\r\nexport default VerticalCardTopSection;\r\n"],"mappings":";AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,OAAOC,MAAM,IAAIC,QAAQ,QAAQ,mBAAmB;AACpD,SAAQC,UAAU,EAAEC,kBAAkB,QAAO,yBAAyB;AACtE,OAAOC,QAAQ,MA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MAAA,CAAAG,UAAA;IAAU3B,MAAM,EAAAqB,GAAA,CAAAG,MAAA;IAAWhB,KAAK,EAAAa,GAAA,CAAAG,MAAA;IAAWjB,MAAM,EAAAc,GAAA,CAAAC;EAAA;EAEjG5C,QAAQ,EAAA2C,GAAA,CAAAC;AAAA;AAwHV,eAAerC,sBAAsB","ignoreList":[]}
@@ -0,0 +1,124 @@
1
+ import React from 'react';
2
+ import { fireEvent, render } from '../../../test-utils';
3
+ import 'jest-styled-components';
4
+ import { VerticalCard } from '../../VerticalCard/index';
5
+ import { COLORS } from '../../../styles';
6
+ import { SystemIcons } from '../../../icons';
7
+
8
+
9
+ describe('<VerticalCard />',()=>{
10
+ it('renders top section', async () => {
11
+ const{getByTestId} = render(
12
+ <VerticalCard topSectionProps={{disabled: false}} disabled/>
13
+ );
14
+
15
+ expect(getByTestId('card-topSection')).toBeDefined();
16
+ });
17
+
18
+ it('renders middle section', async () => {
19
+ const{getByTestId} = render(
20
+ <VerticalCard middleSectionProps={{title:'title',disabled:false}} disabled/>
21
+ );
22
+
23
+ expect(getByTestId('card-middleSection')).toBeDefined();
24
+ });
25
+
26
+ it('renders bottom section', async () => {
27
+ const{getByTestId} = render(
28
+ <VerticalCard bottomSectionProps={{disabled:false}} disabled/>
29
+ );
30
+
31
+ expect(getByTestId('card-bottomSection')).toBeDefined();
32
+ });
33
+
34
+ it('fires card clicked event on click', async () => {
35
+ const cardClicked = jest.fn();
36
+ const{getByTestId} = render(
37
+ <VerticalCard bottomSectionProps={{disabled:false}} disabled={false} onCardClicked={cardClicked}/>
38
+ );
39
+
40
+ fireEvent.click(getByTestId('card-link'));
41
+ expect(cardClicked).toHaveBeenCalled();
42
+ });
43
+
44
+ it('fires card clicked event on keyDown', async () => {
45
+ const cardClicked = jest.fn();
46
+ const{getByTestId} = render(
47
+ <VerticalCard bottomSectionProps={{disabled:false}} disabled={false} onCardClicked={cardClicked}/>
48
+ );
49
+
50
+ fireEvent.keyDown(getByTestId('card-wrapper'), {key: 'Enter', code: 'Enter', charCode: 13});
51
+ expect(cardClicked).toHaveBeenCalled();
52
+ });
53
+
54
+ it('renders tag in top section', async () => {
55
+ const{getByText} = render(
56
+ <VerticalCard topSectionProps={{disabled: false, tagLabel:'test_label'}} disabled/>
57
+ );
58
+
59
+ expect(getByText('test_label')).toBeDefined();
60
+ });
61
+
62
+ it('renders checkbox in top section', async () => {
63
+ const{getByTestId} = render(
64
+ <VerticalCard topSectionProps={{disabled: false, selected: true}} disabled/>
65
+ );
66
+
67
+ expect(getByTestId('card-topSection-checkbox')).toBeDefined();
68
+ });
69
+
70
+ it('renders highlight ribbon in top section', async () => {
71
+ const{getByTestId, getByText} = render(
72
+ <VerticalCard topSectionProps={{disabled: false, highlightRibbonText:'testRibbon', highlightRibbonBgColor:'red'}} disabled={false}/>
73
+ );
74
+
75
+ expect(getByText('testRibbon')).toBeDefined();
76
+ expect(getByTestId('card-topSection-ribbon')).toHaveStyleRule('background-color','red');
77
+ });
78
+
79
+ it('renders title ,description and category label in middle section', async () => {
80
+ const{getByText} = render(
81
+ <VerticalCard middleSectionProps={{title:'testTitle', disabled: false, description:'testDescription', categoryLabel:'testCatLabel'}} disabled={false}/>
82
+ );
83
+
84
+ expect(getByText('testTitle')).toBeDefined();
85
+ expect(getByText('testDescription')).toBeDefined();
86
+ expect(getByText('testCatLabel')).toBeDefined();
87
+ });
88
+
89
+ it('renders tags in middle section', async () => {
90
+ const{getByText} = render(
91
+ <VerticalCard middleSectionProps={{title:'testTitle', disabled: false, tags:[{label:'testTag'}], row2Tags:[{label:'testTag2'}]}} disabled={false}/>
92
+ );
93
+
94
+ expect(getByText('testTitle')).toBeDefined();
95
+ expect(getByText('testTag2')).toBeDefined();
96
+ });
97
+
98
+ it('renders note text in bottom section', async () => {
99
+ const{getByText} = render(
100
+ <VerticalCard bottomSectionProps={{disabled: false, noteLeft:'leftNote', noteRight:'rightNote'}} disabled={false}/>
101
+ );
102
+
103
+ expect(getByText('leftNote')).toBeDefined();
104
+ expect(getByText('rightNote')).toBeDefined();
105
+ });
106
+
107
+ it('renders author in bottom section', async () => {
108
+ const{getByText,getByTestId} = render(
109
+ <VerticalCard bottomSectionProps={{disabled: true, authorName:'testAuthor'}} disabled={true}/>
110
+ );
111
+
112
+ expect(getByText('testAuthor')).toBeDefined();
113
+ expect(getByTestId('card-bottomSection-author')).toBeDefined();
114
+ });
115
+
116
+ it('renders actions in bottom section', async () => {
117
+ const{getByText,getByTestId} = render(
118
+ <VerticalCard bottomSectionProps={{disabled: true, authorName:'testAuthor', actions:[{icon:<SystemIcons.Add/>,onClick:()=>{}}]}} disabled={true}/>
119
+ );
120
+
121
+ expect(getByText('testAuthor')).toBeDefined();
122
+ expect(getByTestId('card-bottomSection-author')).toBeDefined();
123
+ });
124
+ })
@@ -0,0 +1,146 @@
1
+ import React from 'react';
2
+ import { fireEvent, getByRole, render } from '../../test-utils';
3
+ import 'jest-styled-components';
4
+ import { Card } from '../..';
5
+ import { COLORS } from '../../styles';
6
+ import { SystemIcons } from '../../icons';
7
+
8
+ describe('<Card />',()=>{
9
+ it('renders top section', async () => {
10
+ const{getByTestId} = render(
11
+ <Card topSectionProps={{disabled: false}} disabled/>
12
+ );
13
+
14
+ expect(getByTestId('card-topSection')).toBeDefined();
15
+ //expect(getByTestId('card-middleSection')).toBeDefined();
16
+ });
17
+
18
+ it('renders middle section', async () => {
19
+ const{getByTestId} = render(
20
+ <Card middleSectionProps={{title:'title',disabled:false}} disabled/>
21
+ );
22
+
23
+ expect(getByTestId('card-middleSection')).toBeDefined();
24
+ });
25
+
26
+ it('renders bottom section', async () => {
27
+ const{getByTestId} = render(
28
+ <Card bottomSectionProps={{disabled:false}} disabled/>
29
+ );
30
+
31
+ expect(getByTestId('card-bottomSection')).toBeDefined();
32
+ });
33
+
34
+ it('fires card clicked event on click', async () => {
35
+ const cardClicked = jest.fn();
36
+ const{getByTestId} = render(
37
+ <Card bottomSectionProps={{disabled:false}} disabled={false} onCardClicked={cardClicked}/>
38
+ );
39
+
40
+ fireEvent.click(getByTestId('card-link'));
41
+ expect(cardClicked).toHaveBeenCalled();
42
+ });
43
+
44
+ it('fires card clicked event on keyDown', async () => {
45
+ const cardClicked = jest.fn();
46
+ const{getByTestId} = render(
47
+ <Card bottomSectionProps={{disabled:false}} disabled={false} onCardClicked={cardClicked}/>
48
+ );
49
+
50
+ fireEvent.keyDown(getByTestId('card-wrapper'), {key: 'Enter', code: 'Enter', charCode: 13});
51
+ expect(cardClicked).toHaveBeenCalled();
52
+ });
53
+
54
+ it('renders tag in top section', async () => {
55
+ const{getByText} = render(
56
+ <Card topSectionProps={{disabled: false, tagLabel:'test_label'}} disabled/>
57
+ );
58
+
59
+ expect(getByText('test_label')).toBeDefined();
60
+ });
61
+
62
+ it('renders checkbox in top section', async () => {
63
+ const{getByTestId} = render(
64
+ <Card topSectionProps={{disabled: false, selected: true}} disabled/>
65
+ );
66
+
67
+ expect(getByTestId('card-topSection-checkbox')).toBeDefined();
68
+ });
69
+
70
+ it('renders highlight ribbon in top section', async () => {
71
+ const{getByTestId, getByText} = render(
72
+ <Card topSectionProps={{disabled: false, highlightRibbonText:'testRibbon', highlightRibbonBgColor:'red'}} disabled={false}/>
73
+ );
74
+
75
+ expect(getByText('testRibbon')).toBeDefined();
76
+ expect(getByTestId('card-topSection-ribbon')).toHaveStyleRule('background-color','red');
77
+ });
78
+
79
+ it('renders title ,description and category label in middle section', async () => {
80
+ const{getByText} = render(
81
+ <Card middleSectionProps={{title:'testTitle', disabled: false, description:'testDescription', categoryLabel:'testCatLabel'}} disabled={false}/>
82
+ );
83
+
84
+ expect(getByText('testTitle')).toBeDefined();
85
+ expect(getByText('testDescription')).toBeDefined();
86
+ expect(getByText('testCatLabel')).toBeDefined();
87
+ });
88
+
89
+ it('renders tags in middle section', async () => {
90
+ const{getByText} = render(
91
+ <Card middleSectionProps={{title:'testTitle', disabled: false, tags:[{label:'testTag'}], row2Tags:[{label:'testTag2'}]}} disabled={false}/>
92
+ );
93
+
94
+ expect(getByText('testTitle')).toBeDefined();
95
+ expect(getByText('testTag2')).toBeDefined();
96
+ });
97
+
98
+ it('renders note text in bottom section', async () => {
99
+ const{getByText} = render(
100
+ <Card bottomSectionProps={{disabled: false, noteLeft:'leftNote', noteRight:'rightNote'}} disabled={false}/>
101
+ );
102
+
103
+ expect(getByText('leftNote')).toBeDefined();
104
+ expect(getByText('rightNote')).toBeDefined();
105
+ });
106
+
107
+ it('renders author in bottom section', async () => {
108
+ const{getByText,getByTestId} = render(
109
+ <Card bottomSectionProps={{disabled: true, authorName:'testAuthor'}} disabled={true}/>
110
+ );
111
+
112
+ expect(getByText('testAuthor')).toBeDefined();
113
+ expect(getByTestId('card-bottomSection-author')).toBeDefined();
114
+ });
115
+
116
+ it('renders actions in bottom section', async () => {
117
+ const{getByText,getByTestId} = render(
118
+ <Card bottomSectionProps={{disabled: true, authorName:'testAuthor', actions:[{icon:<SystemIcons.Add/>,onClick:()=>{}}]}} disabled={true}/>
119
+ );
120
+
121
+ expect(getByText('testAuthor')).toBeDefined();
122
+ expect(getByTestId('card-bottomSection-author')).toBeDefined();
123
+ });
124
+
125
+ it('fires leftButton click event on click', async () => {
126
+ const leftButtonClicked = jest.fn();
127
+ const{getByRole} = render(
128
+ <Card bottomSectionProps={{disabled: true,
129
+ authorName:'testAuthor',
130
+ actions:[],
131
+ leftButton: {
132
+ variant: 'tertiary',
133
+ buttonText: 'button',
134
+ onClick: (e) => {
135
+ e.stopPropagation();
136
+ leftButtonClicked();
137
+ }
138
+ }
139
+ }}
140
+ disabled={true}/>
141
+ );
142
+
143
+ fireEvent.click(getByRole('button'));
144
+ expect(leftButtonClicked).toBeCalledTimes(1);
145
+ });
146
+ })
@@ -84,7 +84,6 @@ var ChoiceChips = function ChoiceChips(_ref) {
84
84
  tabIndex: disabled ? -1 : 0,
85
85
  className: "".concat(size, " ").concat(disabled ? 'disabled' : '', " ").concat(selectedChip === value ? 'default' : 'outline', " interactive ").concat(className || ''),
86
86
  onMouseDown: _common.defaultOnMouseDownHandler,
87
- "aria-checked": selectedChip === value,
88
87
  onClick: function onClick() {
89
88
  return !disabled && onSelectChip(item);
90
89
  },
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceChips.cjs","names":["React","_interopRequireWildcard","require","_ChipStyles","_common","_types","_jsxRuntime","_excluded","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","ChoiceChips","_ref","selected","disabled","onClick","values","dataTestId","_React$useState","useState","_React$useState2","_slicedToArray2","selectedChip","setSelectedChip","useEffect","onSelectChip","value","handleKeyDown","key","jsx","role","children","map","item","_item$size","size","Size","Medium","label","className","rest","_objectWithoutProperties2","ChipContainer","tabIndex","concat","onMouseDown","defaultOnMouseDownHandler","onKeyDown","ChipContentContainer","ChipContent","_default","exports"],"sources":["../../src/Chips/ChoiceChips.tsx"],"sourcesContent":["/**\r\n * Import React libraries.\r\n */\r\nimport * as React from 'react';\r\n\r\n/**\r\n * Import custom styles.\r\n */\r\nimport {ChipContainer, ChipContent, ChipContentContainer} from './ChipStyles';\r\n\r\n/**\r\n * Import custom types.\r\n */\r\nimport {ChipValue, ChoiceChipProps} from './ChipTypes';\r\nimport {defaultOnMouseDownHandler} from '../common';\r\nimport {Size} from '../types';\r\n\r\nconst ChoiceChips: React.FunctionComponent<ChoiceChipProps> = ({\r\n selected,\r\n disabled,\r\n onClick,\r\n values,\r\n dataTestId\r\n }: ChoiceChipProps) => {\r\n /**\r\n * Globally used variables within the component.\r\n */\r\n const [selectedChip, setSelectedChip] = React.useState<string>('');\r\n\r\n /**\r\n * Set the selected value for the chip.\r\n */\r\n React.useEffect(() => {\r\n setSelectedChip(selected);\r\n }, [selected]);\r\n\r\n /**\r\n * Sets selected chip and fires an event to parent component.\r\n * @param value - Chip which was selected.\r\n */\r\n const onSelectChip = (value: ChipValue) => {\r\n // Update selected chip\r\n setSelectedChip(value.value);\r\n\r\n // Fire the event\r\n onClick && onClick(value);\r\n };\r\n\r\n const handleKeyDown = (e: any, value: ChipValue) => {\r\n if (e.key === 'Enter' || e.key === ' ') {\r\n onSelectChip(value);\r\n }\r\n };\r\n\r\n /**\r\n * Return Choice Chip component.\r\n */\r\n return (\r\n <div role=\"radiogroup\" data-testid={dataTestId}>\r\n {values.map((item: ChipValue) => {\r\n const {value, size = Size.Medium, label, className, ...rest } = item;\r\n return (\r\n <ChipContainer\r\n role=\"radio\"\r\n key={value}\r\n tabIndex={disabled ? -1 : 0}\r\n className={`${size} ${disabled ? 'disabled' : ''} ${selectedChip === value ? 'default' : 'outline'} interactive ${className || ''}`}\r\n onMouseDown={defaultOnMouseDownHandler}\r\n aria-checked={selectedChip === value}\r\n onClick={() => !disabled && onSelectChip(item)}\r\n onKeyDown={e => !disabled && handleKeyDown(e, item)}\r\n {...rest}>\r\n <ChipContentContainer>\r\n <ChipContent>\r\n {label}\r\n </ChipContent>\r\n </ChipContentContainer>\r\n </ChipContainer>\r\n );\r\n })}\r\n </div>\r\n );\r\n};\r\n\r\nexport default ChoiceChips;\r\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAA8B,IAAAI,WAAA,GAAAJ,OAAA;AAAA,IAAAK,SAAA;AAf9B;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AAFA,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AA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AAAkB,MAAA,CAAgBL,SAAS,IAAI,EAAE,CAAG;QACpIM,WAAW,EAAEC,iCAA0B;QACvC,gBAAcxB,YAAY,KAAKI,KAAM;QACrCX,OAAO,EAAE,SAAAA,QAAA;UAAA,OAAM,CAACD,QAAQ,IAAIW,YAAY,CAACQ,IAAI,CAAC;QAAA,CAAC;QAC/Cc,SAAS,EAAE,SAAAA,UAAAtE,CAAC;UAAA,OAAI,CAACqC,QAAQ,IAAIa,aAAa,CAAClD,CAAC,EAAEwD,IAAI,CAAC;QAAA;MAAC,GAChDO,IAAI;QAAAT,QAAA,eACR,IAAAzD,WAAA,CAAAuD,GAAA,EAAC1D,WAAA,CAAA6E,oBAAoB;UAAAjB,QAAA,eACnB,IAAAzD,WAAA,CAAAuD,GAAA,EAAC1D,WAAA,CAAA8E,WAAW;YAAAlB,QAAA,EACTO;UAAK,CACK;QAAC,CACM;MAAC,IAZlBZ,KAaQ,CAAC;IAEpB,CAAC;EAAC,CACC,CAAC;AAEV,CAAC;AAAC,IAAAwB,QAAA,GAEavC,WAAW;AAAAwC,OAAA,cAAAD,QAAA","ignoreList":[]}
1
+ {"version":3,"file":"ChoiceChips.cjs","names":["React","_interopRequireWildcard","require","_ChipStyles","_common","_types","_jsxRuntime","_excluded","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ownKeys","keys","getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","ChoiceChips","_ref","selected","disabled","onClick","values","dataTestId","_React$useState","useState","_React$useState2","_slicedToArray2","selectedChip","setSelectedChip","useEffect","onSelectChip","value","handleKeyDown","key","jsx","role","children","map","item","_item$size","size","Size","Medium","label","className","rest","_objectWithoutProperties2","ChipContainer","tabIndex","concat","onMouseDown","defaultOnMouseDownHandler","onKeyDown","ChipContentContainer","ChipContent","_default","exports"],"sources":["../../src/Chips/ChoiceChips.tsx"],"sourcesContent":["/**\r\n * Import React libraries.\r\n */\r\nimport * as React from 'react';\r\n\r\n/**\r\n * Import custom styles.\r\n */\r\nimport {ChipContainer, ChipContent, ChipContentContainer} from './ChipStyles';\r\n\r\n/**\r\n * Import custom types.\r\n */\r\nimport {ChipValue, ChoiceChipProps} from './ChipTypes';\r\nimport {defaultOnMouseDownHandler} from '../common';\r\nimport {Size} from '../types';\r\n\r\nconst ChoiceChips: React.FunctionComponent<ChoiceChipProps> = ({\r\n selected,\r\n disabled,\r\n onClick,\r\n values,\r\n dataTestId\r\n }: ChoiceChipProps) => {\r\n /**\r\n * Globally used variables within the component.\r\n */\r\n const [selectedChip, setSelectedChip] = React.useState<string>('');\r\n\r\n /**\r\n * Set the selected value for the chip.\r\n */\r\n React.useEffect(() => {\r\n setSelectedChip(selected);\r\n }, [selected]);\r\n\r\n /**\r\n * Sets selected chip and fires an event to parent component.\r\n * @param value - Chip which was selected.\r\n */\r\n const onSelectChip = (value: ChipValue) => {\r\n // Update selected chip\r\n setSelectedChip(value.value);\r\n\r\n // Fire the event\r\n onClick && onClick(value);\r\n };\r\n\r\n const handleKeyDown = (e: any, value: ChipValue) => {\r\n if (e.key === 'Enter' || e.key === ' ') {\r\n onSelectChip(value);\r\n }\r\n };\r\n\r\n /**\r\n * Return Choice Chip component.\r\n */\r\n return (\r\n <div role=\"radiogroup\" data-testid={dataTestId}>\r\n {values.map((item: ChipValue) => {\r\n const {value, size = Size.Medium, label, className, ...rest } = item;\r\n return (\r\n <ChipContainer\r\n role=\"radio\"\r\n key={value}\r\n tabIndex={disabled ? -1 : 0}\r\n className={`${size} ${disabled ? 'disabled' : ''} ${selectedChip === value ? 'default' : 'outline'} interactive ${className || ''}`}\r\n onMouseDown={defaultOnMouseDownHandler}\r\n onClick={() => !disabled && onSelectChip(item)}\r\n onKeyDown={e => !disabled && handleKeyDown(e, item)}\r\n {...rest}>\r\n <ChipContentContainer>\r\n <ChipContent>\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@ -77,7 +77,6 @@ var ChoiceChips = function ChoiceChips(_ref) {
77
77
  tabIndex: disabled ? -1 : 0,
78
78
  className: "".concat(size, " ").concat(disabled ? 'disabled' : '', " ").concat(selectedChip === value ? 'default' : 'outline', " interactive ").concat(className || ''),
79
79
  onMouseDown: defaultOnMouseDownHandler,
80
- "aria-checked": selectedChip === value,
81
80
  onClick: function onClick() {
82
81
  return !disabled && onSelectChip(item);
83
82
  },
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceChips.js","names":["React","ChipContainer","ChipContent","ChipContentContainer","defaultOnMouseDownHandler","Size","jsx","_jsx","ChoiceChips","_ref","selected","disabled","onClick","values","dataTestId","_React$useState","useState","_React$useState2","_slicedToArray","selectedChip","setSelectedChip","useEffect","onSelectChip","value","handleKeyDown","e","key","role","children","map","item","_item$size","size","Medium","label","className","rest","_objectWithoutProperties","_excluded","_objectSpread","tabIndex","concat","onMouseDown","onKeyDown"],"sources":["../../src/Chips/ChoiceChips.tsx"],"sourcesContent":["/**\r\n * Import React libraries.\r\n */\r\nimport * as React from 'react';\r\n\r\n/**\r\n * Import custom styles.\r\n */\r\nimport {ChipContainer, ChipContent, ChipContentContainer} from './ChipStyles';\r\n\r\n/**\r\n * Import custom types.\r\n */\r\nimport {ChipValue, ChoiceChipProps} from './ChipTypes';\r\nimport {defaultOnMouseDownHandler} from '../common';\r\nimport {Size} from '../types';\r\n\r\nconst ChoiceChips: React.FunctionComponent<ChoiceChipProps> = ({\r\n selected,\r\n disabled,\r\n onClick,\r\n values,\r\n dataTestId\r\n }: ChoiceChipProps) => {\r\n /**\r\n * Globally used variables within the component.\r\n */\r\n const [selectedChip, setSelectedChip] = React.useState<string>('');\r\n\r\n /**\r\n * Set the selected value for the chip.\r\n */\r\n React.useEffect(() => {\r\n setSelectedChip(selected);\r\n }, [selected]);\r\n\r\n /**\r\n * Sets selected chip and fires an event to parent component.\r\n * @param value - Chip which was selected.\r\n */\r\n const onSelectChip = (value: ChipValue) => {\r\n // Update selected chip\r\n setSelectedChip(value.value);\r\n\r\n // Fire the event\r\n onClick && onClick(value);\r\n };\r\n\r\n const handleKeyDown = (e: any, value: ChipValue) => {\r\n if (e.key === 'Enter' || e.key === ' ') {\r\n onSelectChip(value);\r\n }\r\n };\r\n\r\n /**\r\n * Return Choice Chip component.\r\n */\r\n return (\r\n <div role=\"radiogroup\" data-testid={dataTestId}>\r\n {values.map((item: ChipValue) => {\r\n const {value, size = Size.Medium, label, className, ...rest } = item;\r\n return (\r\n <ChipContainer\r\n role=\"radio\"\r\n key={value}\r\n tabIndex={disabled ? -1 : 0}\r\n className={`${size} ${disabled ? 'disabled' : ''} ${selectedChip === value ? 'default' : 'outline'} interactive ${className || ''}`}\r\n onMouseDown={defaultOnMouseDownHandler}\r\n aria-checked={selectedChip === value}\r\n onClick={() => !disabled && onSelectChip(item)}\r\n onKeyDown={e => !disabled && handleKeyDown(e, item)}\r\n {...rest}>\r\n <ChipContentContainer>\r\n <ChipContent>\r\n {label}\r\n </ChipContent>\r\n </ChipContentContainer>\r\n </ChipContainer>\r\n );\r\n })}\r\n </div>\r\n );\r\n};\r\n\r\nexport default ChoiceChips;\r\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;;AAE9B;AACA;AACA;AACA,SAAQC,aAAa,EAAEC,WAAW,EAAEC,oBAAoB,QAAO,cAAc;;AAE7E;AACA;AACA;;AAEA,SAAQC,yBAAyB,QAAO,WAAW;AACnD,SAAQC,IAAI,QAAO,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9B,IAAMC,WAAqD,GAAG,SAAxDA,WAAqDA,CAAAC,IAAA,EAM2B;EAAA,IALrBC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IACPC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,UAAU,GAAAL,IAAA,C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;QACZZ,IAAI,EAAC,OAAO;QAEZa,QAAQ,EAAE7B,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAE;QAC5BwB,SAAS,KAAAM,MAAA,CAAKT,IAAI,OAAAS,MAAA,CAAI9B,QAAQ,GAAG,UAAU,GAAG,EAAE,OAAA8B,MAAA,CAAItB,YAAY,KAAKI,KAAK,GAAG,SAAS,GAAG,SAAS,mBAAAkB,MAAA,CAAgBN,SAAS,IAAI,EAAE,CAAG;QACpIO,WAAW,EAAEtC,yBAA0B;QACvC,gBAAce,YAAY,KAAKI,KAAM;QACrCX,OAAO,EAAE,SAAAA,QAAA;UAAA,OAAM,CAACD,QAAQ,IAAIW,YAAY,CAACQ,IAAI,CAAC;QAAA,CAAC;QAC/Ca,SAAS,EAAE,SAAAA,UAAAlB,CAAC;UAAA,OAAI,CAACd,QAAQ,IAAIa,aAAa,CAACC,CAAC,EAAEK,IAAI,CAAC;QAAA;MAAC,GAChDM,IAAI;QAAAR,QAAA,eACRrB,IAAA,CAACJ,oBAAoB;UAAAyB,QAAA,eACnBrB,IAAA,CAACL,WAAW;YAAA0B,QAAA,EACTM;UAAK,CACK;QAAC,CACM;MAAC,IAZlBX,KAaQ,CAAC;IAEpB,CAAC;EAAC,CACC,CAAC;AAEV,CAAC;AAED,eAAef,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"ChoiceChips.js","names":["React","ChipContainer","ChipContent","ChipContentContainer","defaultOnMouseDownHandler","Size","jsx","_jsx","ChoiceChips","_ref","selected","disabled","onClick","values","dataTestId","_React$useState","useState","_React$useState2","_slicedToArray","selectedChip","setSelectedChip","useEffect","onSelectChip","value","handleKeyDown","e","key","role","children","map","item","_item$size","size","Medium","label","className","rest","_objectWithoutProperties","_excluded","_objectSpread","tabIndex","concat","onMouseDown","onKeyDown"],"sources":["../../src/Chips/ChoiceChips.tsx"],"sourcesContent":["/**\r\n * Import React libraries.\r\n */\r\nimport * as React from 'react';\r\n\r\n/**\r\n * Import custom styles.\r\n */\r\nimport {ChipContainer, ChipContent, ChipContentContainer} from './ChipStyles';\r\n\r\n/**\r\n * Import custom types.\r\n */\r\nimport {ChipValue, ChoiceChipProps} from './ChipTypes';\r\nimport {defaultOnMouseDownHandler} from '../common';\r\nimport {Size} from '../types';\r\n\r\nconst ChoiceChips: React.FunctionComponent<ChoiceChipProps> = ({\r\n selected,\r\n disabled,\r\n onClick,\r\n values,\r\n dataTestId\r\n }: ChoiceChipProps) => {\r\n /**\r\n * Globally used variables within the component.\r\n */\r\n const [selectedChip, setSelectedChip] = React.useState<string>('');\r\n\r\n /**\r\n * Set the selected value for the chip.\r\n */\r\n React.useEffect(() => {\r\n setSelectedChip(selected);\r\n }, [selected]);\r\n\r\n /**\r\n * Sets selected chip and fires an event to parent component.\r\n * @param value - Chip which was selected.\r\n */\r\n const onSelectChip = (value: ChipValue) => {\r\n // Update selected chip\r\n setSelectedChip(value.value);\r\n\r\n // Fire the event\r\n onClick && onClick(value);\r\n };\r\n\r\n const handleKeyDown = (e: any, value: ChipValue) => {\r\n if (e.key === 'Enter' || e.key === ' ') {\r\n onSelectChip(value);\r\n }\r\n };\r\n\r\n /**\r\n * Return Choice Chip component.\r\n */\r\n return (\r\n <div role=\"radiogroup\" data-testid={dataTestId}>\r\n {values.map((item: ChipValue) => {\r\n const {value, size = Size.Medium, label, className, ...rest } = item;\r\n return (\r\n <ChipContainer\r\n role=\"radio\"\r\n key={value}\r\n tabIndex={disabled ? -1 : 0}\r\n className={`${size} ${disabled ? 'disabled' : ''} ${selectedChip === value ? 'default' : 'outline'} interactive ${className || ''}`}\r\n onMouseDown={defaultOnMouseDownHandler}\r\n onClick={() => !disabled && onSelectChip(item)}\r\n onKeyDown={e => !disabled && handleKeyDown(e, item)}\r\n {...rest}>\r\n <ChipContentContainer>\r\n <ChipContent>\r\n {label}\r\n </ChipContent>\r\n </ChipContentContainer>\r\n </ChipContainer>\r\n );\r\n })}\r\n </div>\r\n );\r\n};\r\n\r\nexport default ChoiceChips;\r\n"],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;IAEpB,CAAC;EAAC,CACC,CAAC;AAEV,CAAC;AAED,eAAef,WAAW","ignoreList":[]}
@@ -0,0 +1,94 @@
1
+ import * as React from 'react';
2
+ import {ActionChip} from '../index';
3
+ import {act, fireEvent, render} from '../../test-utils';
4
+ import { SystemIcons } from '../../icons';
5
+
6
+ describe('ActionChip', () => {
7
+
8
+ it('should render', () => {
9
+ const wrapper = render(<ActionChip text={'label'}/>);
10
+
11
+ expect(wrapper.queryByText('label')).toBeInTheDocument();
12
+ });
13
+
14
+ it('should render icon', () => {
15
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>}/>);
16
+
17
+ expect(wrapper.queryByLabelText('Book')).toBeInTheDocument();
18
+ });
19
+
20
+ it('should be focusable if it is not disabled and onClick is defined', () => {
21
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} onClick={jest.fn()}/>);
22
+
23
+ expect(wrapper.container.querySelector('[tabindex="0"]')).toBeInTheDocument();
24
+ });
25
+
26
+ it('should not be focusable if it is disabled', () => {
27
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} disabled={true} onClick={jest.fn()}/>);
28
+
29
+ expect(wrapper.container.querySelector('[tabindex="-1"]')).toBeInTheDocument();
30
+ });
31
+
32
+ it('should not be focusable if it is not interactive', () => {
33
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>}/>);
34
+
35
+ expect(wrapper.container.querySelector('[tabindex="-1"]')).toBeInTheDocument();
36
+ });
37
+
38
+ it('should call onClick when its clicked', () => {
39
+ const onClickSpy = jest.fn();
40
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} onClick={onClickSpy}/>);
41
+
42
+ act(() => {
43
+ wrapper.getByText('label').click();
44
+ });
45
+
46
+ expect(onClickSpy).toHaveBeenCalled();
47
+ });
48
+
49
+ it('should call onClick when Enter is pressed', () => {
50
+ const onClickSpy = jest.fn();
51
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} onClick={onClickSpy}/>);
52
+
53
+ act(() => {
54
+ fireEvent.keyDown(wrapper.getByText('label'), {key: 'Enter', code: 'Enter'});
55
+ });
56
+
57
+ expect(onClickSpy).toHaveBeenCalled();
58
+ });
59
+
60
+ it('should call onClick when Space is pressed', () => {
61
+ const onClickSpy = jest.fn();
62
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} onClick={onClickSpy}/>);
63
+
64
+ act(() => {
65
+ fireEvent.keyDown(wrapper.getByText('label'), {key: ' '});
66
+ });
67
+
68
+ expect(onClickSpy).toHaveBeenCalled();
69
+ });
70
+
71
+ it('should not call onClick when its clicked if disabled', () => {
72
+ const onClickSpy = jest.fn();
73
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} disabled={true} onClick={onClickSpy}/>);
74
+
75
+ act(() => {
76
+ wrapper.getByText('label').click();
77
+ });
78
+
79
+ expect(onClickSpy).not.toHaveBeenCalled();
80
+ });
81
+
82
+ it('should not call onClick when Enter is pressed if disabled', () => {
83
+ const onClickSpy = jest.fn();
84
+ const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} disabled={true} onClick={onClickSpy}/>);
85
+
86
+ act(() => {
87
+ fireEvent.keyDown(wrapper.getByText('label'), {key: 'Enter', code: 'Enter'});
88
+ });
89
+
90
+ expect(onClickSpy).not.toHaveBeenCalled();
91
+ });
92
+
93
+
94
+ });