@pega/cosmos-react-core 3.0.0-dev.16.0 → 3.0.0-dev.18.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 (251) hide show
  1. package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
  2. package/lib/components/AppShell/AppHeader.js +4 -6
  3. package/lib/components/AppShell/AppHeader.js.map +1 -1
  4. package/lib/components/AppShell/AppHeader.styles.d.ts +16 -0
  5. package/lib/components/AppShell/AppHeader.styles.d.ts.map +1 -0
  6. package/lib/components/AppShell/AppHeader.styles.js +155 -0
  7. package/lib/components/AppShell/AppHeader.styles.js.map +1 -0
  8. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  9. package/lib/components/AppShell/AppShell.js +44 -157
  10. package/lib/components/AppShell/AppShell.js.map +1 -1
  11. package/lib/components/AppShell/AppShell.styles.d.ts +7 -51
  12. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  13. package/lib/components/AppShell/AppShell.styles.js +44 -535
  14. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  15. package/lib/components/AppShell/AppShell.types.d.ts +16 -5
  16. package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
  17. package/lib/components/AppShell/AppShell.types.js.map +1 -1
  18. package/lib/components/AppShell/AppShellContext.d.ts +2 -0
  19. package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
  20. package/lib/components/AppShell/AppShellContext.js +2 -0
  21. package/lib/components/AppShell/AppShellContext.js.map +1 -1
  22. package/lib/components/AppShell/AppShellList.js +3 -1
  23. package/lib/components/AppShell/AppShellList.js.map +1 -1
  24. package/lib/components/AppShell/AppShellList.styles.d.ts +19 -0
  25. package/lib/components/AppShell/AppShellList.styles.d.ts.map +1 -0
  26. package/lib/components/AppShell/AppShellList.styles.js +141 -0
  27. package/lib/components/AppShell/AppShellList.styles.js.map +1 -0
  28. package/lib/components/AppShell/AppShellSearch.d.ts +10 -0
  29. package/lib/components/AppShell/AppShellSearch.d.ts.map +1 -0
  30. package/lib/components/AppShell/AppShellSearch.js +32 -0
  31. package/lib/components/AppShell/AppShellSearch.js.map +1 -0
  32. package/lib/components/AppShell/AppShellSearch.styles.d.ts +8 -0
  33. package/lib/components/AppShell/AppShellSearch.styles.d.ts.map +1 -0
  34. package/lib/components/AppShell/AppShellSearch.styles.js +190 -0
  35. package/lib/components/AppShell/AppShellSearch.styles.js.map +1 -0
  36. package/lib/components/AppShell/Drawer.js +2 -2
  37. package/lib/components/AppShell/Drawer.js.map +1 -1
  38. package/lib/components/AppShell/Drawer.styles.d.ts +15 -0
  39. package/lib/components/AppShell/Drawer.styles.d.ts.map +1 -0
  40. package/lib/components/AppShell/Drawer.styles.js +153 -0
  41. package/lib/components/AppShell/Drawer.styles.js.map +1 -0
  42. package/lib/components/AppShell/NavigationList.d.ts +5 -0
  43. package/lib/components/AppShell/NavigationList.d.ts.map +1 -0
  44. package/lib/components/AppShell/NavigationList.js +123 -0
  45. package/lib/components/AppShell/NavigationList.js.map +1 -0
  46. package/lib/components/AppShell/NavigationListItemWrapper.d.ts +5 -0
  47. package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -0
  48. package/lib/components/AppShell/NavigationListItemWrapper.js +109 -0
  49. package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -0
  50. package/lib/components/AppShell/Operator.js +4 -4
  51. package/lib/components/AppShell/Operator.js.map +1 -1
  52. package/lib/components/Badges/Keyboard.d.ts.map +1 -1
  53. package/lib/components/Badges/Keyboard.js +2 -0
  54. package/lib/components/Badges/Keyboard.js.map +1 -1
  55. package/lib/components/Badges/Selection.d.ts +1 -1
  56. package/lib/components/Badges/Selection.d.ts.map +1 -1
  57. package/lib/components/Badges/Selection.js +4 -2
  58. package/lib/components/Badges/Selection.js.map +1 -1
  59. package/lib/components/Banner/Banner.d.ts.map +1 -1
  60. package/lib/components/Banner/Banner.js +2 -0
  61. package/lib/components/Banner/Banner.js.map +1 -1
  62. package/lib/components/Breadcrumbs/Breadcrumbs.d.ts +2 -1
  63. package/lib/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  64. package/lib/components/Breadcrumbs/Breadcrumbs.js +37 -10
  65. package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  66. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  67. package/lib/components/ComboBox/ComboBox.js +56 -15
  68. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  69. package/lib/components/ComboBox/ComboBox.styles.d.ts +3 -1
  70. package/lib/components/ComboBox/ComboBox.styles.d.ts.map +1 -1
  71. package/lib/components/ComboBox/ComboBox.types.d.ts +5 -1
  72. package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
  73. package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
  74. package/lib/components/ComboBox/ComboBoxInput.d.ts +7 -0
  75. package/lib/components/ComboBox/ComboBoxInput.d.ts.map +1 -1
  76. package/lib/components/ComboBox/ComboBoxInput.js +5 -2
  77. package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
  78. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  79. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +113 -37
  80. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  81. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts +10 -0
  82. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts.map +1 -1
  83. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.js.map +1 -1
  84. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
  85. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +2 -2
  86. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  87. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts +2 -0
  88. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.d.ts.map +1 -1
  89. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.types.js.map +1 -1
  90. package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
  91. package/lib/components/CompositeInput/CompositeInput.js +2 -2
  92. package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
  93. package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -1
  94. package/lib/components/CompositeInput/CompositeInput.styles.js +19 -17
  95. package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -1
  96. package/lib/components/Currency/CurrencyInput.d.ts.map +1 -1
  97. package/lib/components/Currency/CurrencyInput.js +17 -4
  98. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  99. package/lib/components/Currency/utils.d.ts.map +1 -1
  100. package/lib/components/Currency/utils.js +3 -2
  101. package/lib/components/Currency/utils.js.map +1 -1
  102. package/lib/components/DateTime/DateTime.types.d.ts +2 -0
  103. package/lib/components/DateTime/DateTime.types.d.ts.map +1 -1
  104. package/lib/components/DateTime/DateTime.types.js.map +1 -1
  105. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  106. package/lib/components/DateTime/Input/DateInput.js +12 -3
  107. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  108. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  109. package/lib/components/DateTime/Input/DateTimeInput.js +12 -3
  110. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  111. package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
  112. package/lib/components/DateTime/Picker/Calendar.js +6 -12
  113. package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
  114. package/lib/components/DateTime/Picker/Calendar.styles.d.ts +2 -4
  115. package/lib/components/DateTime/Picker/Calendar.styles.d.ts.map +1 -1
  116. package/lib/components/DateTime/Picker/Calendar.styles.js +13 -55
  117. package/lib/components/DateTime/Picker/Calendar.styles.js.map +1 -1
  118. package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
  119. package/lib/components/DateTime/Picker/DatePicker.js +2 -1
  120. package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
  121. package/lib/components/DateTime/Picker/DatePicker.styles.d.ts +3 -0
  122. package/lib/components/DateTime/Picker/DatePicker.styles.d.ts.map +1 -0
  123. package/lib/components/DateTime/Picker/DatePicker.styles.js +39 -0
  124. package/lib/components/DateTime/Picker/DatePicker.styles.js.map +1 -0
  125. package/lib/components/DateTime/Picker/DateRangePicker.js +1 -1
  126. package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
  127. package/lib/components/DateTime/Picker/TimePicker.d.ts.map +1 -1
  128. package/lib/components/DateTime/Picker/TimePicker.js +10 -5
  129. package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
  130. package/lib/components/DateTime/index.d.ts +2 -0
  131. package/lib/components/DateTime/index.d.ts.map +1 -1
  132. package/lib/components/DateTime/index.js +2 -0
  133. package/lib/components/DateTime/index.js.map +1 -1
  134. package/lib/components/Dialog/Dialog.d.ts.map +1 -1
  135. package/lib/components/Dialog/Dialog.js +3 -2
  136. package/lib/components/Dialog/Dialog.js.map +1 -1
  137. package/lib/components/ExpandCollapse/ExpandCollapse.d.ts.map +1 -1
  138. package/lib/components/ExpandCollapse/ExpandCollapse.js +1 -1
  139. package/lib/components/ExpandCollapse/ExpandCollapse.js.map +1 -1
  140. package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
  141. package/lib/components/FieldGroup/FieldGroup.js +28 -26
  142. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  143. package/lib/components/FormControl/FormControl.d.ts +6 -2
  144. package/lib/components/FormControl/FormControl.d.ts.map +1 -1
  145. package/lib/components/FormControl/FormControl.js +60 -35
  146. package/lib/components/FormControl/FormControl.js.map +1 -1
  147. package/lib/components/FormField/FormField.d.ts.map +1 -1
  148. package/lib/components/FormField/FormField.js +65 -5
  149. package/lib/components/FormField/FormField.js.map +1 -1
  150. package/lib/components/Input/Input.d.ts.map +1 -1
  151. package/lib/components/Input/Input.js +13 -2
  152. package/lib/components/Input/Input.js.map +1 -1
  153. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  154. package/lib/components/ListToolbar/ListToolbar.js +64 -9
  155. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  156. package/lib/components/ListToolbar/ListToolbar.types.d.ts +2 -0
  157. package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
  158. package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
  159. package/lib/components/ListToolbar/PresetMenuPopover.d.ts +12 -0
  160. package/lib/components/ListToolbar/PresetMenuPopover.d.ts.map +1 -0
  161. package/lib/components/ListToolbar/PresetMenuPopover.js +36 -0
  162. package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -0
  163. package/lib/components/ListToolbar/QueryOptionPopover.d.ts.map +1 -1
  164. package/lib/components/ListToolbar/QueryOptionPopover.js +14 -44
  165. package/lib/components/ListToolbar/QueryOptionPopover.js.map +1 -1
  166. package/lib/components/Menu/Menu.d.ts.map +1 -1
  167. package/lib/components/Menu/Menu.js +8 -5
  168. package/lib/components/Menu/Menu.js.map +1 -1
  169. package/lib/components/Menu/Menu.styles.js +1 -1
  170. package/lib/components/Menu/Menu.styles.js.map +1 -1
  171. package/lib/components/Menu/Menu.types.d.ts +13 -0
  172. package/lib/components/Menu/Menu.types.d.ts.map +1 -1
  173. package/lib/components/Menu/Menu.types.js.map +1 -1
  174. package/lib/components/Menu/MenuGroup.d.ts.map +1 -1
  175. package/lib/components/Menu/MenuGroup.js +3 -3
  176. package/lib/components/Menu/MenuGroup.js.map +1 -1
  177. package/lib/components/Menu/MenuItem.d.ts.map +1 -1
  178. package/lib/components/Menu/MenuItem.js +3 -5
  179. package/lib/components/Menu/MenuItem.js.map +1 -1
  180. package/lib/components/Menu/MenuList.d.ts.map +1 -1
  181. package/lib/components/Menu/MenuList.js +14 -14
  182. package/lib/components/Menu/MenuList.js.map +1 -1
  183. package/lib/components/MetaList/MetaList.d.ts.map +1 -1
  184. package/lib/components/MetaList/MetaList.js +13 -10
  185. package/lib/components/MetaList/MetaList.js.map +1 -1
  186. package/lib/components/Number/NumberInput.d.ts.map +1 -1
  187. package/lib/components/Number/NumberInput.js +18 -5
  188. package/lib/components/Number/NumberInput.js.map +1 -1
  189. package/lib/components/Number/NumberInput.styles.d.ts +6 -2
  190. package/lib/components/Number/NumberInput.styles.d.ts.map +1 -1
  191. package/lib/components/Number/NumberInput.styles.js +4 -2
  192. package/lib/components/Number/NumberInput.styles.js.map +1 -1
  193. package/lib/components/Number/NumberInput.types.d.ts +2 -0
  194. package/lib/components/Number/NumberInput.types.d.ts.map +1 -1
  195. package/lib/components/Number/NumberInput.types.js.map +1 -1
  196. package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
  197. package/lib/components/PageTemplates/DashboardPage.js +1 -4
  198. package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
  199. package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
  200. package/lib/components/Phone/PhoneInput.js +12 -3
  201. package/lib/components/Phone/PhoneInput.js.map +1 -1
  202. package/lib/components/SearchInput/SearchInput.d.ts +5 -0
  203. package/lib/components/SearchInput/SearchInput.d.ts.map +1 -1
  204. package/lib/components/SearchInput/SearchInput.js +14 -4
  205. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  206. package/lib/components/SearchInput/SearchInput.styles.d.ts +3 -0
  207. package/lib/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  208. package/lib/components/SearchInput/SearchInput.styles.js +6 -0
  209. package/lib/components/SearchInput/SearchInput.styles.js.map +1 -1
  210. package/lib/components/Select/Select.d.ts +2 -0
  211. package/lib/components/Select/Select.d.ts.map +1 -1
  212. package/lib/components/Select/Select.js +4 -3
  213. package/lib/components/Select/Select.js.map +1 -1
  214. package/lib/components/Skeleton/ParagraphSkeleton.d.ts.map +1 -1
  215. package/lib/components/Skeleton/ParagraphSkeleton.js +2 -2
  216. package/lib/components/Skeleton/ParagraphSkeleton.js.map +1 -1
  217. package/lib/components/Tabs/TabPanel.d.ts.map +1 -1
  218. package/lib/components/Tabs/TabPanel.js +1 -7
  219. package/lib/components/Tabs/TabPanel.js.map +1 -1
  220. package/lib/components/Text/Text.js +2 -2
  221. package/lib/components/Text/Text.js.map +1 -1
  222. package/lib/components/TextArea/TextArea.d.ts.map +1 -1
  223. package/lib/components/TextArea/TextArea.js +4 -2
  224. package/lib/components/TextArea/TextArea.js.map +1 -1
  225. package/lib/components/Tooltip/Tooltip.d.ts +5 -0
  226. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  227. package/lib/components/Tooltip/Tooltip.js +22 -5
  228. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  229. package/lib/hooks/useActiveDescendant.d.ts +5 -1
  230. package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
  231. package/lib/hooks/useActiveDescendant.js +166 -95
  232. package/lib/hooks/useActiveDescendant.js.map +1 -1
  233. package/lib/hooks/useI18n.d.ts +36 -1
  234. package/lib/hooks/useI18n.d.ts.map +1 -1
  235. package/lib/hooks/useI18n.js +2 -1
  236. package/lib/hooks/useI18n.js.map +1 -1
  237. package/lib/i18n/default.d.ts +36 -1
  238. package/lib/i18n/default.d.ts.map +1 -1
  239. package/lib/i18n/default.js +50 -14
  240. package/lib/i18n/default.js.map +1 -1
  241. package/lib/i18n/i18n.d.ts +72 -2
  242. package/lib/i18n/i18n.d.ts.map +1 -1
  243. package/lib/i18n/translate.d.ts +3 -0
  244. package/lib/i18n/translate.d.ts.map +1 -1
  245. package/lib/i18n/translate.js.map +1 -1
  246. package/lib/theme/theme.d.ts +12 -0
  247. package/lib/theme/theme.d.ts.map +1 -1
  248. package/lib/theme/themeDefinition.json +7 -1
  249. package/lib/theme/themeOverrides.schema.json +9 -0
  250. package/lib/theme/themes/darkTheme.json +3 -1
  251. package/package.json +1 -1
