@pega/cosmos-react-core 4.0.0-dev.12.0 → 4.0.0-dev.13.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 (227) hide show
  1. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  2. package/lib/components/AppShell/AppShell.js +2 -1
  3. package/lib/components/AppShell/AppShell.js.map +1 -1
  4. package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
  5. package/lib/components/AppShell/NavigationList.js +2 -2
  6. package/lib/components/AppShell/NavigationList.js.map +1 -1
  7. package/lib/components/ColorPicker/ColorPicker.d.ts +2 -2
  8. package/lib/components/ColorPicker/ColorPicker.d.ts.map +1 -1
  9. package/lib/components/ColorPicker/ColorPicker.js +5 -3
  10. package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
  11. package/lib/components/ColorPicker/ColorPicker.test-ids.d.ts +2 -0
  12. package/lib/components/ColorPicker/ColorPicker.test-ids.d.ts.map +1 -0
  13. package/lib/components/ColorPicker/ColorPicker.test-ids.js +3 -0
  14. package/lib/components/ColorPicker/ColorPicker.test-ids.js.map +1 -0
  15. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  16. package/lib/components/ComboBox/ComboBox.js +6 -3
  17. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  18. package/lib/components/ComboBox/ComboBox.types.d.ts +2 -2
  19. package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
  20. package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
  21. package/lib/components/ComboBox/ComboxBox.test-ids.d.ts +2 -0
  22. package/lib/components/ComboBox/ComboxBox.test-ids.d.ts.map +1 -0
  23. package/lib/components/ComboBox/ComboxBox.test-ids.js +3 -0
  24. package/lib/components/ComboBox/ComboxBox.test-ids.js.map +1 -0
  25. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  26. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +1 -1
  27. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  28. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
  29. package/lib/components/CompositeInput/CompositeInput.js +17 -4
  30. package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
  31. package/lib/components/CompositeInput/CompositeInput.test-ids.d.ts +2 -0
  32. package/lib/components/CompositeInput/CompositeInput.test-ids.d.ts.map +1 -0
  33. package/lib/components/CompositeInput/CompositeInput.test-ids.js +3 -0
  34. package/lib/components/CompositeInput/CompositeInput.test-ids.js.map +1 -0
  35. package/lib/components/CompositeInput/CompositeInput.types.d.ts +2 -2
  36. package/lib/components/CompositeInput/CompositeInput.types.d.ts.map +1 -1
  37. package/lib/components/CompositeInput/CompositeInput.types.js.map +1 -1
  38. package/lib/components/Configuration/Configuration.d.ts +6 -0
  39. package/lib/components/Configuration/Configuration.d.ts.map +1 -1
  40. package/lib/components/Configuration/Configuration.js +3 -1
  41. package/lib/components/Configuration/Configuration.js.map +1 -1
  42. package/lib/components/Currency/Currency.test-ids.d.ts +2 -0
  43. package/lib/components/Currency/Currency.test-ids.d.ts.map +1 -0
  44. package/lib/components/Currency/Currency.test-ids.js +3 -0
  45. package/lib/components/Currency/Currency.test-ids.js.map +1 -0
  46. package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
  47. package/lib/components/Currency/CurrencyInput.js +6 -3
  48. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  49. package/lib/components/Currency/CurrencyInput.types.d.ts +2 -2
  50. package/lib/components/Currency/CurrencyInput.types.d.ts.map +1 -1
  51. package/lib/components/Currency/CurrencyInput.types.js.map +1 -1
  52. package/lib/components/DateTime/utils.d.ts.map +1 -1
  53. package/lib/components/DateTime/utils.js +61 -1
  54. package/lib/components/DateTime/utils.js.map +1 -1
  55. package/lib/components/FieldGroup/FieldGroup.js +1 -1
  56. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  57. package/lib/components/FieldValueList/FieldValueList.d.ts +4 -4
  58. package/lib/components/FieldValueList/FieldValueList.d.ts.map +1 -1
  59. package/lib/components/FieldValueList/FieldValueList.js +11 -9
  60. package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
  61. package/lib/components/FieldValueList/FieldValueList.test-ids.d.ts +3 -0
  62. package/lib/components/FieldValueList/FieldValueList.test-ids.d.ts.map +1 -0
  63. package/lib/components/FieldValueList/FieldValueList.test-ids.js +7 -0
  64. package/lib/components/FieldValueList/FieldValueList.test-ids.js.map +1 -0
  65. package/lib/components/File/File.test-ids.d.ts +2 -0
  66. package/lib/components/File/File.test-ids.d.ts.map +1 -0
  67. package/lib/components/File/File.test-ids.js +3 -0
  68. package/lib/components/File/File.test-ids.js.map +1 -0
  69. package/lib/components/File/FileInput.d.ts +2 -2
  70. package/lib/components/File/FileInput.d.ts.map +1 -1
  71. package/lib/components/File/FileInput.js +15 -4
  72. package/lib/components/File/FileInput.js.map +1 -1
  73. package/lib/components/FormField/FormField.d.ts +2 -2
  74. package/lib/components/FormField/FormField.d.ts.map +1 -1
  75. package/lib/components/FormField/FormField.js +15 -10
  76. package/lib/components/FormField/FormField.js.map +1 -1
  77. package/lib/components/FormField/FormField.test-ids.d.ts +2 -0
  78. package/lib/components/FormField/FormField.test-ids.d.ts.map +1 -0
  79. package/lib/components/FormField/FormField.test-ids.js +9 -0
  80. package/lib/components/FormField/FormField.test-ids.js.map +1 -0
  81. package/lib/components/Input/Input.d.ts +2 -2
  82. package/lib/components/Input/Input.d.ts.map +1 -1
  83. package/lib/components/Input/Input.js +6 -2
  84. package/lib/components/Input/Input.js.map +1 -1
  85. package/lib/components/Input/Input.test-ids.d.ts +2 -0
  86. package/lib/components/Input/Input.test-ids.d.ts.map +1 -0
  87. package/lib/components/Input/Input.test-ids.js +3 -0
  88. package/lib/components/Input/Input.test-ids.js.map +1 -0
  89. package/lib/components/ListToolbar/ListToolbar.js +2 -2
  90. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  91. package/lib/components/Location/Location.test-ids.d.ts +2 -0
  92. package/lib/components/Location/Location.test-ids.d.ts.map +1 -0
  93. package/lib/components/Location/Location.test-ids.js +3 -0
  94. package/lib/components/Location/Location.test-ids.js.map +1 -0
  95. package/lib/components/Location/LocationInput.d.ts +2 -2
  96. package/lib/components/Location/LocationInput.d.ts.map +1 -1
  97. package/lib/components/Location/LocationInput.js +17 -4
  98. package/lib/components/Location/LocationInput.js.map +1 -1
  99. package/lib/components/Menu/Menu.d.ts.map +1 -1
  100. package/lib/components/Menu/Menu.js +7 -5
  101. package/lib/components/Menu/Menu.js.map +1 -1
  102. package/lib/components/Menu/Menu.styles.d.ts +5 -1
  103. package/lib/components/Menu/Menu.styles.d.ts.map +1 -1
  104. package/lib/components/Menu/Menu.styles.js +80 -85
  105. package/lib/components/Menu/Menu.styles.js.map +1 -1
  106. package/lib/components/Menu/Menu.test-ids.d.ts +3 -0
  107. package/lib/components/Menu/Menu.test-ids.d.ts.map +1 -0
  108. package/lib/components/Menu/Menu.test-ids.js +4 -0
  109. package/lib/components/Menu/Menu.test-ids.js.map +1 -0
  110. package/lib/components/Menu/Menu.types.d.ts +3 -3
  111. package/lib/components/Menu/Menu.types.d.ts.map +1 -1
  112. package/lib/components/Menu/Menu.types.js.map +1 -1
  113. package/lib/components/Menu/MenuItem.d.ts.map +1 -1
  114. package/lib/components/Menu/MenuItem.js +70 -73
  115. package/lib/components/Menu/MenuItem.js.map +1 -1
  116. package/lib/components/Menu/MenuList.d.ts.map +1 -1
  117. package/lib/components/Menu/MenuList.js +3 -3
  118. package/lib/components/Menu/MenuList.js.map +1 -1
  119. package/lib/components/Menu/MenuListHeader.d.ts.map +1 -1
  120. package/lib/components/Menu/MenuListHeader.js +3 -4
  121. package/lib/components/Menu/MenuListHeader.js.map +1 -1
  122. package/lib/components/MetaList/MetaList.d.ts +2 -2
  123. package/lib/components/MetaList/MetaList.d.ts.map +1 -1
  124. package/lib/components/MetaList/MetaList.js +5 -3
  125. package/lib/components/MetaList/MetaList.js.map +1 -1
  126. package/lib/components/MetaList/MetaList.test-ids.d.ts +2 -0
  127. package/lib/components/MetaList/MetaList.test-ids.d.ts.map +1 -0
  128. package/lib/components/MetaList/MetaList.test-ids.js +3 -0
  129. package/lib/components/MetaList/MetaList.test-ids.js.map +1 -0
  130. package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -1
  131. package/lib/components/MultiStepForm/MultiStepForm.js +18 -6
  132. package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
  133. package/lib/components/Number/Number.test-ids.d.ts +3 -0
  134. package/lib/components/Number/Number.test-ids.d.ts.map +1 -0
  135. package/lib/components/Number/Number.test-ids.js +8 -0
  136. package/lib/components/Number/Number.test-ids.js.map +1 -0
  137. package/lib/components/Number/NumberInput.d.ts.map +1 -1
  138. package/lib/components/Number/NumberInput.js +9 -6
  139. package/lib/components/Number/NumberInput.js.map +1 -1
  140. package/lib/components/Number/NumberInput.types.d.ts +2 -2
  141. package/lib/components/Number/NumberInput.types.d.ts.map +1 -1
  142. package/lib/components/Number/NumberInput.types.js.map +1 -1
  143. package/lib/components/Number/NumberRangeInput.d.ts.map +1 -1
  144. package/lib/components/Number/NumberRangeInput.js +6 -4
  145. package/lib/components/Number/NumberRangeInput.js.map +1 -1
  146. package/lib/components/Phone/Phone.test-ids.d.ts +2 -0
  147. package/lib/components/Phone/Phone.test-ids.d.ts.map +1 -0
  148. package/lib/components/Phone/Phone.test-ids.js +6 -0
  149. package/lib/components/Phone/Phone.test-ids.js.map +1 -0
  150. package/lib/components/Phone/PhoneInput.d.ts +2 -2
  151. package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
  152. package/lib/components/Phone/PhoneInput.js +7 -4
  153. package/lib/components/Phone/PhoneInput.js.map +1 -1
  154. package/lib/components/RadioCheck/RadioCheck.d.ts +2 -0
  155. package/lib/components/RadioCheck/RadioCheck.d.ts.map +1 -1
  156. package/lib/components/RadioCheck/RadioCheck.js +3 -3
  157. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  158. package/lib/components/Select/Select.d.ts +2 -2
  159. package/lib/components/Select/Select.d.ts.map +1 -1
  160. package/lib/components/Select/Select.js +6 -3
  161. package/lib/components/Select/Select.js.map +1 -1
  162. package/lib/components/Select/Select.test-ids.d.ts +2 -0
  163. package/lib/components/Select/Select.test-ids.d.ts.map +1 -0
  164. package/lib/components/Select/Select.test-ids.js +3 -0
  165. package/lib/components/Select/Select.test-ids.js.map +1 -0
  166. package/lib/components/Slider/Slider.d.ts.map +1 -1
  167. package/lib/components/Slider/Slider.js +7 -5
  168. package/lib/components/Slider/Slider.js.map +1 -1
  169. package/lib/components/Slider/Slider.test-ids.d.ts +2 -0
  170. package/lib/components/Slider/Slider.test-ids.d.ts.map +1 -0
  171. package/lib/components/Slider/Slider.test-ids.js +3 -0
  172. package/lib/components/Slider/Slider.test-ids.js.map +1 -0
  173. package/lib/components/Slider/Slider.types.d.ts +2 -2
  174. package/lib/components/Slider/Slider.types.d.ts.map +1 -1
  175. package/lib/components/Slider/Slider.types.js.map +1 -1
  176. package/lib/components/SummaryItem/SummaryItem.d.ts +2 -2
  177. package/lib/components/SummaryItem/SummaryItem.d.ts.map +1 -1
  178. package/lib/components/SummaryItem/SummaryItem.js +6 -3
  179. package/lib/components/SummaryItem/SummaryItem.js.map +1 -1
  180. package/lib/components/SummaryItem/SummaryItem.test-ids.d.ts +2 -0
  181. package/lib/components/SummaryItem/SummaryItem.test-ids.d.ts.map +1 -0
  182. package/lib/components/SummaryItem/SummaryItem.test-ids.js +8 -0
  183. package/lib/components/SummaryItem/SummaryItem.test-ids.js.map +1 -0
  184. package/lib/components/TextArea/TextArea.d.ts +2 -2
  185. package/lib/components/TextArea/TextArea.d.ts.map +1 -1
  186. package/lib/components/TextArea/TextArea.js +6 -2
  187. package/lib/components/TextArea/TextArea.js.map +1 -1
  188. package/lib/components/TextArea/TextArea.test-ids.d.ts +2 -0
  189. package/lib/components/TextArea/TextArea.test-ids.d.ts.map +1 -0
  190. package/lib/components/TextArea/TextArea.test-ids.js +3 -0
  191. package/lib/components/TextArea/TextArea.test-ids.js.map +1 -0
  192. package/lib/hooks/index.d.ts +1 -0
  193. package/lib/hooks/index.d.ts.map +1 -1
  194. package/lib/hooks/index.js +1 -0
  195. package/lib/hooks/index.js.map +1 -1
  196. package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
  197. package/lib/hooks/useActiveDescendant.js +6 -2
  198. package/lib/hooks/useActiveDescendant.js.map +1 -1
  199. package/lib/hooks/useI18n.d.ts +15 -9
  200. package/lib/hooks/useI18n.d.ts.map +1 -1
  201. package/lib/hooks/useTestIds.d.ts +10 -0
  202. package/lib/hooks/useTestIds.d.ts.map +1 -0
  203. package/lib/hooks/useTestIds.js +18 -0
  204. package/lib/hooks/useTestIds.js.map +1 -0
  205. package/lib/i18n/default.d.ts +15 -9
  206. package/lib/i18n/default.d.ts.map +1 -1
  207. package/lib/i18n/default.js +20 -14
  208. package/lib/i18n/default.js.map +1 -1
  209. package/lib/i18n/i18n.d.ts +15 -9
  210. package/lib/i18n/i18n.d.ts.map +1 -1
  211. package/lib/theme/theme.d.ts +16 -16
  212. package/lib/types/types.d.ts +9 -0
  213. package/lib/types/types.d.ts.map +1 -1
  214. package/lib/types/types.js.map +1 -1
  215. package/lib/utils/createTestIds.d.ts +9 -0
  216. package/lib/utils/createTestIds.d.ts.map +1 -0
  217. package/lib/utils/createTestIds.js +10 -0
  218. package/lib/utils/createTestIds.js.map +1 -0
  219. package/lib/utils/index.d.ts +3 -0
  220. package/lib/utils/index.d.ts.map +1 -1
  221. package/lib/utils/index.js +2 -0
  222. package/lib/utils/index.js.map +1 -1
  223. package/lib/utils/kebabToCamel.d.ts +7 -0
  224. package/lib/utils/kebabToCamel.d.ts.map +1 -0
  225. package/lib/utils/kebabToCamel.js +10 -0
  226. package/lib/utils/kebabToCamel.js.map +1 -0
  227. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { forwardRef, useCallback, useContext, useEffect, useState } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import ComboBox from '../ComboBox';
