@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
@@ -1 +1 @@
1
- {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/FormField/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,iBAAiB,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK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EAAE;YACT,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;YACpC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;YACzC,GAAG,SAAS;SACb,EACD,EAAE,EAAE,eAAe,EACnB,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,EAAE,EAAE,GAAG,EAAE,QAAQ,EACjB,WAAW,EAAE,EAAE,EACf,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,sBAC9B,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,EAClE,GAAG,EAAE,eAAe,aAEnB,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,IAAI,QAAQ,EAC1C,OAAO,EACP,CAAC,aAAa,IAAI,UAAU,IAAI,QAAQ,EACxC,CAAC,QAAQ,IAAI,WAAW,IACpB,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { cloneElement, useEffect, forwardRef, useRef } from 'react';\nimport type { FC, ReactNode, ComponentType, ReactElement, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor, rgba } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport type { Action, ExcludeStrict, ForwardProps, OmitStrict, TestIdProp } from '../../types';\nimport Flex from '../Flex';\nimport type { FlexProps } from '../Flex';\nimport Actions from '../Actions';\nimport type { FormControlProps } from '../FormControl';\nimport {\n useConsolidatedRef,\n useDirection,\n useI18n,\n useLiveLog,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Label, { StyledLabel } from '../Label';\nimport type { LabelProps } from '../Label';\nimport { calculateFontSize, getHoverColors } from '../../styles';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport { getFocusables, tryCatch, withTestIds } from '../../utils';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport AdditionalInfo, { StyledAdditionalInfo } from '../AdditionalInfo';\n\nimport { getFormFieldTestIds } from './FormField.test-ids';\nimport type { elements } from './FormField.test-ids';\n\nregisterIcon(warnSolidIcon, flagWaveSolidIcon, checkIcon);\n\nexport interface FormFieldProps\n extends OmitStrict<FormControlProps, 'placeholder' | 'value' | 'defaultValue'>,\n TestIdProp<typeof elements> {\n /** Pass a single form control component i.e. Input | TextArea | Select | etc.. */\n children: ReactElement | ReactElement[];\n /**\n * An id is required to connect a FormField's wrapping element, control element and info(aria-describedby) live region.\n * A random id will be generated if none is provided.\n * Since MOST FormControls should possess an id(excl. i.e RadioCheckGroup and others) this can be used.\n * The id prop will be used to generate the following:\n * - FormControl <-> Label association via a Label's htmlFor prop.\n * - FormField's wrapping element id {id}-field.\n * - FormField info element id ${id}-info.\n */\n id?: string;\n /**\n * Determines how the wrapping label should be rendered.\n * @default 'label'\n */\n labelAs?: LabelProps['as'];\n /**\n * Overrides the for attribute on the label. If this is not set it will default to the forms id.\n * @default undefined\n */\n labelFor?: LabelProps['htmlFor'];\n /**\n * Sets the id of the label.\n * @default undefined\n */\n labelId?: LabelProps['id'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: boolean;\n /**\n * Visually places the label after the input.\n * @default false\n */\n labelAfter?: boolean;\n /**\n * Property used to check whether input type is radio to handle styling for RadioCheck\n * @default false\n */\n isRadioCheck?: boolean;\n /**\n * Wrapping HTML element tag. Renders as a fieldset for grouped elements i.e. RadioButtons/CheckboxGroup\n * @default 'div'\n */\n as?: 'div' | 'fieldset' | ComponentType<any>;\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: boolean;\n /** Optionally utilized by Input or Select. */\n actions?: Action[];\n /** Enables Flex container prop pass through. */\n container?: ExcludeStrict<FlexProps['container'], true>;\n /** Character remaining count. Typically used on Textareas only */\n charLimitDisplay?: ReactNode;\n}\n\nconst StyledStatusIcon = styled(Icon)<{ status: NonNullable<FormFieldProps['status']> }>(\n ({ theme, status }) => {\n return css`\n height: 1em;\n width: 1em;\n color: ${theme.components['form-field'][status]['status-color']};\n vertical-align: baseline;\n margin-inline-end: 0.5ch;\n `;\n }\n);\n\nStyledStatusIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFormFieldInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { 'form-field': formField }\n }\n }) => {\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n max-width: max-content;\n margin-top: calc(0.25 * ${spacing});\n font-size: ${infoFontSize};\n word-break: break-word;\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `;\n }\n);\n\nStyledFormFieldInfo.defaultProps = defaultThemeProp;\n\nconst StyledRequiredAsterisk = styled.span(({ theme }) => {\n const {\n base: {\n palette: { urgent }\n }\n } = theme;\n\n return css`\n vertical-align: top;\n color: ${urgent};\n `;\n});\n\nStyledRequiredAsterisk.defaultProps = defaultThemeProp;\n\nconst StyledLabelRow = styled.div`\n ${StyledRequiredAsterisk} {\n margin-inline-end: auto;\n }\n`;\n\nexport const StyledFormField = styled.div<\n FormFieldProps & { labelAsLegend: boolean; showAdditionalInfo: boolean }\n>(props => {\n const {\n labelAsLegend,\n showAdditionalInfo,\n disabled,\n required,\n theme: {\n base: { 'disabled-opacity': disabledOpacity, spacing }\n }\n } = props;\n const { ltr } = useDirection();\n\n return css`\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n -webkit-user-select: none;\n user-select: none;\n `}\n position: relative;\n border: 0;\n\n > ${StyledLabel}, > ${StyledLabelRow} {\n margin-bottom: calc(0.25 * ${spacing});\n }\n\n > ${StyledLabel}, > ${StyledLabelRow} > ${StyledLabel} {\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n }\n\n ${labelAsLegend &&\n (showAdditionalInfo || required) &&\n css`\n display: block;\n\n > legend {\n float: ${ltr ? 'left' : 'right'};\n }\n\n > ${StyledRequiredAsterisk} {\n float: ${ltr ? 'left' : 'right'};\n\n ${!showAdditionalInfo &&\n css`\n + * {\n clear: both;\n }\n `}\n }\n\n > ${StyledAdditionalInfo} {\n float: ${ltr ? 'right' : 'left'};\n\n + * {\n clear: both;\n }\n }\n `}\n `;\n});\n\nStyledFormField.defaultProps = defaultThemeProp;\n\nconst StyledSuggestionButton = styled(Button)(\n ({\n theme: {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n 'border-radius': baseRadius,\n spacing\n },\n components: {\n 'form-control': { 'border-radius': radius, 'border-width': borderWidth },\n 'form-field': formField\n }\n }\n }) => {\n const { xxs: buttonFontSize } = calculateFontSize(fontSize, fontScale);\n const backgroundColor = formField.pending['status-color'];\n const hoverColors = getHoverColors(backgroundColor);\n const color = tryCatch(() => readableColor(backgroundColor));\n const borderColor = color ? rgba(color, 0.4) : color;\n\n return css`\n background-color: ${backgroundColor};\n color: ${color};\n font-size: ${buttonFontSize};\n min-width: calc(3 * ${spacing});\n min-height: calc(3 * ${spacing});\n padding: 0 ${spacing};\n border-radius: 0;\n border: none;\n &:first-child {\n border-inline-end: ${borderWidth} solid ${borderColor};\n border-end-start-radius: calc(${baseRadius} * ${radius});\n margin-inline-start: calc(2 * ${spacing});\n }\n &:last-child {\n border-end-end-radius: calc(${baseRadius} * ${radius});\n margin-inline-start: 0;\n }\n &:hover {\n color: ${hoverColors.foreground};\n background-color: ${hoverColors.background};\n }\n\n @media (pointer: coarse) {\n min-height: 2rem;\n }\n `;\n }\n);\n\nStyledSuggestionButton.defaultProps = defaultThemeProp;\n\nconst statusIconMap = { error: 'warn-solid', warning: 'flag-wave-solid', success: 'check' };\n\nconst FormField: FC<FormFieldProps & ForwardProps> = forwardRef(function FormField(\n props: PropsWithoutRef<FormFieldProps>,\n ref: Ref<HTMLElement>\n) {\n const uid = useUID();\n const {\n testId,\n children: controlElement,\n id = uid,\n as = 'div',\n label,\n labelAs = 'label',\n labelFor = id,\n labelId,\n labelHidden = false,\n labelAfter = false,\n info,\n status,\n isRadioCheck,\n charLimitDisplay,\n required = false,\n disabled = false,\n readOnly = false,\n inline = false,\n actions,\n container,\n additionalInfo,\n onResolveSuggestion,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getFormFieldTestIds);\n\n const t = useI18n();\n const { announceAssertive } = useLiveLog();\n const labelAsLegend: boolean = labelAs === 'legend';\n const hasSuggestion = status === 'pending' && !!onResolveSuggestion;\n const consolidatedRef = useConsolidatedRef(ref);\n const labelRef = useRef<HTMLLabelElement | HTMLLegendElement>(null);\n\n const showAdditionalInfo = !!additionalInfo && !disabled && !labelHidden;\n\n const labelContent = (\n <>\n <Label\n data-testid={testIds.label}\n id={labelId}\n as={labelAs}\n htmlFor={labelAs === 'label' ? labelFor : undefined}\n labelHidden={labelHidden}\n onClick={(e: MouseEvent) => {\n if (readOnly) e.preventDefault();\n }}\n inline={inline}\n ref={labelRef}\n >\n {label}\n </Label>\n\n {required && !labelHidden && (\n <StyledRequiredAsterisk aria-hidden>&nbsp;*</StyledRequiredAsterisk>\n )}\n\n {showAdditionalInfo && (\n <AdditionalInfo data-testid={testIds.additionalInfo} heading={additionalInfo.heading}>\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </>\n );\n\n const labelRow =\n !isRadioCheck && !labelAsLegend ? (\n <Flex\n as={StyledLabelRow}\n container={{ justify: 'between', alignItems: 'end' }}\n item={{ alignSelf: 'stretch' }}\n >\n {labelContent}\n </Flex>\n ) : (\n labelContent\n );\n\n useEffect(() => {\n if (status === 'error' || status === 'warning') {\n let message = `${t(status)} ${info}`;\n if (labelRef.current?.textContent) message = `${labelRef.current?.textContent} ${message}`;\n announceAssertive({ message, type: status });\n }\n }, [status, info]);\n\n // fieldset or single form control element\n let content: FormFieldProps['children'] = labelAsLegend\n ? controlElement\n : cloneElement(controlElement as ReactElement, {\n 'aria-describedby': info && `${id}-info`\n });\n\n if (actions) {\n content = (\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {content}\n <Actions items={actions} menuAt={3} />\n </Flex>\n );\n }\n\n let infoContent = (\n <Flex\n id={`${id}-info`}\n data-testid={testIds.info}\n status={status}\n as={StyledFormFieldInfo}\n container={{ alignItems: 'center' }}\n >\n {status && status !== 'pending' && (\n <>\n <StyledStatusIcon status={status} name={statusIconMap[status]} />\n <VisuallyHiddenText>{`${t(status)} `}</VisuallyHiddenText>\n </>\n )}\n {info}\n </Flex>\n );\n\n if (charLimitDisplay) {\n infoContent = (\n <Flex container={{ justify: infoContent ? 'between' : 'end', gap: 1 }}>\n {infoContent}\n <Flex item={{ shrink: 0 }}>{charLimitDisplay}</Flex>\n </Flex>\n );\n }\n\n if (hasSuggestion) {\n const focusables = getFocusables(consolidatedRef);\n infoContent = (\n <Flex container={{ alignItems: 'start', justify: 'between' }}>\n <StyledFormFieldInfo data-testid={testIds.info} status={status} id={`${id}-info`}>\n {t('suggestion_info')}\n <VisuallyHiddenText aria-live='polite'>{t('suggestion_assist')}</VisuallyHiddenText>\n </StyledFormFieldInfo>\n <Flex container={{ wrap: 'nowrap' }}>\n <StyledSuggestionButton\n data-testid={testIds.suggestionReject}\n onClick={() => {\n onResolveSuggestion(false);\n focusables[0]?.focus();\n }}\n aria-label={t('reject_suggestion_button_a11y')}\n >\n {t('no')}\n </StyledSuggestionButton>\n <StyledSuggestionButton\n data-testid={testIds.suggestionAccept}\n onClick={() => {\n onResolveSuggestion(true);\n focusables[0]?.focus();\n }}\n aria-label={t('accept_suggestion_button_a11y')}\n >\n {t('yes')}\n </StyledSuggestionButton>\n </Flex>\n </Flex>\n );\n }\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n const target = e.target as HTMLElement;\n if (!target.closest('button')) {\n e.preventDefault();\n onResolveSuggestion?.(true);\n }\n }\n };\n\n return (\n <Flex\n data-testid={testIds.root}\n {...restProps}\n container={{\n direction: inline ? 'row' : 'column',\n alignItems: inline ? 'center' : undefined,\n ...container\n }}\n as={StyledFormField}\n labelAsLegend={labelAsLegend}\n showAdditionalInfo={showAdditionalInfo}\n id={`${id}-field`}\n forwardedAs={as}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n onKeyDown={hasSuggestion ? onKeyDown : undefined}\n aria-describedby={labelAsLegend && info ? `${id}-info` : undefined}\n ref={consolidatedRef}\n >\n {(labelAsLegend || !labelAfter) && labelRow}\n {content}\n {!labelAsLegend && labelAfter && labelRow}\n {!readOnly && infoContent}\n </Flex>\n );\n});\n\nexport default withTestIds(FormField, getFormFieldTestIds);\n"]}
1
+ {"version":3,"file":"FormField.js","sourceRoot":"","sources":["../../../src/components/FormField/FormField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,UAAU,EACV,MAAM,EACP,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,iBAAiB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Aa,IAAI,CAAC,UAAU,CAAC,IAAI,QAAQ,EAC1C,OAAO,EACP,CAAC,aAAa,IAAI,UAAU,IAAI,QAAQ,EACxC,CAAC,QAAQ,IAAI,WAAW,IACpB,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { cloneElement, useEffect, forwardRef, useState, useRef } from 'react';\nimport type { FC, ReactNode, ComponentType, ReactElement, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { readableColor, rgba } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport type { Action, ExcludeStrict, ForwardProps, OmitStrict, TestIdProp } from '../../types';\nimport Flex from '../Flex';\nimport type { FlexProps } from '../Flex';\nimport Actions from '../Actions';\nimport type { FormControlProps } from '../FormControl';\nimport {\n useConsolidatedRef,\n useDirection,\n useI18n,\n useLiveLog,\n useTestIds,\n useUID\n} from '../../hooks';\nimport Label, { StyledLabel } from '../Label';\nimport type { LabelProps } from '../Label';\nimport { calculateFontSize, getHoverColors } from '../../styles';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\nimport { getFocusables, tryCatch, withTestIds } from '../../utils';\nimport Button from '../Button';\nimport Icon, { registerIcon } from '../Icon';\nimport * as warnSolidIcon from '../Icon/icons/warn-solid.icon';\nimport * as flagWaveSolidIcon from '../Icon/icons/flag-wave-solid.icon';\nimport * as checkIcon from '../Icon/icons/check.icon';\nimport AdditionalInfo, { StyledAdditionalInfo } from '../AdditionalInfo';\n\nimport { getFormFieldTestIds } from './FormField.test-ids';\nimport type { elements } from './FormField.test-ids';\n\nregisterIcon(warnSolidIcon, flagWaveSolidIcon, checkIcon);\n\nexport interface FormFieldProps\n extends OmitStrict<FormControlProps, 'placeholder' | 'value' | 'defaultValue'>,\n TestIdProp<typeof elements> {\n /** Pass a single form control component i.e. Input | TextArea | Select | etc.. */\n children: ReactElement | ReactElement[];\n /**\n * An id is required to connect a FormField's wrapping element, control element and info(aria-describedby) live region.\n * A random id will be generated if none is provided.\n * Since MOST FormControls should possess an id(excl. i.e RadioCheckGroup and others) this can be used.\n * The id prop will be used to generate the following:\n * - FormControl <-> Label association via a Label's htmlFor prop.\n * - FormField's wrapping element id {id}-field.\n * - FormField info element id ${id}-info.\n */\n id?: string;\n /**\n * Determines how the wrapping label should be rendered.\n * @default 'label'\n */\n labelAs?: LabelProps['as'];\n /**\n * Overrides the for attribute on the label. If this is not set it will default to the forms id.\n * @default undefined\n */\n labelFor?: LabelProps['htmlFor'];\n /**\n * Sets the id of the label.\n * @default undefined\n */\n labelId?: LabelProps['id'];\n /**\n * Visually hides the label region.\n * @default false\n */\n labelHidden?: boolean;\n /**\n * Visually places the label after the input.\n * @default false\n */\n labelAfter?: boolean;\n /**\n * Property used to check whether input type is radio to handle styling for RadioCheck\n * @default false\n */\n isRadioCheck?: boolean;\n /**\n * Wrapping HTML element tag. Renders as a fieldset for grouped elements i.e. RadioButtons/CheckboxGroup\n * @default 'div'\n */\n as?: 'div' | 'fieldset' | ComponentType<any>;\n /**\n * Layout field elements inline in a row.\n * @default false\n */\n inline?: boolean;\n /** Optionally utilized by Input or Select. */\n actions?: Action[];\n /** Enables Flex container prop pass through. */\n container?: ExcludeStrict<FlexProps['container'], true>;\n /** Character remaining count. Typically used on Textareas only */\n charLimitDisplay?: ReactNode;\n}\n\nconst StyledStatusIcon = styled(Icon)<{ status: NonNullable<FormFieldProps['status']> }>(\n ({ theme, status }) => {\n return css`\n height: 1em;\n width: 1em;\n color: ${theme.components['form-field'][status]['status-color']};\n vertical-align: baseline;\n margin-inline-end: 0.5ch;\n `;\n }\n);\n\nStyledStatusIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFormFieldInfo = styled.div<Pick<FormControlProps, 'status'>>(\n ({\n status,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing },\n components: { 'form-field': formField }\n }\n }) => {\n const { xxs: infoFontSize } = calculateFontSize(fontSize, fontScale);\n\n return css`\n max-width: max-content;\n margin-top: calc(0.25 * ${spacing});\n font-size: ${infoFontSize};\n word-break: break-word;\n ${status &&\n formField[status] &&\n css`\n color: ${formField[status]['status-color']};\n `}\n `;\n }\n);\n\nStyledFormFieldInfo.defaultProps = defaultThemeProp;\n\nexport const StyledRequiredAsterisk = styled.span(({ theme }) => {\n const {\n base: {\n palette: { urgent }\n }\n } = theme;\n\n return css`\n vertical-align: top;\n color: ${urgent};\n `;\n});\n\nStyledRequiredAsterisk.defaultProps = defaultThemeProp;\n\nconst StyledLabelRow = styled.div`\n ${StyledRequiredAsterisk} {\n margin-inline-end: auto;\n }\n`;\n\nexport const StyledFormField = styled.div<\n FormFieldProps & { labelAsLegend: boolean; showAdditionalInfo: boolean }\n>(props => {\n const {\n labelAsLegend,\n showAdditionalInfo,\n disabled,\n required,\n theme: {\n base: { 'disabled-opacity': disabledOpacity, spacing }\n }\n } = props;\n const { ltr } = useDirection();\n\n return css`\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n -webkit-user-select: none;\n user-select: none;\n `}\n position: relative;\n border: 0;\n\n > ${StyledLabel}, > ${StyledLabelRow} {\n margin-bottom: calc(0.25 * ${spacing});\n }\n\n > ${StyledLabel}, > ${StyledLabelRow} > ${StyledLabel} {\n ${disabled &&\n css`\n cursor: not-allowed;\n `}\n }\n\n ${labelAsLegend &&\n (showAdditionalInfo || required) &&\n css`\n display: block;\n\n > legend {\n float: ${ltr ? 'left' : 'right'};\n }\n\n > ${StyledRequiredAsterisk} {\n float: ${ltr ? 'left' : 'right'};\n\n ${!showAdditionalInfo &&\n css`\n + * {\n clear: both;\n }\n `}\n }\n\n > ${StyledAdditionalInfo} {\n float: ${ltr ? 'right' : 'left'};\n\n + * {\n clear: both;\n }\n }\n `}\n `;\n});\n\nStyledFormField.defaultProps = defaultThemeProp;\n\nconst StyledSuggestionButton = styled(Button)(\n ({\n theme: {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n 'border-radius': baseRadius,\n spacing\n },\n components: {\n 'form-control': { 'border-radius': radius, 'border-width': borderWidth },\n 'form-field': formField\n }\n }\n }) => {\n const { xxs: buttonFontSize } = calculateFontSize(fontSize, fontScale);\n const backgroundColor = formField.pending['status-color'];\n const hoverColors = getHoverColors(backgroundColor);\n const color = tryCatch(() => readableColor(backgroundColor));\n const borderColor = color ? rgba(color, 0.4) : color;\n\n return css`\n background-color: ${backgroundColor};\n color: ${color};\n font-size: ${buttonFontSize};\n min-width: calc(3 * ${spacing});\n min-height: calc(3 * ${spacing});\n padding: 0 ${spacing};\n border-radius: 0;\n border: none;\n &:first-child {\n border-inline-end: ${borderWidth} solid ${borderColor};\n border-end-start-radius: calc(${baseRadius} * ${radius});\n margin-inline-start: calc(2 * ${spacing});\n }\n &:last-child {\n border-end-end-radius: calc(${baseRadius} * ${radius});\n margin-inline-start: 0;\n }\n &:hover {\n color: ${hoverColors.foreground};\n background-color: ${hoverColors.background};\n }\n\n @media (pointer: coarse) {\n min-height: 2rem;\n }\n `;\n }\n);\n\nStyledSuggestionButton.defaultProps = defaultThemeProp;\n\nconst statusIconMap = { error: 'warn-solid', warning: 'flag-wave-solid', success: 'check' };\n\nconst FormField: FC<FormFieldProps & ForwardProps> = forwardRef(function FormField(\n props: PropsWithoutRef<FormFieldProps>,\n ref: Ref<HTMLElement>\n) {\n const uid = useUID();\n const {\n testId,\n children: controlElement,\n id = uid,\n as = 'div',\n label,\n labelAs = 'label',\n labelFor = id,\n labelId,\n labelHidden = false,\n labelAfter = false,\n info,\n status,\n isRadioCheck,\n charLimitDisplay,\n required = false,\n disabled = false,\n readOnly = false,\n inline = false,\n actions,\n container,\n additionalInfo,\n onResolveSuggestion,\n ...restProps\n } = props;\n\n const testIds = useTestIds(testId, getFormFieldTestIds);\n\n const t = useI18n();\n const { announceAssertive } = useLiveLog();\n const labelAsLegend: boolean = labelAs === 'legend';\n const hasSuggestion = status === 'pending' && !!onResolveSuggestion;\n const consolidatedRef = useConsolidatedRef(ref);\n const labelRef = useRef<HTMLLabelElement | HTMLLegendElement>(null);\n const [labelText, setLabelText] = useState<string | null>(null);\n\n const showAdditionalInfo = !!additionalInfo && !disabled && !labelHidden;\n\n const labelContent = (\n <>\n <Label\n data-testid={testIds.label}\n id={labelId}\n as={labelAs}\n htmlFor={labelAs === 'label' ? labelFor : undefined}\n labelHidden={labelHidden}\n onClick={(e: MouseEvent) => {\n if (readOnly) e.preventDefault();\n }}\n inline={inline}\n ref={labelRef}\n >\n {label}\n </Label>\n\n {required && !labelHidden && (\n <StyledRequiredAsterisk aria-hidden>&nbsp;*</StyledRequiredAsterisk>\n )}\n\n {showAdditionalInfo && labelText && (\n <AdditionalInfo\n data-testid={testIds.additionalInfo}\n heading={additionalInfo.heading}\n contextualLabel={labelText}\n >\n {additionalInfo.content}\n </AdditionalInfo>\n )}\n </>\n );\n\n const labelRow =\n !isRadioCheck && !labelAsLegend ? (\n <Flex\n as={StyledLabelRow}\n container={{ justify: 'between', alignItems: 'end' }}\n item={{ alignSelf: 'stretch' }}\n >\n {labelContent}\n </Flex>\n ) : (\n labelContent\n );\n\n useEffect(() => {\n setLabelText(labelRef.current?.textContent ?? null);\n }, [label]);\n\n useEffect(() => {\n if (status === 'error' || status === 'warning') {\n let message = `${t(status)} ${info}`;\n if (labelRef.current?.textContent) message = `${labelRef.current?.textContent} ${message}`;\n announceAssertive({ message, type: status });\n }\n }, [status, info]);\n\n // fieldset or single form control element\n let content: FormFieldProps['children'] = labelAsLegend\n ? controlElement\n : cloneElement(controlElement as ReactElement, {\n 'aria-describedby': info && `${id}-info`\n });\n\n if (actions) {\n content = (\n <Flex container={{ alignItems: 'center', gap: 0.5 }}>\n {content}\n <Actions items={actions} menuAt={3} />\n </Flex>\n );\n }\n\n let infoContent = (\n <Flex\n id={`${id}-info`}\n data-testid={testIds.info}\n status={status}\n as={StyledFormFieldInfo}\n container={{ alignItems: 'center' }}\n >\n {status && status !== 'pending' && (\n <>\n <StyledStatusIcon status={status} name={statusIconMap[status]} />\n <VisuallyHiddenText>{`${t(status)} `}</VisuallyHiddenText>\n </>\n )}\n {info}\n </Flex>\n );\n\n if (charLimitDisplay) {\n infoContent = (\n <Flex container={{ justify: infoContent ? 'between' : 'end', gap: 1 }}>\n {infoContent}\n <Flex item={{ shrink: 0 }}>{charLimitDisplay}</Flex>\n </Flex>\n );\n }\n\n if (hasSuggestion) {\n const focusables = getFocusables(consolidatedRef);\n infoContent = (\n <Flex container={{ alignItems: 'start', justify: 'between' }}>\n <StyledFormFieldInfo data-testid={testIds.info} status={status} id={`${id}-info`}>\n {t('suggestion_info')}\n <VisuallyHiddenText aria-live='polite'>{t('suggestion_assist')}</VisuallyHiddenText>\n </StyledFormFieldInfo>\n <Flex container={{ wrap: 'nowrap' }}>\n <StyledSuggestionButton\n data-testid={testIds.suggestionReject}\n onClick={() => {\n onResolveSuggestion(false);\n focusables[0]?.focus();\n }}\n aria-label={t('reject_suggestion_button_a11y')}\n >\n {t('no')}\n </StyledSuggestionButton>\n <StyledSuggestionButton\n data-testid={testIds.suggestionAccept}\n onClick={() => {\n onResolveSuggestion(true);\n focusables[0]?.focus();\n }}\n aria-label={t('accept_suggestion_button_a11y')}\n >\n {t('yes')}\n </StyledSuggestionButton>\n </Flex>\n </Flex>\n );\n }\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n const target = e.target as HTMLElement;\n if (!target.closest('button')) {\n e.preventDefault();\n onResolveSuggestion?.(true);\n }\n }\n };\n\n return (\n <Flex\n data-testid={testIds.root}\n {...restProps}\n container={{\n direction: inline ? 'row' : 'column',\n alignItems: inline ? 'center' : undefined,\n ...container\n }}\n as={StyledFormField}\n labelAsLegend={labelAsLegend}\n showAdditionalInfo={showAdditionalInfo}\n id={`${id}-field`}\n forwardedAs={as}\n required={required}\n disabled={disabled}\n readOnly={readOnly}\n onKeyDown={hasSuggestion ? onKeyDown : undefined}\n aria-describedby={labelAsLegend && info ? `${id}-info` : undefined}\n ref={consolidatedRef}\n >\n {(labelAsLegend || !labelAfter) && labelRow}\n {content}\n {!labelAsLegend && labelAfter && labelRow}\n {!readOnly && infoContent}\n </Flex>\n );\n});\n\nexport default withTestIds(FormField, getFormFieldTestIds);\n"]}
@@ -200,7 +200,7 @@ const HTML = forwardRef(function HTML({ testId, content, customTags, ...restProp
200
200
  ? DOMPurify.sanitize(content, {
201
201
  FORBID_TAGS: ['style'],
202
202
  CUSTOM_ELEMENT_HANDLING: {
203
- tagNameCheck: customTags ? tagName => customTags.includes(tagName) : null
203
+ tagNameCheck: customTags ? tagName => customTags.includes(tagName) : undefined
204
204
  }
205
205
  })
206
206
  : '';
@@ -1 +1 @@
1
- {"version":3,"file":"HTML.js","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,eAAe,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;AAQpC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C5B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,GAAG,CAAA;;;;8BAI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CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;iBAC1E;aACF,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,KAAC,UAAU,mBACI,OAAO,CAAC,IAAI,KACrB,SAAS,EACb,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAClD,GAAG,EAAE,GAAG,GACR,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useEffect, useMemo } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { DefaultTheme } from 'styled-components';\nimport createDOMPurify from 'dompurify';\n\nimport { StyledPopover } from '../Popover';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport type { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport { sameOrigin, withTestIds } from '../../utils';\nimport { useTestIds } from '../../hooks';\n\nimport { getHTMLTestIds } from './HTML.test-ids';\n\nconst DOMPurify = createDOMPurify();\n\nexport interface HTMLProps extends BaseProps, NoChildrenProp, TestIdProp {\n content: string;\n customTags?: string[];\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const listStyles = css`\n ul,\n ol {\n padding-inline-start: 2.5rem;\n }\n\n li {\n margin: 0.5rem 0;\n }\n\n ul li {\n ul {\n margin-inline-start: 1rem;\n list-style-type: circle;\n }\n\n ul ul {\n margin-inline-start: 2rem;\n list-style-type: square;\n }\n\n ul ul ul {\n margin-inline-start: 3rem;\n list-style-type: disc;\n }\n }\n\n ol li {\n ol {\n margin-inline-start: 1rem;\n list-style-type: lower-alpha;\n }\n\n ol ol {\n margin-inline-start: 2rem;\n list-style-type: lower-roman;\n }\n\n ol ol ol {\n margin-inline-start: 3rem;\n list-style-type: decimal;\n }\n }\n`;\n\nexport const getTableStyles = (theme: DefaultTheme) => css`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n min-width: 6.25rem;\n }\n\n tr:first-child {\n td:first-child {\n border-top-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-top-right-radius: 0.125rem;\n }\n }\n\n tr:last-child {\n td:first-child {\n border-bottom-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-bottom-right-radius: 0.125rem;\n }\n }\n`;\n\nexport const getHtmlStyles = (theme: DefaultTheme) => {\n const {\n base: { 'font-size': baseFontSize, 'font-scale': baseFontScale, palette },\n components: { text }\n } = theme;\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n return `\n ${listStyles}\n table {\n ${getTableStyles(theme)}\n }\n img {\n max-width: 100%;\n height: auto;\n border-radius: 0.25rem;\n }\n a {\n color: ${palette.interactive};\n }\n pre {\n white-space: break-spaces;\n }\n p {\n min-height: ${fontSize[text.primary['font-size'] as FontSize]};\n }\n h1 {\n font-size: ${fontSize[text.h1['font-size'] as FontSize]};\n font-weight: ${text.h1['font-weight']};\n min-height: ${fontSize[text.h1['font-size'] as FontSize]};\n }\n h2 {\n font-size: ${fontSize[text.h2['font-size'] as FontSize]};\n font-weight: ${text.h2['font-weight']};\n min-height: ${fontSize[text.h2['font-size'] as FontSize]};\n }\n h3 {\n font-size: ${fontSize[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n min-height: ${fontSize[text.h3['font-size'] as FontSize]};\n }\n h4 {\n font-size: ${fontSize[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n min-height: ${fontSize[text.h4['font-size'] as FontSize]};\n }\n h5 {\n font-size: ${fontSize[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n min-height: ${fontSize[text.h5['font-size'] as FontSize]};\n }\n h6 {\n font-size: ${fontSize[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n min-height: ${fontSize[text.h6['font-size'] as FontSize]};\n }\n `;\n};\n\nexport const StyledHTML = styled.div(({ theme }) => {\n return css`\n width: 100%;\n overflow-x: auto;\n overflow-wrap: break-word;\n contain: paint;\n ${getHtmlStyles(theme)}\n\n ${StyledPopover} ul {\n ul {\n padding-inline-start: 0;\n }\n ol {\n padding-inline-start: 0;\n }\n }\n\n ${StyledPopover} li {\n margin: 0;\n }\n `;\n});\n\nStyledHTML.defaultProps = defaultThemeProp;\n\nif (DOMPurify.isSupported) {\n const targetBlankSet = new WeakSet<HTMLAnchorElement>();\n\n DOMPurify.addHook('beforeSanitizeAttributes', node => {\n // Can be passed text nodes\n if (!(node instanceof HTMLElement || node instanceof SVGElement)) return;\n\n node.removeAttribute('class');\n\n if (\n node.tagName === 'A' &&\n node.hasAttribute('href') &&\n node.getAttribute('target') === '_blank'\n ) {\n targetBlankSet.add(node as HTMLAnchorElement);\n }\n });\n\n DOMPurify.addHook('afterSanitizeAttributes', node => {\n if (node.tagName === 'A' && node.hasAttribute('href')) {\n const href = node.getAttribute('href')!;\n\n let fullURL: URL;\n try {\n fullURL = new URL(href, window.location.href);\n } catch (e) {\n return;\n }\n\n if (!sameOrigin(window.location, fullURL)) {\n node.setAttribute('target', '_blank');\n node.setAttribute('rel', 'noopener');\n } else if (targetBlankSet.has(node as HTMLAnchorElement)) {\n node.setAttribute('target', '_blank');\n targetBlankSet.delete(node as HTMLAnchorElement);\n }\n }\n });\n}\n\nconst HTML: FunctionComponent<HTMLProps & ForwardProps> = forwardRef(function HTML(\n { testId, content, customTags, ...restProps }: PropsWithoutRef<HTMLProps>,\n ref: HTMLProps['ref']\n) {\n const [mounted, setMounted] = useState(false);\n const sanitizedHtml = useMemo(() => {\n // Don't render content on the server at all.\n return mounted && DOMPurify.isSupported\n ? DOMPurify.sanitize(content, {\n FORBID_TAGS: ['style'],\n CUSTOM_ELEMENT_HANDLING: {\n tagNameCheck: customTags ? tagName => customTags.includes(tagName) : null\n }\n })\n : '';\n }, [content, customTags, mounted]);\n const testIds = useTestIds(testId, getHTMLTestIds);\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n return (\n <StyledHTML\n data-testid={testIds.root}\n {...restProps}\n dangerouslySetInnerHTML={{ __html: sanitizedHtml }}\n ref={ref}\n />\n );\n});\n\nexport default withTestIds(HTML, getHTMLTestIds);\n"]}
1
+ {"version":3,"file":"HTML.js","sourceRoot":"","sources":["../../../src/components/HTML/HTML.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,eAAe,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;AAQpC,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C5B,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC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AAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;iBAC/E;aACF,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,KAAC,UAAU,mBACI,OAAO,CAAC,IAAI,KACrB,SAAS,EACb,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAClD,GAAG,EAAE,GAAG,GACR,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { forwardRef, useState, useEffect, useMemo } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport type { DefaultTheme } from 'styled-components';\nimport createDOMPurify from 'dompurify';\n\nimport { StyledPopover } from '../Popover';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport type { BaseProps, ForwardProps, NoChildrenProp, TestIdProp } from '../../types';\nimport { sameOrigin, withTestIds } from '../../utils';\nimport { useTestIds } from '../../hooks';\n\nimport { getHTMLTestIds } from './HTML.test-ids';\n\nconst DOMPurify = createDOMPurify();\n\nexport interface HTMLProps extends BaseProps, NoChildrenProp, TestIdProp {\n content: string;\n customTags?: string[];\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const listStyles = css`\n ul,\n ol {\n padding-inline-start: 2.5rem;\n }\n\n li {\n margin: 0.5rem 0;\n }\n\n ul li {\n ul {\n margin-inline-start: 1rem;\n list-style-type: circle;\n }\n\n ul ul {\n margin-inline-start: 2rem;\n list-style-type: square;\n }\n\n ul ul ul {\n margin-inline-start: 3rem;\n list-style-type: disc;\n }\n }\n\n ol li {\n ol {\n margin-inline-start: 1rem;\n list-style-type: lower-alpha;\n }\n\n ol ol {\n margin-inline-start: 2rem;\n list-style-type: lower-roman;\n }\n\n ol ol ol {\n margin-inline-start: 3rem;\n list-style-type: decimal;\n }\n }\n`;\n\nexport const getTableStyles = (theme: DefaultTheme) => css`\n border-collapse: collapse;\n\n td {\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n min-width: 6.25rem;\n }\n\n tr:first-child {\n td:first-child {\n border-top-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-top-right-radius: 0.125rem;\n }\n }\n\n tr:last-child {\n td:first-child {\n border-bottom-left-radius: 0.125rem;\n }\n\n td:last-child {\n border-bottom-right-radius: 0.125rem;\n }\n }\n`;\n\nexport const getHtmlStyles = (theme: DefaultTheme) => {\n const {\n base: { 'font-size': baseFontSize, 'font-scale': baseFontScale, palette },\n components: { text }\n } = theme;\n const fontSize = calculateFontSize(baseFontSize, baseFontScale);\n return `\n ${listStyles}\n table {\n ${getTableStyles(theme)}\n }\n img {\n max-width: 100%;\n height: auto;\n border-radius: 0.25rem;\n }\n a {\n color: ${palette.interactive};\n }\n pre {\n white-space: break-spaces;\n }\n p {\n min-height: ${fontSize[text.primary['font-size'] as FontSize]};\n }\n h1 {\n font-size: ${fontSize[text.h1['font-size'] as FontSize]};\n font-weight: ${text.h1['font-weight']};\n min-height: ${fontSize[text.h1['font-size'] as FontSize]};\n }\n h2 {\n font-size: ${fontSize[text.h2['font-size'] as FontSize]};\n font-weight: ${text.h2['font-weight']};\n min-height: ${fontSize[text.h2['font-size'] as FontSize]};\n }\n h3 {\n font-size: ${fontSize[text.h3['font-size'] as FontSize]};\n font-weight: ${text.h3['font-weight']};\n min-height: ${fontSize[text.h3['font-size'] as FontSize]};\n }\n h4 {\n font-size: ${fontSize[text.h4['font-size'] as FontSize]};\n font-weight: ${text.h4['font-weight']};\n min-height: ${fontSize[text.h4['font-size'] as FontSize]};\n }\n h5 {\n font-size: ${fontSize[text.h5['font-size'] as FontSize]};\n font-weight: ${text.h5['font-weight']};\n min-height: ${fontSize[text.h5['font-size'] as FontSize]};\n }\n h6 {\n font-size: ${fontSize[text.h6['font-size'] as FontSize]};\n font-weight: ${text.h6['font-weight']};\n min-height: ${fontSize[text.h6['font-size'] as FontSize]};\n }\n `;\n};\n\nexport const StyledHTML = styled.div(({ theme }) => {\n return css`\n width: 100%;\n overflow-x: auto;\n overflow-wrap: break-word;\n contain: paint;\n ${getHtmlStyles(theme)}\n\n ${StyledPopover} ul {\n ul {\n padding-inline-start: 0;\n }\n ol {\n padding-inline-start: 0;\n }\n }\n\n ${StyledPopover} li {\n margin: 0;\n }\n `;\n});\n\nStyledHTML.defaultProps = defaultThemeProp;\n\nif (DOMPurify.isSupported) {\n const targetBlankSet = new WeakSet<HTMLAnchorElement>();\n\n DOMPurify.addHook('beforeSanitizeAttributes', node => {\n // Can be passed text nodes\n if (!(node instanceof HTMLElement || node instanceof SVGElement)) return;\n\n node.removeAttribute('class');\n\n if (\n node.tagName === 'A' &&\n node.hasAttribute('href') &&\n node.getAttribute('target') === '_blank'\n ) {\n targetBlankSet.add(node as HTMLAnchorElement);\n }\n });\n\n DOMPurify.addHook('afterSanitizeAttributes', node => {\n if (node.tagName === 'A' && node.hasAttribute('href')) {\n const href = node.getAttribute('href')!;\n\n let fullURL: URL;\n try {\n fullURL = new URL(href, window.location.href);\n } catch (e) {\n return;\n }\n\n if (!sameOrigin(window.location, fullURL)) {\n node.setAttribute('target', '_blank');\n node.setAttribute('rel', 'noopener');\n } else if (targetBlankSet.has(node as HTMLAnchorElement)) {\n node.setAttribute('target', '_blank');\n targetBlankSet.delete(node as HTMLAnchorElement);\n }\n }\n });\n}\n\nconst HTML: FunctionComponent<HTMLProps & ForwardProps> = forwardRef(function HTML(\n { testId, content, customTags, ...restProps }: PropsWithoutRef<HTMLProps>,\n ref: HTMLProps['ref']\n) {\n const [mounted, setMounted] = useState(false);\n const sanitizedHtml = useMemo(() => {\n // Don't render content on the server at all.\n return mounted && DOMPurify.isSupported\n ? DOMPurify.sanitize(content, {\n FORBID_TAGS: ['style'],\n CUSTOM_ELEMENT_HANDLING: {\n tagNameCheck: customTags ? tagName => customTags.includes(tagName) : undefined\n }\n })\n : '';\n }, [content, customTags, mounted]);\n const testIds = useTestIds(testId, getHTMLTestIds);\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n return (\n <StyledHTML\n data-testid={testIds.root}\n {...restProps}\n dangerouslySetInnerHTML={{ __html: sanitizedHtml }}\n ref={ref}\n />\n );\n});\n\nexport default withTestIds(HTML, getHTMLTestIds);\n"]}
@@ -2,7 +2,7 @@ import type { FunctionComponent } from 'react';
2
2
  import type { ForwardProps } from '../../types';
3
3
  import type { LightboxProps } from './Lightbox.types';
4
4
  declare const _default: FunctionComponent<LightboxProps & ForwardProps> & {
5
- getTestIds: (testIdProp?: string | undefined) => import("../../types").TestIdsRecord<readonly ["content", "name", "metadata", "download", "close", "prev", "next", "pagination"]>;
5
+ getTestIds: (testIdProp?: string | undefined) => import("../../types").TestIdsRecord<readonly ["content", "name", "metadata", "download", "close", "prev", "next", "pagination", "non-previewable-download", "link"]>;
6
6
  };
7
7
  export default _default;
8
8
  //# sourceMappingURL=Lightbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Lightbox.d.ts","sourceRoot":"","sources":["../../../src/components/Lightbox/Lightbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAoD,MAAM,OAAO,CAAC;AAGjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA+BhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;;;;AAsPtD,wBAAyD"}
1
+ {"version":3,"file":"Lightbox.d.ts","sourceRoot":"","sources":["../../../src/components/Lightbox/Lightbox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAsChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;;;;AAmVtD,wBAAyD"}
@@ -1,17 +1,23 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState, forwardRef } from 'react';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState, forwardRef, useCallback } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { cap, withTestIds } from '../../utils';
5
5
  import Flex from '../Flex';
6
6
  import MetaList from '../MetaList';
7
7
  import Icon from '../Icon';
8
+ import Image from '../Image';
8
9
  import Text from '../Text';
9
10
  import { useConfiguration, useConsolidatedRef, useDirection, useEvent, useFocusTrap, useI18n, useScrollToggle, useTestIds } from '../../hooks';
10
11
  import ErrorState from '../ErrorState';
11
12
  import Progress from '../Progress';
12
- import { StyledHeader, StyledCountTracker, StyledInfo, StyledActionButton, StyledPreviewRegion, StyledNavButton, StyledImageContainer, StyledImage, StyledLiveRegion, StyledLightbox } from './Lightbox.styles';
13
+ import FileVisual from '../File/FileVisual';
14
+ import Button from '../Button';
15
+ import Link from '../Link/Link';
16
+ import mimeTypes from '../File/mimeTypes.json';
17
+ import { getKindFromMimeType } from '../File/utils';
18
+ import { StyledHeader, StyledCountTracker, StyledInfo, StyledPreviewRegion, StyledNavButton, StyledMediaContainer, StyledLiveRegion, StyledLightbox, StyledContainer, StyledObject } from './Lightbox.styles';
13
19
  import { getLightboxTestIds } from './Lightbox.test-ids';
14
- const Lightbox = forwardRef(function Lightbox({ testId, items, defaultIndex = 0, cycle, onItemLoad, onItemError, onNavigate, onItemDownload, onAfterClose, ...restProps }, refArg) {
20
+ const Lightbox = forwardRef(function Lightbox({ testId, items, defaultIndex = 0, cycle = false, onItemLoad, onItemError, onNavigate, onItemDownload, onAfterClose, ...restProps }, refArg) {
15
21
  const t = useI18n();
16
22
  const { start, end } = useDirection();
17
23
  const { portalTarget } = useConfiguration();
@@ -24,8 +30,7 @@ const Lightbox = forwardRef(function Lightbox({ testId, items, defaultIndex = 0,
24
30
  const prevButtonRef = useRef(null);
25
31
  const nextButtonRef = useRef(null);
26
32
  const [open, setOpen] = useState(true);
27
- const imageRef = useConsolidatedRef(currentItem.ref);
28
- const [error, setError] = useState(false);
33
+ const mediaRef = useConsolidatedRef(currentItem.ref);
29
34
  const [liveText, setLiveText] = useState('');
30
35
  const countTrackerText = items.length > 1 ? t('x_of_y', [currentIndex + 1, items.length]) : '';
31
36
  const testIds = useTestIds(testId, getLightboxTestIds);
@@ -36,20 +41,16 @@ const Lightbox = forwardRef(function Lightbox({ testId, items, defaultIndex = 0,
36
41
  if (direction === 1) {
37
42
  if (currentIndex < items.length - 1) {
38
43
  setCurrentIndex(cur => cur + 1);
39
- setError(false);
40
44
  }
41
45
  else if (cycle) {
42
46
  setCurrentIndex(0);
43
- setError(false);
44
47
  }
45
48
  }
46
49
  else if (currentIndex > 0) {
47
50
  setCurrentIndex(cur => cur - 1);
48
- setError(false);
49
51
  }
50
52
  else if (cycle) {
51
53
  setCurrentIndex(items.length - 1);
52
- setError(false);
53
54
  }
54
55
  };
55
56
  const keyDownHandler = (e) => {
@@ -76,6 +77,58 @@ const Lightbox = forwardRef(function Lightbox({ testId, items, defaultIndex = 0,
76
77
  useEffect(() => {
77
78
  lightboxRef.current?.focus();
78
79
  }, []);
80
+ const handleLoad = useCallback((e) => {
81
+ onItemLoad?.(currentItem.id, e);
82
+ }, [onItemLoad, currentItem.id]);
83
+ const handleError = useCallback((e) => {
84
+ onItemError?.(currentItem.id, e);
85
+ }, [onItemError, currentItem.id]);
86
+ // Object elements appear to need native event handlers bound as JSX does not work.
87
+ // TODO: Follow up on reason why.
88
+ useEffect(() => {
89
+ if (!mediaRef.current || currentItem.format !== 'pdf')
90
+ return;
91
+ const pdfObject = mediaRef.current;
92
+ pdfObject.addEventListener('load', handleLoad);
93
+ pdfObject.addEventListener('error', handleError);
94
+ return () => {
95
+ pdfObject.removeEventListener('load', handleLoad);
96
+ pdfObject.removeEventListener('error', handleError);
97
+ };
98
+ }, [currentItem]);
99
+ let media;
100
+ let validContent;
101
+ let attachmentType = 'generic';
102
+ if (currentItem.format === undefined || currentItem.error) {
103
+ validContent = false;
104
+ }
105
+ else {
106
+ const extractMimeType = mimeTypes[currentItem.format.toLowerCase()];
107
+ const getType = currentItem.format === 'url' ? 'link' : 'generic';
108
+ attachmentType = extractMimeType ? getKindFromMimeType(extractMimeType) : getType;
109
+ const previewableAttachmentTypes = ['pdf', 'image', 'link'];
110
+ validContent = previewableAttachmentTypes.includes(attachmentType)
111
+ ? currentItem.src
112
+ : attachmentType;
113
+ }
114
+ if (validContent) {
115
+ const nonPreviewableContent = (_jsxs(_Fragment, { children: [_jsx(Text, { children: t('non_previewable', [currentItem.format ? currentItem.format.toUpperCase() : '']) }), onItemDownload && (_jsx(Button, { "aria-label": t('download'), onClick: () => onItemDownload(currentItem.id), "data-testid": testIds.nonPreviewableDownload, children: t('download') }))] }));
116
+ const defaultContent = (_jsxs(Flex, { container: { direction: 'column', gap: 2, alignItems: 'center' }, as: StyledInfo, "data-testid": testIds.content, children: [_jsx(FileVisual, { type: attachmentType, size: 'l' }), attachmentType === 'link' && currentItem.src ? (_jsx(Link, { href: currentItem.src, "data-testid": testIds.link, children: currentItem.name })) : (nonPreviewableContent)] }));
117
+ switch (attachmentType) {
118
+ case 'image':
119
+ media = currentItem.src && (_jsx(Image, { "data-testid": testIds.content, src: currentItem.src, alt: currentItem.description, onLoad: handleLoad, onError: handleError, ref: mediaRef }));
120
+ break;
121
+ case 'pdf':
122
+ media = currentItem.src && (_jsx(_Fragment, { children: navigator.pdfViewerEnabled ? (_jsx(StyledObject, { "data-testid": testIds.content, data: currentItem.src, type: 'application/pdf', ref: mediaRef, children: currentItem.description })) : ({ defaultContent }) }));
123
+ break;
124
+ default: {
125
+ media = defaultContent;
126
+ }
127
+ }
128
+ }
129
+ else {
130
+ media = _jsx(Progress, { placement: 'block', delay: true });
131
+ }
79
132
  const content = (_jsxs(StyledLightbox, { "data-testid": testIds.root, ...restProps, tabIndex: -1, ref: lightboxRef, open: open, role: 'dialog', "aria-modal": 'true', container: { alignItems: 'start', justify: 'start', direction: 'column' }, alpha: 0.9, variant: 'dark', transitionSpeed: 'slow', onBeforeTransitionIn: disableScroll, onAfterTransitionOut: () => {
80
133
  enableScroll();
81
134
  onAfterClose?.();
@@ -94,20 +147,14 @@ const Lightbox = forwardRef(function Lightbox({ testId, items, defaultIndex = 0,
94
147
  justify: 'center',
95
148
  colGap: 2,
96
149
  rowGap: 0.5
97
- }, children: [_jsx(Text, { "data-testid": testIds.name, variant: 'primary', as: 'h2', children: currentItem.name }), currentItem.metadata && (_jsx(MetaList, { "data-testid": testIds.metadata, items: currentItem.metadata }))] }), _jsxs(Flex, { container: true, children: [onItemDownload && (_jsx(StyledActionButton, { "data-testid": testIds.download, variant: 'simple', "aria-label": t('download'), icon: true, onClick: () => onItemDownload(currentItem.id), children: _jsx(Icon, { name: 'download' }) })), _jsx(StyledActionButton, { "data-testid": testIds.close, variant: 'simple', ref: closeButtonRef, "aria-label": t('close'), icon: true, onClick: close, children: _jsx(Icon, { name: 'times' }) })] })] }), _jsxs(Flex, { container: { justify: 'between' }, as: StyledPreviewRegion, item: { grow: 1, shrink: 0 }, children: [items.length > 1 && (_jsx(StyledNavButton, { "data-testid": testIds.prev, ref: prevButtonRef, variant: 'simple', "aria-label": t('pagination_prev'), hidden: !cycle && currentIndex === 0, icon: true, onClick: () => {
150
+ }, children: [_jsx(Text, { "data-testid": testIds.name, variant: 'primary', as: 'h2', children: currentItem.name }), currentItem.metadata && (_jsx(MetaList, { "data-testid": testIds.metadata, items: currentItem.metadata }))] }), _jsxs(Flex, { container: true, as: StyledContainer, children: [attachmentType !== 'link' && onItemDownload && (_jsx(Button, { "data-testid": testIds.download, variant: 'simple', "aria-label": t('download'), icon: true, onClick: () => onItemDownload(currentItem.id), children: _jsx(Icon, { name: 'download' }) })), _jsx(Button, { "data-testid": testIds.close, variant: 'simple', ref: closeButtonRef, "aria-label": t('close'), icon: true, onClick: close, children: _jsx(Icon, { name: 'times' }) })] })] }), _jsxs(Flex, { container: { justify: 'between' }, as: StyledPreviewRegion, item: { grow: 1, shrink: 0 }, children: [items.length > 1 && (_jsx(StyledNavButton, { "data-testid": testIds.prev, ref: prevButtonRef, variant: 'simple', "aria-label": t('pagination_prev'), hidden: !cycle && currentIndex === 0, icon: true, onClick: () => {
98
151
  navigate(-1);
99
- }, children: _jsx("span", { children: _jsx(Icon, { name: 'caret-left' }) }) })), _jsx(Flex, { item: { grow: 1 }, as: StyledImageContainer, children: _jsxs(Flex, { container: { alignItems: 'center' }, onMouseDown: (e) => {
152
+ }, children: _jsx("span", { children: _jsx(Icon, { name: 'caret-left' }) }) })), _jsx(Flex, { item: { grow: 1 }, as: StyledMediaContainer, children: _jsx(Flex, { container: { alignItems: 'center', justify: 'center' }, onMouseDown: (e) => {
100
153
  if (e.button !== 0)
101
154
  return;
102
155
  if (e.target === e.currentTarget)
103
156
  close();
104
- }, children: [error && _jsx(ErrorState, { message: t('image_load_error') }), !error &&
105
- (currentItem.src ? (_jsx(StyledImage, { "data-testid": testIds.content, ref: imageRef, src: currentItem.src, alt: currentItem.description, onLoad: (e) => {
106
- onItemLoad?.(currentItem.id, e);
107
- }, onError: (e) => {
108
- onItemError?.(currentItem.id, e);
109
- setError(true);
110
- } })) : (_jsx(Progress, { placement: 'block', delay: true })))] }) }), items.length > 1 && (_jsx(StyledNavButton, { "data-testid": testIds.next, ref: nextButtonRef, variant: 'simple', "aria-label": t('pagination_next'), hidden: !cycle && currentIndex === items.length - 1, icon: true, onClick: () => {
157
+ }, children: currentItem.error ? _jsx(ErrorState, { message: t('content_load_error') }) : media }) }), items.length > 1 && (_jsx(StyledNavButton, { "data-testid": testIds.next, ref: nextButtonRef, variant: 'simple', "aria-label": t('pagination_next'), hidden: !cycle && currentIndex === items.length - 1, icon: true, onClick: () => {
111
158
  navigate(1);
112
159
  }, children: _jsx("span", { children: _jsx(Icon, { name: 'caret-right' }) }) }))] }), _jsx(StyledLiveRegion, { "aria-live": 'polite', "aria-label": liveText })] }));
113
160
  return portalTarget ? createPortal(content, portalTarget) : content;
@@ -1 +1 @@
1
- {"version":3,"file":"Lightbox.js","sourceRoot":"","sources":["../../../src/components/Lightbox/Lightbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,QAAQ,GAAoD,UAAU,CAAC,S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Ref, useState, forwardRef } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref, MouseEvent, SyntheticEvent } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport type { ForwardProps } from '../../types';\nimport { cap, withTestIds } from '../../utils';\nimport Flex from '../Flex';\nimport MetaList from '../MetaList';\nimport Icon from '../Icon';\nimport Text from '../Text';\nimport {\n useConfiguration,\n useConsolidatedRef,\n useDirection,\n useEvent,\n useFocusTrap,\n useI18n,\n useScrollToggle,\n useTestIds\n} from '../../hooks';\nimport ErrorState from '../ErrorState';\nimport Progress from '../Progress';\n\nimport {\n StyledHeader,\n StyledCountTracker,\n StyledInfo,\n StyledActionButton,\n StyledPreviewRegion,\n StyledNavButton,\n StyledImageContainer,\n StyledImage,\n StyledLiveRegion,\n StyledLightbox\n} from './Lightbox.styles';\nimport type { LightboxProps } from './Lightbox.types';\nimport { getLightboxTestIds } from './Lightbox.test-ids';\n\nconst Lightbox: FunctionComponent<LightboxProps & ForwardProps> = forwardRef(function Lightbox(\n {\n testId,\n items,\n defaultIndex = 0,\n cycle,\n onItemLoad,\n onItemError,\n onNavigate,\n onItemDownload,\n onAfterClose,\n ...restProps\n }: PropsWithoutRef<LightboxProps>,\n refArg: Ref<HTMLDivElement>\n) {\n const t = useI18n();\n const { start, end } = useDirection();\n const { portalTarget } = useConfiguration();\n const [currentIndex, setCurrentIndex] = useState(defaultIndex);\n const currentItem = items[currentIndex];\n const { disableScroll, enableScroll } = useScrollToggle();\n const lightboxRef = useConsolidatedRef(refArg);\n const headerRef = useRef<HTMLDivElement>(null);\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n const prevButtonRef = useRef<HTMLButtonElement>(null);\n const nextButtonRef = useRef<HTMLButtonElement>(null);\n const [open, setOpen] = useState(true);\n const imageRef = useConsolidatedRef(currentItem.ref);\n const [error, setError] = useState(false);\n const [liveText, setLiveText] = useState('');\n const countTrackerText = items.length > 1 ? t('x_of_y', [currentIndex + 1, items.length]) : '';\n const testIds = useTestIds(testId, getLightboxTestIds);\n\n const close = () => {\n setOpen(false);\n };\n\n const navigate = (direction: 1 | -1) => {\n if (direction === 1) {\n if (currentIndex < items.length - 1) {\n setCurrentIndex(cur => cur + 1);\n setError(false);\n } else if (cycle) {\n setCurrentIndex(0);\n setError(false);\n }\n } else if (currentIndex > 0) {\n setCurrentIndex(cur => cur - 1);\n setError(false);\n } else if (cycle) {\n setCurrentIndex(items.length - 1);\n setError(false);\n }\n };\n const keyDownHandler = (e: KeyboardEvent) => {\n if (e.repeat) return;\n\n if (e.key === 'Escape') {\n close();\n } else if (e.key === `Arrow${cap(end)}`) {\n navigate(1);\n } else if (e.key === `Arrow${cap(start)}`) {\n navigate(-1);\n }\n };\n\n useEvent('keydown', keyDownHandler);\n useFocusTrap(lightboxRef);\n\n useEffect(() => {\n setLiveText(\n `${currentItem.name}. ${countTrackerText ? `${countTrackerText}.` : ''} ${\n currentItem.description\n }.`\n );\n }, [currentItem.name, countTrackerText, currentItem.description]);\n\n useEffect(() => {\n onNavigate?.(currentItem.id, currentIndex);\n }, [currentIndex]);\n\n useEffect(() => {\n lightboxRef.current?.focus();\n }, []);\n\n const content = (\n <StyledLightbox\n data-testid={testIds.root}\n {...restProps}\n tabIndex={-1}\n ref={lightboxRef}\n open={open}\n role='dialog'\n aria-modal='true'\n container={{ alignItems: 'start', justify: 'start', direction: 'column' }}\n alpha={0.9}\n variant='dark'\n transitionSpeed='slow'\n onBeforeTransitionIn={disableScroll}\n onAfterTransitionOut={() => {\n enableScroll();\n onAfterClose?.();\n }}\n >\n <Flex\n as={StyledHeader}\n ref={headerRef}\n container={{\n justify: 'between',\n alignItems: 'center',\n gap: 2\n }}\n onMouseDown={(e: MouseEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n if (e.target === e.currentTarget) close();\n }}\n >\n <StyledCountTracker data-testid={testIds.pagination} aria-hidden='true'>\n {countTrackerText}\n </StyledCountTracker>\n\n <Flex\n as={StyledInfo}\n container={{\n wrap: 'wrap',\n alignItems: 'center',\n justify: 'center',\n colGap: 2,\n rowGap: 0.5\n }}\n >\n <Text data-testid={testIds.name} variant='primary' as='h2'>\n {currentItem.name}\n </Text>\n {currentItem.metadata && (\n <MetaList data-testid={testIds.metadata} items={currentItem.metadata} />\n )}\n </Flex>\n\n <Flex container>\n {onItemDownload && (\n <StyledActionButton\n data-testid={testIds.download}\n variant='simple'\n aria-label={t('download')}\n icon\n onClick={() => onItemDownload(currentItem.id)}\n >\n <Icon name='download' />\n </StyledActionButton>\n )}\n <StyledActionButton\n data-testid={testIds.close}\n variant='simple'\n ref={closeButtonRef}\n aria-label={t('close')}\n icon\n onClick={close}\n >\n <Icon name='times' />\n </StyledActionButton>\n </Flex>\n </Flex>\n\n <Flex\n container={{ justify: 'between' }}\n as={StyledPreviewRegion}\n item={{ grow: 1, shrink: 0 }}\n >\n {items.length > 1 && (\n <StyledNavButton\n data-testid={testIds.prev}\n ref={prevButtonRef}\n variant='simple'\n aria-label={t('pagination_prev')}\n hidden={!cycle && currentIndex === 0}\n icon\n onClick={() => {\n navigate(-1);\n }}\n >\n <span>\n <Icon name='caret-left' />\n </span>\n </StyledNavButton>\n )}\n\n <Flex item={{ grow: 1 }} as={StyledImageContainer}>\n <Flex\n container={{ alignItems: 'center' }}\n onMouseDown={(e: MouseEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n if (e.target === e.currentTarget) close();\n }}\n >\n {error && <ErrorState message={t('image_load_error')} />}\n\n {!error &&\n (currentItem.src ? (\n <StyledImage\n data-testid={testIds.content}\n ref={imageRef}\n src={currentItem.src}\n alt={currentItem.description}\n onLoad={(e: SyntheticEvent<HTMLImageElement>) => {\n onItemLoad?.(currentItem.id, e);\n }}\n onError={(e: SyntheticEvent<HTMLImageElement>) => {\n onItemError?.(currentItem.id, e);\n setError(true);\n }}\n />\n ) : (\n <Progress placement='block' delay />\n ))}\n </Flex>\n </Flex>\n\n {items.length > 1 && (\n <StyledNavButton\n data-testid={testIds.next}\n ref={nextButtonRef}\n variant='simple'\n aria-label={t('pagination_next')}\n hidden={!cycle && currentIndex === items.length - 1}\n icon\n onClick={() => {\n navigate(1);\n }}\n >\n <span>\n <Icon name='caret-right' />\n </span>\n </StyledNavButton>\n )}\n </Flex>\n <StyledLiveRegion aria-live='polite' aria-label={liveText} />\n </StyledLightbox>\n );\n\n return portalTarget ? createPortal(content, portalTarget) : content;\n});\n\nexport default withTestIds(Lightbox, getLightboxTestIds);\n"]}
1
+ {"version":3,"file":"Lightbox.js","sourceRoot":"","sources":["../../../src/components/Lightbox/Lightbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAS7E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,MAAM,UAAU,CAAC;AAC7B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,UAAU,MAAM,oBAAoB,CAAC;AAC5C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,MAAM,cAAc,CAAC;AAChC,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EAC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,OAAO,EAAE,GAAG,EAAE;4BACZ,QAAQ,CAAC,CAAC,CAAC,CAAC;wBACd,CAAC,YAED,yBACE,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,GAAG,GACtB,GACS,CACnB,IACI,EACP,KAAC,gBAAgB,iBAAW,QAAQ,gBAAa,QAAQ,GAAI,IAC9C,CAClB,CAAC;IAEF,OAAO,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACtE,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { useEffect, useRef, useState, forwardRef, useCallback } from 'react';\nimport type {\n FunctionComponent,\n PropsWithoutRef,\n Ref,\n MouseEvent,\n SyntheticEvent,\n RefObject\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport type { ForwardProps } from '../../types';\nimport { cap, withTestIds } from '../../utils';\nimport Flex from '../Flex';\nimport MetaList from '../MetaList';\nimport Icon from '../Icon';\nimport Image from '../Image';\nimport Text from '../Text';\nimport {\n useConfiguration,\n useConsolidatedRef,\n useDirection,\n useEvent,\n useFocusTrap,\n useI18n,\n useScrollToggle,\n useTestIds\n} from '../../hooks';\nimport ErrorState from '../ErrorState';\nimport Progress from '../Progress';\nimport FileVisual from '../File/FileVisual';\nimport Button from '../Button';\nimport Link from '../Link/Link';\nimport mimeTypes from '../File/mimeTypes.json';\nimport { getKindFromMimeType } from '../File/utils';\nimport type { AttachmentType } from '../File/utils';\n\nimport {\n StyledHeader,\n StyledCountTracker,\n StyledInfo,\n StyledPreviewRegion,\n StyledNavButton,\n StyledMediaContainer,\n StyledLiveRegion,\n StyledLightbox,\n StyledContainer,\n StyledObject\n} from './Lightbox.styles';\nimport type { LightboxProps } from './Lightbox.types';\nimport { getLightboxTestIds } from './Lightbox.test-ids';\n\nconst Lightbox: FunctionComponent<LightboxProps & ForwardProps> = forwardRef(function Lightbox(\n {\n testId,\n items,\n defaultIndex = 0,\n cycle = false,\n onItemLoad,\n onItemError,\n onNavigate,\n onItemDownload,\n onAfterClose,\n ...restProps\n }: PropsWithoutRef<LightboxProps>,\n refArg: Ref<HTMLDivElement>\n) {\n const t = useI18n();\n const { start, end } = useDirection();\n const { portalTarget } = useConfiguration();\n const [currentIndex, setCurrentIndex] = useState(defaultIndex);\n const currentItem = items[currentIndex];\n const { disableScroll, enableScroll } = useScrollToggle();\n const lightboxRef = useConsolidatedRef(refArg);\n const headerRef = useRef<HTMLDivElement>(null);\n const closeButtonRef = useRef<HTMLButtonElement>(null);\n const prevButtonRef = useRef<HTMLButtonElement>(null);\n const nextButtonRef = useRef<HTMLButtonElement>(null);\n const [open, setOpen] = useState(true);\n const mediaRef = useConsolidatedRef(currentItem.ref);\n const [liveText, setLiveText] = useState('');\n const countTrackerText = items.length > 1 ? t('x_of_y', [currentIndex + 1, items.length]) : '';\n const testIds = useTestIds(testId, getLightboxTestIds);\n\n const close = () => {\n setOpen(false);\n };\n\n const navigate = (direction: 1 | -1) => {\n if (direction === 1) {\n if (currentIndex < items.length - 1) {\n setCurrentIndex(cur => cur + 1);\n } else if (cycle) {\n setCurrentIndex(0);\n }\n } else if (currentIndex > 0) {\n setCurrentIndex(cur => cur - 1);\n } else if (cycle) {\n setCurrentIndex(items.length - 1);\n }\n };\n const keyDownHandler = (e: KeyboardEvent) => {\n if (e.repeat) return;\n\n if (e.key === 'Escape') {\n close();\n } else if (e.key === `Arrow${cap(end)}`) {\n navigate(1);\n } else if (e.key === `Arrow${cap(start)}`) {\n navigate(-1);\n }\n };\n\n useEvent('keydown', keyDownHandler);\n useFocusTrap(lightboxRef);\n\n useEffect(() => {\n setLiveText(\n `${currentItem.name}. ${countTrackerText ? `${countTrackerText}.` : ''} ${\n currentItem.description\n }.`\n );\n }, [currentItem.name, countTrackerText, currentItem.description]);\n\n useEffect(() => {\n onNavigate?.(currentItem.id, currentIndex);\n }, [currentIndex]);\n\n useEffect(() => {\n lightboxRef.current?.focus();\n }, []);\n\n const handleLoad = useCallback(\n (e: SyntheticEvent<HTMLImageElement | HTMLObjectElement> | Event) => {\n onItemLoad?.(currentItem.id, e);\n },\n [onItemLoad, currentItem.id]\n );\n\n const handleError = useCallback(\n (e: SyntheticEvent<HTMLImageElement | HTMLObjectElement> | Event) => {\n onItemError?.(currentItem.id, e);\n },\n [onItemError, currentItem.id]\n );\n\n // Object elements appear to need native event handlers bound as JSX does not work.\n // TODO: Follow up on reason why.\n useEffect(() => {\n if (!mediaRef.current || currentItem.format !== 'pdf') return;\n const pdfObject = mediaRef.current;\n pdfObject.addEventListener('load', handleLoad);\n pdfObject.addEventListener('error', handleError);\n\n return () => {\n pdfObject.removeEventListener('load', handleLoad);\n pdfObject.removeEventListener('error', handleError);\n };\n }, [currentItem]);\n\n let media;\n let validContent;\n let attachmentType: AttachmentType = 'generic';\n if (currentItem.format === undefined || currentItem.error) {\n validContent = false;\n } else {\n const extractMimeType = (mimeTypes as Record<string, string>)[currentItem.format.toLowerCase()];\n const getType = currentItem.format === 'url' ? 'link' : 'generic';\n attachmentType = extractMimeType ? getKindFromMimeType(extractMimeType) : getType;\n const previewableAttachmentTypes = ['pdf', 'image', 'link'];\n validContent = previewableAttachmentTypes.includes(attachmentType)\n ? currentItem.src\n : attachmentType;\n }\n\n if (validContent) {\n const nonPreviewableContent = (\n <>\n <Text>\n {t('non_previewable', [currentItem.format ? currentItem.format.toUpperCase() : ''])}\n </Text>\n {onItemDownload && (\n <Button\n aria-label={t('download')}\n onClick={() => onItemDownload(currentItem.id)}\n data-testid={testIds.nonPreviewableDownload}\n >\n {t('download')}\n </Button>\n )}\n </>\n );\n\n const defaultContent = (\n <Flex\n container={{ direction: 'column', gap: 2, alignItems: 'center' }}\n as={StyledInfo}\n data-testid={testIds.content}\n >\n <FileVisual type={attachmentType} size='l' />\n {attachmentType === 'link' && currentItem.src ? (\n <Link href={currentItem.src} data-testid={testIds.link}>\n {currentItem.name}\n </Link>\n ) : (\n nonPreviewableContent\n )}\n </Flex>\n );\n\n switch (attachmentType) {\n case 'image':\n media = currentItem.src && (\n <Image\n data-testid={testIds.content}\n src={currentItem.src}\n alt={currentItem.description}\n onLoad={handleLoad}\n onError={handleError}\n ref={mediaRef as RefObject<HTMLImageElement>}\n />\n );\n break;\n case 'pdf':\n media = currentItem.src && (\n <>\n {navigator.pdfViewerEnabled ? (\n <StyledObject\n data-testid={testIds.content}\n data={currentItem.src}\n type='application/pdf'\n ref={mediaRef as RefObject<HTMLObjectElement>}\n >\n {currentItem.description}\n </StyledObject>\n ) : (\n { defaultContent }\n )}\n </>\n );\n break;\n default: {\n media = defaultContent;\n }\n }\n } else {\n media = <Progress placement='block' delay />;\n }\n\n const content = (\n <StyledLightbox\n data-testid={testIds.root}\n {...restProps}\n tabIndex={-1}\n ref={lightboxRef}\n open={open}\n role='dialog'\n aria-modal='true'\n container={{ alignItems: 'start', justify: 'start', direction: 'column' }}\n alpha={0.9}\n variant='dark'\n transitionSpeed='slow'\n onBeforeTransitionIn={disableScroll}\n onAfterTransitionOut={() => {\n enableScroll();\n onAfterClose?.();\n }}\n >\n <Flex\n as={StyledHeader}\n ref={headerRef}\n container={{\n justify: 'between',\n alignItems: 'center',\n gap: 2\n }}\n onMouseDown={(e: MouseEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n if (e.target === e.currentTarget) close();\n }}\n >\n <StyledCountTracker data-testid={testIds.pagination} aria-hidden='true'>\n {countTrackerText}\n </StyledCountTracker>\n\n <Flex\n as={StyledInfo}\n container={{\n wrap: 'wrap',\n alignItems: 'center',\n justify: 'center',\n colGap: 2,\n rowGap: 0.5\n }}\n >\n <Text data-testid={testIds.name} variant='primary' as='h2'>\n {currentItem.name}\n </Text>\n {currentItem.metadata && (\n <MetaList data-testid={testIds.metadata} items={currentItem.metadata} />\n )}\n </Flex>\n\n <Flex container as={StyledContainer}>\n {attachmentType !== 'link' && onItemDownload && (\n <Button\n data-testid={testIds.download}\n variant='simple'\n aria-label={t('download')}\n icon\n onClick={() => onItemDownload(currentItem.id)}\n >\n <Icon name='download' />\n </Button>\n )}\n <Button\n data-testid={testIds.close}\n variant='simple'\n ref={closeButtonRef}\n aria-label={t('close')}\n icon\n onClick={close}\n >\n <Icon name='times' />\n </Button>\n </Flex>\n </Flex>\n\n <Flex\n container={{ justify: 'between' }}\n as={StyledPreviewRegion}\n item={{ grow: 1, shrink: 0 }}\n >\n {items.length > 1 && (\n <StyledNavButton\n data-testid={testIds.prev}\n ref={prevButtonRef}\n variant='simple'\n aria-label={t('pagination_prev')}\n hidden={!cycle && currentIndex === 0}\n icon\n onClick={() => {\n navigate(-1);\n }}\n >\n <span>\n <Icon name='caret-left' />\n </span>\n </StyledNavButton>\n )}\n\n <Flex item={{ grow: 1 }} as={StyledMediaContainer}>\n <Flex\n container={{ alignItems: 'center', justify: 'center' }}\n onMouseDown={(e: MouseEvent<HTMLDivElement>) => {\n if (e.button !== 0) return;\n if (e.target === e.currentTarget) close();\n }}\n >\n {currentItem.error ? <ErrorState message={t('content_load_error')} /> : media}\n </Flex>\n </Flex>\n\n {items.length > 1 && (\n <StyledNavButton\n data-testid={testIds.next}\n ref={nextButtonRef}\n variant='simple'\n aria-label={t('pagination_next')}\n hidden={!cycle && currentIndex === items.length - 1}\n icon\n onClick={() => {\n navigate(1);\n }}\n >\n <span>\n <Icon name='caret-right' />\n </span>\n </StyledNavButton>\n )}\n </Flex>\n <StyledLiveRegion aria-live='polite' aria-label={liveText} />\n </StyledLightbox>\n );\n\n return portalTarget ? createPortal(content, portalTarget) : content;\n});\n\nexport default withTestIds(Lightbox, getLightboxTestIds);\n"]}
@@ -2,10 +2,10 @@ export declare const StyledHeader: import("styled-components").StyledComponent<"
2
2
  export declare const StyledCountTracker: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
3
  export declare const StyledInfo: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
4
  export declare const StyledNavButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Button/BareButton").BareButtonProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
5
- export declare const StyledActionButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Button").ButtonProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
6
- export declare const StyledImageContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
5
+ export declare const StyledContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const StyledMediaContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
7
+ export declare const StyledObject: import("styled-components").StyledComponent<"object", import("styled-components").DefaultTheme, {}, never>;
7
8
  export declare const StyledPreviewRegion: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
- export declare const StyledImage: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../Image").ImageProps & import("../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
9
9
  export declare const StyledLiveRegion: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
10
10
  export declare const StyledLightbox: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<Omit<import("../Backdrop").BackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
11
11
  getTestIds: (testIdProp?: string | undefined) => import("../..").TestIdsRecord<readonly []>;
@@ -1 +1 @@
1
- {"version":3,"file":"Lightbox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Lightbox/Lightbox.styles.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,YAAY,4GAkBvB,CAAC;AAIH,eAAO,MAAM,kBAAkB,yGAY7B,CAAC;AAIH,eAAO,MAAM,UAAU,yGAKrB,CAAC;AAIH,eAAO,MAAM,eAAe,oNAgE1B,CAAC;AAIH,eAAO,MAAM,kBAAkB,qMAS7B,CAAC;AAIH,eAAO,MAAM,oBAAoB,yGAkB/B,CAAC;AAIH,eAAO,MAAM,mBAAmB,yGAG/B,CAAC;AAEF,eAAO,MAAM,WAAW,mMAKvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,yGAE5B,CAAC;AAEF,eAAO,MAAM,cAAc;;uDAQzB,CAAC"}
1
+ {"version":3,"file":"Lightbox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Lightbox/Lightbox.styles.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,YAAY,4GAkBvB,CAAC;AAIH,eAAO,MAAM,kBAAkB,yGAY7B,CAAC;AAIH,eAAO,MAAM,UAAU,yGAUrB,CAAC;AAIH,eAAO,MAAM,eAAe,oNAgE1B,CAAC;AAIH,eAAO,MAAM,eAAe,yGAW1B,CAAC;AAIH,eAAO,MAAM,oBAAoB,yGAyB/B,CAAC;AAEH,eAAO,MAAM,YAAY,4GAKxB,CAAC;AAIF,eAAO,MAAM,mBAAmB,yGAG/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,yGAE5B,CAAC;AAEF,eAAO,MAAM,cAAc;;uDAQzB,CAAC"}
@@ -3,8 +3,6 @@ import { hideVisually, rgba } from 'polished';
3
3
  import { defaultThemeProp } from '../../theme';
4
4
  import { tryCatch } from '../../utils';
5
5
  import { calculateFontSize } from '../../styles';
6
- import Image from '../Image';
7
- import Button from '../Button';
8
6
  import BareButton from '../Button/BareButton';
9
7
  import { StyledIcon } from '../Icon';
10
8
  import { StyledMetaList } from '../MetaList/MetaList';
@@ -12,6 +10,7 @@ import { StyledErrorState } from '../ErrorState';
12
10
  import { StyledText } from '../Text';
13
11
  import { useDirection } from '../../hooks';
14
12
  import Backdrop from '../Backdrop';
13
+ import { StyledLink } from '../Link/Link';
15
14
  export const StyledHeader = styled.header(({ theme }) => {
16
15
  const color = tryCatch(() => rgba(theme.base.palette.light, theme.base.transparency['transparent-2']));
17
16
  return css `
@@ -46,6 +45,11 @@ export const StyledInfo = styled.div(({ theme }) => {
46
45
  return css `
47
46
  color: ${theme.base.palette.light};
48
47
  font-weight: ${theme.base['font-weight']['semi-bold']};
48
+
49
+ ${StyledLink} {
50
+ color: inherit;
51
+ text-decoration: underline;
52
+ }
49
53
  `;
50
54
  });
51
55
  StyledInfo.defaultProps = defaultThemeProp;
@@ -114,18 +118,20 @@ export const StyledNavButton = styled(BareButton)(({ theme }) => {
114
118
  `;
115
119
  });
116
120
  StyledNavButton.defaultProps = defaultThemeProp;
117
- export const StyledActionButton = styled(Button)(({ theme }) => {
121
+ export const StyledContainer = styled.div(({ theme }) => {
118
122
  return css `
119
- padding: ${theme.base.spacing};
120
- color: ${theme.base.palette.light};
123
+ button {
124
+ padding: ${theme.base.spacing};
125
+ color: ${theme.base.palette.light};
121
126
 
122
- &:focus:enabled {
123
- box-shadow: ${theme.base.shadow.focus};
127
+ &:focus:enabled {
128
+ box-shadow: ${theme.base.shadow.focus};
129
+ }
124
130
  }
125
131
  `;
126
132
  });
127
- StyledActionButton.defaultProps = defaultThemeProp;
128
- export const StyledImageContainer = styled.div(({ theme }) => {
133
+ StyledContainer.defaultProps = defaultThemeProp;
134
+ export const StyledMediaContainer = styled.div(({ theme }) => {
129
135
  return css `
130
136
  position: relative;
131
137
 
@@ -142,19 +148,26 @@ export const StyledImageContainer = styled.div(({ theme }) => {
142
148
  color: ${theme.base.palette.light};
143
149
  }
144
150
  }
151
+
152
+ img {
153
+ display: block;
154
+ max-width: 100%;
155
+ max-height: 100%;
156
+ margin: auto;
157
+ }
145
158
  `;
146
159
  });
147
- StyledImageContainer.defaultProps = defaultThemeProp;
160
+ export const StyledObject = styled.object `
161
+ display: block;
162
+ margin: auto;
163
+ width: calc(100% - 5rem);
164
+ height: 100%;
165
+ `;
166
+ StyledMediaContainer.defaultProps = defaultThemeProp;
148
167
  export const StyledPreviewRegion = styled.div `
149
168
  position: relative;
150
169
  width: 100%;
151
170
  `;
152
- export const StyledImage = styled(Image) `
153
- display: block;
154
- max-width: 100%;
155
- max-height: 100%;
156
- margin: auto;
157
- `;
158
171
  export const StyledLiveRegion = styled.div `
159
172
  ${hideVisually}
160
173
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"Lightbox.styles.js","sourceRoot":"","sources":["../../../src/components/Lightbox/Lightbox.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,MAAM,UAAU,CAAC;AAC7B,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACtD,MAAM,KAAK,GAAuB,QAAQ,CAAC,GAAG,EAAE,CAC9C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CACzE,CAAC;IAEF,OAAO,GAAG,CAAA;;;eAGG,KAAK,CAAC,IAAI,CAAC,OAAO;aACpB,KAAK;;MAEZ,cAAc;;;iBAGH,KAAK;;;GAGnB,CAAC;AACJ,CAAC,CAAC,CA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OAAO,GAAG,CAAA;;;;;;kCAMsB,KAAK,CAAC,IAAI,CAAC,OAAO;;;;MAI9C,gBAAgB;;YAEV,UAAU;iBACL,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK;;;GAGtC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAG5C,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;;;;;CAKvC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;IACtC,YAAY;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3D,OAAO,GAAG,CAAA;eACG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG;;;;;GAKrC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { hideVisually, rgba } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport Image from '../Image';\nimport Button from '../Button';\nimport BareButton from '../Button/BareButton';\nimport { StyledIcon } from '../Icon';\nimport { StyledMetaList } from '../MetaList/MetaList';\nimport { StyledErrorState } from '../ErrorState';\nimport { StyledText } from '../Text';\nimport { useDirection } from '../../hooks';\nimport Backdrop from '../Backdrop';\n\nexport const StyledHeader = styled.header(({ theme }) => {\n const color: string | undefined = tryCatch(() =>\n rgba(theme.base.palette.light, theme.base.transparency['transparent-2'])\n );\n\n return css`\n position: relative;\n width: 100%;\n padding: ${theme.base.spacing};\n color: ${color};\n\n ${StyledMetaList} {\n justify-content: center;\n li {\n color: ${color};\n }\n }\n `;\n});\n\nStyledHeader.defaultProps = defaultThemeProp;\n\nexport const StyledCountTracker = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n font-size: ${fontSize.xs};\n text-align: center;\n min-width: calc(2 * ${theme.base['hit-area']['mouse-min']});\n\n @media (pointer: coarse) {\n min-width: calc(2 * ${theme.base['hit-area']['finger-min']});\n }\n `;\n});\n\nStyledCountTracker.defaultProps = defaultThemeProp;\n\nexport const StyledInfo = styled.div(({ theme }) => {\n return css`\n color: ${theme.base.palette.light};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n `;\n});\n\nStyledInfo.defaultProps = defaultThemeProp;\n\nexport const StyledNavButton = styled(BareButton)(({ theme }) => {\n const bg = tryCatch(() => rgba(theme.base.colors.gray.medium, 0.5));\n const hoverBg = tryCatch(() => rgba(theme.base.colors.gray.medium, 0.7));\n const { rtl } = useDirection();\n\n return css`\n position: absolute;\n z-index: 1;\n inset-block: 0;\n min-width: ${theme.base['hit-area']['mouse-min']};\n color: ${theme.base.palette['foreground-color']};\n box-shadow: none;\n border-radius: 0;\n\n @media (pointer: coarse) {\n min-width: ${theme.base['hit-area']['finger-min']};\n }\n\n &[hidden] {\n display: none;\n }\n\n & > span {\n display: inline-block;\n background-color: ${bg};\n\n ${StyledIcon} {\n color: ${theme.base.palette.light};\n width: 2rem;\n height: 3rem;\n\n ${rtl &&\n css`\n transform: rotateZ(180deg);\n `}\n }\n }\n\n &:nth-of-type(1) {\n inset-inline-start: 0;\n text-align: start;\n & > span {\n border-start-end-radius: calc(${theme.base['border-radius']} / 2);\n border-end-end-radius: calc(${theme.base['border-radius']} / 2);\n }\n }\n\n &:nth-of-type(2) {\n inset-inline-end: 0;\n text-align: end;\n & > span {\n border-start-start-radius: calc(${theme.base['border-radius']} / 2);\n border-end-start-radius: calc(${theme.base['border-radius']} / 2);\n }\n }\n\n &:hover > span {\n background-color: ${hoverBg};\n }\n\n &:focus > span {\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n});\n\nStyledNavButton.defaultProps = defaultThemeProp;\n\nexport const StyledActionButton = styled(Button)(({ theme }) => {\n return css`\n padding: ${theme.base.spacing};\n color: ${theme.base.palette.light};\n\n &:focus:enabled {\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n});\n\nStyledActionButton.defaultProps = defaultThemeProp;\n\nexport const StyledImageContainer = styled.div(({ theme }) => {\n return css`\n position: relative;\n\n & > div {\n position: absolute;\n inset-block-start: 0;\n inset-block-end: calc(2 * ${theme.base.spacing});\n inset-inline: 0;\n }\n\n ${StyledErrorState} {\n margin: auto;\n & > ${StyledText} {\n color: ${theme.base.palette.light};\n }\n }\n `;\n});\n\nStyledImageContainer.defaultProps = defaultThemeProp;\n\nexport const StyledPreviewRegion = styled.div`\n position: relative;\n width: 100%;\n`;\n\nexport const StyledImage = styled(Image)`\n display: block;\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n`;\n\nexport const StyledLiveRegion = styled.div`\n ${hideVisually}\n`;\n\nexport const StyledLightbox = styled(Backdrop)(({ theme }) => {\n return css`\n z-index: ${theme.base['z-index'].max};\n\n &:focus {\n outline: none;\n }\n `;\n});\n\nStyledLightbox.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"Lightbox.styles.js","sourceRoot":"","sources":["../../../src/components/Lightbox/Lightbox.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,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C;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3D,OAAO,GAAG,CAAA;eACG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG;;;;;GAKrC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { hideVisually, rgba } from 'polished';\n\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { calculateFontSize } from '../../styles';\nimport BareButton from '../Button/BareButton';\nimport { StyledIcon } from '../Icon';\nimport { StyledMetaList } from '../MetaList/MetaList';\nimport { StyledErrorState } from '../ErrorState';\nimport { StyledText } from '../Text';\nimport { useDirection } from '../../hooks';\nimport Backdrop from '../Backdrop';\nimport { StyledLink } from '../Link/Link';\n\nexport const StyledHeader = styled.header(({ theme }) => {\n const color: string | undefined = tryCatch(() =>\n rgba(theme.base.palette.light, theme.base.transparency['transparent-2'])\n );\n\n return css`\n position: relative;\n width: 100%;\n padding: ${theme.base.spacing};\n color: ${color};\n\n ${StyledMetaList} {\n justify-content: center;\n li {\n color: ${color};\n }\n }\n `;\n});\n\nStyledHeader.defaultProps = defaultThemeProp;\n\nexport const StyledCountTracker = styled.div(({ theme }) => {\n const fontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']);\n\n return css`\n font-size: ${fontSize.xs};\n text-align: center;\n min-width: calc(2 * ${theme.base['hit-area']['mouse-min']});\n\n @media (pointer: coarse) {\n min-width: calc(2 * ${theme.base['hit-area']['finger-min']});\n }\n `;\n});\n\nStyledCountTracker.defaultProps = defaultThemeProp;\n\nexport const StyledInfo = styled.div(({ theme }) => {\n return css`\n color: ${theme.base.palette.light};\n font-weight: ${theme.base['font-weight']['semi-bold']};\n\n ${StyledLink} {\n color: inherit;\n text-decoration: underline;\n }\n `;\n});\n\nStyledInfo.defaultProps = defaultThemeProp;\n\nexport const StyledNavButton = styled(BareButton)(({ theme }) => {\n const bg = tryCatch(() => rgba(theme.base.colors.gray.medium, 0.5));\n const hoverBg = tryCatch(() => rgba(theme.base.colors.gray.medium, 0.7));\n const { rtl } = useDirection();\n\n return css`\n position: absolute;\n z-index: 1;\n inset-block: 0;\n min-width: ${theme.base['hit-area']['mouse-min']};\n color: ${theme.base.palette['foreground-color']};\n box-shadow: none;\n border-radius: 0;\n\n @media (pointer: coarse) {\n min-width: ${theme.base['hit-area']['finger-min']};\n }\n\n &[hidden] {\n display: none;\n }\n\n & > span {\n display: inline-block;\n background-color: ${bg};\n\n ${StyledIcon} {\n color: ${theme.base.palette.light};\n width: 2rem;\n height: 3rem;\n\n ${rtl &&\n css`\n transform: rotateZ(180deg);\n `}\n }\n }\n\n &:nth-of-type(1) {\n inset-inline-start: 0;\n text-align: start;\n & > span {\n border-start-end-radius: calc(${theme.base['border-radius']} / 2);\n border-end-end-radius: calc(${theme.base['border-radius']} / 2);\n }\n }\n\n &:nth-of-type(2) {\n inset-inline-end: 0;\n text-align: end;\n & > span {\n border-start-start-radius: calc(${theme.base['border-radius']} / 2);\n border-end-start-radius: calc(${theme.base['border-radius']} / 2);\n }\n }\n\n &:hover > span {\n background-color: ${hoverBg};\n }\n\n &:focus > span {\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n});\n\nStyledNavButton.defaultProps = defaultThemeProp;\n\nexport const StyledContainer = styled.div(({ theme }) => {\n return css`\n button {\n padding: ${theme.base.spacing};\n color: ${theme.base.palette.light};\n\n &:focus:enabled {\n box-shadow: ${theme.base.shadow.focus};\n }\n }\n `;\n});\n\nStyledContainer.defaultProps = defaultThemeProp;\n\nexport const StyledMediaContainer = styled.div(({ theme }) => {\n return css`\n position: relative;\n\n & > div {\n position: absolute;\n inset-block-start: 0;\n inset-block-end: calc(2 * ${theme.base.spacing});\n inset-inline: 0;\n }\n\n ${StyledErrorState} {\n margin: auto;\n & > ${StyledText} {\n color: ${theme.base.palette.light};\n }\n }\n\n img {\n display: block;\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n }\n `;\n});\n\nexport const StyledObject = styled.object`\n display: block;\n margin: auto;\n width: calc(100% - 5rem);\n height: 100%;\n`;\n\nStyledMediaContainer.defaultProps = defaultThemeProp;\n\nexport const StyledPreviewRegion = styled.div`\n position: relative;\n width: 100%;\n`;\n\nexport const StyledLiveRegion = styled.div`\n ${hideVisually}\n`;\n\nexport const StyledLightbox = styled(Backdrop)(({ theme }) => {\n return css`\n z-index: ${theme.base['z-index'].max};\n\n &:focus {\n outline: none;\n }\n `;\n});\n\nStyledLightbox.defaultProps = defaultThemeProp;\n"]}