@@ -1,12 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cloneElement, useEffect, useState, forwardRef } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
+ import { readableColor, rgba } from 'polished';
4
5
  import { defaultThemeProp } from '../../theme';
5
6
  import Flex from '../Flex';
6
7
  import Actions from '../Actions';
7
- import { useUID } from '../../hooks';
8
+ import { useConsolidatedRef, useI18n, useUID } from '../../hooks';
8
9
  import Label, { StyledLabel } from '../Label';
9
- import { calculateFontSize } from '../../styles';
10
+ import { calculateFontSize, getHoverColors } from '../../styles';
11
+ import VisuallyHiddenText from '../VisuallyHiddenText';
12
+ import { getFocusables, tryCatch } from '../../utils';
13
+ import Button from '../Button';
10
14
  import Icon, { registerIcon } from '../Icon';
11
15
  import * as warnSolidIcon from '../Icon/icons/warn-solid.icon';
12
16
  import * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';
@@ -66,15 +70,52 @@ export const StyledFormField = styled.div(props => {
66
70
  `;
67
71
  });
68
72
  StyledFormField.defaultProps = defaultThemeProp;
73
+ const StyledSuggestionButton = styled(Button)(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, 'border-radius': baseRadius, spacing }, components: { 'form-control': { 'border-radius': radius, 'border-width': borderWidth }, 'form-field': formField } } }) => {
74
+ const { xxs: buttonFontSize } = calculateFontSize(fontSize, fontScale);
75
+ const backgroundColor = formField.pending['status-color'];
76
+ const hoverColors = getHoverColors(backgroundColor);
77
+ const color = tryCatch(() => readableColor(backgroundColor));
78
+ const borderColor = color ? rgba(color, 0.4) : color;
79
+ return css `
80
+ background-color: ${backgroundColor};
81
+ color: ${color};
82
+ font-size: ${buttonFontSize};
83
+ min-width: calc(3 * ${spacing});
84
+ min-height: calc(3 * ${spacing});
85
+ padding: 0 ${spacing};
86
+ border-radius: 0;
87
+ border: none;
88
+ &:first-child {
89
+ border-inline-end: ${borderWidth} solid ${borderColor};
90
+ border-end-start-radius: calc(${baseRadius} * ${radius});
91
+ margin-inline-start: calc(2 * ${spacing});
92
+ }
93
+ &:last-child {
94
+ border-end-end-radius: calc(${baseRadius} * ${radius});
95
+ margin-inline-start: 0;
96
+ }
97
+ &:hover {
98
+ background-color: ${hoverColors.background};
99
+ }
100
+
101
+ @media (pointer: coarse) {
102
+ min-height: 2rem;
103
+ }
104
+ `;
105
+ });
106
+ StyledSuggestionButton.defaultProps = defaultThemeProp;
69
107
  const statusIconMap = { error: 'warn-solid', warning: 'flag-wave-solid', success: 'check' };
70
108
  const FormField = forwardRef((props, ref) => {
71
109
  const uid = useUID();
72
- const { children: controlElement, id = uid, as = 'div', label, labelAs = 'label', labelFor = id, labelId, labelHidden = false, labelAfter = false, info, status, charLimitDisplay, required = false, disabled = false, readOnly = false, inline = false, actions, container, ...restProps } = props;
110
+ const { children: controlElement, id = uid, as = 'div', label, labelAs = 'label', labelFor = id, labelId, labelHidden = false, labelAfter = false, info, status, charLimitDisplay, required = false, disabled = false, readOnly = false, inline = false, actions, container, onResolveSuggestion, ...restProps } = props;
111
+ const t = useI18n();
73
112
  const labelAsLegend = labelAs === 'legend';
113
+ const hasSuggestion = status === 'pending' && !!onResolveSuggestion;
114
+ const consolidatedRef = useConsolidatedRef(ref);
74
115
  const styledLabel = (_jsxs(Label, { id: labelId, as: labelAs, htmlFor: labelAs === 'label' ? labelFor : undefined, labelHidden: labelHidden, onClick: (e) => {
75
116
  if (readOnly)
76
117
  e.preventDefault();
77
- }, inline: inline, children: [status && !labelHidden && (_jsx(StyledStatusIcon, { status: status, name: statusIconMap[status] })), label] }));
118
+ }, inline: inline, children: [status && status !== 'pending' && !labelHidden && (_jsx(StyledStatusIcon, { status: status, name: statusIconMap[status] })), label] }));
78
119
  /*
79
120
  We have to use an internal state and an effect to set the text value of info after the DOM element is rendered.
80
121
  This is to ensure screen readers will announce info on errors when role is set to alert.
@@ -107,11 +148,30 @@ const FormField = forwardRef((props, ref) => {
107
148
  if (charLimitDisplay) {
108
149
  infoContent = (_jsxs(Flex, { container: { justify: infoContent ? 'between' : 'end', gap: 1 }, children: [infoContent, _jsx(Flex, { item: { shrink: 0 }, children: charLimitDisplay })] }));
109
150
  }
151
+ if (hasSuggestion) {
152
+ const focusables = getFocusables(consolidatedRef);
153
+ infoContent = (_jsxs(Flex, { container: { alignItems: 'start', justify: 'between' }, children: [_jsxs(StyledFormFieldInfo, { status: status, id: `${id}-info`, children: [t('suggestion_info'), _jsx(VisuallyHiddenText, { "aria-live": 'polite', children: t('suggestion_assist') })] }), _jsxs(Flex, { container: { wrap: 'nowrap' }, children: [_jsx(StyledSuggestionButton, { onClick: () => {
154
+ onResolveSuggestion(false);
155
+ focusables[0]?.focus();
156
+ }, "aria-label": t('reject_suggestion_button_a11y'), children: t('no') }), _jsx(StyledSuggestionButton, { onClick: () => {
157
+ onResolveSuggestion(true);
158
+ focusables[0]?.focus();
159
+ }, "aria-label": t('accept_suggestion_button_a11y'), children: t('yes') })] })] }));
160
+ }
161
+ const onKeyDown = (e) => {
162
+ if (e.key === 'Enter') {
163
+ const target = e.target;
164
+ if (!target.closest('button')) {
165
+ e.preventDefault();
166
+ onResolveSuggestion?.(true);
167
+ }
168
+ }
169
+ };
110
170
  return (_jsxs(Flex, { ...restProps, container: {
111
171
  direction: inline ? 'row' : 'column',
112
172
  alignItems: inline ? 'center' : undefined,
113
173
  ...container
114
- }, as: StyledFormField, id: `${id}-field`, forwardedAs: as, required: required, disabled: disabled, readOnly: readOnly, "aria-describedby": labelAsLegend && info ? `${id}-info` : undefined, ref: ref, children: [(labelAsLegend || !labelAfter) && styledLabel, content, !labelAsLegend && labelAfter && styledLabel, infoContent] }));
174
+ }, as: StyledFormField, id: `${id}-field`, forwardedAs: as, required: required, disabled: disabled, readOnly: readOnly, onKeyDown: hasSuggestion ? onKeyDown : undefined, "aria-describedby": labelAsLegend && info ? `${id}-info` : undefined, ref: consolidatedRef, children: [(labelAsLegend || !labelAfter) && styledLabel, content, !labelAsLegend && labelAfter && styledLabel, infoContent] }));
115
175
  });
116
176
  export default FormField;
117
177
  //# sourceMappingURL=FormField.js.map
@@ -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,GAAG,EAAE,QAAQ,EACjB,WAAW,EAAE,EAAE,EACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,sBACA,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,EAClE,GAAG,EAAE,GAAG,aAEP,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,IAAI,WAAW,EAC7C,OAAO,EACP,CAAC,aAAa,IAAI,UAAU,IAAI,WAAW,EAC3C,WAAW,IACP,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import {\n FC,\n ReactNode,\n ComponentType,\n cloneElement,\n ReactElement,\n useEffect,\n useState,\n PropsWithoutRef,\n forwardRef,\n Ref\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { Action, ForwardProps, OmitStrict } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport Actions from '../Actions';\nimport { FormControlProps } from '../FormControl';\nimport { useUID } from '../../hooks';\nimport Label, { LabelProps, StyledLabel } from '../Label';\nimport { calculateFontSize } from '../../styles';\nimport Icon, { registerIcon } from '../Icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\n\nregisterIcon(warnSolidIcon, flagWaveSolidIcon, checkIcon);\n\nexport interface FormFieldProps\n extends OmitStrict<FormControlProps, 'placeholder' | 'value' | 'defaultValue'> {\n /** Pass a single form control component i.e. Input | TextArea | Select | etc.. */\n children: ReactElement | ReactElement[];\n /**\n * An id is required to connect a FormField's wrapping element, control element and info(aria-describedby) live region.\n * A random id will be generated if none is provided.\n * Since MOST FormControls should possess an id(excl. i.e RadioCheckGroup and others) this can be used.\n * The id prop will be used to generate the following:\n * - FormControl <-> Label association via a Label's htmlFor prop.\n * - FormField's wrapping element id {id}-field.\n * - FormField info element id ${id}-info.\n */\n id?: string;\n /**\n * Determines how the wrapping label should be rendered.\n * @default \"label\"\n */\n labelAs?: LabelProps['as'];\n /**\n * Overrides the for attribute on the label. If this is not set it will default to the forms id.\n * @default undefined\n */\n labelFor?: LabelProps['htmlFor'];\n /**\n * Sets the id of the label.\n * @default undefined\n */\n labelId?: LabelProps['id'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: boolean;\n /**\n * Visually places the label after the input.\n * @default false\n */\n labelAfter?: boolean;\n /**\n * Wrapping HTML element tag. Renders as a fieldset for grouped elements i.e. RadioButtons/CheckboxGroup\n * @default \"div\"\n */\n as?: 'div' | 'fieldset' | ComponentType<any>;\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: boolean;\n /** Optionally utilized by Input or Select. */\n actions?: Action[];\n /** Enables Flex container prop pass through. */\n container?: Exclude<FlexProps['container'], boolean>;\n /** Character remaining count. Typically used on Textareas only */\n charLimitDisplay?: ReactNode;\n}\n\nconst StyledStatusIcon = styled(Icon)<{ status: NonNullable<FormFieldProps['status']> }>(\n ({ theme, status }) => {\n return css`\n height: 1em;\n width: 1em;\n color: ${theme.components['form-field'][status]['status-color']};\n vertical-align: baseline;\n margin-inline-end: 0.5ch;\n `;\n }\n);\n\nStyledStatusIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFormFieldInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { 'form-field': formField }\n }\n }) => {\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n max-width: max-content;\n margin-top: calc(0.25 * ${spacing});\n font-size: ${infoFontSize};\n word-break: break-word;\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `;\n }\n);\n\nStyledFormFieldInfo.defaultProps = defaultThemeProp;\n\nexport const StyledFormField = styled.div<FormFieldProps>(props => {\n const {\n disabled,\n required,\n theme: {\n base: {\n palette: { urgent },\n 'disabled-opacity': disabledOpacity,\n spacing\n }\n }\n } = props;\n\n return css`\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n -webkit-user-select: none;\n user-select: none;\n `}\n position: relative;\n border: 0;\n\n > ${StyledLabel} {\n margin-bottom: calc(0.25 * ${spacing});\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n }\n `;\n});\n\nStyledFormField.defaultProps = defaultThemeProp;\n\nconst statusIconMap = { error: 'warn-solid', warning: 'flag-wave-solid', success: 'check' };\n\nconst FormField: FC<FormFieldProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FormFieldProps>, ref: Ref<HTMLElement>) => {\n const uid = useUID();\n const {\n children: controlElement,\n id = uid,\n as = 'div',\n label,\n labelAs = 'label',\n labelFor = id,\n labelId,\n labelHidden = false,\n labelAfter = false,\n info,\n status,\n charLimitDisplay,\n required = false,\n disabled = false,\n readOnly = false,\n inline = false,\n actions,\n container,\n ...restProps\n } = props;\n\n const labelAsLegend: boolean = labelAs === 'legend';\n\n const styledLabel = (\n <Label\n id={labelId}\n as={labelAs}\n htmlFor={labelAs === 'label' ? labelFor : undefined}\n labelHidden={labelHidden}\n onClick={(e: MouseEvent) => {\n if (readOnly) e.preventDefault();\n }}\n inline={inline}\n >\n {status && !labelHidden && (\n <StyledStatusIcon status={status} name={statusIconMap[status]} />\n )}\n {label}\n </Label>\n );\n\n /*\n We have to use an internal state and an effect to set the text value of info after the DOM element is rendered.\n This is to ensure screen readers will announce info on errors when role is set to alert.\n Needs testing to confirm. Currently the expected sequence would be:\n - FormField renders with no error and no info\n - user input triggers an error status\n - props passed set error status and provide info text\n - effect runs and sets live region state which renders and is announced\n */\n const [liveRegionInfo, setLiveRegionInfo] = useState<ReactNode>(null);\n\n useEffect(() => {\n setLiveRegionInfo(info);\n }, [info]);\n\n // fieldset or single form control element\n let content: FormFieldProps['children'] = labelAsLegend\n ? controlElement\n : cloneElement(controlElement as ReactElement, {\n 'aria-describedby': info && `${id}-info`\n });\n\n if (actions) {\n content = (\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {content}\n <Actions items={actions} menuAt={3} />\n </Flex>\n );\n }\n\n let infoContent = info ? (\n /*\n Region for additional info, help or error message.\n Withholding aria-live=\"assertive\" to avoid iOS issue. See below.\n https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions#Preferring_specialized_live_region_roles\n */\n <StyledFormFieldInfo\n status={status}\n role={status === 'error' || status === 'warning' ? 'alert' : undefined}\n id={`${id}-info`}\n >\n {liveRegionInfo}\n </StyledFormFieldInfo>\n ) : undefined;\n\n if (charLimitDisplay) {\n infoContent = (\n <Flex container={{ justify: infoContent ? 'between' : 'end', gap: 1 }}>\n {infoContent}\n <Flex item={{ shrink: 0 }}>{charLimitDisplay}</Flex>\n </Flex>\n );\n }\n\n return (\n <Flex\n {...restProps}\n container={{\n direction: inline ? 'row' : 'column',\n alignItems: inline ? 'center' : undefined,\n ...container\n }}\n as={StyledFormField}\n id={`${id}-field`}\n forwardedAs={as}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n aria-describedby={labelAsLegend && info ? `${id}-info` : undefined}\n ref={ref}\n >\n {(labelAsLegend || !labelAfter) && styledLabel}\n {content}\n {!labelAsLegend && labelAfter && styledLabel}\n {infoContent}\n </Flex>\n );\n }\n);\n\nexport default FormField;\n"]}
1
+ {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/FormField/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAIL,YAAY,EAEZ,SAAS,EACT,QAAQ,EAER,UAAU,EAEX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE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EAAE,eAAe,EACnB,EAAE,EAAE,GAAG,EAAE,QAAQ,EACjB,WAAW,EAAE,EAAE,EACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,sBAC9B,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,EAClE,GAAG,EAAE,eAAe,aAEnB,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,IAAI,WAAW,EAC7C,OAAO,EACP,CAAC,aAAa,IAAI,UAAU,IAAI,WAAW,EAC3C,WAAW,IACP,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import {\n FC,\n ReactNode,\n ComponentType,\n cloneElement,\n ReactElement,\n useEffect,\n useState,\n PropsWithoutRef,\n forwardRef,\n Ref\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor, rgba } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport { Action, ForwardProps, OmitStrict } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport Actions from '../Actions';\nimport { FormControlProps } from '../FormControl';\nimport { useConsolidatedRef, useI18n, useUID } from '../../hooks';\nimport Label, { LabelProps, StyledLabel } from '../Label';\nimport { calculateFontSize, getHoverColors } from '../../styles';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport { getFocusables, tryCatch } from '../../utils';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\n\nregisterIcon(warnSolidIcon, flagWaveSolidIcon, checkIcon);\n\nexport interface FormFieldProps\n extends OmitStrict<FormControlProps, 'placeholder' | 'value' | 'defaultValue'> {\n /** Pass a single form control component i.e. Input | TextArea | Select | etc.. */\n children: ReactElement | ReactElement[];\n /**\n * An id is required to connect a FormField's wrapping element, control element and info(aria-describedby) live region.\n * A random id will be generated if none is provided.\n * Since MOST FormControls should possess an id(excl. i.e RadioCheckGroup and others) this can be used.\n * The id prop will be used to generate the following:\n * - FormControl <-> Label association via a Label's htmlFor prop.\n * - FormField's wrapping element id {id}-field.\n * - FormField info element id ${id}-info.\n */\n id?: string;\n /**\n * Determines how the wrapping label should be rendered.\n * @default \"label\"\n */\n labelAs?: LabelProps['as'];\n /**\n * Overrides the for attribute on the label. If this is not set it will default to the forms id.\n * @default undefined\n */\n labelFor?: LabelProps['htmlFor'];\n /**\n * Sets the id of the label.\n * @default undefined\n */\n labelId?: LabelProps['id'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: boolean;\n /**\n * Visually places the label after the input.\n * @default false\n */\n labelAfter?: boolean;\n /**\n * Wrapping HTML element tag. Renders as a fieldset for grouped elements i.e. RadioButtons/CheckboxGroup\n * @default \"div\"\n */\n as?: 'div' | 'fieldset' | ComponentType<any>;\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: boolean;\n /** Optionally utilized by Input or Select. */\n actions?: Action[];\n /** Enables Flex container prop pass through. */\n container?: Exclude<FlexProps['container'], boolean>;\n /** Character remaining count. Typically used on Textareas only */\n charLimitDisplay?: ReactNode;\n}\n\nconst StyledStatusIcon = styled(Icon)<{ status: NonNullable<FormFieldProps['status']> }>(\n ({ theme, status }) => {\n return css`\n height: 1em;\n width: 1em;\n color: ${theme.components['form-field'][status]['status-color']};\n vertical-align: baseline;\n margin-inline-end: 0.5ch;\n `;\n }\n);\n\nStyledStatusIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFormFieldInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { 'form-field': formField }\n }\n }) => {\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n max-width: max-content;\n margin-top: calc(0.25 * ${spacing});\n font-size: ${infoFontSize};\n word-break: break-word;\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `;\n }\n);\n\nStyledFormFieldInfo.defaultProps = defaultThemeProp;\n\nexport const StyledFormField = styled.div<FormFieldProps>(props => {\n const {\n disabled,\n required,\n theme: {\n base: {\n palette: { urgent },\n 'disabled-opacity': disabledOpacity,\n spacing\n }\n }\n } = props;\n\n return css`\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n -webkit-user-select: none;\n user-select: none;\n `}\n position: relative;\n border: 0;\n\n > ${StyledLabel} {\n margin-bottom: calc(0.25 * ${spacing});\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n\n &::after {\n display: ${required ? 'inline' : 'none'};\n content: '\\\\00a0*';\n vertical-align: top;\n color: ${urgent};\n }\n }\n `;\n});\n\nStyledFormField.defaultProps = defaultThemeProp;\n\nconst StyledSuggestionButton = styled(Button)(\n ({\n theme: {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n 'border-radius': baseRadius,\n spacing\n },\n components: {\n 'form-control': { 'border-radius': radius, 'border-width': borderWidth },\n 'form-field': formField\n }\n }\n }) => {\n const { xxs: buttonFontSize } = calculateFontSize(fontSize, fontScale);\n const backgroundColor = formField.pending['status-color'];\n const hoverColors = getHoverColors(backgroundColor);\n const color = tryCatch(() => readableColor(backgroundColor));\n const borderColor = color ? rgba(color, 0.4) : color;\n\n return css`\n background-color: ${backgroundColor};\n color: ${color};\n font-size: ${buttonFontSize};\n min-width: calc(3 * ${spacing});\n min-height: calc(3 * ${spacing});\n padding: 0 ${spacing};\n border-radius: 0;\n border: none;\n &:first-child {\n border-inline-end: ${borderWidth} solid ${borderColor};\n border-end-start-radius: calc(${baseRadius} * ${radius});\n margin-inline-start: calc(2 * ${spacing});\n }\n &:last-child {\n border-end-end-radius: calc(${baseRadius} * ${radius});\n margin-inline-start: 0;\n }\n &:hover {\n background-color: ${hoverColors.background};\n }\n\n @media (pointer: coarse) {\n min-height: 2rem;\n }\n `;\n }\n);\n\nStyledSuggestionButton.defaultProps = defaultThemeProp;\n\nconst statusIconMap = { error: 'warn-solid', warning: 'flag-wave-solid', success: 'check' };\n\nconst FormField: FC<FormFieldProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<FormFieldProps>, ref: Ref<HTMLElement>) => {\n const uid = useUID();\n const {\n children: controlElement,\n id = uid,\n as = 'div',\n label,\n labelAs = 'label',\n labelFor = id,\n labelId,\n labelHidden = false,\n labelAfter = false,\n info,\n status,\n charLimitDisplay,\n required = false,\n disabled = false,\n readOnly = false,\n inline = false,\n actions,\n container,\n onResolveSuggestion,\n ...restProps\n } = props;\n const t = useI18n();\n const labelAsLegend: boolean = labelAs === 'legend';\n const hasSuggestion = status === 'pending' && !!onResolveSuggestion;\n const consolidatedRef = useConsolidatedRef(ref);\n\n const styledLabel = (\n <Label\n id={labelId}\n as={labelAs}\n htmlFor={labelAs === 'label' ? labelFor : undefined}\n labelHidden={labelHidden}\n onClick={(e: MouseEvent) => {\n if (readOnly) e.preventDefault();\n }}\n inline={inline}\n >\n {status && status !== 'pending' && !labelHidden && (\n <StyledStatusIcon status={status} name={statusIconMap[status]} />\n )}\n {label}\n </Label>\n );\n\n /*\n We have to use an internal state and an effect to set the text value of info after the DOM element is rendered.\n This is to ensure screen readers will announce info on errors when role is set to alert.\n Needs testing to confirm. Currently the expected sequence would be:\n - FormField renders with no error and no info\n - user input triggers an error status\n - props passed set error status and provide info text\n - effect runs and sets live region state which renders and is announced\n */\n const [liveRegionInfo, setLiveRegionInfo] = useState<ReactNode>(null);\n\n useEffect(() => {\n setLiveRegionInfo(info);\n }, [info]);\n\n // fieldset or single form control element\n let content: FormFieldProps['children'] = labelAsLegend\n ? controlElement\n : cloneElement(controlElement as ReactElement, {\n 'aria-describedby': info && `${id}-info`\n });\n\n if (actions) {\n content = (\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {content}\n <Actions items={actions} menuAt={3} />\n </Flex>\n );\n }\n\n let infoContent = info ? (\n /*\n Region for additional info, help or error message.\n Withholding aria-live=\"assertive\" to avoid iOS issue. See below.\n https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions#Preferring_specialized_live_region_roles\n */\n <StyledFormFieldInfo\n status={status}\n role={status === 'error' || status === 'warning' ? 'alert' : undefined}\n id={`${id}-info`}\n >\n {liveRegionInfo}\n </StyledFormFieldInfo>\n ) : undefined;\n\n if (charLimitDisplay) {\n infoContent = (\n <Flex container={{ justify: infoContent ? 'between' : 'end', gap: 1 }}>\n {infoContent}\n <Flex item={{ shrink: 0 }}>{charLimitDisplay}</Flex>\n </Flex>\n );\n }\n\n if (hasSuggestion) {\n const focusables = getFocusables(consolidatedRef);\n infoContent = (\n <Flex container={{ alignItems: 'start', justify: 'between' }}>\n <StyledFormFieldInfo status={status} id={`${id}-info`}>\n {t('suggestion_info')}\n <VisuallyHiddenText aria-live='polite'>{t('suggestion_assist')}</VisuallyHiddenText>\n </StyledFormFieldInfo>\n <Flex container={{ wrap: 'nowrap' }}>\n <StyledSuggestionButton\n onClick={() => {\n onResolveSuggestion(false);\n focusables[0]?.focus();\n }}\n aria-label={t('reject_suggestion_button_a11y')}\n >\n {t('no')}\n </StyledSuggestionButton>\n <StyledSuggestionButton\n onClick={() => {\n onResolveSuggestion(true);\n focusables[0]?.focus();\n }}\n aria-label={t('accept_suggestion_button_a11y')}\n >\n {t('yes')}\n </StyledSuggestionButton>\n </Flex>\n </Flex>\n );\n }\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n const target = e.target as HTMLElement;\n if (!target.closest('button')) {\n e.preventDefault();\n onResolveSuggestion?.(true);\n }\n }\n };\n\n return (\n <Flex\n {...restProps}\n container={{\n direction: inline ? 'row' : 'column',\n alignItems: inline ? 'center' : undefined,\n ...container\n }}\n as={StyledFormField}\n id={`${id}-field`}\n forwardedAs={as}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n onKeyDown={hasSuggestion ? onKeyDown : undefined}\n aria-describedby={labelAsLegend && info ? `${id}-info` : undefined}\n ref={consolidatedRef}\n >\n {(labelAsLegend || !labelAfter) && styledLabel}\n {content}\n {!labelAsLegend && labelAfter && styledLabel}\n {infoContent}\n </Flex>\n );\n }\n);\n\nexport default FormField;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAoC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9E,OAAO,EAAE,gBAAgB,EAAqB,MAAM,gBAAgB,CAAC;AAMrE,MAAM,WAAW,UAAW,SAAQ,gBAAgB,EAAE,SAAS,EAAE,cAAc;IAC7E;;;OAGG;IACH,IAAI,CAAC,EACD,MAAM,GACN,UAAU,GACV,QAAQ,GACR,OAAO,GACP,KAAK,GACL,QAAQ,GACR,KAAK,GACL,MAAM,GACN,gBAAgB,GAChB,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,CAAC;IACZ,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,GAAG,YAAY,CAoDxC,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAoC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9E,OAAO,EAAE,gBAAgB,EAAqB,MAAM,gBAAgB,CAAC;AAMrE,MAAM,WAAW,UAAW,SAAQ,gBAAgB,EAAE,SAAS,EAAE,cAAc;IAC7E;;;OAGG;IACH,IAAI,CAAC,EACD,MAAM,GACN,UAAU,GACV,QAAQ,GACR,OAAO,GACP,KAAK,GACL,QAAQ,GACR,KAAK,GACL,MAAM,GACN,gBAAgB,GAChB,MAAM,GACN,MAAM,GACN,OAAO,GACP,OAAO,CAAC;IACZ,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,GAAG,YAAY,CAkExC,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -7,7 +7,7 @@ import { useUID } from '../../hooks';
7
7
  import StyledInput from './Input.styles';
8
8
  const Input = forwardRef((props, ref) => {
9
9
  const uid = useUID();
10
- const { id = uid, value, defaultValue, required = false, disabled = false, label, labelHidden, info, status, actions, ...restProps } = props;
10
+ const { id = uid, value, defaultValue, required = false, disabled = false, label, labelHidden, info, status, actions, onResolveSuggestion, ...restProps } = props;
11
11
  const controlProp = {};
12
12
  // Conditionally render component as controlled/uncontrolled
13
13
  if (hasProp(props, 'value')) {
@@ -22,11 +22,22 @@ const Input = forwardRef((props, ref) => {
22
22
  required,
23
23
  disabled,
24
24
  status,
25
+ hasSuggestion: !!onResolveSuggestion && status === 'pending',
25
26
  ...controlProp,
26
27
  ...restProps,
27
28
  as: StyledInput
28
29
  } }));
29
- return label ? (_jsx(FormField, { ...{ label, labelHidden, id, info, status, required, disabled, actions }, children: Comp })) : (Comp);
30
+ return label ? (_jsx(FormField, { ...{
31
+ label,
32
+ labelHidden,
33
+ id,
34
+ info,
35
+ status,
36
+ required,
37
+ disabled,
38
+ actions,
39
+ onResolveSuggestion
40
+ }, children: Comp })) : (Comp);
30
41
  });
31
42
  export default Input;
32
43
  //# sourceMappingURL=Input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names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AO,EAAE,YACjF,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { FC, Ref, forwardRef, PropsWithoutRef } from 'react';\n\nimport { Action, BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport { hasProp } from '../../utils';\nimport { useUID } from '../../hooks';\n\nimport StyledInput from './Input.styles';\n\nexport interface InputProps extends FormControlProps, BaseProps, NoChildrenProp {\n /**\n * Specifies the type of input to be used.\n * @default \"text\"\n */\n type?:\n | 'text'\n | 'password'\n | 'number'\n | 'email'\n | 'url'\n | 'search'\n | 'tel'\n | 'date'\n | 'datetime-local'\n | 'time'\n | 'week'\n | 'month'\n | 'color';\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: Action[];\n}\n\nconst Input: FC<InputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<InputProps>, ref: Ref<HTMLInputElement>) => {\n const uid = useUID();\n const {\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n label,\n labelHidden,\n info,\n status,\n actions,\n ...restProps\n } = props;\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n // Conditionally render component as controlled/uncontrolled\n if (hasProp(props, 'value')) {\n controlProp.value = value ?? '';\n } else if (hasProp(props, 'defaultValue')) {\n controlProp.defaultValue = defaultValue ?? '';\n }\n\n const Comp = (\n <StyledFormControl\n {...{\n ref,\n id,\n required,\n disabled,\n status,\n ...controlProp,\n ...restProps,\n as: StyledInput\n }}\n />\n );\n\n return label ? (\n <FormField {...{ label, labelHidden, id, info, status, required, disabled, actions }}>\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default Input;\n"]}
1
+ {"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,E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I;YACJ,MAAM;YACN,QAAQ;YACR,QAAQ;YACR,OAAO;YACP,mBAAmB;SACpB,YAEA,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { FC, Ref, forwardRef, PropsWithoutRef } from 'react';\n\nimport { Action, BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport FormField from '../FormField';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport { hasProp } from '../../utils';\nimport { useUID } from '../../hooks';\n\nimport StyledInput from './Input.styles';\n\nexport interface InputProps extends FormControlProps, BaseProps, NoChildrenProp {\n /**\n * Specifies the type of input to be used.\n * @default \"text\"\n */\n type?:\n | 'text'\n | 'password'\n | 'number'\n | 'email'\n | 'url'\n | 'search'\n | 'tel'\n | 'date'\n | 'datetime-local'\n | 'time'\n | 'week'\n | 'month'\n | 'color';\n /** Pass an array of Action objects to append button(s) inline with the Input. */\n actions?: Action[];\n}\n\nconst Input: FC<InputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<InputProps>, ref: Ref<HTMLInputElement>) => {\n const uid = useUID();\n const {\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n label,\n labelHidden,\n info,\n status,\n actions,\n onResolveSuggestion,\n ...restProps\n } = props;\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n // Conditionally render component as controlled/uncontrolled\n if (hasProp(props, 'value')) {\n controlProp.value = value ?? '';\n } else if (hasProp(props, 'defaultValue')) {\n controlProp.defaultValue = defaultValue ?? '';\n }\n\n const Comp = (\n <StyledFormControl\n {...{\n ref,\n id,\n required,\n disabled,\n status,\n hasSuggestion: !!onResolveSuggestion && status === 'pending',\n ...controlProp,\n ...restProps,\n as: StyledInput\n }}\n />\n );\n\n return label ? (\n <FormField\n {...{\n label,\n labelHidden,\n id,\n info,\n status,\n required,\n disabled,\n actions,\n onResolveSuggestion\n }}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default Input;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAQlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAe3C,OAAO,EACL,gBAAgB,EAKjB,MAAM,qBAAqB,CAAC;AAiH7B,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAgKnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"ListToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAQlB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAU,YAAY,EAAE,MAAM,aAAa,CAAC;AAgBnD,OAAO,EACL,gBAAgB,EAKjB,MAAM,qBAAqB,CAAC;AAiH7B,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CA+PnE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -15,6 +15,7 @@ import * as moreIcon from '../Icon/icons/more.icon';
15
15
  import { hasProp } from '../../utils';
16
16
  import MenuButton from '../MenuButton';
17
17
  import { Count } from '../Badges';
18
+ import PresetMenuPopover from './PresetMenuPopover';
18
19
  import { StyledViewSelector, StyledSearchForm, StyledListToolbar } from './ListToolbar.styles';
19
20
  import QueryOptionPopover from './QueryOptionPopover';
20
21
  registerIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);
@@ -78,17 +79,19 @@ const QueryOptionButton = ({ id, queryOptionProps, iconOnly, setCurrentQueryOpti
78
79
  }
79
80
  return null;
80
81
  };
81
- const ListToolbar = forwardRef(({ heading, onCreateNew, search, count, additionalActions, filter, sort, group, actions, actionsButtonRef }, ref) => {
82
+ const ListToolbar = forwardRef(({ heading, onCreateNew, search, count, additionalActions, filter, sort, group, actions, actionsButtonRef, condensed }, ref) => {
82
83
  const t = useI18n();
83
84
  const isSmallOrAbove = useBreakpoint('sm');
84
85
  const isMediumOrAbove = useBreakpoint('md');
85
86
  const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);
86
87
  const [queryOptionDialogState, setQueryOptionDialogState] = useState(null);
88
+ const [actionsQueryOptionPreset, setActionsQueryOptionPreset] = useState();
89
+ const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);
87
90
  const createNewButton = useMemo(() => {
88
91
  if (!onCreateNew)
89
92
  return null;
90
93
  const text = t('create_new');
91
- return (_jsx(Button, { variant: isSmallOrAbove ? 'secondary' : 'simple', icon: !isSmallOrAbove, label: isSmallOrAbove ? undefined : text, onClick: onCreateNew, children: _jsxs(Flex, { as: 'span', container: { inline: true, alignItems: 'center', gap: 1 }, children: [_jsx(Icon, { name: 'plus' }), isSmallOrAbove && _jsx("span", { children: text })] }) }));
94
+ return (_jsx(Button, { variant: isSmallOrAbove ? 'secondary' : 'simple', icon: !isSmallOrAbove, label: isSmallOrAbove ? undefined : text, onClick: onCreateNew, children: isSmallOrAbove ? _jsx("span", { children: text }) : _jsx(Icon, { name: 'plus' }) }));
92
95
  }, [t, onCreateNew, isSmallOrAbove]);
93
96
  const filterButton = filter && (_jsx(QueryOptionButton, { id: 'filter', queryOptionProps: filter, iconOnly: !isMediumOrAbove, setCurrentQueryOption: setQueryOptionDialogState }));
94
97
  const sortButton = sort && (_jsx(QueryOptionButton, { id: 'sort', queryOptionProps: sort, iconOnly: !isMediumOrAbove, setCurrentQueryOption: setQueryOptionDialogState }));
@@ -103,15 +106,67 @@ const ListToolbar = forwardRef(({ heading, onCreateNew, search, count, additiona
103
106
  return;
104
107
  setQueryOptionDialogState(null);
105
108
  }, [queryOptionDialogState]);
106
- return (_jsxs(Flex, { as: StyledListToolbar, container: { direction: 'column', gap: 2 }, item: { grow: 1 }, ref: ref, children: [(heading || createNewButton) && (_jsxs(Flex, { container: { alignItems: 'center', justify: 'between' }, children: [heading &&
107
- (typeof heading === 'string' ? (_jsx(Text, { variant: 'h3', children: heading })) : (_jsx(StyledViewSelector, { variant: 'text', text: heading.views.find(view => view.selected)?.text ?? heading.views[0].text, menu: {
108
- mode: 'single-select',
109
- items: heading.views.map(view => ({ ...view, primary: view.text })),
110
- onItemClick: heading.onViewSelect
111
- } }))), createNewButton] })), _jsxs(Flex, { container: { alignItems: 'start', justify: 'between', gap: 2 }, children: [_jsxs(Flex, { as: StyledSearchForm, container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, item: { grow: 1 }, children: [search && _jsx(SearchInput, { ...search }), isSmallOrAbove && (_jsxs(_Fragment, { children: [count && _jsx(CountMeta, { count: count }), additionalActions] }))] }), (filterButton || sortButton || groupButton || actions) && (_jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, md: { container: { gap: 3 } }, children: [_jsxs(_Fragment, { children: [filterButton, sortButton, groupButton] }), actions && (_jsx(Actions, { items: actions.map(({ icon, ...restProps }) => ({
109
+ const getQueryOptionAction = useCallback((id, icon, queryOptionProps) => {
110
+ return {
111
+ text: t(id),
112
+ id,
113
+ icon,
114
+ count: queryOptionProps.count,
115
+ onClick: () => {
116
+ if (hasProp(queryOptionProps, 'renderer')) {
117
+ setQueryOptionDialogState({
118
+ id,
119
+ popoverTarget: consolidatedActionsButtonRef.current,
120
+ props: queryOptionProps
121
+ });
122
+ }
123
+ if (hasProp(queryOptionProps, 'items')) {
124
+ setActionsQueryOptionPreset({
125
+ heading: t(`${id}_by`),
126
+ menu: {
127
+ mode: queryOptionProps.mode,
128
+ items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),
129
+ onItemClick: queryOptionProps.onItemClick
130
+ }
131
+ });
132
+ setOptionPresetMenuOpen(true);
133
+ }
134
+ }
135
+ };
136
+ }, []);
137
+ const basicModeActions = useMemo(() => {
138
+ let basicActions = [];
139
+ if (filter) {
140
+ const filterAction = getQueryOptionAction('filter', 'filter', filter);
141
+ basicActions.push(filterAction);
142
+ }
143
+ if (sort) {
144
+ const sortAction = getQueryOptionAction('sort', 'arrow-up-down', sort);
145
+ basicActions.push(sortAction);
146
+ }
147
+ if (group) {
148
+ const groupAction = getQueryOptionAction('group', 'row', group);
149
+ basicActions.push(groupAction);
150
+ }
151
+ if (actions) {
152
+ basicActions = basicActions.concat(actions);
153
+ }
154
+ return basicActions.length ? basicActions : undefined;
155
+ }, [actions, filter, sort, group, getQueryOptionAction]);
156
+ return (_jsxs(Flex, { as: StyledListToolbar, container: { direction: 'column', gap: 2 }, item: { grow: 1 }, ref: ref, children: [(heading ||
157
+ createNewButton ||
158
+ (condensed && (count || additionalActions || search || basicModeActions))) && (_jsxs(Flex, { container: { alignItems: 'start', justify: 'between', gap: 2 }, children: [_jsxs(Flex, { container: { alignItems: 'center', gap: 2, wrap: 'wrap' }, children: [heading &&
159
+ (typeof heading === 'string' ? (_jsx(Text, { variant: 'h3', children: heading })) : (_jsx(StyledViewSelector, { variant: 'text', text: heading.views.find(view => view.selected)?.text ?? heading.views[0].text, menu: {
160
+ mode: 'single-select',
161
+ items: heading.views.map(view => ({ ...view, primary: view.text })),
162
+ onItemClick: heading.onViewSelect
163
+ } }))), isSmallOrAbove && condensed && (_jsxs(_Fragment, { children: [count && _jsx(CountMeta, { count: count }), additionalActions] }))] }), _jsxs(Flex, { container: { alignItems: 'center', gap: 2 }, children: [search && condensed && isSmallOrAbove && _jsx(SearchInput, { ...search }), createNewButton, condensed && basicModeActions && (_jsx("span", { children: _jsx(Actions, { items: basicModeActions.map(({ icon, ...restProps }) => ({
164
+ visual: icon ? _jsx(Icon, { name: icon }) : undefined,
165
+ ...restProps
166
+ })), menuAt: 1, ref: consolidatedActionsButtonRef }) }))] })] })), (!condensed || !isSmallOrAbove) && (_jsxs(Flex, { container: { alignItems: 'start', justify: 'between', gap: 2 }, children: [_jsxs(Flex, { as: StyledSearchForm, container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, item: { grow: 1 }, children: [search && _jsx(SearchInput, { ...search }), isSmallOrAbove && !condensed && (_jsxs(_Fragment, { children: [count && _jsx(CountMeta, { count: count }), additionalActions] }))] }), !condensed && (filterButton || sortButton || groupButton || actions) && (_jsxs(Flex, { container: { alignItems: 'center', gap: 1 }, md: { container: { gap: 2 } }, children: [_jsxs(_Fragment, { children: [filterButton, sortButton, groupButton] }), actions && (_jsx(Actions, { items: actions.map(({ icon, ...restProps }) => ({
112
167
  visual: icon ? _jsx(Icon, { name: icon }) : undefined,
113
168
  ...restProps
114
- })), menuAt: 1, ref: consolidatedActionsButtonRef }))] }))] }), !isSmallOrAbove && (count || additionalActions) && (_jsxs(Flex, { container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, children: [count && _jsx(CountMeta, { count: count }), additionalActions] })), queryOptionDialogState && (_jsx(QueryOptionPopover, { target: queryOptionDialogState.popoverTarget, heading: t(`${queryOptionDialogState.id}_by`), onCancel: onQueryOptionCancel, onSubmit: onQueryOptionSubmit, children: _jsx(queryOptionDialogState.props.renderer, {}) }))] }));
169
+ })), menuAt: 1, ref: consolidatedActionsButtonRef }))] }))] })), !isSmallOrAbove && (count || additionalActions) && (_jsxs(Flex, { container: { alignItems: 'center', wrap: 'wrap', gap: 2 }, children: [count && _jsx(CountMeta, { count: count }), additionalActions] })), queryOptionDialogState && (_jsx(QueryOptionPopover, { target: queryOptionDialogState.popoverTarget, heading: t(`${queryOptionDialogState.id}_by`), onCancel: onQueryOptionCancel, onSubmit: onQueryOptionSubmit, children: _jsx(queryOptionDialogState.props.renderer, {}) })), condensed && (_jsx(PresetMenuPopover, { buttonRef: consolidatedActionsButtonRef, heading: actionsQueryOptionPreset?.heading, menu: actionsQueryOptionPreset?.menu, isOpen: optionPresetMenuOpen, onClose: () => setOptionPresetMenuOpen(false) }))] }));
115
170
  });
116
171
  export default ListToolbar;
117
172
  //# sourceMappingURL=ListToolb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,IAAI,KAAC,SAAS,IAAC,KAAK,EAAE,KAAK,GAAI,EACpC,iBAAiB,IACb,CACR,EAEA,sBAAsB,IAAI,CACzB,KAAC,kBAAkB,IACjB,MAAM,EAAE,sBAAsB,CAAC,aAAa,EAC5C,OAAO,EAAE,CAAC,CAAC,GAAG,sBAAsB,CAAC,EAAE,KAAK,CAAC,EAC7C,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,mBAAmB,YAE7B,KAAC,sBAAsB,CAAC,KAAK,CAAC,QAAQ,KAAG,GACtB,CACtB,IACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n Dispatch,\n forwardRef,\n FunctionComponent,\n MouseEvent,\n PropsWithoutRef,\n SetStateAction,\n useCallback,\n useEffect,\n useMemo,\n useState\n} from 'react';\n\nimport Actions from '../Actions';\nimport Text from '../Text';\nimport Button from '../Button';\nimport { ForwardProps } from '../../types';\nimport { useBreakpoint, useConsolidatedRef, useI18n } from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp } from '../../utils';\nimport MenuButton from '../MenuButton';\nimport { Count } from '../Badges';\n\nimport { StyledViewSelector, StyledSearchForm, StyledListToolbar } from './ListToolbar.styles';\nimport {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionDialogState,\n QueryOptionId\n} from './ListToolbar.types';\nimport QueryOptionPopover from './QueryOptionPopover';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({ count }: { count: NonNullable<ListToolbarProps['count']> }) => {\n const t = useI18n();\n return (\n <Text variant='secondary'>\n {count.total !== undefined &&\n t('results_count', [count.totalHasMore ? `${count.total}+` : count.total], {\n count: count.total\n })}\n {count.total && count.selected && ' '}\n {count.selected !== undefined &&\n `(${t('selected_count', [count.selected], { count: count.selected })})`}\n </Text>\n );\n};\n\nconst QueryOptionButton = ({\n id,\n queryOptionProps,\n iconOnly,\n setCurrentQueryOption\n}: {\n id: QueryOptionId;\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps;\n iconOnly: boolean;\n setCurrentQueryOption: Dispatch<SetStateAction<QueryOptionDialogState>>;\n}) => {\n const t = useI18n();\n let i18nKey!: 'filter' | 'sort' | 'group';\n let icon!: 'filter' | 'arrow-up-down' | 'row';\n\n if (id === 'filter') {\n i18nKey = 'filter';\n icon = 'filter';\n } else if (id === 'sort') {\n i18nKey = 'sort';\n icon = 'arrow-up-down';\n } else if (id === 'group') {\n i18nKey = 'group';\n icon = 'row';\n }\n\n const text = t(i18nKey);\n const variant = iconOnly ? 'simple' : 'text';\n\n useEffect(() => {\n if (!queryOptionProps || !hasProp(queryOptionProps, 'renderer')) {\n return;\n }\n\n setCurrentQueryOption(cur => {\n if (!cur) return null;\n if (cur.id === id) {\n return {\n ...cur,\n props: queryOptionProps\n };\n }\n return cur;\n });\n }, [queryOptionProps, setCurrentQueryOption, id]);\n\n if (hasProp(queryOptionProps, 'renderer')) {\n return (\n <div>\n <Button\n variant={variant}\n icon={iconOnly}\n label={iconOnly ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n setCurrentQueryOption({\n id,\n props: queryOptionProps,\n popoverTarget: e.currentTarget\n });\n }}\n >\n <Flex container={{ inline: true, alignItems: 'center', gap: 1 }} as='span'>\n <Icon name={icon} />\n {!iconOnly && text}\n {!iconOnly && queryOptionProps.count && <Count>{queryOptionProps.count}</Count>}\n </Flex>\n </Button>\n </div>\n );\n }\n\n if (hasProp(queryOptionProps, 'items')) {\n return (\n <div>\n <MenuButton\n variant={variant}\n text={text}\n icon={icon}\n iconOnly={iconOnly}\n count={queryOptionProps.count}\n menu={{\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }}\n />\n </div>\n );\n }\n\n return null;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n (\n {\n heading,\n onCreateNew,\n search,\n count,\n additionalActions,\n filter,\n sort,\n group,\n actions,\n actionsButtonRef\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) => {\n const t = useI18n();\n const isSmallOrAbove = useBreakpoint('sm');\n const isMediumOrAbove = useBreakpoint('md');\n const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);\n\n const [queryOptionDialogState, setQueryOptionDialogState] =\n useState<QueryOptionDialogState>(null);\n\n const createNewButton = useMemo(() => {\n if (!onCreateNew) return null;\n const text = t('create_new');\n\n return (\n <Button\n variant={isSmallOrAbove ? 'secondary' : 'simple'}\n icon={!isSmallOrAbove}\n label={isSmallOrAbove ? undefined : text}\n onClick={onCreateNew}\n >\n <Flex as='span' container={{ inline: true, alignItems: 'center', gap: 1 }}>\n <Icon name='plus' />\n {isSmallOrAbove && <span>{text}</span>}\n </Flex>\n </Button>\n );\n }, [t, onCreateNew, isSmallOrAbove]);\n\n const filterButton = filter && (\n <QueryOptionButton\n id='filter'\n queryOptionProps={filter}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const sortButton = sort && (\n <QueryOptionButton\n id='sort'\n queryOptionProps={sort}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const groupButton = group && (\n <QueryOptionButton\n id='group'\n queryOptionProps={group}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const onQueryOptionCancel = useCallback(() => {\n if (queryOptionDialogState?.props.onCancel() === false) return;\n setQueryOptionDialogState(null);\n }, [queryOptionDialogState]);\n\n const onQueryOptionSubmit = useCallback(() => {\n if (queryOptionDialogState?.props.onSubmit() === false) return;\n setQueryOptionDialogState(null);\n }, [queryOptionDialogState]);\n\n return (\n <Flex\n as={StyledListToolbar}\n container={{ direction: 'column', gap: 2 }}\n item={{ grow: 1 }}\n ref={ref}\n >\n {(heading || createNewButton) && (\n <Flex container={{ alignItems: 'center', justify: 'between' }}>\n {heading &&\n (typeof heading === 'string' ? (\n <Text variant='h3'>{heading}</Text>\n ) : (\n <StyledViewSelector\n variant='text'\n text={heading.views.find(view => view.selected)?.text ?? heading.views[0].text}\n menu={{\n mode: 'single-select',\n items: heading.views.map(view => ({ ...view, primary: view.text })),\n onItemClick: heading.onViewSelect\n }}\n />\n ))}\n {createNewButton}\n </Flex>\n )}\n <Flex container={{ alignItems: 'start', justify: 'between', gap: 2 }}>\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 2 }}\n item={{ grow: 1 }}\n >\n {search && <SearchInput {...search} />}\n {isSmallOrAbove && (\n <>\n {count && <CountMeta count={count} />}\n {additionalActions}\n </>\n )}\n </Flex>\n {(filterButton || sortButton || groupButton || actions) && (\n <Flex container={{ alignItems: 'center', gap: 1 }} md={{ container: { gap: 3 } }}>\n <>\n {filterButton}\n {sortButton}\n {groupButton}\n </>\n {actions && (\n <Actions\n items={actions.map(({ icon, ...restProps }) => ({\n visual: icon ? <Icon name={icon} /> : undefined,\n ...restProps\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n </Flex>\n )}\n </Flex>\n {!isSmallOrAbove && (count || additionalActions) && (\n <Flex container={{ alignItems: 'center', wrap: 'wrap', gap: 2 }}>\n {count && <CountMeta count={count} />}\n {additionalActions}\n </Flex>\n )}\n\n {queryOptionDialogState && (\n <QueryOptionPopover\n target={queryOptionDialogState.popoverTarget}\n heading={t(`${queryOptionDialogState.id}_by`)}\n onCancel={onQueryOptionCancel}\n onSubmit={onQueryOptionSubmit}\n >\n <queryOptionDialogState.props.renderer />\n </QueryOptionPopover>\n )}\n </Flex>\n );\n }\n);\n\nexport default ListToolbar;\n"]}
1
+ {"version":3,"file":"ListToolbar.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAKV,WAAW,EACX,SAAS,EACT,OAAO,EACP,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,eAAe,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,iBAA6C,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAQ/F,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,YAAY,CAAC,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAEvE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Callback,\n useEffect,\n useMemo,\n useState\n} from 'react';\n\nimport Actions from '../Actions';\nimport Text from '../Text';\nimport Button from '../Button';\nimport { Action, ForwardProps } from '../../types';\nimport { useBreakpoint, useConsolidatedRef, useI18n } from '../../hooks';\nimport Flex from '../Flex';\nimport SearchInput from '../SearchInput';\nimport Icon, { registerIcon } from '../Icon';\nimport * as filterIcon from '../Icon/icons/filter.icon';\nimport * as arrowUpDownIcon from '../Icon/icons/arrow-up-down.icon';\nimport * as rowIcon from '../Icon/icons/row.icon';\nimport * as plusIcon from '../Icon/icons/plus.icon';\nimport * as moreIcon from '../Icon/icons/more.icon';\nimport { hasProp } from '../../utils';\nimport MenuButton from '../MenuButton';\nimport { Count } from '../Badges';\n\nimport PresetMenuPopover, { PresetMenuPopoverProps } from './PresetMenuPopover';\nimport { StyledViewSelector, StyledSearchForm, StyledListToolbar } from './ListToolbar.styles';\nimport {\n ListToolbarProps,\n PresetMenuProps,\n QueryOptionDialogProps,\n QueryOptionDialogState,\n QueryOptionId\n} from './ListToolbar.types';\nimport QueryOptionPopover from './QueryOptionPopover';\n\nregisterIcon(filterIcon, arrowUpDownIcon, rowIcon, plusIcon, moreIcon);\n\nconst CountMeta = ({ count }: { count: NonNullable<ListToolbarProps['count']> }) => {\n const t = useI18n();\n return (\n <Text variant='secondary'>\n {count.total !== undefined &&\n t('results_count', [count.totalHasMore ? `${count.total}+` : count.total], {\n count: count.total\n })}\n {count.total && count.selected && ' '}\n {count.selected !== undefined &&\n `(${t('selected_count', [count.selected], { count: count.selected })})`}\n </Text>\n );\n};\n\nconst QueryOptionButton = ({\n id,\n queryOptionProps,\n iconOnly,\n setCurrentQueryOption\n}: {\n id: QueryOptionId;\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps;\n iconOnly: boolean;\n setCurrentQueryOption: Dispatch<SetStateAction<QueryOptionDialogState>>;\n}) => {\n const t = useI18n();\n let i18nKey!: 'filter' | 'sort' | 'group';\n let icon!: 'filter' | 'arrow-up-down' | 'row';\n\n if (id === 'filter') {\n i18nKey = 'filter';\n icon = 'filter';\n } else if (id === 'sort') {\n i18nKey = 'sort';\n icon = 'arrow-up-down';\n } else if (id === 'group') {\n i18nKey = 'group';\n icon = 'row';\n }\n\n const text = t(i18nKey);\n const variant = iconOnly ? 'simple' : 'text';\n\n useEffect(() => {\n if (!queryOptionProps || !hasProp(queryOptionProps, 'renderer')) {\n return;\n }\n\n setCurrentQueryOption(cur => {\n if (!cur) return null;\n if (cur.id === id) {\n return {\n ...cur,\n props: queryOptionProps\n };\n }\n return cur;\n });\n }, [queryOptionProps, setCurrentQueryOption, id]);\n\n if (hasProp(queryOptionProps, 'renderer')) {\n return (\n <div>\n <Button\n variant={variant}\n icon={iconOnly}\n label={iconOnly ? text : undefined}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n setCurrentQueryOption({\n id,\n props: queryOptionProps,\n popoverTarget: e.currentTarget\n });\n }}\n >\n <Flex container={{ inline: true, alignItems: 'center', gap: 1 }} as='span'>\n <Icon name={icon} />\n {!iconOnly && text}\n {!iconOnly && queryOptionProps.count && <Count>{queryOptionProps.count}</Count>}\n </Flex>\n </Button>\n </div>\n );\n }\n\n if (hasProp(queryOptionProps, 'items')) {\n return (\n <div>\n <MenuButton\n variant={variant}\n text={text}\n icon={icon}\n iconOnly={iconOnly}\n count={queryOptionProps.count}\n menu={{\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }}\n />\n </div>\n );\n }\n\n return null;\n};\n\nconst ListToolbar: FunctionComponent<ListToolbarProps & ForwardProps> = forwardRef(\n (\n {\n heading,\n onCreateNew,\n search,\n count,\n additionalActions,\n filter,\n sort,\n group,\n actions,\n actionsButtonRef,\n condensed\n }: PropsWithoutRef<ListToolbarProps>,\n ref: ListToolbarProps['ref']\n ) => {\n const t = useI18n();\n const isSmallOrAbove = useBreakpoint('sm');\n const isMediumOrAbove = useBreakpoint('md');\n const consolidatedActionsButtonRef = useConsolidatedRef(actionsButtonRef);\n\n const [queryOptionDialogState, setQueryOptionDialogState] =\n useState<QueryOptionDialogState>(null);\n\n const [actionsQueryOptionPreset, setActionsQueryOptionPreset] =\n useState<Pick<PresetMenuPopoverProps, 'heading' | 'menu'>>();\n const [optionPresetMenuOpen, setOptionPresetMenuOpen] = useState(false);\n\n const createNewButton = useMemo(() => {\n if (!onCreateNew) return null;\n const text = t('create_new');\n\n return (\n <Button\n variant={isSmallOrAbove ? 'secondary' : 'simple'}\n icon={!isSmallOrAbove}\n label={isSmallOrAbove ? undefined : text}\n onClick={onCreateNew}\n >\n {isSmallOrAbove ? <span>{text}</span> : <Icon name='plus' />}\n </Button>\n );\n }, [t, onCreateNew, isSmallOrAbove]);\n\n const filterButton = filter && (\n <QueryOptionButton\n id='filter'\n queryOptionProps={filter}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const sortButton = sort && (\n <QueryOptionButton\n id='sort'\n queryOptionProps={sort}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const groupButton = group && (\n <QueryOptionButton\n id='group'\n queryOptionProps={group}\n iconOnly={!isMediumOrAbove}\n setCurrentQueryOption={setQueryOptionDialogState}\n />\n );\n\n const onQueryOptionCancel = useCallback(() => {\n if (queryOptionDialogState?.props.onCancel() === false) return;\n setQueryOptionDialogState(null);\n }, [queryOptionDialogState]);\n\n const onQueryOptionSubmit = useCallback(() => {\n if (queryOptionDialogState?.props.onSubmit() === false) return;\n setQueryOptionDialogState(null);\n }, [queryOptionDialogState]);\n\n const getQueryOptionAction = useCallback(\n (\n id: 'sort' | 'group' | 'filter',\n icon: string,\n queryOptionProps: QueryOptionDialogProps | PresetMenuProps\n ) => {\n return {\n text: t(id),\n id,\n icon,\n count: queryOptionProps.count,\n onClick: () => {\n if (hasProp(queryOptionProps, 'renderer')) {\n setQueryOptionDialogState({\n id,\n popoverTarget: consolidatedActionsButtonRef.current,\n props: queryOptionProps\n });\n }\n if (hasProp(queryOptionProps, 'items')) {\n setActionsQueryOptionPreset({\n heading: t(`${id}_by`),\n menu: {\n mode: queryOptionProps.mode,\n items: queryOptionProps.items.map(item => ({ ...item, primary: item.text })),\n onItemClick: queryOptionProps.onItemClick\n }\n });\n setOptionPresetMenuOpen(true);\n }\n }\n };\n },\n []\n );\n\n const basicModeActions = useMemo(() => {\n let basicActions: Action[] = [];\n if (filter) {\n const filterAction: Action = getQueryOptionAction('filter', 'filter', filter);\n basicActions.push(filterAction);\n }\n if (sort) {\n const sortAction: Action = getQueryOptionAction('sort', 'arrow-up-down', sort);\n basicActions.push(sortAction);\n }\n if (group) {\n const groupAction: Action = getQueryOptionAction('group', 'row', group);\n basicActions.push(groupAction);\n }\n if (actions) {\n basicActions = basicActions.concat(actions);\n }\n\n return basicActions.length ? basicActions : undefined;\n }, [actions, filter, sort, group, getQueryOptionAction]);\n\n return (\n <Flex\n as={StyledListToolbar}\n container={{ direction: 'column', gap: 2 }}\n item={{ grow: 1 }}\n ref={ref}\n >\n {(heading ||\n createNewButton ||\n (condensed && (count || additionalActions || search || basicModeActions))) && (\n <Flex container={{ alignItems: 'start', justify: 'between', gap: 2 }}>\n <Flex container={{ alignItems: 'center', gap: 2, wrap: 'wrap' }}>\n {heading &&\n (typeof heading === 'string' ? (\n <Text variant='h3'>{heading}</Text>\n ) : (\n <StyledViewSelector\n variant='text'\n text={heading.views.find(view => view.selected)?.text ?? heading.views[0].text}\n menu={{\n mode: 'single-select',\n items: heading.views.map(view => ({ ...view, primary: view.text })),\n onItemClick: heading.onViewSelect\n }}\n />\n ))}\n {isSmallOrAbove && condensed && (\n <>\n {count && <CountMeta count={count} />}\n {additionalActions}\n </>\n )}\n </Flex>\n <Flex container={{ alignItems: 'center', gap: 2 }}>\n {search && condensed && isSmallOrAbove && <SearchInput {...search} />}\n {createNewButton}\n {condensed && basicModeActions && (\n <span>\n <Actions\n items={basicModeActions.map(({ icon, ...restProps }) => ({\n visual: icon ? <Icon name={icon} /> : undefined,\n ...restProps\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n </span>\n )}\n </Flex>\n </Flex>\n )}\n {(!condensed || !isSmallOrAbove) && (\n <Flex container={{ alignItems: 'start', justify: 'between', gap: 2 }}>\n <Flex\n as={StyledSearchForm}\n container={{ alignItems: 'center', wrap: 'wrap', gap: 2 }}\n item={{ grow: 1 }}\n >\n {search && <SearchInput {...search} />}\n {isSmallOrAbove && !condensed && (\n <>\n {count && <CountMeta count={count} />}\n {additionalActions}\n </>\n )}\n </Flex>\n {!condensed && (filterButton || sortButton || groupButton || actions) && (\n <Flex container={{ alignItems: 'center', gap: 1 }} md={{ container: { gap: 2 } }}>\n <>\n {filterButton}\n {sortButton}\n {groupButton}\n </>\n {actions && (\n <Actions\n items={actions.map(({ icon, ...restProps }) => ({\n visual: icon ? <Icon name={icon} /> : undefined,\n ...restProps\n }))}\n menuAt={1}\n ref={consolidatedActionsButtonRef}\n />\n )}\n </Flex>\n )}\n </Flex>\n )}\n {!isSmallOrAbove && (count || additionalActions) && (\n <Flex container={{ alignItems: 'center', wrap: 'wrap', gap: 2 }}>\n {count && <CountMeta count={count} />}\n {additionalActions}\n </Flex>\n )}\n\n {queryOptionDialogState && (\n <QueryOptionPopover\n target={queryOptionDialogState.popoverTarget}\n heading={t(`${queryOptionDialogState.id}_by`)}\n onCancel={onQueryOptionCancel}\n onSubmit={onQueryOptionSubmit}\n >\n <queryOptionDialogState.props.renderer />\n </QueryOptionPopover>\n )}\n {condensed && (\n <PresetMenuPopover\n buttonRef={consolidatedActionsButtonRef}\n heading={actionsQueryOptionPreset?.heading}\n menu={actionsQueryOptionPreset?.menu}\n isOpen={optionPresetMenuOpen}\n onClose={() => setOptionPresetMenuOpen(false)}\n />\n )}\n </Flex>\n );\n }\n);\n\nexport default ListToolbar;\n"]}
@@ -78,5 +78,7 @@ export interface ListToolbarProps extends BaseProps {
78
78
  ref?: Ref<HTMLDivElement>;
79
79
  /** Ref for the actions button element. */
80
80
  actionsButtonRef?: Ref<HTMLButtonElement>;
81
+ /** Renders toolbar in condensed mode. */
82
+ condensed?: boolean;
81
83
  }
82
84
  //# sourceMappingURL=ListToolbar.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.types.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IACzD,sCAAsC;IACtC,YAAY,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;CACxC;AACD,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,4EAA4E;IAC5E,QAAQ,EAAE,aAAa,CAAC;IACxB;;;OAGG;IACH,QAAQ,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;IAC/B;;;OAGG;IACH,QAAQ,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;CAChC;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC5C,KAAK,EAAE;QAAE,EAAE,EAAE,MA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rB"}
@@ -1 +1 @@
1
- {"version":3,"file":"ListToolbar.types.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.types.ts"],"names":[],"mappings":"","sourcesContent":["import { MouseEvent, Ref, ComponentType, ReactNode } from 'react';\n\nimport { SearchInputProps } from '../SearchInput';\nimport { MenuProps } from '../Menu';\nimport { Action, BaseProps } from '../../types';\n\nexport interface ViewSelectorProps {\n /** A list of pre-defined data views. */\n views: { id: string; text: string; selected: boolean }[];\n /** Called when a view is selected. */\n onViewSelect: MenuProps['onItemClick'];\n}\nexport interface QueryOption {\n /** A count representing the number of applied conditions within the query option. */\n count?: number;\n}\n\nexport interface QueryOptionDialogProps extends QueryOption {\n /** A component to render the content portion of the query option dialog. */\n renderer: ComponentType;\n /**\n * Called when the user explicitly or implicitly cancels(closes) the query dialog.\n * Returning false will block the dialog from closing.\n */\n onCancel: () => boolean | void;\n /**\n * Called when the user explicitly applies the query option conditions.\n * Returning false will block the dialog from closing.\n */\n onSubmit: () => boolean | void;\n}\n\n/** Optionally provide query option presets. */\nexport interface PresetMenuProps extends QueryOption {\n mode?: Exclude<MenuProps['mode'], 'action'>;\n items: { id: string; text: string; selected: boolean; icon?: string }[];\n onItemClick: MenuProps['onItemClick'];\n}\nexport type QueryOptionId = 'filter' | 'sort' | 'group';\n\nexport type QueryOptionDialogState = {\n id: 'filter' | 'sort' | 'group';\n props: QueryOptionDialogProps;\n popoverTarget: HTMLButtonElement | null;\n} | null;\n\nexport interface ListToolbarProps extends BaseProps {\n /** Rendering a simple heading or view selection menu.. */\n heading?: string | ViewSelectorProps;\n /** Callback that will render a Create new button and is fired when that button is clicked. */\n onCreateNew?: (e: MouseEvent) => void;\n /** Props related to the Search Input. */\n search?: SearchInputProps;\n /** Total returned results related for a given search. Optional indication of a selected item count. */\n count?: {\n total?: number;\n /**\n * If true renders + next to total number.\n * @default false\n */\n totalHasMore?: boolean;\n selected?: number;\n };\n /** Additional actions region */\n additionalActions?: ReactNode;\n /** Custom Rendering or available presets for filtering. */\n filter?: QueryOptionDialogProps | PresetMenuProps;\n /** Custom Rendering or available presets for sorting. */\n sort?: QueryOptionDialogProps | PresetMenuProps;\n /** Custom Rendering or available presets for grouping. */\n group?: QueryOptionDialogProps | PresetMenuProps;\n /** Top level dataset actions. */\n actions?: Action[];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n /** Ref for the actions button element. */\n actionsButtonRef?: Ref<HTMLButtonElement>;\n}\n"]}
1
+ {"version":3,"file":"ListToolbar.types.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/ListToolbar.types.ts"],"names":[],"mappings":"","sourcesContent":["import { MouseEvent, Ref, ComponentType, ReactNode } from 'react';\n\nimport { SearchInputProps } from '../SearchInput';\nimport { MenuProps } from '../Menu';\nimport { Action, BaseProps } from '../../types';\n\nexport interface ViewSelectorProps {\n /** A list of pre-defined data views. */\n views: { id: string; text: string; selected: boolean }[];\n /** Called when a view is selected. */\n onViewSelect: MenuProps['onItemClick'];\n}\nexport interface QueryOption {\n /** A count representing the number of applied conditions within the query option. */\n count?: number;\n}\n\nexport interface QueryOptionDialogProps extends QueryOption {\n /** A component to render the content portion of the query option dialog. */\n renderer: ComponentType;\n /**\n * Called when the user explicitly or implicitly cancels(closes) the query dialog.\n * Returning false will block the dialog from closing.\n */\n onCancel: () => boolean | void;\n /**\n * Called when the user explicitly applies the query option conditions.\n * Returning false will block the dialog from closing.\n */\n onSubmit: () => boolean | void;\n}\n\n/** Optionally provide query option presets. */\nexport interface PresetMenuProps extends QueryOption {\n mode?: Exclude<MenuProps['mode'], 'action'>;\n items: { id: string; text: string; selected: boolean; icon?: string }[];\n onItemClick: MenuProps['onItemClick'];\n}\nexport type QueryOptionId = 'filter' | 'sort' | 'group';\n\nexport type QueryOptionDialogState = {\n id: 'filter' | 'sort' | 'group';\n props: QueryOptionDialogProps;\n popoverTarget: HTMLButtonElement | null;\n} | null;\n\nexport interface ListToolbarProps extends BaseProps {\n /** Rendering a simple heading or view selection menu.. */\n heading?: string | ViewSelectorProps;\n /** Callback that will render a Create new button and is fired when that button is clicked. */\n onCreateNew?: (e: MouseEvent) => void;\n /** Props related to the Search Input. */\n search?: SearchInputProps;\n /** Total returned results related for a given search. Optional indication of a selected item count. */\n count?: {\n total?: number;\n /**\n * If true renders + next to total number.\n * @default false\n */\n totalHasMore?: boolean;\n selected?: number;\n };\n /** Additional actions region */\n additionalActions?: ReactNode;\n /** Custom Rendering or available presets for filtering. */\n filter?: QueryOptionDialogProps | PresetMenuProps;\n /** Custom Rendering or available presets for sorting. */\n sort?: QueryOptionDialogProps | PresetMenuProps;\n /** Custom Rendering or available presets for grouping. */\n group?: QueryOptionDialogProps | PresetMenuProps;\n /** Top level dataset actions. */\n actions?: Action[];\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n /** Ref for the actions button element. */\n actionsButtonRef?: Ref<HTMLButtonElement>;\n /** Renders toolbar in condensed mode. */\n condensed?: boolean;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { FunctionComponent, RefObject } from 'react';
2
+ import type { MenuProps } from '../Menu/Menu.types';
3
+ export interface PresetMenuPopoverProps {
4
+ heading?: string;
5
+ buttonRef: RefObject<HTMLButtonElement>;
6
+ menu?: MenuProps;
7
+ isOpen: boolean;
8
+ onClose: () => void;
9
+ }
10
+ declare const PresetMenuPopover: FunctionComponent<PresetMenuPopoverProps>;
11
+ export default PresetMenuPopover;
12
+ //# sourceMappingURL=PresetMenuPopover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PresetMenuPopover.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/PresetMenuPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAc,SAAS,EAAsB,MAAM,OAAO,CAAC;AAKrF,OAAO,KAAK,EAAE,SAAS,EAA6B,MAAM,oBAAoB,CAAC;AAO/E,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACxC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAgBD,QAAA,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,sBAAsB,CAqDhE,CAAC;AACF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import Popover from '../Popover';
5
+ import { useConsolidatedRef, useDirection, useOuterEvent, useEscape, useUID } from '../../hooks';
6
+ import Menu from '../Menu';
7
+ import { defaultThemeProp } from '../../theme';
8
+ import Flex from '../Flex';
9
+ import { getFocusables } from '../../utils';
10
+ import Text from '../Text';
11
+ const StyledPresetMenuPopover = styled(Popover)(({ theme: { base: { 'content-width': contentWidth } } }) => {
12
+ return css `
13
+ min-width: ${contentWidth.xs};
14
+ `;
15
+ });
16
+ StyledPresetMenuPopover.defaultProps = defaultThemeProp;
17
+ const PresetMenuPopover = ({ heading, buttonRef, menu, isOpen, onClose }) => {
18
+ const popoverRef = useConsolidatedRef();
19
+ const { rtl } = useDirection();
20
+ const headingId = useUID();
21
+ useEscape(onClose, buttonRef);
22
+ useOuterEvent(['mousedown', 'focusin'], [popoverRef], () => isOpen && onClose());
23
+ useEffect(() => {
24
+ getFocusables(popoverRef)[0]?.focus();
25
+ }, [popoverRef]);
26
+ return (_jsx(StyledPresetMenuPopover, { placement: rtl ? 'bottom-end' : 'bottom-start', hideOnTargetHidden: true, show: !!menu && isOpen, target: buttonRef?.current, ref: popoverRef, "aria-labelledby": headingId, children: menu && (_jsxs(_Fragment, { children: [_jsx(Flex, { container: { pad: [1, 2] }, children: _jsx(Text, { variant: 'h3', id: headingId, children: heading }) }), _jsx(Menu, { ...menu, items: menu.items, onItemClick: (itemId, e) => {
27
+ if (menu?.mode !== 'multi-select' &&
28
+ e
29
+ .detail > 0) {
30
+ onClose();
31
+ }
32
+ menu?.onItemClick?.(itemId, e);
33
+ }, focusControlEl: buttonRef?.current ?? undefined })] })) }));
34
+ };
35
+ export default PresetMenuPopover;
36
+ //# sourceMappingURL=PresetMenuPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PresetMenuPopover.js","sourceRoot":"","sources":["../../../src/components/ListToolbar/PresetMenuPopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqD,SAAS,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjG,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,SAAS,CAAC;AAU3B,MAAM,uBAAuB,GAAG,MAAM,CAAC,OAAO,CAAC,CAC7C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,EACxC,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;mBACK,YAAY,CAAC,EAAE;KAC7B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,uBAAuB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAExD,MAAM,iBAAiB,GAA8C,CAAC,EACpE,OAAO,EACP,SAAS,EACT,IAAI,EACJ,MAAM,EACN,OAAO,EACgB,EAAE,EAAE;IAC3B,MAAM,UAAU,GAAG,kBAAkB,EAAkB,CAAC;IACxD,MAAM,E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,IACD,CACJ,GACuB,CAC3B,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,iBAAiB,CAAC","sourcesContent":["import { FunctionComponent, MouseEvent, RefObject, UIEvent, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Popover from '../Popover';\nimport { useConsolidatedRef, useDirection, useOuterEvent, useEscape, useUID } from '../../hooks';\nimport type { MenuProps, AcceptedMouseEventElement } from '../Menu/Menu.types';\nimport Menu from '../Menu';\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport { getFocusables } from '../../utils';\nimport Text from '../Text';\n\nexport interface PresetMenuPopoverProps {\n heading?: string;\n buttonRef: RefObject<HTMLButtonElement>;\n menu?: MenuProps;\n isOpen: boolean;\n onClose: () => void;\n}\n\nconst StyledPresetMenuPopover = styled(Popover)(\n ({\n theme: {\n base: { 'content-width': contentWidth }\n }\n }) => {\n return css`\n min-width: ${contentWidth.xs};\n `;\n }\n);\n\nStyledPresetMenuPopover.defaultProps = defaultThemeProp;\n\nconst PresetMenuPopover: FunctionComponent<PresetMenuPopoverProps> = ({\n heading,\n buttonRef,\n menu,\n isOpen,\n onClose\n}: PresetMenuPopoverProps) => {\n const popoverRef = useConsolidatedRef<HTMLDivElement>();\n const { rtl } = useDirection();\n const headingId = useUID();\n\n useEscape(onClose, buttonRef);\n useOuterEvent(['mousedown', 'focusin'], [popoverRef], () => isOpen && onClose());\n\n useEffect(() => {\n getFocusables(popoverRef)[0]?.focus();\n }, [popoverRef]);\n\n return (\n <StyledPresetMenuPopover\n placement={rtl ? 'bottom-end' : 'bottom-start'}\n hideOnTargetHidden\n show={!!menu && isOpen}\n target={buttonRef?.current}\n ref={popoverRef}\n aria-labelledby={headingId}\n >\n {menu && (\n <>\n <Flex container={{ pad: [1, 2] }}>\n <Text variant='h3' id={headingId}>\n {heading}\n </Text>\n </Flex>\n <Menu\n {...menu}\n items={menu.items}\n onItemClick={(itemId, e) => {\n if (\n menu?.mode !== 'multi-select' &&\n (e as MouseEvent<AcceptedMouseEventElement> & UIEvent<AcceptedMouseEventElement>)\n .detail > 0\n ) {\n onClose();\n }\n menu?.onItemClick?.(itemId, e);\n }}\n focusControlEl={buttonRef?.current ?? undefined}\n />\n </>\n )}\n </StyledPresetMenuPopover>\n );\n};\nexport default PresetMenuPopover;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"QueryOptionPopover.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/QueryOptionPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,SAAS,EAGV,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIvD,OAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,UAAU,uBACR,SAAQ,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,EACxC,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,UAAU,CAAC;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACnC;AAMD,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,GAAG,YAAY,CAiGjF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"QueryOptionPopover.d.ts","sourceRoot":"","sources":["../../../src/components/ListToolbar/QueryOptionPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA+B,SAAS,EAAa,MAAM,OAAO,CAAC;AAW7F,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIvD,OAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAInD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,UAAU,uBACR,S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