5
- import { useI18n } from '../../hooks';
5
+ import { useI18n, useTestIds } from '../../hooks';
6
6
  import { createUID } from '../../utils';
7
7
  import FormField from '../FormField';
8
8
  import Flex from '../Flex';
@@ -11,6 +11,7 @@ import CurrentLocationButton from './CurrentLocationButton';
11
11
  import MapsContext from './MapsContext';
12
12
  import { getPlaceById, getPlacePredictions, loadMapsAPI } from './utils';
13
13
  import LocationView, { StyledLocationView } from './LocationView';
14
+ import { getLocationInputTestIds } from './Location.test-ids';
14
15
  const StyledLocationMap = styled.div `
15
16
  ${StyledLocationView} {
16
17
  border-top-left-radius: 0;
@@ -18,7 +19,8 @@ const StyledLocationMap = styled.div `
18
19
  }
19
20
  `;
20
21
  const LocationInput = forwardRef((props, ref) => {
21
- const { label, labelHidden, id = createUID(), location = '', value = '', info, status, required, readOnly, disabled, additionalInfo, onSelect, onError, onChange, bias, showMap, defaultToCurrentLocation, centerMapOnChange, height, zoomLevel, onClick, onBlur, ...restProps } = props;
22
+ const { testId, label, labelHidden, id = createUID(), location = '', value = '', info, status, required, readOnly, disabled, additionalInfo, onSelect, onError, onChange, bias, showMap, defaultToCurrentLocation, centerMapOnChange, height, zoomLevel, onClick, onBlur, ...restProps } = props;
23
+ const testIds = useTestIds(testId, getLocationInputTestIds);
22
24
  const { name, ...providerOpts } = useContext(MapsContext);
23
25
  const t = useI18n();
24
26
  const [placePredictionMenu, setPlacePredictionMenu] = useState({ items: [] });
@@ -59,7 +61,7 @@ const LocationInput = forwardRef((props, ref) => {
59
61
  onSelect?.(placeInfo);
60
62
  onClick?.(placeInfo);
61
63
  }, [onSelect, onClick]);
62
- const Comp = (_jsxs(_Fragment, { children: [_jsx(ComboBox, { placeholder: t('location_input_placeholder'), menu: filterValue
64
+ const Comp = (_jsxs(_Fragment, { children: [_jsx(ComboBox, { "data-testid": testIds.control, placeholder: t('location_input_placeholder'), menu: filterValue
63
65
  ? {
64
66
  ...placePredictionMenu,
65
67
  items: placePredictionMenu.items.concat({
@@ -90,7 +92,18 @@ const LocationInput = forwardRef((props, ref) => {
90
92
  height,
91
93
  zoomLevel
92
94
  } }) }))] }));
93
- return label ? (_jsx(FormField, { ...{ label, labelHidden, id, info, status, ref, required, disabled, additionalInfo }, children: Comp })) : (Comp);
95
+ return label ? (_jsx(FormField, { ...{
96
+ testId: testIds.root,
97
+ label,
98
+ labelHidden,
99
+ id,
100
+ info,
101
+ status,
102
+ ref,
103
+ required,
104
+ disabled,
105
+ additionalInfo
106
+ }, children: Comp })) : (Comp);
94
107
  });
95
108
  export default LocationInput;
96
109
  //# sourceMappingURL=LocationInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocationInput.js","sourceRoot":"","sources":["../../../src/components/Location/LocationInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAGV,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGzE,OAAO,YAAY,EAAE,EAAqB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AA0CrF,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;IAChC,kBAAkB;;;;CAIrB,CA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,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,YAEpF,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n ChangeEvent,\n FC,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useCallback,\n useContext,\n useEffect,\n useState\n} from 'react';\nimport styled from 'styled-components';\n\nimport ComboBox from '../ComboBox';\nimport { MenuProps } from '../Menu';\nimport { useI18n } from '../../hooks';\nimport { createUID } from '../../utils';\nimport FormField from '../FormField';\nimport { FormControlProps } from '../FormControl';\nimport { BaseProps, ForwardProps } from '../../types';\nimport Flex from '../Flex';\n\nimport PoweredByGoogleImage from './PoweredByGoogleImage';\nimport CurrentLocationButton from './CurrentLocationButton';\nimport MapsContext from './MapsContext';\nimport { getPlaceById, getPlacePredictions, loadMapsAPI } from './utils';\nimport BaseLocationProps from './Location.types';\nimport { LatLng } from './types';\nimport LocationView, { LocationViewProps, StyledLocationView } from './LocationView';\n\nexport interface LocationInputProps\n extends LocationViewProps,\n BaseLocationProps,\n BaseProps,\n FormControlProps {\n /** Button when clicked will show additional information for the location input */\n additionalInfo?: FormControlProps['additionalInfo'];\n /**\n * Get user current location on component first render.\n * @default false\n */\n defaultToCurrentLocation?: boolean;\n /** The value of the location field. */\n value?: string;\n /**\n * Callback fired on every change of the location input.\n * The argument passed back is the component's value prop.\n */\n onChange?: (value: string) => void;\n /**\n * Callback fired when the control's input loses focus.\n * The argument passed back is the component's value prop.\n */\n onBlur?: (value: string) => void;\n /**\n * Set to true renders the map view below input.\n * @default false\n */\n showMap?: boolean;\n /** Location coordinates used for the map view. */\n location?: LatLng | string;\n /** Callback fired when user chooses location from the dropdown of suggestions or submits input value. */\n onSelect?: (value: {\n name?: string;\n address?: string;\n latitude?: number;\n longitude?: number;\n }) => void;\n}\n\nconst StyledLocationMap = styled.div`\n ${StyledLocationView} {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n`;\n\nconst LocationInput: FC<LocationInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<LocationInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n label,\n labelHidden,\n id = createUID(),\n location = '',\n value = '',\n info,\n status,\n required,\n readOnly,\n disabled,\n additionalInfo,\n onSelect,\n onError,\n onChange,\n bias,\n showMap,\n defaultToCurrentLocation,\n centerMapOnChange,\n height,\n zoomLevel,\n onClick,\n onBlur,\n ...restProps\n } = props;\n const { name, ...providerOpts } = useContext(MapsContext);\n const t = useI18n();\n const [placePredictionMenu, setPlacePredictionMenu] = useState<MenuProps>({ items: [] });\n const [filterValue, setFilterValue] = useState('');\n\n useEffect(() => {\n const mapApiPromise = loadMapsAPI(name, providerOpts).catch(error => onError?.(error));\n\n if (filterValue) {\n mapApiPromise\n .then(() => getPlacePredictions(filterValue, bias))\n .then(({ placePredictions, token }) => {\n setPlacePredictionMenu({\n items: placePredictions.map(item => ({\n id: item.place_id,\n primary: item.structured_formatting.main_text,\n secondary: [item.structured_formatting.secondary_text]\n })),\n emptyText: t('location_not_found_text'),\n onItemClick: itemId =>\n getPlaceById(itemId, token).then(arg => {\n setFilterValue('');\n onSelect?.(arg);\n })\n });\n })\n .catch(error => {\n setPlacePredictionMenu({ items: [] });\n onError?.(error);\n });\n } else {\n setPlacePredictionMenu({ items: [] });\n }\n }, [filterValue, bias, onError, onSelect]);\n\n const onInputChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n setFilterValue(e.target.value);\n onChange?.(e.target.value);\n },\n [onChange]\n );\n\n const onMapClick = useCallback(\n (placeInfo: { latitude: number; longitude: number; name?: string; address?: string }) => {\n onSelect?.(placeInfo);\n onClick?.(placeInfo);\n },\n [onSelect, onClick]\n );\n\n const Comp = (\n <>\n <ComboBox\n placeholder={t('location_input_placeholder')}\n menu={\n filterValue\n ? {\n ...placePredictionMenu,\n items: placePredictionMenu.items.concat({\n id: createUID(),\n primary: t('use_input_value', [filterValue])\n }),\n mode: 'action',\n footer: !showMap && (\n <Flex container={{ justify: 'end' }}>\n <PoweredByGoogleImage />\n </Flex>\n )\n }\n : undefined\n }\n actions={\n !disabled &&\n !readOnly && (\n <CurrentLocationButton\n {...{ defaultToCurrentLocation, onError, onChange: onSelect }}\n />\n )\n }\n onChange={onInputChange}\n onBlur={() => {\n setFilterValue('');\n onBlur?.(value);\n }}\n value={value}\n {...{\n required,\n disabled,\n readOnly,\n status,\n ...restProps\n }}\n />\n {showMap && (\n <StyledLocationMap>\n <LocationView\n {...{\n location,\n onClick: onMapClick,\n onError,\n bias,\n disabled,\n readOnly,\n centerMapOnChange,\n height,\n zoomLevel\n }}\n />\n </StyledLocationMap>\n )}\n </>\n );\n\n return label ? (\n <FormField\n {...{ label, labelHidden, id, info, status, ref, required, disabled, additionalInfo }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default LocationInput;\n"]}
1
+ {"version":3,"file":"LocationInput.js","sourceRoot":"","sources":["../../../src/components/Location/LocationInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAGV,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,WAAW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,SAAS;iBACb,GACD,EACD,OAAO,IAAI,CACV,KAAC,iBAAiB,cAChB,KAAC,YAAY,OACP;wBACF,QAAQ;wBACR,OAAO,EAAE,UAAU;wBACnB,OAAO;wBACP,IAAI;wBACJ,QAAQ;wBACR,QAAQ;wBACR,iBAAiB;wBACjB,MAAM;wBACN,SAAS;qBACV,GACD,GACgB,CACrB,IACA,CACJ,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,OACJ;YACF,MAAM,EAAE,OAAO,CAAC,IAAI;YACpB,KAAK;YACL,WAAW;YACX,EAAE;YACF,IAAI;YACJ,MAAM;YACN,GAAG;YACH,QAAQ;YACR,QAAQ;YACR,cAAc;SACf,YAEA,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n ChangeEvent,\n FC,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useCallback,\n useContext,\n useEffect,\n useState\n} from 'react';\nimport styled from 'styled-components';\n\nimport ComboBox from '../ComboBox';\nimport { MenuProps } from '../Menu';\nimport { useI18n, useTestIds } from '../../hooks';\nimport { createUID } from '../../utils';\nimport FormField from '../FormField';\nimport { FormControlProps } from '../FormControl';\nimport { BaseProps, ForwardProps, TestIdProp } from '../../types';\nimport Flex from '../Flex';\n\nimport PoweredByGoogleImage from './PoweredByGoogleImage';\nimport CurrentLocationButton from './CurrentLocationButton';\nimport MapsContext from './MapsContext';\nimport { getPlaceById, getPlacePredictions, loadMapsAPI } from './utils';\nimport BaseLocationProps from './Location.types';\nimport { LatLng } from './types';\nimport LocationView, { LocationViewProps, StyledLocationView } from './LocationView';\nimport { getLocationInputTestIds } from './Location.test-ids';\n\nexport interface LocationInputProps\n extends LocationViewProps,\n BaseLocationProps,\n BaseProps,\n FormControlProps,\n TestIdProp {\n /** Button when clicked will show additional information for the location input */\n additionalInfo?: FormControlProps['additionalInfo'];\n /**\n * Get user current location on component first render.\n * @default false\n */\n defaultToCurrentLocation?: boolean;\n /** The value of the location field. */\n value?: string;\n /**\n * Callback fired on every change of the location input.\n * The argument passed back is the component's value prop.\n */\n onChange?: (value: string) => void;\n /**\n * Callback fired when the control's input loses focus.\n * The argument passed back is the component's value prop.\n */\n onBlur?: (value: string) => void;\n /**\n * Set to true renders the map view below input.\n * @default false\n */\n showMap?: boolean;\n /** Location coordinates used for the map view. */\n location?: LatLng | string;\n /** Callback fired when user chooses location from the dropdown of suggestions or submits input value. */\n onSelect?: (value: {\n name?: string;\n address?: string;\n latitude?: number;\n longitude?: number;\n }) => void;\n}\n\nconst StyledLocationMap = styled.div`\n ${StyledLocationView} {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n`;\n\nconst LocationInput: FC<LocationInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<LocationInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n testId,\n label,\n labelHidden,\n id = createUID(),\n location = '',\n value = '',\n info,\n status,\n required,\n readOnly,\n disabled,\n additionalInfo,\n onSelect,\n onError,\n onChange,\n bias,\n showMap,\n defaultToCurrentLocation,\n centerMapOnChange,\n height,\n zoomLevel,\n onClick,\n onBlur,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getLocationInputTestIds);\n\n const { name, ...providerOpts } = useContext(MapsContext);\n const t = useI18n();\n const [placePredictionMenu, setPlacePredictionMenu] = useState<MenuProps>({ items: [] });\n const [filterValue, setFilterValue] = useState('');\n\n useEffect(() => {\n const mapApiPromise = loadMapsAPI(name, providerOpts).catch(error => onError?.(error));\n\n if (filterValue) {\n mapApiPromise\n .then(() => getPlacePredictions(filterValue, bias))\n .then(({ placePredictions, token }) => {\n setPlacePredictionMenu({\n items: placePredictions.map(item => ({\n id: item.place_id,\n primary: item.structured_formatting.main_text,\n secondary: [item.structured_formatting.secondary_text]\n })),\n emptyText: t('location_not_found_text'),\n onItemClick: itemId =>\n getPlaceById(itemId, token).then(arg => {\n setFilterValue('');\n onSelect?.(arg);\n })\n });\n })\n .catch(error => {\n setPlacePredictionMenu({ items: [] });\n onError?.(error);\n });\n } else {\n setPlacePredictionMenu({ items: [] });\n }\n }, [filterValue, bias, onError, onSelect]);\n\n const onInputChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n setFilterValue(e.target.value);\n onChange?.(e.target.value);\n },\n [onChange]\n );\n\n const onMapClick = useCallback(\n (placeInfo: { latitude: number; longitude: number; name?: string; address?: string }) => {\n onSelect?.(placeInfo);\n onClick?.(placeInfo);\n },\n [onSelect, onClick]\n );\n\n const Comp = (\n <>\n <ComboBox\n data-testid={testIds.control}\n placeholder={t('location_input_placeholder')}\n menu={\n filterValue\n ? {\n ...placePredictionMenu,\n items: placePredictionMenu.items.concat({\n id: createUID(),\n primary: t('use_input_value', [filterValue])\n }),\n mode: 'action',\n footer: !showMap && (\n <Flex container={{ justify: 'end' }}>\n <PoweredByGoogleImage />\n </Flex>\n )\n }\n : undefined\n }\n actions={\n !disabled &&\n !readOnly && (\n <CurrentLocationButton\n {...{ defaultToCurrentLocation, onError, onChange: onSelect }}\n />\n )\n }\n onChange={onInputChange}\n onBlur={() => {\n setFilterValue('');\n onBlur?.(value);\n }}\n value={value}\n {...{\n required,\n disabled,\n readOnly,\n status,\n ...restProps\n }}\n />\n {showMap && (\n <StyledLocationMap>\n <LocationView\n {...{\n location,\n onClick: onMapClick,\n onError,\n bias,\n disabled,\n readOnly,\n centerMapOnChange,\n height,\n zoomLevel\n }}\n />\n </StyledLocationMap>\n )}\n </>\n );\n\n return label ? (\n <FormField\n {...{\n testId: testIds.root,\n label,\n labelHidden,\n id,\n info,\n status,\n ref,\n required,\n disabled,\n additionalInfo\n }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default LocationInput;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/Menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,OAAO,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAC;AAG3D,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CA2VrD,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/Menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAYf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQ3C,OAAO,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAC;AAG3D,QAAA,MAAM,IAAI,EAAE,iBAAiB,CAAC,SAAS,GAAG,YAAY,CA+VrD,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,15 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef, useCallback, useEffect, useState, useRef, useMemo } from 'react';
3
- import { useConsolidatedRef, useUID, useActiveDescendant, useLazyDescendant, useI18n, usePrevious, useDirection } from '../../hooks';
3
+ import { useConsolidatedRef, useUID, useActiveDescendant, useLazyDescendant, useI18n, usePrevious, useDirection, useTestIds } from '../../hooks';
4
4
  import { cap } from '../../utils';
5
5
  import VisuallyHiddenText from '../VisuallyHiddenText';
6
6
  import FlyoutMenuList from './FlyoutMenuList';
7
7
  import MenuContext from './Menu.context';
8
8
  import { StyledMenu, StyledMenuListWrapper } from './Menu.styles';
9
+ import { getMenuTestIds } from './Menu.test-ids';
9
10
  import MenuList from './MenuList';
10
11
  const Menu = forwardRef((props, ref) => {
11
12
  const uid = useUID();
12
- const { id = uid, items = [], mode = 'action', accent, scrollAt = 7, emptyText, onItemClick, onItemActive, onItemExpand, loadMore, onItemCollapse, loading = false, currentItemId, header, footer, variant = 'drill-down', focusControlEl, arrowNavigationUnsupported, 'aria-describedby': ariaDescribedBy, 'aria-label': label, role = 'menu', listId, pauseDescendantEvaluation, ...restProps } = props;
13
+ const { testId, id = uid, items = [], mode = 'action', accent, scrollAt = 7, emptyText, onItemClick, onItemActive, onItemExpand, loadMore, onItemCollapse, loading = false, currentItemId, header, footer, variant = 'drill-down', focusControlEl, arrowNavigationUnsupported, 'aria-describedby': ariaDescribedBy, 'aria-label': label, role = 'menu', listId, pauseDescendantEvaluation, ...restProps } = props;
14
+ const testIds = useTestIds(testId, getMenuTestIds);
13
15
  const t = useI18n();
14
16
  const { end: endDirection, start: startDirection } = useDirection();
15
17
  const radioName = useUID();
@@ -50,7 +52,7 @@ const Menu = forwardRef((props, ref) => {
50
52
  scopeSelector: variant === 'drill-down'
51
53
  ? 'fieldset[aria-hidden="false"]'
52
54
  : activeFlyoutSelector,
53
- selector: `[role="${role === 'menu' ? 'menuitem' : 'option'}"], legend button`,
55
+ selector: `[role="${role === 'menu' ? 'menuitem' : 'option'}"], legend`,
54
56
  focusDescendantEl: focusDescendant,
55
57
  clearFocusDescendant: () => {
56
58
  setFocusDescendant(null);
@@ -94,7 +96,7 @@ const Menu = forwardRef((props, ref) => {
94
96
  if (activeDescendant) {
95
97
  // expand
96
98
  if (activeDescendant.dataset.expand === 'true' && action !== 'collapse') {
97
- activeDescendant.querySelector('button')?.click();
99
+ activeDescendant.querySelector('span[aria-hidden="true"]')?.click();
98
100
  return;
99
101
  }
100
102
  // collapse
@@ -234,7 +236,7 @@ const Menu = forwardRef((props, ref) => {
234
236
  flyOutActiveIdStack,
235
237
  updateParentDescendantStack
236
238
  ]);
237
- return (_jsxs(StyledMenu, { id: id, "aria-describedby": !focusControlEl ? `${id}-menuDescription` : undefined, ...restProps, ref: menuRef, children: [!focusControlEl && (_jsx("span", { id: `${id}-menuDescription`, hidden: true, children: (`${t('menu_selection_instructions')} ` && ariaDescribedBy) || '' })), label && _jsx(VisuallyHiddenText, { id: `${id}-menuLabel`, children: label }), header && _jsx("header", { children: header }), _jsx(StyledMenuListWrapper, { children: _jsx(MenuContext.Provider, { value: contextValue, children: variant === 'drill-down' ? (_jsx(MenuList, { items: items, id: listId, menuRole: role, "aria-labelledby": label ? `${id}-menuLabel` : undefined })) : (_jsx(FlyoutMenuList, { items: items, menuRole: role })) }) }), footer && _jsx("footer", { children: footer })] }));
239
+ return (_jsxs(StyledMenu, { "data-testid": testIds.root, id: id, "aria-describedby": !focusControlEl ? `${id}-menuDescription` : undefined, ...restProps, ref: menuRef, children: [!focusControlEl && (_jsx("span", { id: `${id}-menuDescription`, hidden: true, children: (`${t('menu_selection_instructions')} ` && ariaDescribedBy) || '' })), label && _jsx(VisuallyHiddenText, { id: `${id}-menuLabel`, children: label }), header && _jsx("header", { children: header }), _jsx(StyledMenuListWrapper, { children: _jsx(MenuContext.Provider, { value: contextValue, children: variant === 'drill-down' ? (_jsx(MenuList, { items: items, id: listId, menuRole: role, "aria-labelledby": label ? `${id}-menuLabel` : undefined })) : (_jsx(FlyoutMenuList, { items: items, menuRole: role })) }) }), footer && _jsx("footer", { children: footer })] }));
238
240
  });
239
241
  export default Menu;
240
242
  //# sourceMappingURL=Menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,WAAW,EACX,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACR,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAEvD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,WAAW,MAAM,gBAAgB,CAAC;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AAkB,EAAE,MAAM,kBACtC,CAAC,GAAG,CAAC,CAAC,6BAA6B,CAAC,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,GAC7D,CACR,EACA,KAAK,IAAI,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,EAAE,YAAY,YAAG,KAAK,GAAsB,EAEhF,MAAM,IAAI,2BAAS,MAAM,GAAU,EAEpC,KAAC,qBAAqB,cACpB,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YACtC,OAAO,KAAK,YAAY,CAAC,CAAC,CAAC,CAC1B,KAAC,QAAQ,IACP,KAAK,EAAE,KAAK,EACZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,IAAI,qBACG,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,SAAS,GACtD,CACH,CAAC,CAAC,CAAC,CACF,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAI,CACjD,GACoB,GACD,EACvB,MAAM,IAAI,2BAAS,MAAM,GAAU,IACzB,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useCallback,\n useEffect,\n useState,\n useRef,\n useMemo\n} from 'react';\n\nimport {\n useConsolidatedRef,\n useUID,\n useActiveDescendant,\n useLazyDescendant,\n useI18n,\n usePrevious,\n useDirection\n} from '../../hooks';\nimport { ForwardProps } from '../../types';\nimport { cap } from '../../utils';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport FlyoutMenuList from './FlyoutMenuList';\nimport MenuContext from './Menu.context';\nimport { StyledMenu, StyledMenuListWrapper } from './Menu.styles';\nimport { MenuContextProps, MenuProps } from './Menu.types';\nimport MenuList from './MenuList';\n\nconst Menu: FunctionComponent<MenuProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MenuProps>, ref: MenuProps['ref']) => {\n const uid = useUID();\n const {\n id = uid,\n items = [],\n mode = 'action',\n accent,\n scrollAt = 7,\n emptyText,\n onItemClick,\n onItemActive,\n onItemExpand,\n loadMore,\n onItemCollapse,\n loading = false,\n currentItemId,\n header,\n footer,\n variant = 'drill-down',\n focusControlEl,\n arrowNavigationUnsupported,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': label,\n role = 'menu',\n listId,\n pauseDescendantEvaluation,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n const { end: endDirection, start: startDirection } = useDirection();\n const radioName = useUID();\n const menuRef = useConsolidatedRef(ref);\n const previousItemCount = useRef(0);\n const [activeDescendantUpdateId, setActiveDescendantUpdateId] = useState(0);\n const [focusDescendant, setFocusDescendant] = useState<HTMLElement | null>(null);\n const [flyOutActiveIdStack, setFlyoutActiveIdStack] = useState<string[]>([id]);\n const [focusReturnEl, setFocusReturnEl] = useState<HTMLElement | null>();\n const [preventInitialScroll, setPreventInitialScroll] = useState(false);\n const [flyoutFocusReturnStack, setFlyoutFocusReturnStack] = useState<(HTMLElement | null)[]>(\n []\n );\n\n const activeFlyoutSelector = useMemo(\n () =>\n `fieldset[data-flyout-menu-id=\"${flyOutActiveIdStack[flyOutActiveIdStack.length - 1]}\"]`,\n [flyOutActiveIdStack]\n );\n\n const focusControl = useMemo(() => {\n return focusControlEl || menuRef.current;\n }, [focusControlEl, menuRef.current]);\n\n const pushFlyoutId = useCallback(\n (flyoutId: string) => {\n setFlyoutActiveIdStack([...flyOutActiveIdStack, flyoutId]);\n },\n [flyOutActiveIdStack]\n );\n\n useEffect(() => {\n setFlyoutActiveIdStack([...flyOutActiveIdStack, id]);\n }, [id]);\n\n const updateParentDescendantStack = useCallback(\n (item: HTMLElement | null) => {\n setFlyoutFocusReturnStack([...flyoutFocusReturnStack, item]);\n },\n [flyoutFocusReturnStack]\n );\n\n const getScopedItemId = useCallback(\n (itemId: string) => {\n return `${id}-item-${itemId}`;\n },\n [id]\n );\n\n const getUnscopedItemId = useCallback(\n (itemId: string) => {\n return itemId.split(`${id}-item-`)[1];\n },\n [id]\n );\n\n const updateActiveDescendants: MenuContextProps['updateActiveDescendants'] = useCallback(\n ({ preventScroll = false } = {}) => {\n setPreventInitialScroll(preventScroll);\n setActiveDescendantUpdateId(Math.random());\n },\n []\n );\n\n const uadConfig = useMemo(\n () => ({\n focusEl: focusControl,\n scope: menuRef.current,\n scopeSelector:\n variant === 'drill-down'\n ? ('fieldset[aria-hidden=\"false\"]' as keyof HTMLElementTagNameMap)\n : activeFlyoutSelector,\n selector: `[role=\"${\n role === 'menu' ? 'menuitem' : 'option'\n }\"], legend button` as keyof HTMLElementTagNameMap,\n focusDescendantEl: focusDescendant,\n clearFocusDescendant: () => {\n setFocusDescendant(null);\n },\n focusReturnEl,\n clearFocusReturn: () => {\n setFocusReturnEl(null);\n },\n currentDescendantId: currentItemId ? getScopedItemId(currentItemId) : undefined,\n preventInitialScroll,\n clearPreventScroll: () => {\n setPreventInitialScroll(false);\n },\n pauseDescendantEvaluation\n }),\n [\n focusControl,\n menuRef.current,\n activeFlyoutSelector,\n focusReturnEl,\n focusDescendant,\n currentItemId,\n preventInitialScroll,\n pauseDescendantEvaluation\n ]\n );\n\n const { activeDescendant, descendants } = useActiveDescendant(uadConfig, [\n activeDescendantUpdateId\n ]);\n\n const previousActiveDescendant = usePrevious(activeDescendant);\n\n useLazyDescendant({\n loading,\n descendants,\n previousActiveDescendant,\n activeDescendant,\n focusReturnEl,\n setFocusReturnEl,\n scrollEl: uadConfig.scope?.querySelector(uadConfig.scopeSelector)?.querySelector('ul')\n });\n\n // ## Bind Menu-specific navigation keyDown.\n useEffect(() => {\n const expandOrCollapse: (action?: 'collapse' | 'expand' | null) => void = (action = null) => {\n if (activeDescendant) {\n // expand\n if (activeDescendant.dataset.expand === 'true' && action !== 'collapse') {\n (activeDescendant!.querySelector('button') as HTMLElement)?.click();\n return;\n }\n\n // collapse\n if (action !== 'expand') {\n if (\n variant === 'flyout' &&\n flyOutActiveIdStack.length > 1 &&\n flyoutFocusReturnStack.length > 0\n ) {\n setFlyoutActiveIdStack([...flyOutActiveIdStack].slice(0, -1));\n\n const parentDescendant = flyoutFocusReturnStack.pop();\n if (parentDescendant !== undefined) setFocusReturnEl(parentDescendant);\n updateActiveDescendants();\n } else if (activeDescendant.dataset.collapse === 'true') activeDescendant.click();\n }\n }\n };\n\n const additionalKeydown = (e: KeyboardEvent) => {\n switch (e.key) {\n case `Arrow${cap(endDirection)}`: {\n if (arrowNavigationUnsupported) break;\n expandOrCollapse('expand');\n break;\n }\n case `Arrow${cap(startDirection)}`: {\n if (arrowNavigationUnsupported) break;\n expandOrCollapse('collapse');\n break;\n }\n case 'Escape': {\n if (\n variant === 'flyout' &&\n flyOutActiveIdStack.length > 1 &&\n flyoutFocusReturnStack.length > 0\n ) {\n e.preventDefault();\n e.stopPropagation();\n\n setFlyoutActiveIdStack([...flyOutActiveIdStack].slice(0, -1));\n const parentDescendant = flyoutFocusReturnStack.pop();\n if (parentDescendant !== undefined) setFocusReturnEl(parentDescendant);\n updateActiveDescendants();\n }\n break;\n }\n default:\n break;\n }\n\n if (arrowNavigationUnsupported && (e.key === ' ' || e.key === 'Spacebar') && e.shiftKey) {\n e.preventDefault();\n expandOrCollapse();\n }\n };\n\n if (activeDescendant) onItemActive?.(getUnscopedItemId(activeDescendant.id));\n\n focusControl?.addEventListener('keydown', additionalKeydown);\n\n return () => focusControl?.removeEventListener('keydown', additionalKeydown);\n }, [focusControl, activeDescendant, flyOutActiveIdStack]);\n\n // ## Update useActiveDescendant on change of items, not selection of items.\n useEffect(() => {\n // Next tick for DOM updates.\n const timeoutId = setTimeout(() => {\n if (items.length === previousItemCount.current) {\n const previousDescendantIds = descendants?.map(node => node.id);\n const newDescendants = uadConfig.scope\n ?.querySelector(uadConfig.scopeSelector)\n ?.querySelectorAll(uadConfig.selector);\n\n if (!newDescendants) {\n updateActiveDescendants();\n return;\n }\n\n const scopedDescendants = Array.from(newDescendants);\n\n if (scopedDescendants?.length !== previousDescendantIds?.length) {\n updateActiveDescendants();\n return;\n }\n\n const itemsUnchanged = scopedDescendants.every(\n (node, index) => node.id === previousDescendantIds[index]\n );\n\n if (!itemsUnchanged) {\n updateActiveDescendants();\n }\n\n return;\n }\n\n previousItemCount.current = items.length;\n updateActiveDescendants();\n }, 0);\n\n return () => clearTimeout(timeoutId);\n }, [items]);\n\n const contextValue = useMemo(() => {\n return {\n componentId: id,\n 'aria-label': label,\n mode,\n arrowNavigationUnsupported,\n onItemClick,\n onItemActive,\n onItemExpand,\n onItemCollapse,\n accent,\n scrollAt,\n emptyText,\n radioName,\n loadMore,\n loading,\n variant,\n focusControl,\n updateActiveDescendants,\n setFocusReturnEl,\n setFocusDescendant,\n getScopedItemId,\n pushFlyoutId,\n flyOutActiveIdStack,\n updateParentDescendantStack\n };\n }, [\n id,\n label,\n mode,\n arrowNavigationUnsupported,\n onItemClick,\n onItemActive,\n onItemExpand,\n onItemCollapse,\n accent,\n scrollAt,\n emptyText,\n radioName,\n loadMore,\n loading,\n variant,\n focusControl,\n updateActiveDescendants,\n setFocusReturnEl,\n setFocusDescendant,\n getScopedItemId,\n pushFlyoutId,\n flyOutActiveIdStack,\n updateParentDescendantStack\n ]);\n\n return (\n <StyledMenu\n id={id}\n aria-describedby={!focusControlEl ? `${id}-menuDescription` : undefined}\n {...restProps}\n ref={menuRef}\n >\n {!focusControlEl && (\n <span id={`${id}-menuDescription`} hidden>\n {(`${t('menu_selection_instructions')} ` && ariaDescribedBy) || ''}\n </span>\n )}\n {label && <VisuallyHiddenText id={`${id}-menuLabel`}>{label}</VisuallyHiddenText>}\n\n {header && <header>{header}</header>}\n\n <StyledMenuListWrapper>\n <MenuContext.Provider value={contextValue}>\n {variant === 'drill-down' ? (\n <MenuList\n items={items}\n id={listId}\n menuRole={role}\n aria-labelledby={label ? `${id}-menuLabel` : undefined}\n />\n ) : (\n <FlyoutMenuList items={items} menuRole={role} />\n )}\n </MenuContext.Provider>\n </StyledMenuListWrapper>\n {footer && <footer>{footer}</footer>}\n </StyledMenu>\n );\n }\n);\n\nexport default Menu;\n"]}
1
+ {"version":3,"file":"Menu.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAGV,WAAW,EACX,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACR,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAEvD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,MAAM,IAAI,GAAgD,UAAU,CAClE,CAAC,KAAiC,EAAE,GAAqB,EAAE,EAAE;IAC3D,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,MAAM,EACJ,MAAM,EACN,EAAE,GAAG,GAAG,EACR,KAAK,GAAG,EAAE,EACV,IAAI,GAAG,QAAQ,EACf,MAAM,EACN,QAAQ,GAAG,CAAC,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,OAAO,GAAG,KAAK,EACf,aAAa,EACb,MAAM,EACN,MAAM,EACN,OAAO,GAAG,YAAY,EACtB,cAAc,EACd,0BAA0B,EAC1B,kBAAkB,EAAE,eAAe,EACnC,YAAY,EAAE,KAAK,EACnB,IAAI,GAAG,MAAM,EACb,MAAM,EACN,yBAAyB,EACzB,GAAG,S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,CAAC,CAAC,CAAC,CACF,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAI,CACjD,GACoB,GACD,EACvB,MAAM,IAAI,2BAAS,MAAM,GAAU,IACzB,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n PropsWithoutRef,\n useCallback,\n useEffect,\n useState,\n useRef,\n useMemo\n} from 'react';\n\nimport {\n useConsolidatedRef,\n useUID,\n useActiveDescendant,\n useLazyDescendant,\n useI18n,\n usePrevious,\n useDirection,\n useTestIds\n} from '../../hooks';\nimport { ForwardProps } from '../../types';\nimport { cap } from '../../utils';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport FlyoutMenuList from './FlyoutMenuList';\nimport MenuContext from './Menu.context';\nimport { StyledMenu, StyledMenuListWrapper } from './Menu.styles';\nimport { getMenuTestIds } from './Menu.test-ids';\nimport { MenuContextProps, MenuProps } from './Menu.types';\nimport MenuList from './MenuList';\n\nconst Menu: FunctionComponent<MenuProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MenuProps>, ref: MenuProps['ref']) => {\n const uid = useUID();\n const {\n testId,\n id = uid,\n items = [],\n mode = 'action',\n accent,\n scrollAt = 7,\n emptyText,\n onItemClick,\n onItemActive,\n onItemExpand,\n loadMore,\n onItemCollapse,\n loading = false,\n currentItemId,\n header,\n footer,\n variant = 'drill-down',\n focusControlEl,\n arrowNavigationUnsupported,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': label,\n role = 'menu',\n listId,\n pauseDescendantEvaluation,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getMenuTestIds);\n\n const t = useI18n();\n\n const { end: endDirection, start: startDirection } = useDirection();\n const radioName = useUID();\n const menuRef = useConsolidatedRef(ref);\n const previousItemCount = useRef(0);\n const [activeDescendantUpdateId, setActiveDescendantUpdateId] = useState(0);\n const [focusDescendant, setFocusDescendant] = useState<HTMLElement | null>(null);\n const [flyOutActiveIdStack, setFlyoutActiveIdStack] = useState<string[]>([id]);\n const [focusReturnEl, setFocusReturnEl] = useState<HTMLElement | null>();\n const [preventInitialScroll, setPreventInitialScroll] = useState(false);\n const [flyoutFocusReturnStack, setFlyoutFocusReturnStack] = useState<(HTMLElement | null)[]>(\n []\n );\n\n const activeFlyoutSelector = useMemo(\n () =>\n `fieldset[data-flyout-menu-id=\"${flyOutActiveIdStack[flyOutActiveIdStack.length - 1]}\"]`,\n [flyOutActiveIdStack]\n );\n\n const focusControl = useMemo(() => {\n return focusControlEl || menuRef.current;\n }, [focusControlEl, menuRef.current]);\n\n const pushFlyoutId = useCallback(\n (flyoutId: string) => {\n setFlyoutActiveIdStack([...flyOutActiveIdStack, flyoutId]);\n },\n [flyOutActiveIdStack]\n );\n\n useEffect(() => {\n setFlyoutActiveIdStack([...flyOutActiveIdStack, id]);\n }, [id]);\n\n const updateParentDescendantStack = useCallback(\n (item: HTMLElement | null) => {\n setFlyoutFocusReturnStack([...flyoutFocusReturnStack, item]);\n },\n [flyoutFocusReturnStack]\n );\n\n const getScopedItemId = useCallback(\n (itemId: string) => {\n return `${id}-item-${itemId}`;\n },\n [id]\n );\n\n const getUnscopedItemId = useCallback(\n (itemId: string) => {\n return itemId.split(`${id}-item-`)[1];\n },\n [id]\n );\n\n const updateActiveDescendants: MenuContextProps['updateActiveDescendants'] = useCallback(\n ({ preventScroll = false } = {}) => {\n setPreventInitialScroll(preventScroll);\n setActiveDescendantUpdateId(Math.random());\n },\n []\n );\n\n const uadConfig = useMemo(\n () => ({\n focusEl: focusControl,\n scope: menuRef.current,\n scopeSelector:\n variant === 'drill-down'\n ? ('fieldset[aria-hidden=\"false\"]' as keyof HTMLElementTagNameMap)\n : activeFlyoutSelector,\n selector: `[role=\"${\n role === 'menu' ? 'menuitem' : 'option'\n }\"], legend` as keyof HTMLElementTagNameMap,\n focusDescendantEl: focusDescendant,\n clearFocusDescendant: () => {\n setFocusDescendant(null);\n },\n focusReturnEl,\n clearFocusReturn: () => {\n setFocusReturnEl(null);\n },\n currentDescendantId: currentItemId ? getScopedItemId(currentItemId) : undefined,\n preventInitialScroll,\n clearPreventScroll: () => {\n setPreventInitialScroll(false);\n },\n pauseDescendantEvaluation\n }),\n [\n focusControl,\n menuRef.current,\n activeFlyoutSelector,\n focusReturnEl,\n focusDescendant,\n currentItemId,\n preventInitialScroll,\n pauseDescendantEvaluation\n ]\n );\n\n const { activeDescendant, descendants } = useActiveDescendant(uadConfig, [\n activeDescendantUpdateId\n ]);\n\n const previousActiveDescendant = usePrevious(activeDescendant);\n\n useLazyDescendant({\n loading,\n descendants,\n previousActiveDescendant,\n activeDescendant,\n focusReturnEl,\n setFocusReturnEl,\n scrollEl: uadConfig.scope?.querySelector(uadConfig.scopeSelector)?.querySelector('ul')\n });\n\n // ## Bind Menu-specific navigation keyDown.\n useEffect(() => {\n const expandOrCollapse: (action?: 'collapse' | 'expand' | null) => void = (action = null) => {\n if (activeDescendant) {\n // expand\n if (activeDescendant.dataset.expand === 'true' && action !== 'collapse') {\n activeDescendant.querySelector<HTMLSpanElement>('span[aria-hidden=\"true\"]')?.click();\n return;\n }\n\n // collapse\n if (action !== 'expand') {\n if (\n variant === 'flyout' &&\n flyOutActiveIdStack.length > 1 &&\n flyoutFocusReturnStack.length > 0\n ) {\n setFlyoutActiveIdStack([...flyOutActiveIdStack].slice(0, -1));\n\n const parentDescendant = flyoutFocusReturnStack.pop();\n if (parentDescendant !== undefined) setFocusReturnEl(parentDescendant);\n updateActiveDescendants();\n } else if (activeDescendant.dataset.collapse === 'true') activeDescendant.click();\n }\n }\n };\n\n const additionalKeydown = (e: KeyboardEvent) => {\n switch (e.key) {\n case `Arrow${cap(endDirection)}`: {\n if (arrowNavigationUnsupported) break;\n expandOrCollapse('expand');\n break;\n }\n case `Arrow${cap(startDirection)}`: {\n if (arrowNavigationUnsupported) break;\n expandOrCollapse('collapse');\n break;\n }\n case 'Escape': {\n if (\n variant === 'flyout' &&\n flyOutActiveIdStack.length > 1 &&\n flyoutFocusReturnStack.length > 0\n ) {\n e.preventDefault();\n e.stopPropagation();\n\n setFlyoutActiveIdStack([...flyOutActiveIdStack].slice(0, -1));\n const parentDescendant = flyoutFocusReturnStack.pop();\n if (parentDescendant !== undefined) setFocusReturnEl(parentDescendant);\n updateActiveDescendants();\n }\n break;\n }\n default:\n break;\n }\n\n if (arrowNavigationUnsupported && (e.key === ' ' || e.key === 'Spacebar') && e.shiftKey) {\n e.preventDefault();\n expandOrCollapse();\n }\n };\n\n if (activeDescendant) onItemActive?.(getUnscopedItemId(activeDescendant.id));\n\n focusControl?.addEventListener('keydown', additionalKeydown);\n\n return () => focusControl?.removeEventListener('keydown', additionalKeydown);\n }, [focusControl, activeDescendant, flyOutActiveIdStack]);\n\n // ## Update useActiveDescendant on change of items, not selection of items.\n useEffect(() => {\n // Next tick for DOM updates.\n const timeoutId = setTimeout(() => {\n if (items.length === previousItemCount.current) {\n const previousDescendantIds = descendants?.map(node => node.id);\n const newDescendants = uadConfig.scope\n ?.querySelector(uadConfig.scopeSelector)\n ?.querySelectorAll(uadConfig.selector);\n\n if (!newDescendants) {\n updateActiveDescendants();\n return;\n }\n\n const scopedDescendants = Array.from(newDescendants);\n\n if (scopedDescendants?.length !== previousDescendantIds?.length) {\n updateActiveDescendants();\n return;\n }\n\n const itemsUnchanged = scopedDescendants.every(\n (node, index) => node.id === previousDescendantIds[index]\n );\n\n if (!itemsUnchanged) {\n updateActiveDescendants();\n }\n\n return;\n }\n\n previousItemCount.current = items.length;\n updateActiveDescendants();\n }, 0);\n\n return () => clearTimeout(timeoutId);\n }, [items]);\n\n const contextValue = useMemo(() => {\n return {\n componentId: id,\n 'aria-label': label,\n mode,\n arrowNavigationUnsupported,\n onItemClick,\n onItemActive,\n onItemExpand,\n onItemCollapse,\n accent,\n scrollAt,\n emptyText,\n radioName,\n loadMore,\n loading,\n variant,\n focusControl,\n updateActiveDescendants,\n setFocusReturnEl,\n setFocusDescendant,\n getScopedItemId,\n pushFlyoutId,\n flyOutActiveIdStack,\n updateParentDescendantStack\n };\n }, [\n id,\n label,\n mode,\n arrowNavigationUnsupported,\n onItemClick,\n onItemActive,\n onItemExpand,\n onItemCollapse,\n accent,\n scrollAt,\n emptyText,\n radioName,\n loadMore,\n loading,\n variant,\n focusControl,\n updateActiveDescendants,\n setFocusReturnEl,\n setFocusDescendant,\n getScopedItemId,\n pushFlyoutId,\n flyOutActiveIdStack,\n updateParentDescendantStack\n ]);\n\n return (\n <StyledMenu\n data-testid={testIds.root}\n id={id}\n aria-describedby={!focusControlEl ? `${id}-menuDescription` : undefined}\n {...restProps}\n ref={menuRef}\n >\n {!focusControlEl && (\n <span id={`${id}-menuDescription`} hidden>\n {(`${t('menu_selection_instructions')} ` && ariaDescribedBy) || ''}\n </span>\n )}\n {label && <VisuallyHiddenText id={`${id}-menuLabel`}>{label}</VisuallyHiddenText>}\n\n {header && <header>{header}</header>}\n\n <StyledMenuListWrapper>\n <MenuContext.Provider value={contextValue}>\n {variant === 'drill-down' ? (\n <MenuList\n items={items}\n id={listId}\n menuRole={role}\n aria-labelledby={label ? `${id}-menuLabel` : undefined}\n />\n ) : (\n <FlyoutMenuList items={items} menuRole={role} />\n )}\n </MenuContext.Provider>\n </StyledMenuListWrapper>\n {footer && <footer>{footer}</footer>}\n </StyledMenu>\n );\n }\n);\n\nexport default Menu;\n"]}
@@ -1,7 +1,11 @@
1
+ import { MenuProps } from './Menu.types';
1
2
  export declare const StyledExpandButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Button").ButtonProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
