@pega/cosmos-react-core 5.0.0-dev.9.2 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/SECURITY.md +11 -0
  2. package/lib/components/AdditionalInfo/AdditionalInfo.d.ts +8 -6
  3. package/lib/components/AdditionalInfo/AdditionalInfo.d.ts.map +1 -1
  4. package/lib/components/AdditionalInfo/AdditionalInfo.js +3 -2
  5. package/lib/components/AdditionalInfo/AdditionalInfo.js.map +1 -1
  6. package/lib/components/AppShell/AppShell.js +1 -1
  7. package/lib/components/AppShell/AppShell.js.map +1 -1
  8. package/lib/components/AppShell/Drawer.d.ts.map +1 -1
  9. package/lib/components/AppShell/Drawer.js +3 -3
  10. package/lib/components/AppShell/Drawer.js.map +1 -1
  11. package/lib/components/AppShell/Operator.d.ts.map +1 -1
  12. package/lib/components/AppShell/Operator.js +5 -2
  13. package/lib/components/AppShell/Operator.js.map +1 -1
  14. package/lib/components/Badges/Keyboard.d.ts.map +1 -1
  15. package/lib/components/Badges/Keyboard.js +10 -10
  16. package/lib/components/Badges/Keyboard.js.map +1 -1
  17. package/lib/components/Badges/Status.d.ts.map +1 -1
  18. package/lib/components/Badges/Status.js +2 -0
  19. package/lib/components/Badges/Status.js.map +1 -1
  20. package/lib/components/Banner/Banner.d.ts +5 -3
  21. package/lib/components/Banner/Banner.d.ts.map +1 -1
  22. package/lib/components/Banner/Banner.js +22 -15
  23. package/lib/components/Banner/Banner.js.map +1 -1
  24. package/lib/components/Banner/Banner.test-ids.d.ts +2 -0
  25. package/lib/components/Banner/Banner.test-ids.d.ts.map +1 -0
  26. package/lib/components/Banner/Banner.test-ids.js +10 -0
  27. package/lib/components/Banner/Banner.test-ids.js.map +1 -0
  28. package/lib/components/Button/Button.js +1 -1
  29. package/lib/components/Button/Button.js.map +1 -1
  30. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +1 -1
  31. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  32. package/lib/components/Configuration/Configuration.d.ts +3 -0
  33. package/lib/components/Configuration/Configuration.d.ts.map +1 -1
  34. package/lib/components/Configuration/Configuration.js +20 -12
  35. package/lib/components/Configuration/Configuration.js.map +1 -1
  36. package/lib/components/Configuration/index.d.ts +1 -0
  37. package/lib/components/Configuration/index.d.ts.map +1 -1
  38. package/lib/components/Configuration/index.js +1 -0
  39. package/lib/components/Configuration/index.js.map +1 -1
  40. package/lib/components/Configuration/withConfiguration.d.ts +8 -0
  41. package/lib/components/Configuration/withConfiguration.d.ts.map +1 -0
  42. package/lib/components/Configuration/withConfiguration.js +9 -0
  43. package/lib/components/Configuration/withConfiguration.js.map +1 -0
  44. package/lib/components/DateTime/DateTime.types.d.ts +1 -4
  45. package/lib/components/DateTime/DateTime.types.d.ts.map +1 -1
  46. package/lib/components/DateTime/DateTime.types.js.map +1 -1
  47. package/lib/components/DateTime/DurationDisplay.d.ts +7 -3
  48. package/lib/components/DateTime/DurationDisplay.d.ts.map +1 -1
  49. package/lib/components/DateTime/DurationDisplay.js +2 -2
  50. package/lib/components/DateTime/DurationDisplay.js.map +1 -1
  51. package/lib/components/DateTime/Input/DateInput.d.ts +3 -5
  52. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  53. package/lib/components/DateTime/Input/DateInput.js +2 -17
  54. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  55. package/lib/components/DateTime/Input/DateRangeInput.d.ts +2 -4
  56. package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
  57. package/lib/components/DateTime/Input/DateRangeInput.js +33 -84
  58. package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
  59. package/lib/components/DateTime/Input/DateTime.styles.d.ts.map +1 -1
  60. package/lib/components/DateTime/Input/DateTime.styles.js +2 -1
  61. package/lib/components/DateTime/Input/DateTime.styles.js.map +1 -1
  62. package/lib/components/DateTime/Input/DateTimeInput.d.ts +3 -0
  63. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  64. package/lib/components/DateTime/Input/DateTimeInput.js +20 -38
  65. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  66. package/lib/components/DateTime/Input/Duration/NumberUnit.d.ts.map +1 -1
  67. package/lib/components/DateTime/Input/Duration/NumberUnit.js +2 -1
  68. package/lib/components/DateTime/Input/Duration/NumberUnit.js.map +1 -1
  69. package/lib/components/DateTime/Input/MonthInput.d.ts +5 -0
  70. package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
  71. package/lib/components/DateTime/Input/MonthInput.js +14 -6
  72. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  73. package/lib/components/DateTime/Input/PartInput.js +1 -1
  74. package/lib/components/DateTime/Input/PartInput.js.map +1 -1
  75. package/lib/components/DateTime/Input/QuarterInput.d.ts.map +1 -1
  76. package/lib/components/DateTime/Input/QuarterInput.js +5 -0
  77. package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
  78. package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
  79. package/lib/components/DateTime/Input/TimeInput.js +13 -24
  80. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  81. package/lib/components/DateTime/Input/TimeRangeInput.d.ts +2 -4
  82. package/lib/components/DateTime/Input/TimeRangeInput.d.ts.map +1 -1
  83. package/lib/components/DateTime/Input/TimeRangeInput.js +25 -64
  84. package/lib/components/DateTime/Input/TimeRangeInput.js.map +1 -1
  85. package/lib/components/DateTime/Input/utils.d.ts +3 -2
  86. package/lib/components/DateTime/Input/utils.d.ts.map +1 -1
  87. package/lib/components/DateTime/Input/utils.js +19 -16
  88. package/lib/components/DateTime/Input/utils.js.map +1 -1
  89. package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
  90. package/lib/components/DateTime/Picker/DatePicker.js +3 -3
  91. package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
  92. package/lib/components/DateTime/Picker/DatePicker.styles.d.ts +2 -0
  93. package/lib/components/DateTime/Picker/DatePicker.styles.d.ts.map +1 -1
  94. package/lib/components/DateTime/Picker/DatePicker.styles.js +37 -1
  95. package/lib/components/DateTime/Picker/DatePicker.styles.js.map +1 -1
  96. package/lib/components/DateTime/Picker/DateRangePicker.d.ts.map +1 -1
  97. package/lib/components/DateTime/Picker/DateRangePicker.js +3 -3
  98. package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
  99. package/lib/components/DateTime/Picker/TimePicker.js +1 -1
  100. package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
  101. package/lib/components/DateTime/utils.d.ts +13 -2
  102. package/lib/components/DateTime/utils.d.ts.map +1 -1
  103. package/lib/components/DateTime/utils.js +7 -13
  104. package/lib/components/DateTime/utils.js.map +1 -1
  105. package/lib/components/Dialog/FormDialog.js +1 -1
  106. package/lib/components/Dialog/FormDialog.js.map +1 -1
  107. package/lib/components/Dialog/InfoDialog.js +1 -1
  108. package/lib/components/Dialog/InfoDialog.js.map +1 -1
  109. package/lib/components/FieldGroup/FieldGroup.d.ts +23 -15
  110. package/lib/components/FieldGroup/FieldGroup.d.ts.map +1 -1
  111. package/lib/components/FieldGroup/FieldGroup.js +3 -3
  112. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  113. package/lib/components/FieldGroup/FieldGroupList.d.ts +2 -2
  114. package/lib/components/FieldGroup/FieldGroupList.d.ts.map +1 -1
  115. package/lib/components/FieldGroup/FieldGroupList.js +5 -2
  116. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  117. package/lib/components/FormControl/FormControl.d.ts +1 -1
  118. package/lib/components/FormControl/FormControl.d.ts.map +1 -1
  119. package/lib/components/FormControl/FormControl.js.map +1 -1
  120. package/lib/components/FormField/FormField.d.ts +1 -0
  121. package/lib/components/FormField/FormField.d.ts.map +1 -1
  122. package/lib/components/FormField/FormField.js +7 -3
  123. package/lib/components/FormField/FormField.js.map +1 -1
  124. package/lib/components/HTML/HTML.js +1 -1
  125. package/lib/components/HTML/HTML.js.map +1 -1
  126. package/lib/components/Lightbox/Lightbox.d.ts +1 -1
  127. package/lib/components/Lightbox/Lightbox.d.ts.map +1 -1
  128. package/lib/components/Lightbox/Lightbox.js +66 -19
  129. package/lib/components/Lightbox/Lightbox.js.map +1 -1
  130. package/lib/components/Lightbox/Lightbox.styles.d.ts +3 -3
  131. package/lib/components/Lightbox/Lightbox.styles.d.ts.map +1 -1
  132. package/lib/components/Lightbox/Lightbox.styles.js +29 -16
  133. package/lib/components/Lightbox/Lightbox.styles.js.map +1 -1
  134. package/lib/components/Lightbox/Lightbox.test-ids.d.ts +1 -1
  135. package/lib/components/Lightbox/Lightbox.test-ids.d.ts.map +1 -1
  136. package/lib/components/Lightbox/Lightbox.test-ids.js +3 -1
  137. package/lib/components/Lightbox/Lightbox.test-ids.js.map +1 -1
  138. package/lib/components/Lightbox/Lightbox.types.d.ts +19 -8
  139. package/lib/components/Lightbox/Lightbox.types.d.ts.map +1 -1
  140. package/lib/components/Lightbox/Lightbox.types.js.map +1 -1
  141. package/lib/components/ListToolbar/ListToolbar.d.ts +1 -1
  142. package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
  143. package/lib/components/ListToolbar/ListToolbar.js +61 -51
  144. package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
  145. package/lib/components/ListToolbar/ListToolbar.styles.d.ts +4 -0
  146. package/lib/components/ListToolbar/ListToolbar.styles.d.ts.map +1 -1
  147. package/lib/components/ListToolbar/ListToolbar.styles.js +41 -8
  148. package/lib/components/ListToolbar/ListToolbar.styles.js.map +1 -1
  149. package/lib/components/ListToolbar/ListToolbar.test-ids.d.ts +1 -1
  150. package/lib/components/ListToolbar/ListToolbar.test-ids.d.ts.map +1 -1
  151. package/lib/components/ListToolbar/ListToolbar.test-ids.js +2 -1
  152. package/lib/components/ListToolbar/ListToolbar.test-ids.js.map +1 -1
  153. package/lib/components/ListToolbar/ListToolbar.types.d.ts +1 -1
  154. package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
  155. package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
  156. package/lib/components/Menu/MenuItem.js +1 -1
  157. package/lib/components/Menu/MenuItem.js.map +1 -1
  158. package/lib/components/MenuButton/MenuButton.d.ts.map +1 -1
  159. package/lib/components/MenuButton/MenuButton.js +8 -4
  160. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  161. package/lib/components/Modal/MinimizedModal.d.ts.map +1 -1
  162. package/lib/components/Modal/MinimizedModal.js +3 -3
  163. package/lib/components/Modal/MinimizedModal.js.map +1 -1
  164. package/lib/components/Modal/Modal.d.ts.map +1 -1
  165. package/lib/components/Modal/Modal.js +4 -4
  166. package/lib/components/Modal/Modal.js.map +1 -1
  167. package/lib/components/MultiStepForm/FormProgress.styles.d.ts +2 -0
  168. package/lib/components/MultiStepForm/FormProgress.styles.d.ts.map +1 -1
  169. package/lib/components/MultiStepForm/FormProgress.styles.js +26 -2
  170. package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -1
  171. package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts +0 -1
  172. package/lib/components/MultiStepForm/HorizontalFormProgress.d.ts.map +1 -1
  173. package/lib/components/MultiStepForm/HorizontalFormProgress.js +26 -29
  174. package/lib/components/MultiStepForm/HorizontalFormProgress.js.map +1 -1
  175. package/lib/components/MultiStepForm/MultiStepForm.d.ts.map +1 -1
  176. package/lib/components/MultiStepForm/MultiStepForm.js +27 -11
  177. package/lib/components/MultiStepForm/MultiStepForm.js.map +1 -1
  178. package/lib/components/NoValue/NoValue.d.ts.map +1 -1
  179. package/lib/components/NoValue/NoValue.js +6 -1
  180. package/lib/components/NoValue/NoValue.js.map +1 -1
  181. package/lib/components/Popover/Popover.d.ts.map +1 -1
  182. package/lib/components/Popover/Popover.js +9 -0
  183. package/lib/components/Popover/Popover.js.map +1 -1
  184. package/lib/components/RadioCheck/RadioCheck.d.ts.map +1 -1
  185. package/lib/components/RadioCheck/RadioCheck.js +3 -1
  186. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  187. package/lib/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  188. package/lib/components/SearchInput/SearchInput.styles.js +15 -0
  189. package/lib/components/SearchInput/SearchInput.styles.js.map +1 -1
  190. package/lib/components/ShortcutManager/ShortcutManager.js +1 -1
  191. package/lib/components/ShortcutManager/ShortcutManager.js.map +1 -1
  192. package/lib/components/TextArea/TextArea.d.ts +1 -1
  193. package/lib/components/TextArea/TextArea.d.ts.map +1 -1
  194. package/lib/components/TextArea/TextArea.js +16 -8
  195. package/lib/components/TextArea/TextArea.js.map +1 -1
  196. package/lib/components/TextArea/TextArea.styles.d.ts +1 -0
  197. package/lib/components/TextArea/TextArea.styles.d.ts.map +1 -1
  198. package/lib/components/TextArea/TextArea.styles.js +32 -4
  199. package/lib/components/TextArea/TextArea.styles.js.map +1 -1
  200. package/lib/components/Tooltip/Tooltip.js +1 -1
  201. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  202. package/lib/hooks/useArrows.d.ts +2 -1
  203. package/lib/hooks/useArrows.d.ts.map +1 -1
  204. package/lib/hooks/useArrows.js +47 -22
  205. package/lib/hooks/useArrows.js.map +1 -1
  206. package/lib/hooks/useFocusTrap.d.ts.map +1 -1
  207. package/lib/hooks/useFocusTrap.js +30 -3
  208. package/lib/hooks/useFocusTrap.js.map +1 -1
  209. package/lib/hooks/useI18n.d.ts +21 -0
  210. package/lib/hooks/useI18n.d.ts.map +1 -1
  211. package/lib/i18n/default.d.ts +21 -0
  212. package/lib/i18n/default.d.ts.map +1 -1
  213. package/lib/i18n/default.js +25 -2
  214. package/lib/i18n/default.js.map +1 -1
  215. package/lib/i18n/i18n.d.ts +21 -0
  216. package/lib/i18n/i18n.d.ts.map +1 -1
  217. package/lib/styles/GlobalStyle.d.ts.map +1 -1
  218. package/lib/styles/GlobalStyle.js +11 -1
  219. package/lib/styles/GlobalStyle.js.map +1 -1
  220. package/lib/utils/focusHeadingOrContainer.d.ts +1 -1
  221. package/lib/utils/focusHeadingOrContainer.d.ts.map +1 -1
  222. package/lib/utils/focusHeadingOrContainer.js +1 -1
  223. package/lib/utils/focusHeadingOrContainer.js.map +1 -1
  224. package/lib/utils/getFocusables.d.ts +7 -3
  225. package/lib/utils/getFocusables.d.ts.map +1 -1
  226. package/lib/utils/getFocusables.js +31 -9
  227. package/lib/utils/getFocusables.js.map +1 -1
  228. package/package.json +6 -5