2
- export declare const StyledItemLabel: import("styled-components").StyledComponent<"label", import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const StyledCheckMarkIcon: import("styled-components").StyledComponent<"svg", import("styled-components").DefaultTheme, {}, never>;
3
4
  export declare const StyledMenuItem: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {
4
5
  isParentItem: boolean;
6
+ mode?: MenuProps['mode'];
7
+ isChecked?: boolean | undefined;
8
+ selectableParent?: boolean | undefined;
5
9
  }, never>;
6
10
  export declare const StyledAncestors: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
7
11
  export declare const StyledVisibilityHidden: import("styled-components").StyledComponent<"p", import("styled-components").DefaultTheme, {}, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/Menu.styles.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,kBAAkB,qMAE9B,CAAC;AAEF,eAAO,MAAM,eAAe,2GA8D1B,CAAC;AAIH,eAAO,MAAM,cAAc;kBAA6B,OAAO;SA+C9D,CAAC;AAIF,eAAO,MAAM,eAAe,yGAW3B,CAAC;AAEF,eAAO,MAAM,sBAAsB,uGAElC,CAAC;AAEF,eAAO,MAAM,eAAe,wGAM1B,CAAC;AAIH,eAAO,MAAM,mBAAmB,wGAM9B,CAAC;AAIH,eAAO,MAAM,qBAAqB,yGAUhC,CAAC;AAIH,eAAO,MAAM,oBAAoB,4GAgD/B,CAAC;AAIH,eAAO,MAAM,cAAc,wGAiB1B,CAAC;AAIF,eAAO,MAAM,uBAAuB,8GAOlC,CAAC;AAIH,eAAO,MAAM,6BAA6B,8GAEzC,CAAC;AAEF,eAAO,MAAM,iBAAiB,wGAI7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,yGAqBjC,CAAC;AAIF,eAAO,MAAM,UAAU,yGAyCrB,CAAC"}
1
+ {"version":3,"file":"Menu.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/Menu.styles.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,eAAO,MAAM,kBAAkB,qMAE9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,yGAAuB,CAAC;AAExD,eAAO,MAAM,cAAc;kBACX,OAAO;WACd,SAAS,CAAC,MAAM,CAAC;;;SAqHzB,CAAC;AAIF,eAAO,MAAM,eAAe,yGAW3B,CAAC;AAEF,eAAO,MAAM,sBAAsB,uGAElC,CAAC;AAEF,eAAO,MAAM,eAAe,wGAM1B,CAAC;AAIH,eAAO,MAAM,mBAAmB,wGAM9B,CAAC;AAIH,eAAO,MAAM,qBAAqB,yGAUhC,CAAC;AAIH,eAAO,MAAM,oBAAoB,4GA6C/B,CAAC;AAIH,eAAO,MAAM,cAAc,wGAiB1B,CAAC;AAIF,eAAO,MAAM,uBAAuB,8GAOlC,CAAC;AAIH,eAAO,MAAM,6BAA6B,8GAEzC,CAAC;AAEF,eAAO,MAAM,iBAAiB,wGAI7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,yGAqBjC,CAAC;AAIF,eAAO,MAAM,UAAU,yGAyCrB,CAAC"}
@@ -4,7 +4,6 @@ import { defaultThemeProp } from '../../theme';
4
4
  import { StyledEmptyState } from '../EmptyState';