@@ -211,7 +211,9 @@ const RadioCheck = forwardRef(function RadioCheck(props, ref) {
211
211
  newRef.current.indeterminate = !!indeterminate;
212
212
  }
213
213
  }, [newRef, indeterminate, isRadio]);
214
- return (_jsx(FormField, { as: card ? StyledRadioCheckCard : StyledRadioCheck, label: _jsxs(_Fragment, { children: [_jsx(StyledPseudoRadioCheck, { status: status, isRadio: isRadio, as: StyledFormControl, required: required, disabled: disabled, readOnly: readOnly }), _jsxs(_Fragment, { children: [label, readOnly && _jsx(VisuallyHiddenText, { children: ` ${t('read_only')}` })] })] }), labelAs: card ? 'div' : undefined, id: id, required: required, disabled: disabled, readOnly: readOnly, status: status, info: info, isRadioCheck: true, inline: true, labelAfter: true, additionalInfo: additionalInfo, children: _jsx(StyledRadioCheckInput, { ...restProps, id: id, type: type, required: required, disabled: disabled, readOnly: readOnly, onClick: (e) => {
214
+ return (_jsx(FormField, { as: card ? StyledRadioCheckCard : StyledRadioCheck, label: _jsxs(_Fragment, { children: [_jsx(StyledPseudoRadioCheck, { status: status, isRadio: isRadio, as: StyledFormControl, required: required, disabled: disabled, readOnly: readOnly, onMouseDown: (e) => {
215
+ e.preventDefault();
216
+ } }), _jsxs(_Fragment, { children: [label, readOnly && _jsx(VisuallyHiddenText, { children: ` ${t('read_only')}` })] })] }), labelAs: card ? 'div' : undefined, id: id, required: required, disabled: disabled, readOnly: readOnly, status: status, info: info, isRadioCheck: true, inline: true, labelAfter: true, additionalInfo: additionalInfo, children: _jsx(StyledRadioCheckInput, { ...restProps, id: id, type: type, required: required, disabled: disabled, readOnly: readOnly, onClick: (e) => {
215
217
  if (readOnly)
216
218
  e.preventDefault();
217
219
  onClick?.(e);
@@ -1 +1 @@
1
- {"version":3,"file":"RadioCheck.js","sourceRoot":"","sources":["../../../src/components/RadioCheck/RadioCheck.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAU9C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE5D,OAAO,SAAS,EAAE,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAgDvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAC9C,KAAK,CAAC,EAAE;IACN,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,OAAO,EAAE,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,EACrD,EACD,UAAU,EAAE,EACV,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,EACb,IAAI,EACJ,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,cAAc,EAAE,WAAW,EAC5B,EACF,EACF,EACD,MAAM,EACP,GAAG,KAAK,CAAC;IAEV,MAAM,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AAC,QAAQ,CAAC,OAAO,CAAC,EAAE;oBAC3D,CAAC,CAAC,cAAc,EAAE,CAAC;iBACpB;gBAED,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,EACD,GAAG,EAAE,MAAM,GACX,GACQ,CACb,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useEffect } from 'react';\nimport type {\n FC,\n Ref,\n MouseEvent,\n KeyboardEvent,\n PropsWithoutRef,\n MouseEventHandler,\n KeyboardEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor, hideVisually, mix } from 'polished';\n\nimport FormField, { StyledFormFieldInfo } from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport type { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { useConsolidatedRef, useDirection, useI18n, useUID } from '../../hooks';\nimport { StyledLabel } from '../Label';\nimport { calculateFontSize } from '../../styles';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nexport interface RadioCheckProps extends BaseProps, NoChildrenProp {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Sets the type of input. */\n type: 'radio' | 'checkbox';\n /** Sets checked prop via onChange when using as controlled component. */\n checked?: boolean;\n /** Initialize checked prop when using as uncontrolled component. */\n defaultChecked?: boolean;\n /**\n * Sets control to an an indeterminate state.\n * @default false\n */\n indeterminate?: boolean;\n /**\n * Controls the styling of the RadioCheck.\n * @default 'simple'\n */\n variant?: 'simple' | 'card';\n /** Callback function for onClick events. */\n onClick?: MouseEventHandler<HTMLInputElement>;\n /** Callback function for onKeyDown events. */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n /** info like error, success, warning messages */\n info?: FormControlProps['info'];\n /** Ref forwarded to the underlying input. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const StyledPseudoRadioCheck = styled.div<Pick<RadioCheckProps, 'readOnly' | 'status'>>(\n props => {\n const {\n theme: {\n base: {\n spacing,\n palette: { 'primary-background': primaryBackground }\n },\n components: {\n 'form-field': formField,\n 'radio-check': {\n size,\n 'touch-size': touchSize,\n 'background-color': backgroundColor,\n 'border-color': borderColor,\n 'border-width': borderWidth\n }\n }\n },\n status\n } = props;\n\n const useBorderColor = status === 'error' ? formField.error['status-color'] : borderColor;\n const useBackgroundColor =\n status && formField[status]\n ? tryCatch(() => mix(0.8, primaryBackground, formField[status]['status-color']))\n : backgroundColor;\n\n return css`\n display: flex;\n flex-shrink: 0;\n position: relative;\n width: ${size};\n height: ${size};\n margin-inline-end: ${spacing};\n border: ${borderWidth} solid ${useBorderColor};\n background-color: ${useBackgroundColor};\n\n @media (pointer: coarse) {\n width: ${touchSize};\n height: ${touchSize};\n }\n\n &::after {\n content: '';\n display: none;\n }\n `;\n }\n);\n\nStyledPseudoRadioCheck.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheckInput = styled.input(props => {\n const {\n disabled,\n theme: {\n base: { 'border-radius': baseBorderRadius },\n components: {\n 'form-control': {\n ':focus': { 'box-shadow': shadow, 'border-color': focusBorderColor },\n ':read-only': { 'background-color': readOnlyBackgroundColor }\n },\n 'radio-check': {\n size,\n ':checked': {\n 'background-color': checkedBackgroundColor,\n 'border-color': checkedBorderColor\n }\n },\n checkbox: { 'border-radius': checkRadius },\n 'radio-button': { 'border-radius': radioRadius }\n }\n }\n } = props;\n\n const backgroundColor = props.readOnly ? readOnlyBackgroundColor : checkedBackgroundColor;\n const foreground = tryCatch(() => readableColor(backgroundColor));\n\n const prcSelector = `+ ${StyledLabel} ${StyledPseudoRadioCheck}`;\n const { ltr } = useDirection();\n\n return css`\n ${hideVisually}\n margin: 0;\n\n /* Sets rect size for JAWS focus outline */\n width: ${size};\n height: ${size};\n\n ${!disabled &&\n css`\n &:focus ${prcSelector} {\n box-shadow: ${shadow};\n border-color: ${focusBorderColor};\n }\n `}\n\n &:checked\n ${prcSelector},\n &:checked:disabled\n ${prcSelector},\n &[type='checkbox']:indeterminate\n ${prcSelector},\n &[type='checkbox']:indeterminate:disabled\n ${prcSelector} {\n border-color: ${props.readOnly ? 'inherit' : checkedBorderColor};\n background-color: ${backgroundColor};\n\n &::after {\n display: block;\n }\n }\n\n &[type='radio'] ${prcSelector}, &[type='radio'] ${prcSelector}::after {\n border-radius: ${radioRadius};\n }\n\n &[type='radio'] ${prcSelector}::after {\n margin: auto;\n width: 100%;\n height: 100%;\n background-color: ${foreground};\n transform: scale(0.4);\n }\n\n &[type='checkbox'] ${prcSelector} {\n border-radius: min(calc(${baseBorderRadius} * ${checkRadius}), 0.25rem);\n }\n\n &[type='checkbox']:not(:indeterminate) ${prcSelector} {\n &::after {\n width: 40%;\n height: 75%;\n ${ltr\n ? css`\n transform: rotate(45deg) translate(50%, -30%);\n `\n : css`\n transform: rotate(45deg) translate(-50%, 30%);\n `}\n border-right: 0.15em solid ${foreground};\n border-bottom: 0.15em solid ${foreground};\n }\n }\n\n &[type='checkbox']:indeterminate ${prcSelector} {\n display: flex;\n &::after {\n width: 90%;\n height: 0.15em;\n margin: auto;\n background-color: ${foreground};\n }\n }\n `;\n});\n\nStyledRadioCheckInput.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheck = styled.div<Pick<RadioCheckProps, 'disabled' | 'readOnly'>>(\n props => {\n const {\n disabled,\n readOnly,\n theme: {\n base,\n components: {\n 'radio-check': {\n label: { color: labelColor, 'font-weight': labelFontWeight }\n },\n 'form-control': {\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n } = props;\n\n const fontSize = calculateFontSize(base['font-size'], base['font-scale']);\n\n return css`\n > ${StyledLabel} {\n cursor: pointer;\n display: flex;\n align-items: center;\n font-weight: ${labelFontWeight};\n word-break: break-word;\n font-size: ${fontSize.s};\n color: ${labelColor};\n margin: 0;\n min-height: ${base['hit-area']['mouse-min']};\n\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n }\n\n > ${StyledFormFieldInfo} {\n margin: 0;\n padding-inline-start: calc(${base.spacing} / 4);\n }\n\n ${!(disabled || readOnly) &&\n css`\n &:not(:focus-within) > ${StyledLabel}:hover ${StyledPseudoRadioCheck} {\n border-color: ${hoverBorderColor};\n }\n `}\n `;\n }\n);\n\nStyledRadioCheck.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheckCard = styled.label<\n Pick<RadioCheckProps, 'disabled' | 'readOnly' | 'status'>\n>(\n ({\n disabled,\n readOnly,\n status,\n theme: {\n base: { palette, shadow, spacing },\n components: {\n card,\n 'form-field': formField,\n 'radio-check': { label },\n 'form-control': {\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n }) => {\n const useBorderColor =\n status === 'error' ? formField.error['status-color'] : palette['border-line'];\n\n return css`\n min-width: min-content;\n cursor: pointer;\n background-color: ${card.background};\n border-radius: ${card['border-radius']};\n border: 0.0625rem solid ${useBorderColor};\n padding: ${spacing};\n\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n\n ${!(disabled || readOnly) &&\n css`\n :hover:not(:focus-within) {\n border-color: ${hoverBorderColor};\n ${StyledLabel} ${StyledPseudoRadioCheck} {\n border-color: ${hoverBorderColor};\n }\n }\n\n :focus-within {\n box-shadow: ${shadow.focus};\n border-color: transparent;\n }\n `}\n\n > ${StyledLabel} {\n display: flex;\n align-items: center;\n color: ${label.color};\n font-weight: ${label['font-weight']};\n margin: 0;\n }\n\n > ${StyledFormFieldInfo} {\n margin: 0;\n padding-inline-start: calc(${spacing} / 4);\n }\n `;\n }\n);\n\nStyledRadioCheckCard.defaultProps = defaultThemeProp;\n\nconst RadioCheck: FC<RadioCheckProps & ForwardProps> = forwardRef(function RadioCheck(\n props: PropsWithoutRef<RadioCheckProps>,\n ref: RadioCheckProps['ref']\n) {\n const uid = useUID();\n const t = useI18n();\n\n const {\n type,\n id = uid,\n label,\n required = false,\n disabled = false,\n indeterminate = false,\n readOnly = false,\n variant = 'simple',\n onClick,\n onKeyDown,\n status,\n info,\n additionalInfo,\n ...restProps\n } = props;\n\n const isRadio = type === 'radio';\n const card = variant === 'card';\n const newRef = useConsolidatedRef(ref);\n\n useEffect(() => {\n if (!isRadio && newRef.current) {\n newRef.current.indeterminate = !!indeterminate;\n }\n }, [newRef, indeterminate, isRadio]);\n\n return (\n <FormField\n as={card ? StyledRadioCheckCard : StyledRadioCheck}\n label={\n <>\n <StyledPseudoRadioCheck\n status={status}\n isRadio={isRadio}\n as={StyledFormControl}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n />\n <>\n {label}\n {readOnly && <VisuallyHiddenText>{` ${t('read_only')}`}</VisuallyHiddenText>}\n </>\n </>\n }\n labelAs={card ? 'div' : undefined}\n id={id}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={status}\n info={info}\n isRadioCheck\n inline\n labelAfter\n additionalInfo={additionalInfo}\n >\n <StyledRadioCheckInput\n {...restProps}\n id={id}\n type={type}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n if (readOnly) e.preventDefault();\n\n onClick?.(e);\n }}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (type === 'checkbox' && readOnly && e.key === ' ') {\n e.preventDefault();\n }\n if (type === 'radio' && readOnly && e.key.includes('Arrow')) {\n e.preventDefault();\n }\n\n onKeyDown?.(e);\n }}\n ref={newRef}\n />\n </FormField>\n );\n});\n\nexport default RadioCheck;\n"]}
1
+ {"version":3,"file":"RadioCheck.js","sourceRoot":"","sources":["../../../src/components/RadioCheck/RadioCheck.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAU9C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE5D,OAAO,SAAS,EAAE,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAgDvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAC9C,KAAK,CAAC,EAAE;IACN,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,OAAO,EAAE,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,EACrD,EACD,UAAU,EAAE,EACV,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,EACb,IAAI,EACJ,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,cAAc,EAAE,WAAW,EAC5B,EACF,EACF,EACD,MAAM,EACP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GAAG,EAAE;oBACpD,CAAC,CAAC,cAAc,EAAE,CAAC;iBACpB;gBACD,IAAI,IAAI,KAAK,OAAO,IAAI,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;oBAC3D,CAAC,CAAC,cAAc,EAAE,CAAC;iBACpB;gBAED,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC,EACD,GAAG,EAAE,MAAM,GACX,GACQ,CACb,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, useEffect } from 'react';\nimport type {\n FC,\n Ref,\n MouseEvent,\n KeyboardEvent,\n PropsWithoutRef,\n MouseEventHandler,\n KeyboardEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor, hideVisually, mix } from 'polished';\n\nimport FormField, { StyledFormFieldInfo } from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport type { BaseProps, ForwardProps, NoChildrenProp } from '../../types';\nimport { useConsolidatedRef, useDirection, useI18n, useUID } from '../../hooks';\nimport { StyledLabel } from '../Label';\nimport { calculateFontSize } from '../../styles';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nexport interface RadioCheckProps extends BaseProps, NoChildrenProp {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Sets the type of input. */\n type: 'radio' | 'checkbox';\n /** Sets checked prop via onChange when using as controlled component. */\n checked?: boolean;\n /** Initialize checked prop when using as uncontrolled component. */\n defaultChecked?: boolean;\n /**\n * Sets control to an an indeterminate state.\n * @default false\n */\n indeterminate?: boolean;\n /**\n * Controls the styling of the RadioCheck.\n * @default 'simple'\n */\n variant?: 'simple' | 'card';\n /** Callback function for onClick events. */\n onClick?: MouseEventHandler<HTMLInputElement>;\n /** Callback function for onKeyDown events. */\n onKeyDown?: KeyboardEventHandler<HTMLInputElement>;\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n /** info like error, success, warning messages */\n info?: FormControlProps['info'];\n /** Ref forwarded to the underlying input. */\n ref?: Ref<HTMLInputElement>;\n}\n\nexport const StyledPseudoRadioCheck = styled.div<Pick<RadioCheckProps, 'readOnly' | 'status'>>(\n props => {\n const {\n theme: {\n base: {\n spacing,\n palette: { 'primary-background': primaryBackground }\n },\n components: {\n 'form-field': formField,\n 'radio-check': {\n size,\n 'touch-size': touchSize,\n 'background-color': backgroundColor,\n 'border-color': borderColor,\n 'border-width': borderWidth\n }\n }\n },\n status\n } = props;\n\n const useBorderColor = status === 'error' ? formField.error['status-color'] : borderColor;\n const useBackgroundColor =\n status && formField[status]\n ? tryCatch(() => mix(0.8, primaryBackground, formField[status]['status-color']))\n : backgroundColor;\n\n return css`\n display: flex;\n flex-shrink: 0;\n position: relative;\n width: ${size};\n height: ${size};\n margin-inline-end: ${spacing};\n border: ${borderWidth} solid ${useBorderColor};\n background-color: ${useBackgroundColor};\n\n @media (pointer: coarse) {\n width: ${touchSize};\n height: ${touchSize};\n }\n\n &::after {\n content: '';\n display: none;\n }\n `;\n }\n);\n\nStyledPseudoRadioCheck.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheckInput = styled.input(props => {\n const {\n disabled,\n theme: {\n base: { 'border-radius': baseBorderRadius },\n components: {\n 'form-control': {\n ':focus': { 'box-shadow': shadow, 'border-color': focusBorderColor },\n ':read-only': { 'background-color': readOnlyBackgroundColor }\n },\n 'radio-check': {\n size,\n ':checked': {\n 'background-color': checkedBackgroundColor,\n 'border-color': checkedBorderColor\n }\n },\n checkbox: { 'border-radius': checkRadius },\n 'radio-button': { 'border-radius': radioRadius }\n }\n }\n } = props;\n\n const backgroundColor = props.readOnly ? readOnlyBackgroundColor : checkedBackgroundColor;\n const foreground = tryCatch(() => readableColor(backgroundColor));\n\n const prcSelector = `+ ${StyledLabel} ${StyledPseudoRadioCheck}`;\n const { ltr } = useDirection();\n\n return css`\n ${hideVisually}\n margin: 0;\n\n /* Sets rect size for JAWS focus outline */\n width: ${size};\n height: ${size};\n\n ${!disabled &&\n css`\n &:focus ${prcSelector} {\n box-shadow: ${shadow};\n border-color: ${focusBorderColor};\n }\n `}\n\n &:checked\n ${prcSelector},\n &:checked:disabled\n ${prcSelector},\n &[type='checkbox']:indeterminate\n ${prcSelector},\n &[type='checkbox']:indeterminate:disabled\n ${prcSelector} {\n border-color: ${props.readOnly ? 'inherit' : checkedBorderColor};\n background-color: ${backgroundColor};\n\n &::after {\n display: block;\n }\n }\n\n &[type='radio'] ${prcSelector}, &[type='radio'] ${prcSelector}::after {\n border-radius: ${radioRadius};\n }\n\n &[type='radio'] ${prcSelector}::after {\n margin: auto;\n width: 100%;\n height: 100%;\n background-color: ${foreground};\n transform: scale(0.4);\n }\n\n &[type='checkbox'] ${prcSelector} {\n border-radius: min(calc(${baseBorderRadius} * ${checkRadius}), 0.25rem);\n }\n\n &[type='checkbox']:not(:indeterminate) ${prcSelector} {\n &::after {\n width: 40%;\n height: 75%;\n ${ltr\n ? css`\n transform: rotate(45deg) translate(50%, -30%);\n `\n : css`\n transform: rotate(45deg) translate(-50%, 30%);\n `}\n border-right: 0.15em solid ${foreground};\n border-bottom: 0.15em solid ${foreground};\n }\n }\n\n &[type='checkbox']:indeterminate ${prcSelector} {\n display: flex;\n &::after {\n width: 90%;\n height: 0.15em;\n margin: auto;\n background-color: ${foreground};\n }\n }\n `;\n});\n\nStyledRadioCheckInput.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheck = styled.div<Pick<RadioCheckProps, 'disabled' | 'readOnly'>>(\n props => {\n const {\n disabled,\n readOnly,\n theme: {\n base,\n components: {\n 'radio-check': {\n label: { color: labelColor, 'font-weight': labelFontWeight }\n },\n 'form-control': {\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n } = props;\n\n const fontSize = calculateFontSize(base['font-size'], base['font-scale']);\n\n return css`\n > ${StyledLabel} {\n cursor: pointer;\n display: flex;\n align-items: center;\n font-weight: ${labelFontWeight};\n word-break: break-word;\n font-size: ${fontSize.s};\n color: ${labelColor};\n margin: 0;\n min-height: ${base['hit-area']['mouse-min']};\n\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n }\n }\n\n > ${StyledFormFieldInfo} {\n margin: 0;\n padding-inline-start: calc(${base.spacing} / 4);\n }\n\n ${!(disabled || readOnly) &&\n css`\n &:not(:focus-within) > ${StyledLabel}:hover ${StyledPseudoRadioCheck} {\n border-color: ${hoverBorderColor};\n }\n `}\n `;\n }\n);\n\nStyledRadioCheck.defaultProps = defaultThemeProp;\n\nexport const StyledRadioCheckCard = styled.label<\n Pick<RadioCheckProps, 'disabled' | 'readOnly' | 'status'>\n>(\n ({\n disabled,\n readOnly,\n status,\n theme: {\n base: { palette, shadow, spacing },\n components: {\n card,\n 'form-field': formField,\n 'radio-check': { label },\n 'form-control': {\n ':hover': { 'border-color': hoverBorderColor }\n }\n }\n }\n }) => {\n const useBorderColor =\n status === 'error' ? formField.error['status-color'] : palette['border-line'];\n\n return css`\n min-width: min-content;\n cursor: pointer;\n background-color: ${card.background};\n border-radius: ${card['border-radius']};\n border: 0.0625rem solid ${useBorderColor};\n padding: ${spacing};\n\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n\n ${!(disabled || readOnly) &&\n css`\n :hover:not(:focus-within) {\n border-color: ${hoverBorderColor};\n ${StyledLabel} ${StyledPseudoRadioCheck} {\n border-color: ${hoverBorderColor};\n }\n }\n\n :focus-within {\n box-shadow: ${shadow.focus};\n border-color: transparent;\n }\n `}\n\n > ${StyledLabel} {\n display: flex;\n align-items: center;\n color: ${label.color};\n font-weight: ${label['font-weight']};\n margin: 0;\n }\n\n > ${StyledFormFieldInfo} {\n margin: 0;\n padding-inline-start: calc(${spacing} / 4);\n }\n `;\n }\n);\n\nStyledRadioCheckCard.defaultProps = defaultThemeProp;\n\nconst RadioCheck: FC<RadioCheckProps & ForwardProps> = forwardRef(function RadioCheck(\n props: PropsWithoutRef<RadioCheckProps>,\n ref: RadioCheckProps['ref']\n) {\n const uid = useUID();\n const t = useI18n();\n\n const {\n type,\n id = uid,\n label,\n required = false,\n disabled = false,\n indeterminate = false,\n readOnly = false,\n variant = 'simple',\n onClick,\n onKeyDown,\n status,\n info,\n additionalInfo,\n ...restProps\n } = props;\n\n const isRadio = type === 'radio';\n const card = variant === 'card';\n const newRef = useConsolidatedRef(ref);\n\n useEffect(() => {\n if (!isRadio && newRef.current) {\n newRef.current.indeterminate = !!indeterminate;\n }\n }, [newRef, indeterminate, isRadio]);\n\n return (\n <FormField\n as={card ? StyledRadioCheckCard : StyledRadioCheck}\n label={\n <>\n <StyledPseudoRadioCheck\n status={status}\n isRadio={isRadio}\n as={StyledFormControl}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n onMouseDown={(e: MouseEvent<HTMLInputElement>) => {\n e.preventDefault();\n }}\n />\n <>\n {label}\n {readOnly && <VisuallyHiddenText>{` ${t('read_only')}`}</VisuallyHiddenText>}\n </>\n </>\n }\n labelAs={card ? 'div' : undefined}\n id={id}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n status={status}\n info={info}\n isRadioCheck\n inline\n labelAfter\n additionalInfo={additionalInfo}\n >\n <StyledRadioCheckInput\n {...restProps}\n id={id}\n type={type}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n onClick={(e: MouseEvent<HTMLInputElement>) => {\n if (readOnly) e.preventDefault();\n\n onClick?.(e);\n }}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n if (type === 'checkbox' && readOnly && e.key === ' ') {\n e.preventDefault();\n }\n if (type === 'radio' && readOnly && e.key.includes('Arrow')) {\n e.preventDefault();\n }\n\n onKeyDown?.(e);\n }}\n ref={newRef}\n />\n </FormField>\n );\n});\n\nexport default RadioCheck;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SearchInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/SearchInput/SearchInput.styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB,oNAM7B,CAAC;AAIH,eAAO,MAAM,gBAAgB;;uDA0B5B,CAAC;AAIF,eAAO,MAAM,kBAAkB,qMAW7B,CAAC;AAIH,eAAO,MAAM,qBAAqB;;;eAA8B,OAAO;SA+CrE,CAAC;AAIH,eAAO,MAAM,iBAAiB;gBAA4B,OAAO;SA+BhE,CAAC;AAIF,eAAO,MAAM,gBAAgB,yGAI5B,CAAC;AAEF,eAAO,MAAM,4BAA4B,yGAExC,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAAe,CAAC;AAEjD,eAAO,MAAM,oBAAoB,yGAAe,CAAC"}
1
+ {"version":3,"file":"SearchInput.styles.d.ts","sourceRoot":"","sources":["../../../src/components/SearchInput/SearchInput.styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB,oNAU7B,CAAC;AAIH,eAAO,MAAM,gBAAgB;;uDA0B5B,CAAC;AAIF,eAAO,MAAM,kBAAkB,qMAiB7B,CAAC;AAIH,eAAO,MAAM,qBAAqB;;;eAA8B,OAAO;SA+CrE,CAAC;AAIH,eAAO,MAAM,iBAAiB;gBAA4B,OAAO;SAoChE,CAAC;AAIF,eAAO,MAAM,gBAAgB,yGAI5B,CAAC;AAEF,eAAO,MAAM,4BAA4B,yGAExC,CAAC;AAIF,eAAO,MAAM,oBAAoB,yGAAe,CAAC;AAEjD,eAAO,MAAM,oBAAoB,yGAAe,CAAC"}
@@ -11,6 +11,10 @@ export const StyledSearchButton = styled(BareButton)(({ theme: { base } }) => {
11
11
  return css `
12
12
  padding-inline-start: ${base.spacing};
13
13
  color: ${iconColor};
14
+
15
+ @media (pointer: coarse) {
16
+ padding-inline-start: calc(3 * ${base.spacing});
17
+ }
14
18
  `;
15
19
  });
16
20
  StyledSearchButton.defaultProps = defaultThemeProp;
@@ -45,6 +49,12 @@ export const StyledCancelButton = styled(Button)(({ theme }) => {
45
49
  (${theme.components.input.height} - ${theme.base['hit-area'].compact}) / 2
46
50
  );
47
51
  z-index: 3;
52
+
53
+ @media (pointer: coarse) {
54
+ inset-block-start: calc(
55
+ (${theme.base['hit-area']['finger-min']} - ${theme.base['hit-area'].compact}) / 2
56
+ );
57
+ }
48
58
  `;
49
59
  });
50
60
  StyledCancelButton.defaultProps = defaultThemeProp;
@@ -119,6 +129,11 @@ export const StyledSearchInput = styled.div(({ theme: { base, components: { inpu
119
129
  box-shadow: ${formControl[':focus']['box-shadow']};
120
130
  }
121
131
  `}
132
+
133
+ @media (pointer: coarse) {
134
+ min-height: ${base['hit-area']['finger-min']};
135
+ min-width: ${base['hit-area']['finger-min']};
136
+ }
122
137
  `;
123
138
  });
124
139
  StyledSearchInput.defaultProps = defaultThemeProp;
@@ -1 +1 @@
1
- {"version":3,"file":"SearchInput.styles.js","sourceRoot":"","sources":["../../../src/components/SearchInput/SearchInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,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WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,EAChF,EACD,UAAU,EACX,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;oBACM,WAAW,CAAC,kBAAkB,CAAC;oBAC/B,KAAK,CAAC,MAAM;;gBAEhB,KAAK,CAAC,MAAM;4BACA,WAAW,CAAC,eAAe,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC;QAC3E,UAAU;QACV,CAAC,CAAC,GAAG,CAAA;;WAEF;QACH,CAAC,CAAC,GAAG,CAAA;sBACS,KAAK,CAAC,cAAc,CAAC,UAAU,KAAK,CAAC,cAAc,CAAC;WAC/D;;QAEH,CAAC,UAAU;QACb,GAAG,CAAA;;0BAEiB,IAAI,CAAC,OAAO,CAAC,KAAK;wBACpB,WAAW,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC;;OAEpD;KACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIzC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,GAAG,CAAA;iBACrC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;CACjD,CAAC;AAEF,4BAA4B,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC","sourcesContent":["import { transparentize } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport MenuButton from '../MenuButton';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport Button from '../Button';\nimport BareButton from '../Button/BareButton';\nimport Input from '../Input';\n\nexport const StyledSearchButton = styled(BareButton)(({ theme: { base } }) => {\n const iconColor = tryCatch(() => transparentize(0.3, base.palette['foreground-color']));\n return css`\n padding-inline-start: ${base.spacing};\n color: ${iconColor};\n `;\n});\n\nStyledSearchButton.defaultProps = defaultThemeProp;\n\nexport const StyledMenuButton = styled(MenuButton)(\n ({\n theme: {\n base,\n components: { 'search-input': searchInput, 'form-control': formControl, input }\n }\n }) => {\n const iconColor = tryCatch(() => transparentize(0.3, base.palette['foreground-color']));\n return css`\n border-start-start-radius: calc(${base['border-radius']} * ${searchInput['border-radius']});\n border-end-start-radius: calc(${base['border-radius']} * ${searchInput['border-radius']});\n padding-inline-start: ${base.spacing};\n border: ${input['border-width']} solid ${input['border-color']};\n color: ${iconColor};\n position: relative;\n z-index: 2;\n &:hover {\n text-decoration: none;\n }\n\n &:focus:enabled {\n border-color: ${formControl[':focus']['border-color']};\n box-shadow: ${formControl[':focus']['box-shadow']};\n }\n `;\n }\n);\n\nStyledMenuButton.defaultProps = defaultThemeProp;\n\nexport const StyledCancelButton = styled(Button)(({ theme }) => {\n return css`\n position: absolute;\n inset-inline-end: calc(\n (${theme.base['hit-area'].finger} - ${theme.base['hit-area'].compact}) / 2\n );\n inset-block-start: calc(\n (${theme.components.input.height} - ${theme.base['hit-area'].compact}) / 2\n );\n z-index: 3;\n `;\n});\n\nStyledCancelButton.defaultProps = defaultThemeProp;\n\nexport const StyledSearchTextInput = styled(Input)<{ decoupled: boolean }>(props => {\n const { theme, decoupled } = props;\n const comp = theme.components['search-input'];\n return css`\n flex: 1;\n background: transparent;\n padding-inline-end: calc(${theme.base['hit-area'].finger});\n border-radius: calc(${comp['border-radius']} * ${theme.base['border-radius']});\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n ${decoupled\n ? css`\n border-inline-start: none;\n `\n : css`\n border: none;\n `}\n height: 100%;\n min-height: 100%;\n position: relative;\n z-index: 1;\n\n &[value=''] {\n padding-inline-end: 0;\n }\n\n &::-ms-clear {\n display: none;\n }\n\n &::-webkit-search-cancel-button {\n display: none;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n &:focus:not([disabled]) {\n z-index: 2;\n ${!decoupled &&\n css`\n border: none;\n box-shadow: none;\n `}\n }\n `;\n});\n\nStyledSearchTextInput.defaultProps = defaultThemeProp;\n\nexport const StyledSearchInput = styled.div<{ hasFilters: boolean }>(\n ({\n theme: {\n base,\n components: { input, 'form-control': formControl, 'search-input': searchInput }\n },\n hasFilters\n }) => {\n return css`\n background: ${formControl['background-color']};\n min-height: ${input.height};\n position: relative;\n height: ${input.height};\n border-radius: calc(${searchInput['border-radius']} * ${base['border-radius']});\n ${hasFilters\n ? css`\n border: none;\n `\n : css`\n border: ${input['border-width']} solid ${input['border-color']};\n `}\n\n ${!hasFilters &&\n css`\n :focus-within {\n border-color: ${base.palette.light};\n box-shadow: ${formControl[':focus']['box-shadow']};\n }\n `}\n `;\n }\n);\n\nStyledSearchInput.defaultProps = defaultThemeProp;\n\nexport const StyledSearchMenu = styled.div`\n header {\n border-bottom: none;\n }\n`;\n\nexport const StyledSearchResultsContainer = styled.div`\n padding-top: ${props => props.theme.base.spacing};\n`;\n\nStyledSearchResultsContainer.defaultProps = defaultThemeProp;\n\nexport const StyledFiltersPopover = styled.div``;\n\nexport const StyledResultsPopover = styled.div``;\n"]}
1
+ {"version":3,"file":"SearchInput.styles.js","sourceRoot":"","sources":["../../../src/components/SearchInput/SearchInput.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,KAAK,MAA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AC","sourcesContent":["import { transparentize } from 'polished';\nimport styled, { css } from 'styled-components';\n\nimport MenuButton from '../MenuButton';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport Button from '../Button';\nimport BareButton from '../Button/BareButton';\nimport Input from '../Input';\n\nexport const StyledSearchButton = styled(BareButton)(({ theme: { base } }) => {\n const iconColor = tryCatch(() => transparentize(0.3, base.palette['foreground-color']));\n return css`\n padding-inline-start: ${base.spacing};\n color: ${iconColor};\n\n @media (pointer: coarse) {\n padding-inline-start: calc(3 * ${base.spacing});\n }\n `;\n});\n\nStyledSearchButton.defaultProps = defaultThemeProp;\n\nexport const StyledMenuButton = styled(MenuButton)(\n ({\n theme: {\n base,\n components: { 'search-input': searchInput, 'form-control': formControl, input }\n }\n }) => {\n const iconColor = tryCatch(() => transparentize(0.3, base.palette['foreground-color']));\n return css`\n border-start-start-radius: calc(${base['border-radius']} * ${searchInput['border-radius']});\n border-end-start-radius: calc(${base['border-radius']} * ${searchInput['border-radius']});\n padding-inline-start: ${base.spacing};\n border: ${input['border-width']} solid ${input['border-color']};\n color: ${iconColor};\n position: relative;\n z-index: 2;\n &:hover {\n text-decoration: none;\n }\n\n &:focus:enabled {\n border-color: ${formControl[':focus']['border-color']};\n box-shadow: ${formControl[':focus']['box-shadow']};\n }\n `;\n }\n);\n\nStyledMenuButton.defaultProps = defaultThemeProp;\n\nexport const StyledCancelButton = styled(Button)(({ theme }) => {\n return css`\n position: absolute;\n inset-inline-end: calc(\n (${theme.base['hit-area'].finger} - ${theme.base['hit-area'].compact}) / 2\n );\n inset-block-start: calc(\n (${theme.components.input.height} - ${theme.base['hit-area'].compact}) / 2\n );\n z-index: 3;\n\n @media (pointer: coarse) {\n inset-block-start: calc(\n (${theme.base['hit-area']['finger-min']} - ${theme.base['hit-area'].compact}) / 2\n );\n }\n `;\n});\n\nStyledCancelButton.defaultProps = defaultThemeProp;\n\nexport const StyledSearchTextInput = styled(Input)<{ decoupled: boolean }>(props => {\n const { theme, decoupled } = props;\n const comp = theme.components['search-input'];\n return css`\n flex: 1;\n background: transparent;\n padding-inline-end: calc(${theme.base['hit-area'].finger});\n border-radius: calc(${comp['border-radius']} * ${theme.base['border-radius']});\n border-start-start-radius: 0;\n border-end-start-radius: 0;\n ${decoupled\n ? css`\n border-inline-start: none;\n `\n : css`\n border: none;\n `}\n height: 100%;\n min-height: 100%;\n position: relative;\n z-index: 1;\n\n &[value=''] {\n padding-inline-end: 0;\n }\n\n &::-ms-clear {\n display: none;\n }\n\n &::-webkit-search-cancel-button {\n display: none;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n &:focus:not([disabled]) {\n z-index: 2;\n ${!decoupled &&\n css`\n border: none;\n box-shadow: none;\n `}\n }\n `;\n});\n\nStyledSearchTextInput.defaultProps = defaultThemeProp;\n\nexport const StyledSearchInput = styled.div<{ hasFilters: boolean }>(\n ({\n theme: {\n base,\n components: { input, 'form-control': formControl, 'search-input': searchInput }\n },\n hasFilters\n }) => {\n return css`\n background: ${formControl['background-color']};\n min-height: ${input.height};\n position: relative;\n height: ${input.height};\n border-radius: calc(${searchInput['border-radius']} * ${base['border-radius']});\n ${hasFilters\n ? css`\n border: none;\n `\n : css`\n border: ${input['border-width']} solid ${input['border-color']};\n `}\n\n ${!hasFilters &&\n css`\n :focus-within {\n border-color: ${base.palette.light};\n box-shadow: ${formControl[':focus']['box-shadow']};\n }\n `}\n\n @media (pointer: coarse) {\n min-height: ${base['hit-area']['finger-min']};\n min-width: ${base['hit-area']['finger-min']};\n }\n `;\n }\n);\n\nStyledSearchInput.defaultProps = defaultThemeProp;\n\nexport const StyledSearchMenu = styled.div`\n header {\n border-bottom: none;\n }\n`;\n\nexport const StyledSearchResultsContainer = styled.div`\n padding-top: ${props => props.theme.base.spacing};\n`;\n\nStyledSearchResultsContainer.defaultProps = defaultThemeProp;\n\nexport const StyledFiltersPopover = styled.div``;\n\nexport const StyledResultsPopover = styled.div``;\n"]}
@@ -54,7 +54,7 @@ const ShortcutManager = ({ children, target, bindings: customBindings = {} }) =>
54
54
  // don't process event during typing letters/digits into inputs without modifier keys
55
55
  !(e.target instanceof HTMLElement &&
56
56
  ['input', 'textarea'].includes(e.target.nodeName.toLowerCase()) &&
57
- e.key.match(/a-zA-Z0-9/) &&
57
+ (e.code.startsWith('Key') || e.code.startsWith('Digit') || e.code.startsWith('Numpad')) &&
58
58
  !['Control', 'Meta'].some(modifier => e.getModifierState(modifier))),
59
59
  shortcuts: bindings.map(({ action, shortcut }) => ({
60
60
  shortcut,
@@ -1 +1 @@
1
- {"version":3,"file":"ShortcutManager.js","sourceRoot":"","sources":["../../../src/components/ShortcutManager/ShortcutManager.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAG,OAAyB,EAAQ,EAAE;IACnE,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC3B,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,iBAAiB,EAAE,eAAe,EAAE,EAAE,EAAE;YAC7D,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;gBACrB,QAAQ,GAAG;oBACT,GAAI,QAA8B;oBAClC,CAAC,EAAE,CAAC,EAAE,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE;iBAC1E,CAAC;QACN,CAAC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,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EAAE,CAAC;YACzB,gBAAgB,CAAC,GAAG,CAClB,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;gBACtC,QAAQ;gBACR,OAAO,EAAE,CAAC,CAAC,EAAE;oBACX,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;gBACnC,CAAC;aACF,CAAC,CAAC,CACJ,CAAC;SACH;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE/B,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { FunctionComponent } from 'react';\nimport { Shortcuts } from 'shortcuts';\n\nimport { useAfterInitialEffect, useSimpleStore } from '../../hooks';\nimport { hasProp } from '../../utils';\n\nimport type { ShortcutAction, ShortcutManagerProps } from './ShortcutManager.types';\nimport { actionStore } from './Store';\nimport type { ActionDefinitions } from './Store';\n\n/**\n * Function to register an action triggerable using a shortcut. All actions must be registered before\n * binding a callback.\n * @param actions actions with definitions to be registered.\n */\nexport const registerAction = (...actions: ShortcutAction[]): void => {\n actionStore.setStore(store => {\n let newStore = store;\n actions.forEach(({ id, defaultKeyBinding: defaultShortcut }) => {\n if (!hasProp(store, id))\n newStore = {\n ...(newStore as ActionDefinitions),\n [id]: { defaultKeyBinding: defaultShortcut, keyBinding: defaultShortcut }\n };\n });\n return newStore;\n });\n};\n\nconst dispatchShortcutEvent = (actionId: ShortcutAction['id'], e: KeyboardEvent) => {\n const shortcutEvent = new CustomEvent('shortcut', {\n bubbles: true,\n detail: { actionId }\n });\n e.target?.dispatchEvent(shortcutEvent);\n};\n\nconst ShortcutManager: FunctionComponent<ShortcutManagerProps> = ({\n children,\n target,\n bindings: customBindings = {}\n}) => {\n const shortcutsRef = useRef<Shortcuts>();\n\n const [bindings, setBindings] = useSimpleStore(actionStore, store =>\n Object.entries(store).map(([actionId, actionDefinition]) => ({\n action: actionId,\n shortcut: actionDefinition.keyBinding\n }))\n );\n\n useEffect(() => {\n setBindings(store => {\n let newStore = store;\n Object.entries(customBindings).forEach(([actionId, keyBinding]) => {\n newStore = { ...newStore, [actionId]: { ...newStore[actionId], keyBinding } };\n });\n return newStore;\n });\n }, [JSON.stringify(customBindings)]);\n\n useEffect(() => {\n shortcutsRef.current = new Shortcuts({\n target,\n shouldHandleEvent: e =>\n // both 'keydown' and 'keypress' events are handled by default ('shortcuts' bug?)\n e.type === 'keydown' &&\n !e.defaultPrevented &&\n // don't process event during typing letters/digits into inputs without modifier keys\n !(\n e.target instanceof HTMLElement &&\n ['input', 'textarea'].includes(e.target.nodeName.toLowerCase()) &&\n e.key.match(/a-zA-Z0-9/) &&\n !['Control', 'Meta'].some(modifier => e.getModifierState(modifier))\n ),\n shortcuts: bindings.map(({ action, shortcut }) => ({\n shortcut,\n handler: e => {\n e.preventDefault();\n dispatchShortcutEvent(action, e);\n }\n }))\n });\n\n return () => {\n shortcutsRef.current?.reset();\n shortcutsRef.current = undefined;\n };\n }, [target]);\n\n useAfterInitialEffect(() => {\n const shortcutInstance = shortcutsRef.current;\n if (shortcutInstance) {\n shortcutInstance.reset();\n shortcutInstance.add(\n bindings.map(({ action, shortcut }) => ({\n shortcut,\n handler: e => {\n e.preventDefault();\n dispatchShortcutEvent(action, e);\n }\n }))\n );\n }\n }, [JSON.stringify(bindings)]);\n\n return <>{children}</>;\n};\n\nexport default ShortcutManager;\n"]}
1
+ {"version":3,"file":"ShortcutManager.js","sourceRoot":"","sources":["../../../src/components/ShortcutManager/ShortcutManager.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,qBAAqB,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e,eAAe,CAAC","sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { FunctionComponent } from 'react';\nimport { Shortcuts } from 'shortcuts';\n\nimport { useAfterInitialEffect, useSimpleStore } from '../../hooks';\nimport { hasProp } from '../../utils';\n\nimport type { ShortcutAction, ShortcutManagerProps } from './ShortcutManager.types';\nimport { actionStore } from './Store';\nimport type { ActionDefinitions } from './Store';\n\n/**\n * Function to register an action triggerable using a shortcut. All actions must be registered before\n * binding a callback.\n * @param actions actions with definitions to be registered.\n */\nexport const registerAction = (...actions: ShortcutAction[]): void => {\n actionStore.setStore(store => {\n let newStore = store;\n actions.forEach(({ id, defaultKeyBinding: defaultShortcut }) => {\n if (!hasProp(store, id))\n newStore = {\n ...(newStore as ActionDefinitions),\n [id]: { defaultKeyBinding: defaultShortcut, keyBinding: defaultShortcut }\n };\n });\n return newStore;\n });\n};\n\nconst dispatchShortcutEvent = (actionId: ShortcutAction['id'], e: KeyboardEvent) => {\n const shortcutEvent = new CustomEvent('shortcut', {\n bubbles: true,\n detail: { actionId }\n });\n e.target?.dispatchEvent(shortcutEvent);\n};\n\nconst ShortcutManager: FunctionComponent<ShortcutManagerProps> = ({\n children,\n target,\n bindings: customBindings = {}\n}) => {\n const shortcutsRef = useRef<Shortcuts>();\n\n const [bindings, setBindings] = useSimpleStore(actionStore, store =>\n Object.entries(store).map(([actionId, actionDefinition]) => ({\n action: actionId,\n shortcut: actionDefinition.keyBinding\n }))\n );\n\n useEffect(() => {\n setBindings(store => {\n let newStore = store;\n Object.entries(customBindings).forEach(([actionId, keyBinding]) => {\n newStore = { ...newStore, [actionId]: { ...newStore[actionId], keyBinding } };\n });\n return newStore;\n });\n }, [JSON.stringify(customBindings)]);\n\n useEffect(() => {\n shortcutsRef.current = new Shortcuts({\n target,\n shouldHandleEvent: e =>\n // both 'keydown' and 'keypress' events are handled by default ('shortcuts' bug?)\n e.type === 'keydown' &&\n !e.defaultPrevented &&\n // don't process event during typing letters/digits into inputs without modifier keys\n !(\n e.target instanceof HTMLElement &&\n ['input', 'textarea'].includes(e.target.nodeName.toLowerCase()) &&\n (e.code.startsWith('Key') || e.code.startsWith('Digit') || e.code.startsWith('Numpad')) &&\n !['Control', 'Meta'].some(modifier => e.getModifierState(modifier))\n ),\n shortcuts: bindings.map(({ action, shortcut }) => ({\n shortcut,\n handler: e => {\n e.preventDefault();\n dispatchShortcutEvent(action, e);\n }\n }))\n });\n\n return () => {\n shortcutsRef.current?.reset();\n shortcutsRef.current = undefined;\n };\n }, [target]);\n\n useAfterInitialEffect(() => {\n const shortcutInstance = shortcutsRef.current;\n if (shortcutInstance) {\n shortcutInstance.reset();\n shortcutInstance.add(\n bindings.map(({ action, shortcut }) => ({\n shortcut,\n handler: e => {\n e.preventDefault();\n dispatchShortcutEvent(action, e);\n }\n }))\n );\n }\n }, [JSON.stringify(bindings)]);\n\n return <>{children}</>;\n};\n\nexport default ShortcutManager;\n"]}
@@ -7,7 +7,7 @@ export interface TextAreaProps extends FormControlProps, BaseProps, NoChildrenPr
7
7
  /** Maximum length of characters that can be input. */
8
8
  maxLength?: number;
9
9
  /**
10
- * Allows the user to resize the Text Area.
10
+ * Allows the user to resize the Text Area. This prop is ignored if autoResize is true.
11
11
  * @default false
12
12
  */
13
13
  resizable?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAqC,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEvF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQvD,MAAM,WAAW,aAAc,SAAQ,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU;IAC5F,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CACpD;;;;AAuHD,wBAAyD"}
1
+ {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAqC,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEvF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQvD,MAAM,WAAW,aAAc,SAAQ,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU;IAC5F,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;CACpD;;;;AAoID,wBAAyD"}
@@ -1,27 +1,34 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { forwardRef, useCallback, useState, useEffect } from 'react';
2
+ import { forwardRef, useCallback, useState, useEffect, useRef } from 'react';
3
3
  import FormField from '../FormField';
4
4
  import { StyledFormControl } from '../FormControl';
5
5
  import { hasProp, withTestIds } from '../../utils';
6
- import { useAutoResize, useConsolidatedRef, useI18n, useTestIds, useUID } from '../../hooks';
6
+ import { useI18n, useTestIds, useUID } from '../../hooks';
7
7
  import Text from '../Text';
8
- import StyledTextArea from './TextArea.styles';
8
+ import StyledTextArea, { AutoResizeWrapper } from './TextArea.styles';
9
9
  import { getTextAreaTestIds } from './TextArea.test-ids';
10
10
  const TextArea = forwardRef(function TextArea(props, ref) {
11
11
  const uid = useUID();
12
12
  const { testId, additionalInfo, id = uid, value, defaultValue, required = false, disabled = false, readOnly = false, label, labelHidden, info, status, resizable = false, autoResize = true, maxLength, displayCharCount = false, hardStop = true, onChange: onChangeProp, onResolveSuggestion, ...restProps } = props;
13
13
  const t = useI18n();
14
14
  const testIds = useTestIds(testId, getTextAreaTestIds);
15
- const [textAreaRef, resizeTextArea] = useAutoResize();
16
- const consolidatedRef = useConsolidatedRef(textAreaRef, ref);
15
+ const autoResizeRef = useRef(null);
17
16
  const [charCount, setCharCount] = useState(0);
18
17
  const controlProp = {};
18
+ // Sets the content for the hidden pseudo element that calculates the height of the textarea
19
+ const updateAutoResizeEl = (content) => {
20
+ if (autoResize && autoResizeRef.current) {
21
+ autoResizeRef.current.dataset.textareaContent = content ?? '';
22
+ }
23
+ };
19
24
  useEffect(() => {
20
25
  if ('value' in props) {
21
26
  setCharCount(props.value ? props.value.length : 0);
27
+ updateAutoResizeEl(props.value);
22
28
  }
23
29
  else if ('defaultValue' in props) {
24
30
  setCharCount(props.defaultValue ? props.defaultValue.length : 0);
31
+ updateAutoResizeEl(props.defaultValue);
25
32
  }
26
33
  }, [props]);
27
34
  // Conditionally render component as controlled/uncontrolled
@@ -35,10 +42,11 @@ const TextArea = forwardRef(function TextArea(props, ref) {
35
42
  if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {
36
43
  onChangeProp?.(e);
37
44
  setCharCount(e.target.value.length);
38
- resizeTextArea();
45
+ updateAutoResizeEl(e.target.value);
39
46
  }
40
- }, [onChangeProp, resizeTextArea, hardStop, maxLength]);
41
- const Comp = (_jsx(StyledFormControl, { "data-testid": testIds.control, ref: autoResize ? consolidatedRef : ref, id: id, required: required, disabled: disabled, status: status, readOnly: readOnly, resizable: resizable, maxLength: hardStop ? maxLength : undefined, hasSuggestion: status === 'pending' && !!onResolveSuggestion, ...controlProp, ...restProps, onChange: onChange, as: StyledTextArea }));
47
+ }, [onChangeProp, hardStop, maxLength]);
48
+ const TextAreaControl = (_jsx(StyledFormControl, { "data-testid": testIds.control, ref: ref, id: id, required: required, disabled: disabled, status: status, readOnly: readOnly, resizable: autoResize ? false : resizable, maxLength: hardStop ? maxLength : undefined, hasSuggestion: status === 'pending' && !!onResolveSuggestion, ...controlProp, ...restProps, onChange: onChange, as: StyledTextArea }));
49
+ const Comp = autoResize ? (_jsx(AutoResizeWrapper, { ref: autoResizeRef, children: TextAreaControl })) : (_jsx("div", { children: TextAreaControl }));
42
50
  return label || displayCharCount ? (_jsx(FormField, { testId: testIds, additionalInfo: additionalInfo, label: label, labelHidden: labelHidden, id: id, readOnly: readOnly, info: info, status: status, charLimitDisplay: displayCharCount && typeof maxLength === 'number' ? (_jsx(Text, { readOnly: readOnly, variant: 'secondary', "aria-live": maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off', children: maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount })) : undefined, required: required, disabled: disabled, onResolveSuggestion: onResolveSuggestion, children: Comp })) : (Comp);
43
51
  });
44
52
  export default withTestIds(TextArea, getTextAreaTestIds);
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrE,OAAO,SAAS,MAAM,cAAc,CA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AAkB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useState, useEffect } from 'react';\nimport type { FC, Ref, PropsWithoutRef, ChangeEvent, ChangeEventHandler } from 'react';\n\nimport type { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport { hasProp, withTestIds } from '../../utils';\nimport { useAutoResize, useConsolidatedRef, useI18n, useTestIds, useUID } from '../../hooks';\nimport Text from '../Text';\n\nimport StyledTextArea from './TextArea.styles';\nimport { getTextAreaTestIds } from './TextArea.test-ids';\n\nexport interface TextAreaProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /** Minimum length of characters that can be input. */\n minLength?: number;\n /** Maximum length of characters that can be input. */\n maxLength?: number;\n /**\n * Allows the user to resize the Text Area.\n * @default false\n */\n resizable?: boolean;\n /**\n * Enables the Text Area to resize itself automatically.\n * @default true\n */\n autoResize?: boolean;\n /**\n * Display a live character count in relation to the maxLength.\n * @default false\n */\n displayCharCount?: boolean;\n /**\n * Allow or disallow a value beyond the maxLength.\n * @default true\n */\n hardStop?: boolean;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n}\n\nconst TextArea: FC<TextAreaProps & ForwardProps> = forwardRef(function TextArea(\n props: PropsWithoutRef<TextAreaProps>,\n ref: Ref<HTMLTextAreaElement>\n) {\n const uid = useUID();\n const {\n testId,\n additionalInfo,\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n labelHidden,\n info,\n status,\n resizable = false,\n autoResize = true,\n maxLength,\n displayCharCount = false,\n hardStop = true,\n onChange: onChangeProp,\n onResolveSuggestion,\n ...restProps\n } = props;\n const t = useI18n();\n\n const testIds = useTestIds(testId, getTextAreaTestIds);\n\n const [textAreaRef, resizeTextArea] = useAutoResize<HTMLTextAreaElement>();\n const consolidatedRef = useConsolidatedRef(textAreaRef, ref);\n const [charCount, setCharCount] = useState(0);\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n useEffect(() => {\n if ('value' in props) {\n setCharCount(props.value ? props.value.length : 0);\n } else if ('defaultValue' in props) {\n setCharCount(props.defaultValue ? props.defaultValue.length : 0);\n }\n }, [props]);\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 onChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {\n onChangeProp?.(e);\n setCharCount(e.target.value.length);\n resizeTextArea();\n }\n },\n [onChangeProp, resizeTextArea, hardStop, maxLength]\n );\n\n const Comp = (\n <StyledFormControl\n data-testid={testIds.control}\n ref={autoResize ? consolidatedRef : ref}\n id={id}\n required={required}\n disabled={disabled}\n status={status}\n readOnly={readOnly}\n resizable={resizable}\n maxLength={hardStop ? maxLength : undefined}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n {...controlProp}\n {...restProps}\n onChange={onChange}\n as={StyledTextArea}\n />\n );\n\n return label || displayCharCount ? (\n <FormField\n testId={testIds}\n additionalInfo={additionalInfo}\n label={label}\n labelHidden={labelHidden}\n id={id}\n readOnly={readOnly}\n info={info}\n status={status}\n charLimitDisplay={\n displayCharCount && typeof maxLength === 'number' ? (\n <Text\n readOnly={readOnly}\n variant='secondary'\n aria-live={maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off'}\n >\n {maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount}\n </Text>\n ) : undefined\n }\n required={required}\n disabled={disabled}\n onResolveSuggestion={onResolveSuggestion}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n});\n\nexport default withTestIds(TextArea, getTextAreaTestIds);\n"]}
1
+ {"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.t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QAAQ,CAAC,CAAC,CAAC,CAClD,KAAC,IAAI,IACH,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAC,WAAW,eACR,SAAS,IAAI,CAAC,IAAI,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,YAE1E,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,SAAS,IAAI,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GACnE,CACR,CAAC,CAAC,CAAC,SAAS,EAEf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,mBAAmB,YAEvC,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useState, useEffect, useRef } from 'react';\nimport type { FC, Ref, PropsWithoutRef, ChangeEvent, ChangeEventHandler } from 'react';\n\nimport type { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport FormField from '../FormField';\nimport { StyledFormControl } from '../FormControl';\nimport type { FormControlProps } from '../FormControl';\nimport { hasProp, withTestIds } from '../../utils';\nimport { useI18n, useTestIds, useUID } from '../../hooks';\nimport Text from '../Text';\n\nimport StyledTextArea, { AutoResizeWrapper } from './TextArea.styles';\nimport { getTextAreaTestIds } from './TextArea.test-ids';\n\nexport interface TextAreaProps extends FormControlProps, BaseProps, NoChildrenProp, TestIdProp {\n /** Minimum length of characters that can be input. */\n minLength?: number;\n /** Maximum length of characters that can be input. */\n maxLength?: number;\n /**\n * Allows the user to resize the Text Area. This prop is ignored if autoResize is true.\n * @default false\n */\n resizable?: boolean;\n /**\n * Enables the Text Area to resize itself automatically.\n * @default true\n */\n autoResize?: boolean;\n /**\n * Display a live character count in relation to the maxLength.\n * @default false\n */\n displayCharCount?: boolean;\n /**\n * Allow or disallow a value beyond the maxLength.\n * @default true\n */\n hardStop?: boolean;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n}\n\nconst TextArea: FC<TextAreaProps & ForwardProps> = forwardRef(function TextArea(\n props: PropsWithoutRef<TextAreaProps>,\n ref: Ref<HTMLTextAreaElement>\n) {\n const uid = useUID();\n const {\n testId,\n additionalInfo,\n id = uid,\n value,\n defaultValue,\n required = false,\n disabled = false,\n readOnly = false,\n label,\n labelHidden,\n info,\n status,\n resizable = false,\n autoResize = true,\n maxLength,\n displayCharCount = false,\n hardStop = true,\n onChange: onChangeProp,\n onResolveSuggestion,\n ...restProps\n } = props;\n const t = useI18n();\n\n const testIds = useTestIds(testId, getTextAreaTestIds);\n const autoResizeRef = useRef<HTMLDivElement>(null);\n const [charCount, setCharCount] = useState(0);\n\n const controlProp: {\n value?: string;\n defaultValue?: string;\n } = {};\n\n // Sets the content for the hidden pseudo element that calculates the height of the textarea\n const updateAutoResizeEl = (content?: string) => {\n if (autoResize && autoResizeRef.current) {\n autoResizeRef.current.dataset.textareaContent = content ?? '';\n }\n };\n\n useEffect(() => {\n if ('value' in props) {\n setCharCount(props.value ? props.value.length : 0);\n updateAutoResizeEl(props.value);\n } else if ('defaultValue' in props) {\n setCharCount(props.defaultValue ? props.defaultValue.length : 0);\n updateAutoResizeEl(props.defaultValue);\n }\n }, [props]);\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 onChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!hardStop || maxLength === undefined || e.target.value.length <= maxLength) {\n onChangeProp?.(e);\n setCharCount(e.target.value.length);\n updateAutoResizeEl(e.target.value);\n }\n },\n [onChangeProp, hardStop, maxLength]\n );\n\n const TextAreaControl = (\n <StyledFormControl\n data-testid={testIds.control}\n ref={ref}\n id={id}\n required={required}\n disabled={disabled}\n status={status}\n readOnly={readOnly}\n resizable={autoResize ? false : resizable}\n maxLength={hardStop ? maxLength : undefined}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n {...controlProp}\n {...restProps}\n onChange={onChange}\n as={StyledTextArea}\n />\n );\n\n const Comp = autoResize ? (\n <AutoResizeWrapper ref={autoResizeRef}>{TextAreaControl}</AutoResizeWrapper>\n ) : (\n <div>{TextAreaControl}</div>\n );\n\n return label || displayCharCount ? (\n <FormField\n testId={testIds}\n additionalInfo={additionalInfo}\n label={label}\n labelHidden={labelHidden}\n id={id}\n readOnly={readOnly}\n info={info}\n status={status}\n charLimitDisplay={\n displayCharCount && typeof maxLength === 'number' ? (\n <Text\n readOnly={readOnly}\n variant='secondary'\n aria-live={maxLength >= 0 && maxLength - charCount <= 20 ? 'polite' : 'off'}\n >\n {maxLength >= 0 ? t('x_of_y', [charCount || '0', maxLength]) : charCount}\n </Text>\n ) : undefined\n }\n required={required}\n disabled={disabled}\n onResolveSuggestion={onResolveSuggestion}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n});\n\nexport default withTestIds(TextArea, getTextAreaTestIds);\n"]}
@@ -1,5 +1,6 @@
1
1
  declare const StyledTextArea: import("styled-components").StyledComponent<"textarea", import("styled-components").DefaultTheme, {
2
2
  resizable: boolean;
3
3
  }, never>;
4
+ export declare const AutoResizeWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
5
  export default StyledTextArea;
5
6
  //# sourceMappingURL=TextArea.styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.styles.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.styles.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,cAAc;eAAgC,OAAO;SAWzD,CAAC;AAIH,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"TextArea.styles.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.styles.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,cAAc;eAAgC,OAAO;SAczD,CAAC;AAMH,eAAO,MAAM,iBAAiB,yGAqB5B,CAAC;AAIH,eAAe,cAAc,CAAC"}
@@ -6,12 +6,40 @@ const StyledTextArea = styled.textarea(({ resizable }) => {
6
6
  min-height: ${props => props.theme.components['text-area']['min-height']};
7
7
  padding: ${props => props.theme.components['text-area'].padding};
8
8
  -webkit-appearance: none;
9
- ${!resizable &&
10
- css `
11
- resize: none;
12
- `}
9
+ ${resizable
10
+ ? css `
11
+ resize: vertical;
12
+ `
13
+ : css `
14
+ resize: none;
15
+ `}
13
16
  `;
14
17
  });
15
18
  StyledTextArea.defaultProps = defaultThemeProp;
19
+ // Creates a hidden pseudo element identical in size and content to the textarea element
20
+ // The hidden element mimics the textarea and is used to automatically calculate the necessary height
21
+ export const AutoResizeWrapper = styled.div(({ theme }) => {
22
+ return css `
23
+ display: grid;
24
+ grid-template-columns: minmax(0, 1fr);
25
+
26
+ ${StyledTextArea} {
27
+ overflow: hidden;
28
+ grid-area: 1 / 1 / -1 / -1;
29
+ }
30
+
31
+ &::after {
32
+ content: attr(data-textarea-content);
33
+ white-space: pre-wrap;
34
+ overflow-wrap: break-word;
35
+ visibility: hidden;
36
+ border-width: ${theme.components['form-control']['border-width']};
37
+ padding: ${theme.components['text-area'].padding};
38
+ font: inherit;
39
+ grid-area: 1 / 1 / -1 / -1;
40
+ }
41
+ `;
42
+ });
43
+ AutoResizeWrapper.defaultProps = defaultThemeProp;
16
44
  export default StyledTextArea;
17
45
  //# sourceMappingURL=TextArea.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.styles.js","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAyB,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IAC/E,OAAO,GAAG,CAAA;;kBAEM,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC;eAC7D,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO;;MAE7D,CAAC,SAAS;QACZ,GAAG,CAAA;;KAEF;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,eAAe,cAAc,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\n\nconst StyledTextArea = styled.textarea<{ resizable: boolean }>(({ resizable }) => {\n return css`\n width: 100%;\n min-height: ${props => props.theme.components['text-area']['min-height']};\n padding: ${props => props.theme.components['text-area'].padding};\n -webkit-appearance: none;\n ${!resizable &&\n css`\n resize: none;\n `}\n `;\n});\n\nStyledTextArea.defaultProps = defaultThemeProp;\n\nexport default StyledTextArea;\n"]}
1
+ {"version":3,"file":"TextArea.styles.js","sourceRoot":"","sources":["../../../src/components/TextArea/TextArea.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAyB,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;IAC/E,OAAO,GAAG,CAAA;;kBAEM,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC;eAC7D,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO;;MAE7D,SAAS;QACT,CAAC,CAAC,GAAG,CAAA;;SAEF;QACH,CAAC,CAAC,GAAG,CAAA;;SAEF;GACN,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,wFAAwF;AACxF,qGAAqG;AACrG,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACxD,OAAO,GAAG,CAAA;;;;MAIN,cAAc;;;;;;;;;;sBAUE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC;iBACrD,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO;;;;GAInD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,eAAe,cAAc,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\n\nconst StyledTextArea = styled.textarea<{ resizable: boolean }>(({ resizable }) => {\n return css`\n width: 100%;\n min-height: ${props => props.theme.components['text-area']['min-height']};\n padding: ${props => props.theme.components['text-area'].padding};\n -webkit-appearance: none;\n ${resizable\n ? css`\n resize: vertical;\n `\n : css`\n resize: none;\n `}\n `;\n});\n\nStyledTextArea.defaultProps = defaultThemeProp;\n\n// Creates a hidden pseudo element identical in size and content to the textarea element\n// The hidden element mimics the textarea and is used to automatically calculate the necessary height\nexport const AutoResizeWrapper = styled.div(({ theme }) => {\n return css`\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n\n ${StyledTextArea} {\n overflow: hidden;\n grid-area: 1 / 1 / -1 / -1;\n }\n\n &::after {\n content: attr(data-textarea-content);\n white-space: pre-wrap;\n overflow-wrap: break-word;\n visibility: hidden;\n border-width: ${theme.components['form-control']['border-width']};\n padding: ${theme.components['text-area'].padding};\n font: inherit;\n grid-area: 1 / 1 / -1 / -1;\n }\n `;\n});\n\nAutoResizeWrapper.defaultProps = defaultThemeProp;\n\nexport default StyledTextArea;\n"]}
@@ -46,7 +46,7 @@ const Tooltip = forwardRef(function Tooltip({ testId, children, target, showDela
46
46
  showTooltip();
47
47
  };
48
48
  const onFocusOut = () => {
49
- if (lastClickedRef.current !== tooltipRef.current) {
49
+ if (!lastClickedRef.current || lastClickedRef.current !== tooltipRef.current) {
50
50
  setShow(false);
51
51
  }
52
52
  lastClickedRef.current = null;
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAyCvD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACpD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEtF,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,kBAAkB,CAAC;aACvD,KAAK,CAAC,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AO,CACL,KAAC,OAAO,mBACO,OAAO,CAAC,IAAI,EACzB,EAAE,EAAE,EAAE,KACF,SAAS,EACb,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAC,OAAO,EAChB,EAAE,EAAE,aAAa,EACjB,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,MAAM,EACd,KAAK,QACL,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,kBAAkB,QAClB,GAAG,EAAE,UAAU,YAEd,QAAQ,GACD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';\nimport type { FunctionComponent, MutableRefObject, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type { BaseProps, ForwardProps, TestIdProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Popover from '../Popover';\nimport type { Delay, PopoverProps } from '../Popover';\nimport { useConsolidatedRef, useTestIds, useUID } from '../../hooks';\nimport { calculateFontSize } from '../../styles';\nimport { getActiveElement, withTestIds } from '../../utils';\n\nimport { getTooltipTestIds } from './Tooltip.test-ids';\n\nexport interface TooltipProps extends BaseProps, TestIdProp {\n /** Text content for the tooltip. */\n children: string | string[];\n /** Element to serve as the tooltip's target. */\n target: Element | null;\n /**\n * Delay showing the tooltip on mouseenter.\n * @default 'short'\n */\n showDelay?: Delay;\n /**\n * Delay hiding the tooltip on mouseleave.\n * @default 'long'\n */\n hideDelay?: Delay;\n /**\n * If true, the Tooltip will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default true\n */\n portal?: PopoverProps['portal'];\n /**\n * If true, the Tooltip will automatically apply an aria-describedby attribute to its target.\n * @default true\n */\n describeTarget?: boolean;\n /**\n * Sets the placement of the tooltip relative to the target.\n * @default 'bottom'\n */\n placement?: PopoverProps['placement'];\n /**\n * Conditionally renders a tooltip only if the associated element's text content is truncated.\n * To work, the associated element must be be displayed as a CSS \"block box\" i.e. block, inline-block, etc...\n * @default false\n */\n smart?: boolean;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledTooltip = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n background-color: ${theme.components.tooltip['background-color']};\n color: ${theme.components.tooltip['foreground-color']};\n font-size: ${fontSize.xxs};\n max-width: 40ch;\n padding: ${theme.base.spacing};\n white-space: pre-line;\n word-break: break-word;\n pointer-events: none;\n `;\n});\n\nStyledTooltip.defaultProps = defaultThemeProp;\n\nconst Tooltip: FunctionComponent<TooltipProps & ForwardProps> = forwardRef(function Tooltip(\n {\n testId,\n children,\n target,\n showDelay = 'short',\n hideDelay = 'long',\n placement = 'bottom',\n describeTarget = true,\n smart,\n ...restProps\n }: PropsWithoutRef<TooltipProps>,\n ref: Ref<HTMLDivElement>\n) {\n const id = useUID();\n const [show, setShow] = useState(false);\n const tooltipRef = useConsolidatedRef(ref);\n const lastClickedRef: MutableRefObject<EventTarget | null> = useRef(null);\n const testIds = useTestIds(testId, getTooltipTestIds);\n\n const onMouseDown = useCallback(\n ({ target: eTarget }: MouseEvent) => {\n lastClickedRef.current = eTarget;\n if (eTarget === tooltipRef.current || eTarget === target) return;\n setShow(false);\n },\n [target]\n );\n\n useEffect(() => {\n if (!target) return;\n\n const showTooltip = () => {\n setShow(\n // This approach may result in a tooltip NOT appearing 1px before it should due to browser specifics. Enhance as needed.\n // https://stackoverflow.com/a/64747288\n smart ? target.scrollWidth > target.clientWidth : true\n );\n };\n\n const onFocusIn = () => {\n showTooltip();\n };\n\n const onFocusOut = () => {\n if (lastClickedRef.current !== tooltipRef.current) {\n setShow(false);\n }\n lastClickedRef.current = null;\n };\n\n const onMouseEnter = () => {\n showTooltip();\n };\n\n const onMouseLeave = () => {\n if (getActiveElement() !== target) {\n setShow(false);\n }\n };\n\n const onKeyDown = ({ key }: KeyboardEvent) => {\n if (key === 'Escape' && getActiveElement() === target) {\n setShow(false);\n }\n };\n\n document.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onMouseDown);\n\n target.addEventListener('focusin', onFocusIn);\n target.addEventListener('focusout', onFocusOut);\n\n target.addEventListener('mouseenter', onMouseEnter);\n target.addEventListener('mouseleave', onMouseLeave);\n\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onMouseDown);\n\n target.removeEventListener('focusin', onFocusIn);\n target.removeEventListener('focusout', onFocusOut);\n\n target.removeEventListener('mouseenter', onMouseEnter);\n target.removeEventListener('mouseleave', onMouseLeave);\n };\n }, [target, onMouseDown, smart]);\n\n useEffect(() => {\n if (target && describeTarget && show) {\n const describedBy = target.getAttribute('aria-describedby');\n // Set the attribute to the old attribute plus the id\n target.setAttribute('aria-describedby', describedBy ? `${describedBy} ${id}` : id);\n } else if (target) {\n // Get the old attribute\n const describedBy = target.getAttribute('aria-describedby');\n if (describedBy) {\n // If the old attribute matches the id just remove it entirely\n if (describedBy === id) {\n target.removeAttribute('aria-describedby');\n } else {\n // Otherwise we want to just remove the id that was added and reset the attribute to what it was before\n const oldDescribedBy = describedBy.replace(new RegExp(`(?:^|\\\\s+)${id}`), '');\n target.setAttribute('aria-describedby', oldDescribedBy);\n }\n }\n }\n }, [describeTarget, target, show]);\n\n return (\n <Popover\n data-testid={testIds.root}\n id={id}\n {...restProps}\n show={show}\n showDelay={showDelay}\n hideDelay={hideDelay}\n groupId='tooltip'\n strategy='fixed'\n as={StyledTooltip}\n role='tooltip'\n target={target}\n arrow\n placement={placement}\n onMouseDown={onMouseDown}\n hideOnTargetHidden\n ref={tooltipRef}\n >\n {children}\n </Popover>\n );\n});\n\nexport default withTestIds(Tooltip, getTooltipTestIds);\n"]}
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/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B,GAAG,EAAE,UAAU,YAEd,QAAQ,GACD,CACX,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC","sourcesContent":["import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';\nimport type { FunctionComponent, MutableRefObject, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport type { BaseProps, ForwardProps, TestIdProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport Popover from '../Popover';\nimport type { Delay, PopoverProps } from '../Popover';\nimport { useConsolidatedRef, useTestIds, useUID } from '../../hooks';\nimport { calculateFontSize } from '../../styles';\nimport { getActiveElement, withTestIds } from '../../utils';\n\nimport { getTooltipTestIds } from './Tooltip.test-ids';\n\nexport interface TooltipProps extends BaseProps, TestIdProp {\n /** Text content for the tooltip. */\n children: string | string[];\n /** Element to serve as the tooltip's target. */\n target: Element | null;\n /**\n * Delay showing the tooltip on mouseenter.\n * @default 'short'\n */\n showDelay?: Delay;\n /**\n * Delay hiding the tooltip on mouseleave.\n * @default 'long'\n */\n hideDelay?: Delay;\n /**\n * If true, the Tooltip will render outside of the current DOM hierarchy in a [portal](https://reactjs.org/docs/portals.html).\n * @default true\n */\n portal?: PopoverProps['portal'];\n /**\n * If true, the Tooltip will automatically apply an aria-describedby attribute to its target.\n * @default true\n */\n describeTarget?: boolean;\n /**\n * Sets the placement of the tooltip relative to the target.\n * @default 'bottom'\n */\n placement?: PopoverProps['placement'];\n /**\n * Conditionally renders a tooltip only if the associated element's text content is truncated.\n * To work, the associated element must be be displayed as a CSS \"block box\" i.e. block, inline-block, etc...\n * @default false\n */\n smart?: boolean;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledTooltip = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n background-color: ${theme.components.tooltip['background-color']};\n color: ${theme.components.tooltip['foreground-color']};\n font-size: ${fontSize.xxs};\n max-width: 40ch;\n padding: ${theme.base.spacing};\n white-space: pre-line;\n word-break: break-word;\n pointer-events: none;\n `;\n});\n\nStyledTooltip.defaultProps = defaultThemeProp;\n\nconst Tooltip: FunctionComponent<TooltipProps & ForwardProps> = forwardRef(function Tooltip(\n {\n testId,\n children,\n target,\n showDelay = 'short',\n hideDelay = 'long',\n placement = 'bottom',\n describeTarget = true,\n smart,\n ...restProps\n }: PropsWithoutRef<TooltipProps>,\n ref: Ref<HTMLDivElement>\n) {\n const id = useUID();\n const [show, setShow] = useState(false);\n const tooltipRef = useConsolidatedRef(ref);\n const lastClickedRef: MutableRefObject<EventTarget | null> = useRef(null);\n const testIds = useTestIds(testId, getTooltipTestIds);\n\n const onMouseDown = useCallback(\n ({ target: eTarget }: MouseEvent) => {\n lastClickedRef.current = eTarget;\n if (eTarget === tooltipRef.current || eTarget === target) return;\n setShow(false);\n },\n [target]\n );\n\n useEffect(() => {\n if (!target) return;\n\n const showTooltip = () => {\n setShow(\n // This approach may result in a tooltip NOT appearing 1px before it should due to browser specifics. Enhance as needed.\n // https://stackoverflow.com/a/64747288\n smart ? target.scrollWidth > target.clientWidth : true\n );\n };\n\n const onFocusIn = () => {\n showTooltip();\n };\n\n const onFocusOut = () => {\n if (!lastClickedRef.current || lastClickedRef.current !== tooltipRef.current) {\n setShow(false);\n }\n lastClickedRef.current = null;\n };\n\n const onMouseEnter = () => {\n showTooltip();\n };\n\n const onMouseLeave = () => {\n if (getActiveElement() !== target) {\n setShow(false);\n }\n };\n\n const onKeyDown = ({ key }: KeyboardEvent) => {\n if (key === 'Escape' && getActiveElement() === target) {\n setShow(false);\n }\n };\n\n document.addEventListener('keydown', onKeyDown);\n document.addEventListener('mousedown', onMouseDown);\n\n target.addEventListener('focusin', onFocusIn);\n target.addEventListener('focusout', onFocusOut);\n\n target.addEventListener('mouseenter', onMouseEnter);\n target.addEventListener('mouseleave', onMouseLeave);\n\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n document.removeEventListener('mousedown', onMouseDown);\n\n target.removeEventListener('focusin', onFocusIn);\n target.removeEventListener('focusout', onFocusOut);\n\n target.removeEventListener('mouseenter', onMouseEnter);\n target.removeEventListener('mouseleave', onMouseLeave);\n };\n }, [target, onMouseDown, smart]);\n\n useEffect(() => {\n if (target && describeTarget && show) {\n const describedBy = target.getAttribute('aria-describedby');\n // Set the attribute to the old attribute plus the id\n target.setAttribute('aria-describedby', describedBy ? `${describedBy} ${id}` : id);\n } else if (target) {\n // Get the old attribute\n const describedBy = target.getAttribute('aria-describedby');\n if (describedBy) {\n // If the old attribute matches the id just remove it entirely\n if (describedBy === id) {\n target.removeAttribute('aria-describedby');\n } else {\n // Otherwise we want to just remove the id that was added and reset the attribute to what it was before\n const oldDescribedBy = describedBy.replace(new RegExp(`(?:^|\\\\s+)${id}`), '');\n target.setAttribute('aria-describedby', oldDescribedBy);\n }\n }\n }\n }, [describeTarget, target, show]);\n\n return (\n <Popover\n data-testid={testIds.root}\n id={id}\n {...restProps}\n show={show}\n showDelay={showDelay}\n hideDelay={hideDelay}\n groupId='tooltip'\n strategy='fixed'\n as={StyledTooltip}\n role='tooltip'\n target={target}\n arrow\n placement={placement}\n onMouseDown={onMouseDown}\n hideOnTargetHidden\n ref={tooltipRef}\n >\n {children}\n </Popover>\n );\n});\n\nexport default withTestIds(Tooltip, getTooltipTestIds);\n"]}
@@ -3,12 +3,13 @@ import type { RefObject, DependencyList } from 'react';
3
3
  * @example useArrows(ref, { cycle, selector });
4
4
  * @param ref - A reference to the element that will be navigated through. [React RefObject](https://reactjs.org/docs/refs-and-the-dom.html)
5
5
  */
6
- declare const useArrows: (ref: RefObject<HTMLElement>, { cycle, selector, dir, allowTabFocus, updateTabIndex }?: {
6
+ declare const useArrows: (ref: RefObject<HTMLElement>, { cycle, selector, dir, allowTabFocus, updateTabIndex, initialFocusElement }?: {
7
7
  cycle?: boolean | undefined;
8
8
  selector?: string | undefined;
9
9
  dir?: "up-down" | "left-right" | undefined;
10
10
  allowTabFocus?: boolean | undefined;
11
11
  updateTabIndex?: boolean | undefined;
12
+ initialFocusElement?: Element | null | undefined;
12
13
  }, dependencies?: DependencyList) => void;
13
14
  export default useArrows;
14
15
  //# sourceMappingURL=useArrows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useArrows.d.ts","sourceRoot":"","sources":["../../src/hooks/useArrows.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAWvD;;;GAGG;AACH,QAAA,MAAM,SAAS,QACR,UAAU,WAAW,CAAC;;;;;;yCA+G5B,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"useArrows.d.ts","sourceRoot":"","sources":["../../src/hooks/useArrows.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAWvD;;;GAGG;AACH,QAAA,MAAM,SAAS,QACR,UAAU,WAAW,CAAC;;;;;;;yCAuI5B,CAAC;AAEF,eAAe,SAAS,CAAC"}