5
5
  import { StyledIcon } from '../Icon';
6
6
  import { StyledGrid } from '../Grid';
7
- import { StyledBareButton } from '../Button/BareButton';
8
7
  import { tryCatch } from '../../utils';
9
8
  import { StyledText } from '../Text';
10
9
  import { StyledVisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText';
@@ -13,68 +12,16 @@ const listMaxHeight = '50vh';
13
12
  export const StyledExpandButton = styled(Button) `
14
13
  align-self: center;
15
14
  `;
16
- export const StyledItemLabel = styled.label(({ theme }) => {
17
- const hoverCheckColor = tryCatch(() => rgba(theme.components['radio-check'][':checked']['background-color'], theme.base.transparency['transparent-5']));
18
- const checkedBackground = theme.components['radio-check'][':checked']['background-color'];
19
- const checkedForeground = tryCatch(() => readableColor(checkedBackground));
20
- return css `
21
- padding: calc(0.5 * ${theme.base.spacing}) ${theme.base.spacing};
22
- cursor: pointer;
23
-
24
- &:hover {
25
- & > input[type='radio']:not(:checked) + ${StyledIcon} {
26
- color: ${hoverCheckColor};
27
- }
28
-
29
- & > input[type='checkbox'] + ${StyledIcon} {
30
- border-color: ${theme.components['form-control'][':hover']['border-color']};
31
- }
32
- }
33
-
34
- > ${StyledGrid} {
35
- flex-grow: 1;
36
- }
37
-
38
- > input {
39
- ${hideVisually}
40
-
41
- & + ${StyledIcon} {
42
- margin-inline-start: 0;
43
- flex-shrink: 0;
44
- }
45
-
46
- &[type='radio'] + ${StyledIcon} {
47
- color: transparent;
48
- }
49
-
50
- &[type='radio']:checked + ${StyledIcon} {
51
- color: ${checkedBackground};
52
- }
53
-
54
- &[type='checkbox'] + ${StyledIcon} {
55
- border: 0.0625rem solid ${theme.components['radio-check']['border-color']};
56
- border-radius: min(
57
- calc(${theme.base['border-radius']} * ${theme.components.checkbox['border-radius']}),
58
- 0.25rem
59
- );
60
- color: transparent;
61
- background-color: ${theme.components['radio-check']['background-color']};
62
- }
63
-
64
- &[type='checkbox']:checked + ${StyledIcon} {
65
- background-color: ${checkedBackground};
66
- border-color: ${theme.components['radio-check'][':checked']['border-color']};
67
- color: ${checkedForeground};
68
- }
69
- }
70
- `;
71
- });
72
- StyledItemLabel.defaultProps = defaultThemeProp;
73
- export const StyledMenuItem = styled.li(({ theme: { base, components }, isParentItem }) => {
15
+ export const StyledCheckMarkIcon = styled(StyledIcon) ``;
16
+ export const StyledMenuItem = styled.li(({ theme: { base, components }, isParentItem, mode = 'action', 'aria-selected': isChecked = false, selectableParent = false }) => {
74
17
  const activeColor = tryCatch(() => mix(0.85, base.palette['primary-background'], base.palette.interactive));
75
18
  const hoverColor = tryCatch(() => mix(0.95, base.palette['primary-background'], base.palette.interactive));
19
+ const hoverCheckColor = tryCatch(() => rgba(components['radio-check'][':checked']['background-color'], base.transparency['transparent-5']));
20
+ const checkedBackground = components['radio-check'][':checked']['background-color'];
21
+ const checkedForeground = tryCatch(() => readableColor(checkedBackground));
76
22
  return css `
77
23
  min-height: ${base['hit-area']['mouse-min']};
24
+ padding: calc(0.5 * ${base.spacing}) ${base.spacing};
78
25
 
79
26
  @media (pointer: coarse) {
80
27
  min-height: ${base['hit-area']['finger-min']};
@@ -84,30 +31,81 @@ export const StyledMenuItem = styled.li(({ theme: { base, components }, isParent
84
31
  background-color: ${activeColor};
85
32
  }
86
33
 
34
+ &:hover {
35
+ ${StyledCheckMarkIcon} {
36
+ visibility: visible;
37
+ ${mode === 'single-select' &&
38
+ css `
39
+ color: ${isChecked ? checkedBackground : hoverCheckColor};
40
+ `}
41
+ ${mode === 'multi-select' &&
42
+ css `
43
+ ${!isChecked &&
44
+ css `
45
+ border-color: ${components['form-control'][':hover']['border-color']};
46
+ `}
47
+ `}
48
+ }
49
+ }
50
+
87
51
  &:hover:not([aria-disabled='true']) {
88
52
  background-color: ${hoverColor};
89
53
  }
90
54
 
91
- > button:first-child,
92
- > a:first-child {
55
+ a:first-of-type {
93
56
  display: block;
94
57
  width: 100%;
95
- padding: calc(0.5 * ${base.spacing}) ${base.spacing};
96
- text-align: start;
97
58
  text-decoration: none;
98
59
  color: inherit;
99
- ${isParentItem &&
60
+ }
61
+
62
+ ${isParentItem &&
63
+ !selectableParent &&
64
+ (mode === 'multi-select' || mode === 'single-select') &&
100
65
  css `
101
- padding-inline-start: calc(1.125rem + 2 * ${base.spacing});
66
+ padding-inline-start: calc(1.125rem + 2 * ${base.spacing});
67
+ `}
68
+ cursor: pointer;
69
+
70
+ ${StyledGrid} {
71
+ flex-grow: 1;
72
+ }
73
+
74
+ ${StyledCheckMarkIcon} {
75
+ margin-inline-start: 0;
76
+ flex-shrink: 0;
77
+ ${mode === 'single-select' &&
78
+ css `
79
+ ${isChecked
80
+ ? css `
81
+ color: ${checkedBackground};
82
+ `
83
+ : css `
84
+ visibility: hidden;
85
+ `}
86
+ `}
87
+ ${mode === 'multi-select' &&
88
+ css `
89
+ ${isChecked
90
+ ? css `
91
+ color: ${checkedForeground};
92
+ background-color: ${checkedBackground};
93
+ border: 0.0625rem solid ${components['radio-check'][':checked']['border-color']};
94
+ `
95
+ : css `
96
+ color: transparent;
97
+ border: 0.0625rem solid ${components['radio-check']['border-color']};
98
+ `}
99
+ border-radius: min(
100
+ calc(${base['border-radius']} * ${components.checkbox['border-radius']}),
101
+ 0.25rem
102
+ );
102
103
  `}
103
104
  }
104
105
 
105
106
  &[aria-disabled='true'] {
106
- label,
107
- ${StyledBareButton} {
108
- background-color: ${components['form-control'][':disabled']['background-color']};
109
- opacity: ${base['disabled-opacity']};
110
- }
107
+ background-color: ${components['form-control'][':disabled']['background-color']};
108
+ opacity: ${base['disabled-opacity']};
111
109
  }
112
110
  `;
113
111
  });
@@ -137,7 +135,7 @@ export const StyledSeparator = styled.li(({ theme }) => {
137
135
  StyledSeparator.defaultProps = defaultThemeProp;
138
136
  export const StyledMenuGroupList = styled.ul(({ theme }) => {
139
137
  return css `
140
- ${StyledMenuItem} button {
138
+ ${StyledMenuItem} {
141
139
  padding-inline-start: calc(1.5 * ${theme.base.spacing});
142
140
  }
143
141
  `;
@@ -159,6 +157,7 @@ export const StyledMenuListHeader = styled.legend(({ theme: { base } }) => {
159
157
  const hoverColor = tryCatch(() => mix(0.95, base.palette['primary-background'], base.palette.interactive));
160
158
  const activeColor = tryCatch(() => mix(0.85, base.palette['primary-background'], base.palette.interactive));
161
159
  return css `
160
+ cursor: pointer;
162
161
  width: 100%;
163
162
  background-color: ${base.palette['primary-background']};
164
163
 
@@ -180,22 +179,18 @@ export const StyledMenuListHeader = styled.legend(({ theme: { base } }) => {
180
179
  &:hover:not([aria-disabled='true']):not([data-current='true']) {
181
180
  background-color: ${hoverColor};
182
181
  }
182
+ color: ${base.palette['foreground-color']};
183
+ padding: calc(0.5 * ${base.spacing}) ${base.spacing};
184
+ text-align: start;
185
+ border-radius: inherit;
183
186
 
184
- & > ${StyledBareButton}, & > button {
185
- color: ${base.palette['foreground-color']};
186
- width: 100%;
187
- padding: calc(0.5 * ${base.spacing}) ${base.spacing};
188
- text-align: start;
189
- border-radius: inherit;
190
-
191
- > ${StyledGrid} {
192
- grid-column-gap: ${base.spacing};
193
- }
187
+ > ${StyledGrid} {
188
+ grid-column-gap: ${base.spacing};
189
+ }
194
190
 
195
- ${StyledIcon} {
196
- /* Fixes vertical align issue increasing box size beyond square */
197
- display: block;
198
- }
191
+ ${StyledIcon} {
192
+ /* Fixes vertical align issue increasing box size beyond square */
193
+ display: block;
199
194
  }
200
195
  `;
201
196
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.styles.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,MAAM,aAAa,GAAG,MAAM,CAAC;AAE7B,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;;CAE/C,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACxD,MAAM,eAAe,GAAG,QAAQ,CAAC,GAAG,EAAE,CACpC,IAAI,CACF,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,UAAU,CAAC,CAAC,kBAAkB,CAAC,E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AAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;yBAGK,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI;kBACrE,aAAa;;;;;;;;;;;;;;;GAe5B,CACF,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACjD,MAAM,WAAW,GAAG,mBAAmB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;IAC3E,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,EAAE,CAChC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CACpF,CAAC;IAEF,OAAO,GAAG,CAAA;;;;;;;;;;;;0BAYc,WAAW;;;MAG/B,wBAAwB;UACpB,qBAAqB;;;;;;;;iBAQd,KAAK,CAAC,IAAI,CAAC,OAAO;;;;uBAIZ,WAAW;;;;oBAId,WAAW;;GAE5B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import { hideVisually, mix, readableColor, rgba } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { StyledEmptyState } from '../EmptyState';\nimport { StyledIcon } from '../Icon';\nimport { StyledGrid } from '../Grid';\nimport { StyledBareButton } from '../Button/BareButton';\nimport { tryCatch } from '../../utils';\nimport { StyledText } from '../Text';\nimport { StyledVisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText';\nimport Button from '../Button';\n\nconst listMaxHeight = '50vh';\n\nexport const StyledExpandButton = styled(Button)`\n align-self: center;\n`;\n\nexport const StyledItemLabel = styled.label(({ theme }) => {\n const hoverCheckColor = tryCatch(() =>\n rgba(\n theme.components['radio-check'][':checked']['background-color'],\n theme.base.transparency['transparent-5']\n )\n );\n\n const checkedBackground = theme.components['radio-check'][':checked']['background-color'];\n const checkedForeground = tryCatch(() => readableColor(checkedBackground));\n\n return css`\n padding: calc(0.5 * ${theme.base.spacing}) ${theme.base.spacing};\n cursor: pointer;\n\n &:hover {\n & > input[type='radio']:not(:checked) + ${StyledIcon} {\n color: ${hoverCheckColor};\n }\n\n & > input[type='checkbox'] + ${StyledIcon} {\n border-color: ${theme.components['form-control'][':hover']['border-color']};\n }\n }\n\n > ${StyledGrid} {\n flex-grow: 1;\n }\n\n > input {\n ${hideVisually}\n\n & + ${StyledIcon} {\n margin-inline-start: 0;\n flex-shrink: 0;\n }\n\n &[type='radio'] + ${StyledIcon} {\n color: transparent;\n }\n\n &[type='radio']:checked + ${StyledIcon} {\n color: ${checkedBackground};\n }\n\n &[type='checkbox'] + ${StyledIcon} {\n border: 0.0625rem solid ${theme.components['radio-check']['border-color']};\n border-radius: min(\n calc(${theme.base['border-radius']} * ${theme.components.checkbox['border-radius']}),\n 0.25rem\n );\n color: transparent;\n background-color: ${theme.components['radio-check']['background-color']};\n }\n\n &[type='checkbox']:checked + ${StyledIcon} {\n background-color: ${checkedBackground};\n border-color: ${theme.components['radio-check'][':checked']['border-color']};\n color: ${checkedForeground};\n }\n }\n `;\n});\n\nStyledItemLabel.defaultProps = defaultThemeProp;\n\nexport const StyledMenuItem = styled.li<{ isParentItem: boolean }>(\n ({ theme: { base, components }, isParentItem }) => {\n const activeColor = tryCatch(() =>\n mix(0.85, base.palette['primary-background'], base.palette.interactive)\n );\n const hoverColor = tryCatch(() =>\n mix(0.95, base.palette['primary-background'], base.palette.interactive)\n );\n\n return css`\n min-height: ${base['hit-area']['mouse-min']};\n\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n\n &:focus-within {\n background-color: ${activeColor};\n }\n\n &:hover:not([aria-disabled='true']) {\n background-color: ${hoverColor};\n }\n\n > button:first-child,\n > a:first-child {\n display: block;\n width: 100%;\n padding: calc(0.5 * ${base.spacing}) ${base.spacing};\n text-align: start;\n text-decoration: none;\n color: inherit;\n ${isParentItem &&\n css`\n padding-inline-start: calc(1.125rem + 2 * ${base.spacing});\n `}\n }\n\n &[aria-disabled='true'] {\n label,\n ${StyledBareButton} {\n background-color: ${components['form-control'][':disabled']['background-color']};\n opacity: ${base['disabled-opacity']};\n }\n }\n `;\n }\n);\n\nStyledMenuItem.defaultProps = defaultThemeProp;\n\nexport const StyledAncestors = styled.div`\n ${StyledIcon} {\n width: 1em;\n height: 1em;\n }\n\n & > ${StyledText} {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n`;\n\nexport const StyledVisibilityHidden = styled.p`\n ${hideVisually}\n`;\n\nexport const StyledSeparator = styled.li(({ theme }) => {\n return css`\n height: 0.0625rem;\n background-color: ${theme.base.palette['border-line']};\n margin: ${theme.base.spacing} 0;\n `;\n});\n\nStyledSeparator.defaultProps = defaultThemeProp;\n\nexport const StyledMenuGroupList = styled.ul(({ theme }) => {\n return css`\n ${StyledMenuItem} button {\n padding-inline-start: calc(1.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledMenuGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledMenuGroupHeader = styled.div(({ theme }) => {\n return css`\n min-height: ${theme.base['hit-area']['mouse-min']};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n background-color: ${theme.base.palette['secondary-background']};\n\n @media (pointer: coarse) {\n min-height: ${theme.base['hit-area']['finger-min']};\n }\n `;\n});\n\nStyledMenuGroupHeader.defaultProps = defaultThemeProp;\n\nexport const StyledMenuListHeader = styled.legend(({ theme: { base } }) => {\n const hoverColor = tryCatch(() =>\n mix(0.95, base.palette['primary-background'], base.palette.interactive)\n );\n const activeColor = tryCatch(() =>\n mix(0.85, base.palette['primary-background'], base.palette.interactive)\n );\n\n return css`\n width: 100%;\n background-color: ${base.palette['primary-background']};\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n &:focus-within {\n box-shadow: ${base.shadow['focus-inset']};\n background-color: ${activeColor};\n }\n\n &:hover:not([aria-disabled='true']):not([data-current='true']) {\n background-color: ${hoverColor};\n }\n\n & > ${StyledBareButton}, & > button {\n color: ${base.palette['foreground-color']};\n width: 100%;\n padding: calc(0.5 * ${base.spacing}) ${base.spacing};\n text-align: start;\n border-radius: inherit;\n\n > ${StyledGrid} {\n grid-column-gap: ${base.spacing};\n }\n\n ${StyledIcon} {\n /* Fixes vertical align issue increasing box size beyond square */\n display: block;\n }\n }\n `;\n});\n\nStyledMenuListHeader.defaultProps = defaultThemeProp;\n\nexport const StyledMenuList = styled.ul(\n ({ theme }) => css`\n overflow-x: hidden;\n overflow-y: auto;\n list-style: none;\n height: 100%;\n border-radius: inherit;\n\n ${StyledEmptyState} {\n padding: ${theme.base.spacing};\n height: auto;\n }\n\n li:not(:first-child):not([role='presentation']) > ${StyledMenuGroupHeader} {\n margin-block-start: ${theme.base.spacing};\n }\n `\n);\n\nStyledMenuList.defaultProps = defaultThemeProp;\n\nexport const StyledMenuListContainer = styled.fieldset(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['primary-background']};\n max-height: ${listMaxHeight};\n border: 0;\n border-radius: inherit;\n `;\n});\n\nStyledMenuListContainer.defaultProps = defaultThemeProp;\n\nexport const StyledFlyoutMenuListContainer = styled(StyledMenuListContainer)`\n min-width: 10rem;\n`;\n\nexport const StyledLoadingItem = styled.li`\n display: block;\n position: relative;\n height: 2.8rem;\n`;\n\nexport const StyledMenuListWrapper = styled.div(\n ({ theme }) => css`\n position: relative;\n overflow: hidden;\n transition: height ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n max-height: ${listMaxHeight};\n\n & > fieldset:first-child {\n position: relative;\n }\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n `\n);\n\nStyledMenuListWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledMenu = styled.div(({ theme }) => {\n const borderStyle = `0.0625rem solid ${theme.base.palette['border-line']}`;\n const activeColor = tryCatch(() =>\n mix(0.85, theme.base.palette['primary-background'], theme.base.palette.interactive)\n );\n\n return css`\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n &[data-active-scope='true'] [data-current='true'] {\n background-color: ${activeColor};\n }\n\n ${StyledVisuallyHiddenText}:first-child {\n + ${StyledMenuListWrapper}, + header {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n }\n\n > header,\n > footer {\n padding: ${theme.base.spacing};\n }\n\n > header {\n border-bottom: ${borderStyle};\n }\n\n > footer {\n border-top: ${borderStyle};\n }\n `;\n});\n\nStyledMenu.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"Menu.styles.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EA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pF,CAAC;IAEF,OAAO,GAAG,CAAA;;;;;;;;;;;;0BAYc,WAAW;;;MAG/B,wBAAwB;UACpB,qBAAqB;;;;;;;;iBAQd,KAAK,CAAC,IAAI,CAAC,OAAO;;;;uBAIZ,WAAW;;;;oBAId,WAAW;;GAE5B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import { hideVisually, mix, readableColor, rgba } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { StyledEmptyState } from '../EmptyState';\nimport { StyledIcon } from '../Icon';\nimport { StyledGrid } from '../Grid';\nimport { tryCatch } from '../../utils';\nimport { StyledText } from '../Text';\nimport { StyledVisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText';\nimport Button from '../Button';\n\nimport { MenuProps } from './Menu.types';\n\nconst listMaxHeight = '50vh';\n\nexport const StyledExpandButton = styled(Button)`\n align-self: center;\n`;\n\nexport const StyledCheckMarkIcon = styled(StyledIcon)``;\n\nexport const StyledMenuItem = styled.li<{\n isParentItem: boolean;\n mode?: MenuProps['mode'];\n isChecked?: boolean;\n selectableParent?: boolean;\n}>(\n ({\n theme: { base, components },\n isParentItem,\n mode = 'action',\n 'aria-selected': isChecked = false,\n selectableParent = false\n }) => {\n const activeColor = tryCatch(() =>\n mix(0.85, base.palette['primary-background'], base.palette.interactive)\n );\n const hoverColor = tryCatch(() =>\n mix(0.95, base.palette['primary-background'], base.palette.interactive)\n );\n const hoverCheckColor = tryCatch(() =>\n rgba(\n components['radio-check'][':checked']['background-color'],\n base.transparency['transparent-5']\n )\n );\n\n const checkedBackground = components['radio-check'][':checked']['background-color'];\n const checkedForeground = tryCatch(() => readableColor(checkedBackground));\n\n return css`\n min-height: ${base['hit-area']['mouse-min']};\n padding: calc(0.5 * ${base.spacing}) ${base.spacing};\n\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n\n &:focus-within {\n background-color: ${activeColor};\n }\n\n &:hover {\n ${StyledCheckMarkIcon} {\n visibility: visible;\n ${mode === 'single-select' &&\n css`\n color: ${isChecked ? checkedBackground : hoverCheckColor};\n `}\n ${mode === 'multi-select' &&\n css`\n ${!isChecked &&\n css`\n border-color: ${components['form-control'][':hover']['border-color']};\n `}\n `}\n }\n }\n\n &:hover:not([aria-disabled='true']) {\n background-color: ${hoverColor};\n }\n\n a:first-of-type {\n display: block;\n width: 100%;\n text-decoration: none;\n color: inherit;\n }\n\n ${isParentItem &&\n !selectableParent &&\n (mode === 'multi-select' || mode === 'single-select') &&\n css`\n padding-inline-start: calc(1.125rem + 2 * ${base.spacing});\n `}\n cursor: pointer;\n\n ${StyledGrid} {\n flex-grow: 1;\n }\n\n ${StyledCheckMarkIcon} {\n margin-inline-start: 0;\n flex-shrink: 0;\n ${mode === 'single-select' &&\n css`\n ${isChecked\n ? css`\n color: ${checkedBackground};\n `\n : css`\n visibility: hidden;\n `}\n `}\n ${mode === 'multi-select' &&\n css`\n ${isChecked\n ? css`\n color: ${checkedForeground};\n background-color: ${checkedBackground};\n border: 0.0625rem solid ${components['radio-check'][':checked']['border-color']};\n `\n : css`\n color: transparent;\n border: 0.0625rem solid ${components['radio-check']['border-color']};\n `}\n border-radius: min(\n calc(${base['border-radius']} * ${components.checkbox['border-radius']}),\n 0.25rem\n );\n `}\n }\n\n &[aria-disabled='true'] {\n background-color: ${components['form-control'][':disabled']['background-color']};\n opacity: ${base['disabled-opacity']};\n }\n `;\n }\n);\n\nStyledMenuItem.defaultProps = defaultThemeProp;\n\nexport const StyledAncestors = styled.div`\n ${StyledIcon} {\n width: 1em;\n height: 1em;\n }\n\n & > ${StyledText} {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n`;\n\nexport const StyledVisibilityHidden = styled.p`\n ${hideVisually}\n`;\n\nexport const StyledSeparator = styled.li(({ theme }) => {\n return css`\n height: 0.0625rem;\n background-color: ${theme.base.palette['border-line']};\n margin: ${theme.base.spacing} 0;\n `;\n});\n\nStyledSeparator.defaultProps = defaultThemeProp;\n\nexport const StyledMenuGroupList = styled.ul(({ theme }) => {\n return css`\n ${StyledMenuItem} {\n padding-inline-start: calc(1.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledMenuGroupList.defaultProps = defaultThemeProp;\n\nexport const StyledMenuGroupHeader = styled.div(({ theme }) => {\n return css`\n min-height: ${theme.base['hit-area']['mouse-min']};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n background-color: ${theme.base.palette['secondary-background']};\n\n @media (pointer: coarse) {\n min-height: ${theme.base['hit-area']['finger-min']};\n }\n `;\n});\n\nStyledMenuGroupHeader.defaultProps = defaultThemeProp;\n\nexport const StyledMenuListHeader = styled.legend(({ theme: { base } }) => {\n const hoverColor = tryCatch(() =>\n mix(0.95, base.palette['primary-background'], base.palette.interactive)\n );\n const activeColor = tryCatch(() =>\n mix(0.85, base.palette['primary-background'], base.palette.interactive)\n );\n\n return css`\n cursor: pointer;\n width: 100%;\n background-color: ${base.palette['primary-background']};\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n &:focus-within {\n box-shadow: ${base.shadow['focus-inset']};\n background-color: ${activeColor};\n }\n\n &:hover:not([aria-disabled='true']):not([data-current='true']) {\n background-color: ${hoverColor};\n }\n color: ${base.palette['foreground-color']};\n padding: calc(0.5 * ${base.spacing}) ${base.spacing};\n text-align: start;\n border-radius: inherit;\n\n > ${StyledGrid} {\n grid-column-gap: ${base.spacing};\n }\n\n ${StyledIcon} {\n /* Fixes vertical align issue increasing box size beyond square */\n display: block;\n }\n `;\n});\n\nStyledMenuListHeader.defaultProps = defaultThemeProp;\n\nexport const StyledMenuList = styled.ul(\n ({ theme }) => css`\n overflow-x: hidden;\n overflow-y: auto;\n list-style: none;\n height: 100%;\n border-radius: inherit;\n\n ${StyledEmptyState} {\n padding: ${theme.base.spacing};\n height: auto;\n }\n\n li:not(:first-child):not([role='presentation']) > ${StyledMenuGroupHeader} {\n margin-block-start: ${theme.base.spacing};\n }\n `\n);\n\nStyledMenuList.defaultProps = defaultThemeProp;\n\nexport const StyledMenuListContainer = styled.fieldset(({ theme }) => {\n return css`\n background-color: ${theme.base.palette['primary-background']};\n max-height: ${listMaxHeight};\n border: 0;\n border-radius: inherit;\n `;\n});\n\nStyledMenuListContainer.defaultProps = defaultThemeProp;\n\nexport const StyledFlyoutMenuListContainer = styled(StyledMenuListContainer)`\n min-width: 10rem;\n`;\n\nexport const StyledLoadingItem = styled.li`\n display: block;\n position: relative;\n height: 2.8rem;\n`;\n\nexport const StyledMenuListWrapper = styled.div(\n ({ theme }) => css`\n position: relative;\n overflow: hidden;\n transition: height ${theme.base.animation.speed} ${theme.base.animation.timing.ease};\n max-height: ${listMaxHeight};\n\n & > fieldset:first-child {\n position: relative;\n }\n\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n `\n);\n\nStyledMenuListWrapper.defaultProps = defaultThemeProp;\n\nexport const StyledMenu = styled.div(({ theme }) => {\n const borderStyle = `0.0625rem solid ${theme.base.palette['border-line']}`;\n const activeColor = tryCatch(() =>\n mix(0.85, theme.base.palette['primary-background'], theme.base.palette.interactive)\n );\n\n return css`\n &:first-child {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n\n &:last-child {\n border-bottom-left-radius: inherit;\n border-bottom-right-radius: inherit;\n }\n\n &[data-active-scope='true'] [data-current='true'] {\n background-color: ${activeColor};\n }\n\n ${StyledVisuallyHiddenText}:first-child {\n + ${StyledMenuListWrapper}, + header {\n border-top-left-radius: inherit;\n border-top-right-radius: inherit;\n }\n }\n\n > header,\n > footer {\n padding: ${theme.base.spacing};\n }\n\n > header {\n border-bottom: ${borderStyle};\n }\n\n > footer {\n border-top: ${borderStyle};\n }\n `;\n});\n\nStyledMenu.defaultProps = defaultThemeProp;\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const getMenuTestIds: (testIdProp?: string | undefined) => import("../../utils").TestIdsRecord<readonly []>;
2
+ export declare const getMenuItemTestIds: (testIdProp?: string | undefined) => import("../../utils").TestIdsRecord<readonly []>;
3
+ //# sourceMappingURL=Menu.test-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.test-ids.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/Menu.test-ids.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,uFAAqC,CAAC;AAEjE,eAAO,MAAM,kBAAkB,uFAA0C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { createTestIds } from '../../utils';
2
+ export const getMenuTestIds = createTestIds('menu', []);
3
+ export const getMenuItemTestIds = createTestIds('menu-item', []);
4
+ //# sourceMappingURL=Menu.test-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.test-ids.js","sourceRoot":"","sources":["../../../src/components/Menu/Menu.test-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,EAAE,EAAW,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC,WAAW,EAAE,EAAW,CAAC,CAAC","sourcesContent":["import { createTestIds } from '../../utils';\n\nexport const getMenuTestIds = createTestIds('menu', [] as const);\n\nexport const getMenuItemTestIds = createTestIds('menu-item', [] as const);\n"]}